From ade51c1d898d8796093060b21289ac81ba4ecca1 Mon Sep 17 00:00:00 2001 From: RJ Miller Date: Sat, 9 Jul 2016 13:43:18 -0400 Subject: terminal.c: Handle more special keys --- src/nvim/terminal.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src') diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index bd7b9fc58f..bfcc123161 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -762,6 +762,7 @@ static VTermKey convert_key(int key, VTermModifier *statep) switch (key) { case K_BS: return VTERM_KEY_BACKSPACE; + case K_S_TAB: *statep |= VTERM_MOD_SHIFT; case TAB: return VTERM_KEY_TAB; case Ctrl_M: return VTERM_KEY_ENTER; case ESC: return VTERM_KEY_ESCAPE; @@ -801,6 +802,57 @@ static VTermKey convert_key(int key, VTermModifier *statep) case K_KMULTIPLY: return VTERM_KEY_KP_MULT; case K_KDIVIDE: return VTERM_KEY_KP_DIVIDE; + case K_S_F1: *statep |= VTERM_MOD_SHIFT; + case K_F1: return VTERM_KEY_FUNCTION(1); + case K_S_F2: *statep |= VTERM_MOD_SHIFT; + case K_F2: return VTERM_KEY_FUNCTION(2); + case K_S_F3: *statep |= VTERM_MOD_SHIFT; + case K_F3: return VTERM_KEY_FUNCTION(3); + case K_S_F4: *statep |= VTERM_MOD_SHIFT; + case K_F4: return VTERM_KEY_FUNCTION(4); + case K_S_F5: *statep |= VTERM_MOD_SHIFT; + case K_F5: return VTERM_KEY_FUNCTION(5); + case K_S_F6: *statep |= VTERM_MOD_SHIFT; + case K_F6: return VTERM_KEY_FUNCTION(6); + case K_S_F7: *statep |= VTERM_MOD_SHIFT; + case K_F7: return VTERM_KEY_FUNCTION(7); + case K_S_F8: *statep |= VTERM_MOD_SHIFT; + case K_F8: return VTERM_KEY_FUNCTION(8); + case K_S_F9: *statep |= VTERM_MOD_SHIFT; + case K_F9: return VTERM_KEY_FUNCTION(9); + case K_S_F10: *statep |= VTERM_MOD_SHIFT; + case K_F10: return VTERM_KEY_FUNCTION(10); + case K_S_F11: *statep |= VTERM_MOD_SHIFT; + case K_F11: return VTERM_KEY_FUNCTION(11); + case K_S_F12: *statep |= VTERM_MOD_SHIFT; + case K_F12: return VTERM_KEY_FUNCTION(12); + + case K_F13: return VTERM_KEY_FUNCTION(13); + case K_F14: return VTERM_KEY_FUNCTION(14); + case K_F15: return VTERM_KEY_FUNCTION(15); + case K_F16: return VTERM_KEY_FUNCTION(16); + case K_F17: return VTERM_KEY_FUNCTION(17); + case K_F18: return VTERM_KEY_FUNCTION(18); + case K_F19: return VTERM_KEY_FUNCTION(19); + case K_F20: return VTERM_KEY_FUNCTION(20); + case K_F21: return VTERM_KEY_FUNCTION(21); + case K_F22: return VTERM_KEY_FUNCTION(22); + case K_F23: return VTERM_KEY_FUNCTION(23); + case K_F24: return VTERM_KEY_FUNCTION(24); + case K_F25: return VTERM_KEY_FUNCTION(25); + case K_F26: return VTERM_KEY_FUNCTION(26); + case K_F27: return VTERM_KEY_FUNCTION(27); + case K_F28: return VTERM_KEY_FUNCTION(28); + case K_F29: return VTERM_KEY_FUNCTION(29); + case K_F30: return VTERM_KEY_FUNCTION(30); + case K_F31: return VTERM_KEY_FUNCTION(31); + case K_F32: return VTERM_KEY_FUNCTION(32); + case K_F33: return VTERM_KEY_FUNCTION(33); + case K_F34: return VTERM_KEY_FUNCTION(34); + case K_F35: return VTERM_KEY_FUNCTION(35); + case K_F36: return VTERM_KEY_FUNCTION(36); + case K_F37: return VTERM_KEY_FUNCTION(37); + default: return VTERM_KEY_NONE; } } -- cgit From d23403a1df624792077559badc1f5f1037d81f5d Mon Sep 17 00:00:00 2001 From: RJ Miller Date: Sat, 9 Jul 2016 14:36:20 -0400 Subject: terminal.c: move mod logic into convert_modifiers --- src/nvim/terminal.c | 59 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index bfcc123161..94c8ef0858 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -749,27 +749,56 @@ static int term_sb_pop(int cols, VTermScreenCell *cells, void *data) // }}} // input handling {{{ -static void convert_modifiers(VTermModifier *statep) +static void convert_modifiers(int key, VTermModifier *statep) { if (mod_mask & MOD_MASK_SHIFT) { *statep |= VTERM_MOD_SHIFT; } if (mod_mask & MOD_MASK_CTRL) { *statep |= VTERM_MOD_CTRL; } if (mod_mask & MOD_MASK_ALT) { *statep |= VTERM_MOD_ALT; } + + switch(key) { + case K_S_TAB: + case K_S_LEFT: + case K_S_RIGHT: + case K_S_F1: + case K_S_F2: + case K_S_F3: + case K_S_F4: + case K_S_F5: + case K_S_F6: + case K_S_F7: + case K_S_F8: + case K_S_F9: + case K_S_F10: + case K_S_F11: + case K_S_F12: + *statep |= VTERM_MOD_SHIFT; + break; + + case K_C_LEFT: + case K_C_RIGHT: + *statep |= VTERM_MOD_CTRL; + break; + } } static VTermKey convert_key(int key, VTermModifier *statep) { - convert_modifiers(statep); + convert_modifiers(key, statep); switch (key) { case K_BS: return VTERM_KEY_BACKSPACE; - case K_S_TAB: *statep |= VTERM_MOD_SHIFT; + case K_S_TAB: case TAB: return VTERM_KEY_TAB; case Ctrl_M: return VTERM_KEY_ENTER; case ESC: return VTERM_KEY_ESCAPE; case K_UP: return VTERM_KEY_UP; case K_DOWN: return VTERM_KEY_DOWN; + case K_S_LEFT: + case K_C_LEFT: case K_LEFT: return VTERM_KEY_LEFT; + case K_S_RIGHT: + case K_C_RIGHT: case K_RIGHT: return VTERM_KEY_RIGHT; case K_INS: return VTERM_KEY_INS; @@ -802,29 +831,29 @@ static VTermKey convert_key(int key, VTermModifier *statep) case K_KMULTIPLY: return VTERM_KEY_KP_MULT; case K_KDIVIDE: return VTERM_KEY_KP_DIVIDE; - case K_S_F1: *statep |= VTERM_MOD_SHIFT; + case K_S_F1: case K_F1: return VTERM_KEY_FUNCTION(1); - case K_S_F2: *statep |= VTERM_MOD_SHIFT; + case K_S_F2: case K_F2: return VTERM_KEY_FUNCTION(2); - case K_S_F3: *statep |= VTERM_MOD_SHIFT; + case K_S_F3: case K_F3: return VTERM_KEY_FUNCTION(3); - case K_S_F4: *statep |= VTERM_MOD_SHIFT; + case K_S_F4: case K_F4: return VTERM_KEY_FUNCTION(4); - case K_S_F5: *statep |= VTERM_MOD_SHIFT; + case K_S_F5: case K_F5: return VTERM_KEY_FUNCTION(5); - case K_S_F6: *statep |= VTERM_MOD_SHIFT; + case K_S_F6: case K_F6: return VTERM_KEY_FUNCTION(6); - case K_S_F7: *statep |= VTERM_MOD_SHIFT; + case K_S_F7: case K_F7: return VTERM_KEY_FUNCTION(7); - case K_S_F8: *statep |= VTERM_MOD_SHIFT; + case K_S_F8: case K_F8: return VTERM_KEY_FUNCTION(8); - case K_S_F9: *statep |= VTERM_MOD_SHIFT; + case K_S_F9: case K_F9: return VTERM_KEY_FUNCTION(9); - case K_S_F10: *statep |= VTERM_MOD_SHIFT; + case K_S_F10: case K_F10: return VTERM_KEY_FUNCTION(10); - case K_S_F11: *statep |= VTERM_MOD_SHIFT; + case K_S_F11: case K_F11: return VTERM_KEY_FUNCTION(11); - case K_S_F12: *statep |= VTERM_MOD_SHIFT; + case K_S_F12: case K_F12: return VTERM_KEY_FUNCTION(12); case K_F13: return VTERM_KEY_FUNCTION(13); -- cgit From 4fd4f66514da4dfcd5d84c709be89d57616be753 Mon Sep 17 00:00:00 2001 From: RJ Miller Date: Sun, 10 Jul 2016 14:57:35 -0400 Subject: terminal.c: add more arrow key support --- src/nvim/terminal.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 94c8ef0858..df15921f41 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -755,8 +755,10 @@ static void convert_modifiers(int key, VTermModifier *statep) if (mod_mask & MOD_MASK_CTRL) { *statep |= VTERM_MOD_CTRL; } if (mod_mask & MOD_MASK_ALT) { *statep |= VTERM_MOD_ALT; } - switch(key) { + switch (key) { case K_S_TAB: + case K_S_UP: + case K_S_DOWN: case K_S_LEFT: case K_S_RIGHT: case K_S_F1: @@ -792,7 +794,9 @@ static VTermKey convert_key(int key, VTermModifier *statep) case Ctrl_M: return VTERM_KEY_ENTER; case ESC: return VTERM_KEY_ESCAPE; + case K_S_UP: case K_UP: return VTERM_KEY_UP; + case K_S_DOWN: case K_DOWN: return VTERM_KEY_DOWN; case K_S_LEFT: case K_C_LEFT: -- cgit From 5ffa01c8b78292bef0646168da856c726c2e4bc7 Mon Sep 17 00:00:00 2001 From: RJ Miller Date: Sun, 10 Jul 2016 20:04:09 -0400 Subject: terminal.c: handle ctrl+space and ctrl+@ --- src/nvim/terminal.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index df15921f41..c4a8a52816 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -512,6 +512,12 @@ void terminal_send(Terminal *term, char *data, size_t size) void terminal_send_key(Terminal *term, int c) { VTermModifier mod = VTERM_MOD_NONE; + + // Convert K_ZERO back to ASCII + if (c == K_ZERO) { + c = Ctrl_AT; + } + VTermKey key = convert_key(c, &mod); if (key) { -- cgit From a1d545f8e521e0f58633c42407e24d533111eb6c Mon Sep 17 00:00:00 2001 From: RJ Miller Date: Mon, 14 Nov 2016 18:33:28 -0500 Subject: terminal.c: label fallthrough on big switch --- src/nvim/terminal.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index c4a8a52816..30556a3835 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -795,20 +795,20 @@ static VTermKey convert_key(int key, VTermModifier *statep) switch (key) { case K_BS: return VTERM_KEY_BACKSPACE; - case K_S_TAB: + case K_S_TAB: // FALLTHROUGH case TAB: return VTERM_KEY_TAB; case Ctrl_M: return VTERM_KEY_ENTER; case ESC: return VTERM_KEY_ESCAPE; - case K_S_UP: + case K_S_UP: // FALLTHROUGH case K_UP: return VTERM_KEY_UP; - case K_S_DOWN: + case K_S_DOWN: // FALLTHROUGH case K_DOWN: return VTERM_KEY_DOWN; - case K_S_LEFT: - case K_C_LEFT: + case K_S_LEFT: // FALLTHROUGH + case K_C_LEFT: // FALLTHROUGH case K_LEFT: return VTERM_KEY_LEFT; - case K_S_RIGHT: - case K_C_RIGHT: + case K_S_RIGHT: // FALLTHROUGH + case K_C_RIGHT: // FALLTHROUGH case K_RIGHT: return VTERM_KEY_RIGHT; case K_INS: return VTERM_KEY_INS; @@ -818,22 +818,22 @@ static VTermKey convert_key(int key, VTermModifier *statep) case K_PAGEUP: return VTERM_KEY_PAGEUP; case K_PAGEDOWN: return VTERM_KEY_PAGEDOWN; - case K_K0: + case K_K0: // FALLTHROUGH case K_KINS: return VTERM_KEY_KP_0; - case K_K1: + case K_K1: // FALLTHROUGH case K_KEND: return VTERM_KEY_KP_1; case K_K2: return VTERM_KEY_KP_2; - case K_K3: + case K_K3: // FALLTHROUGH case K_KPAGEDOWN: return VTERM_KEY_KP_3; case K_K4: return VTERM_KEY_KP_4; case K_K5: return VTERM_KEY_KP_5; case K_K6: return VTERM_KEY_KP_6; - case K_K7: + case K_K7: // FALLTHROUGH case K_KHOME: return VTERM_KEY_KP_7; case K_K8: return VTERM_KEY_KP_8; - case K_K9: + case K_K9: // FALLTHROUGH case K_KPAGEUP: return VTERM_KEY_KP_9; - case K_KDEL: + case K_KDEL: // FALLTHROUGH case K_KPOINT: return VTERM_KEY_KP_PERIOD; case K_KENTER: return VTERM_KEY_KP_ENTER; case K_KPLUS: return VTERM_KEY_KP_PLUS; @@ -841,29 +841,29 @@ static VTermKey convert_key(int key, VTermModifier *statep) case K_KMULTIPLY: return VTERM_KEY_KP_MULT; case K_KDIVIDE: return VTERM_KEY_KP_DIVIDE; - case K_S_F1: + case K_S_F1: // FALLTHROUGH case K_F1: return VTERM_KEY_FUNCTION(1); - case K_S_F2: + case K_S_F2: // FALLTHROUGH case K_F2: return VTERM_KEY_FUNCTION(2); - case K_S_F3: + case K_S_F3: // FALLTHROUGH case K_F3: return VTERM_KEY_FUNCTION(3); - case K_S_F4: + case K_S_F4: // FALLTHROUGH case K_F4: return VTERM_KEY_FUNCTION(4); - case K_S_F5: + case K_S_F5: // FALLTHROUGH case K_F5: return VTERM_KEY_FUNCTION(5); - case K_S_F6: + case K_S_F6: // FALLTHROUGH case K_F6: return VTERM_KEY_FUNCTION(6); - case K_S_F7: + case K_S_F7: // FALLTHROUGH case K_F7: return VTERM_KEY_FUNCTION(7); - case K_S_F8: + case K_S_F8: // FALLTHROUGH case K_F8: return VTERM_KEY_FUNCTION(8); - case K_S_F9: + case K_S_F9: // FALLTHROUGH case K_F9: return VTERM_KEY_FUNCTION(9); - case K_S_F10: + case K_S_F10: // FALLTHROUGH case K_F10: return VTERM_KEY_FUNCTION(10); - case K_S_F11: + case K_S_F11: // FALLTHROUGH case K_F11: return VTERM_KEY_FUNCTION(11); - case K_S_F12: + case K_S_F12: // FALLTHROUGH case K_F12: return VTERM_KEY_FUNCTION(12); case K_F13: return VTERM_KEY_FUNCTION(13); -- cgit From d5468d3cdeda54dc7fa108ea7f1612aa88fe22a4 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Fri, 5 May 2017 15:17:32 +0100 Subject: Change TUI resize to use an extended terminal capability. ... rather than hardwiring the string and testing the terminal type every time the screen is re-sized. --- src/nvim/tui/tui.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 736d50ee8b..9587195e8c 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1132,11 +1132,11 @@ static void fix_terminfo(TUIData *data) } // Only define this capability for terminal types that we know understand it. - if (data->term == kTermDTTerm // originated this extension - || data->term == kTermXTerm // per xterm ctlseqs doc - || data->term == kTermKonsole // per commentary in VT102Emulation.cpp - || data->term == kTermTeraTerm // per "Supported Control Functions" doc - || data->term == kTermRxvt) { // per command.C + if (data->term == kTermDTTerm // originated this extension + || data->term == kTermXTerm // per xterm ctlseqs doco + || data->term == kTermKonsole // per commentary in VT102Emulation.cpp + || data->term == kTermTeraTerm // per TeraTerm "Supported Control Functions" doco + || data->term == kTermRxvt) { // per command.C data->unibi_ext.resize_screen = (int)unibi_add_ext_str(ut, NULL, "\x1b[8;%p1%d;%p2%dt"); } -- cgit From 7821eef258eac66905c4490bbd2f0e98d29ff226 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Mon, 22 May 2017 15:27:03 +0100 Subject: Separate 16- and 256- colour control sequences and tidy up some redundancy. --- src/nvim/tui/tui.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 9587195e8c..93ad022470 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1065,7 +1065,6 @@ static void fix_terminfo(TUIData *data) data->term = detect_term(term, colorterm); if (data->term == kTermRxvt) { - unibi_set_if_empty(ut, unibi_exit_attribute_mode, "\x1b[m\x1b(B"); unibi_set_if_empty(ut, unibi_flash_screen, "\x1b[?5h$<20/>\x1b[?5l"); unibi_set_if_empty(ut, unibi_enter_italics_mode, "\x1b[3m"); unibi_set_if_empty(ut, unibi_to_status_line, "\x1b]2"); @@ -1115,9 +1114,9 @@ static void fix_terminfo(TUIData *data) data->unibi_ext.disable_focus_reporting = (int)unibi_add_ext_str(ut, NULL, "\x1b[?1004l"); -#define XTERM_SETAF \ +#define XTERM_SETAF_256 \ "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m" -#define XTERM_SETAB \ +#define XTERM_SETAB_256 \ "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m" if ((colorterm && strstr(colorterm, "256")) @@ -1127,8 +1126,8 @@ static void fix_terminfo(TUIData *data) // Linux 4.8+ supports 256-color SGR, but terminfo has 8-color setaf/setab. // Assume TERM=~xterm|linux or COLORTERM=~256 supports 256 colors. unibi_set_num(ut, unibi_max_colors, 256); - unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF); - unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB); + unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); + unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); } // Only define this capability for terminal types that we know understand it. @@ -1147,6 +1146,12 @@ static void fix_terminfo(TUIData *data) } end: + +#define XTERM_SETAF_16 \ + "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e39%;m" +#define XTERM_SETAB_16 \ + "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e39%;m" + // Fill some empty slots with common terminal strings if (data->term == kTermiTerm) { data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( @@ -1165,14 +1170,14 @@ end: "\x1b[48;2;%p1%d;%p2%d;%p3%dm"); unibi_set_if_empty(ut, unibi_cursor_address, "\x1b[%i%p1%d;%p2%dH"); unibi_set_if_empty(ut, unibi_exit_attribute_mode, "\x1b[0;10m"); - unibi_set_if_empty(ut, unibi_set_a_foreground, XTERM_SETAF); - unibi_set_if_empty(ut, unibi_set_a_background, XTERM_SETAB); + unibi_set_if_empty(ut, unibi_set_a_foreground, XTERM_SETAF_16); + unibi_set_if_empty(ut, unibi_set_a_background, XTERM_SETAB_16); unibi_set_if_empty(ut, unibi_enter_bold_mode, "\x1b[1m"); unibi_set_if_empty(ut, unibi_enter_underline_mode, "\x1b[4m"); unibi_set_if_empty(ut, unibi_enter_reverse_mode, "\x1b[7m"); unibi_set_if_empty(ut, unibi_bell, "\x07"); - unibi_set_if_empty(data->ut, unibi_enter_ca_mode, "\x1b[?1049h"); - unibi_set_if_empty(data->ut, unibi_exit_ca_mode, "\x1b[?1049l"); + unibi_set_if_empty(ut, unibi_enter_ca_mode, "\x1b[?1049h"); + unibi_set_if_empty(ut, unibi_exit_ca_mode, "\x1b[?1049l"); unibi_set_if_empty(ut, unibi_delete_line, "\x1b[M"); unibi_set_if_empty(ut, unibi_parm_delete_line, "\x1b[%p1%dM"); unibi_set_if_empty(ut, unibi_insert_line, "\x1b[L"); -- cgit From 5e5914655ba546c424a13d768469c21b444b8883 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Mon, 22 May 2017 21:07:23 +0100 Subject: tui: document fix_terminfo()'s several tasks --- src/nvim/tui/tui.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 93ad022470..83198ee33c 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1052,6 +1052,14 @@ static TermType detect_term(const char *term, const char *colorterm) return kTermUnknown; } +/// This has three tasks. +/// 1. On termcap-only systems, it reads $TERM and fills in all of the things +/// that unibilium (which uses terminfo) will not have. +/// 2. It fills in extra capabilities that unibilium and terminfo do not know +/// anything about, such as bracketed paste control. Some of these are +/// (wrongly) assumed to be universal. Others are dependent from $TERM . +/// 3. It fills in capabilities that might have been missing from the termcap +/// entry that we nonetheless need, which are also worked out from $TERM . static void fix_terminfo(TUIData *data) { unibi_term *ut = data->ut; -- cgit From d711bb84e6a78360e470d82f3671da64583089c2 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Mon, 22 May 2017 21:16:02 +0100 Subject: tui: Eliminate superfluous SGR resets. Track whether the terminal is in no attribute mode, assuming that it starts this way, and do not attempt to reset back to that mode if already in it. --- src/nvim/tui/tui.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 83198ee33c..84f23062ff 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -90,6 +90,7 @@ typedef struct { bool busy; cursorentry_T cursor_shapes[SHAPE_IDX_COUNT]; HlAttrs print_attrs; + bool default_attr; ModeShape showing_mode; TermType term; struct { @@ -155,6 +156,7 @@ static void terminfo_start(UI *ui) data->scroll_region_is_full_screen = true; data->bufpos = 0; data->bufsize = sizeof(data->buf) - CNORM_COMMAND_MAX_SIZE; + data->default_attr = false; data->showing_mode = SHAPE_IDX_N; data->unibi_ext.enable_mouse = -1; data->unibi_ext.disable_mouse = -1; @@ -336,7 +338,10 @@ static void update_attrs(UI *ui, HlAttrs attrs) } data->print_attrs = attrs; - unibi_out(ui, unibi_exit_attribute_mode); + if (!data->default_attr) { + data->default_attr = true; + unibi_out(ui, unibi_exit_attribute_mode); + } UGrid *grid = &data->grid; int fg = attrs.foreground != -1 ? attrs.foreground : grid->fg; @@ -348,6 +353,7 @@ static void update_attrs(UI *ui, HlAttrs attrs) data->params[1].i = (fg >> 8) & 0xff; // green data->params[2].i = fg & 0xff; // blue unibi_out(ui, data->unibi_ext.set_rgb_foreground); + data->default_attr = false; } if (bg != -1) { @@ -355,30 +361,37 @@ static void update_attrs(UI *ui, HlAttrs attrs) data->params[1].i = (bg >> 8) & 0xff; // green data->params[2].i = bg & 0xff; // blue unibi_out(ui, data->unibi_ext.set_rgb_background); + data->default_attr = false; } } else { if (fg != -1) { data->params[0].i = fg; unibi_out(ui, unibi_set_a_foreground); + data->default_attr = false; } if (bg != -1) { data->params[0].i = bg; unibi_out(ui, unibi_set_a_background); + data->default_attr = false; } } if (attrs.bold) { unibi_out(ui, unibi_enter_bold_mode); + data->default_attr = false; } if (attrs.italic) { unibi_out(ui, unibi_enter_italics_mode); + data->default_attr = false; } if (attrs.underline || attrs.undercurl) { unibi_out(ui, unibi_enter_underline_mode); + data->default_attr = false; } if (attrs.reverse) { unibi_out(ui, unibi_enter_reverse_mode); + data->default_attr = false; } } -- cgit From dbc25f5a87cf3bcfe1caac1eb1ff8b3a6978a415 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Mon, 22 May 2017 21:53:36 +0100 Subject: tui: Optimize cursor motions Instead of emitting CUP in several places each with their own poor local optimizations, funnel all cursor motion through a central place. This central function performs the same optimization for every place that needs to move the cursor, and implements a better set of optimizations: * Emit CUU/CUD/CUF/CUB instad of CUP when they are likely shorter. * Use BS and LF when they are shorter than CUB and CUD. * Use CR for quick returns to column zero. * If printing the next few characters is shorter than a rightwards motion, then just write out the characters. --- src/nvim/tui/tui.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 145 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 84f23062ff..abe0e17d8a 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -199,7 +199,11 @@ static void terminfo_start(UI *ui) uv_loop_init(&data->write_loop); if (data->out_isatty) { uv_tty_init(&data->write_loop, &data->output_handle.tty, data->out_fd, 0); +#ifdef WIN32 uv_tty_set_mode(&data->output_handle.tty, UV_TTY_MODE_RAW); +#else + uv_tty_set_mode(&data->output_handle.tty, UV_TTY_MODE_IO); +#endif } else { uv_pipe_init(&data->write_loop, &data->output_handle.pipe, 0); uv_pipe_open(&data->output_handle.pipe, data->out_fd); @@ -401,10 +405,119 @@ static void print_cell(UI *ui, UCell *ptr) out(ui, ptr->data, strlen(ptr->data)); } +static bool cheap_to_print(UI *ui, int row, int col, int next) +{ + TUIData *data = ui->data; + UGrid *grid = &data->grid; + UCell *cell = grid->cells[row] + col; + while (next) { + --next; + if (attrs_differ(cell->attrs, data->print_attrs)) { + if (data->default_attr) { + return false; + } + } + if (strlen(cell->data) > 1) { + return false; + } + ++cell; + } + return true; +} + +/// This optimizes several cases where it is cheaper to do something other +/// than send a full cursor positioning control sequence. However, there are +/// some further optimizations that may seem obvious but that will not work. +/// +/// We cannot use VT (ASCII 0/11) for moving the cursor up, because VT means +/// move the cursor down on a DEC terminal. Similarly, on a DEC terminal FF +/// (ASCII 0/12) means the same thing and does not mean home. VT, CVT, and +/// TAB also stop at software-defined tabulation stops, not at a fixed set +/// of row/column positions. +static void cursor_goto(UI *ui, int row, int col) +{ + TUIData *data = ui->data; + UGrid *grid = &data->grid; + if (row == grid->row && col == grid->col) + return; + if (0 == row && 0 == col) { + unibi_out(ui, unibi_cursor_home); + ugrid_goto(&data->grid, row, col); + return; + } + if (0 == col && 0 != grid->col) { + unibi_out(ui, unibi_carriage_return); + ugrid_goto(&data->grid, grid->row, col); + } else if (col > grid->col) { + int n = col - grid->col; + if (n <= (row == grid->row ? 4 : 2) && cheap_to_print(ui, grid->row, grid->col, n)) { + UGRID_FOREACH_CELL(grid, grid->row, grid->row, + grid->col, col - 1, { + print_cell(ui, cell); + ++grid->col; + }); + } + } + if (row == grid->row) { + if (col < grid->col) { + int n = grid->col - col; + if (n <= 4) { // This might be just BS, so it is considered really cheap. + while (n--) + unibi_out(ui, unibi_cursor_left); + } else { + data->params[0].i = n; + unibi_out(ui, unibi_parm_left_cursor); + } + ugrid_goto(&data->grid, row, col); + return; + } else if (col > grid->col) { + int n = col - grid->col; + if (n <= 2) { + while (n--) + unibi_out(ui, unibi_cursor_right); + } else { + data->params[0].i = n; + unibi_out(ui, unibi_parm_right_cursor); + } + ugrid_goto(&data->grid, row, col); + return; + } + } + if (col == grid->col) { + if (row > grid->row) { + int n = row - grid->row; + if (n <= 4) { // This might be just LF, so it is considered really cheap. + while (n--) + unibi_out(ui, unibi_cursor_down); + } else { + data->params[0].i = n; + unibi_out(ui, unibi_parm_down_cursor); + } + ugrid_goto(&data->grid, row, col); + return; + } else if (row < grid->row) { + int n = grid->row - row; + if (n <= 2) { + while (n--) + unibi_out(ui, unibi_cursor_up); + } else { + data->params[0].i = n; + unibi_out(ui, unibi_parm_up_cursor); + } + ugrid_goto(&data->grid, row, col); + return; + } + } + unibi_goto(ui, row, col); + ugrid_goto(&data->grid, row, col); +} + static void clear_region(UI *ui, int top, int bot, int left, int right) { TUIData *data = ui->data; UGrid *grid = &data->grid; + int saved_row = grid->row; + int saved_col = grid->col; bool cleared = false; if (grid->bg == -1 && right == ui->width -1) { @@ -419,7 +532,7 @@ static void clear_region(UI *ui, int top, int bot, int left, int right) if (top == 0) { unibi_out(ui, unibi_clear_screen); } else { - unibi_goto(ui, top, 0); + cursor_goto(ui, top, 0); unibi_out(ui, unibi_clr_eos); } cleared = true; @@ -429,7 +542,7 @@ static void clear_region(UI *ui, int top, int bot, int left, int right) if (!cleared) { // iterate through each line and clear with clr_eol for (int row = top; row <= bot; ++row) { - unibi_goto(ui, row, left); + cursor_goto(ui, row, left); unibi_out(ui, unibi_clr_eol); } cleared = true; @@ -438,18 +551,15 @@ static void clear_region(UI *ui, int top, int bot, int left, int right) if (!cleared) { // could not clear using faster terminal codes, refresh the whole region - int currow = -1; UGRID_FOREACH_CELL(grid, top, bot, left, right, { - if (currow != row) { - unibi_goto(ui, row, col); - currow = row; - } + cursor_goto(ui, row, col); print_cell(ui, cell); + ++grid->col; }); } // restore cursor - unibi_goto(ui, grid->row, grid->col); + cursor_goto(ui, saved_row, saved_col); } static bool can_use_scroll(UI * ui) @@ -552,9 +662,7 @@ static void tui_eol_clear(UI *ui) static void tui_cursor_goto(UI *ui, Integer row, Integer col) { - TUIData *data = ui->data; - ugrid_goto(&data->grid, (int)row, (int)col); - unibi_goto(ui, (int)row, (int)col); + cursor_goto(ui, (int)row, (int)col); } CursorShape tui_cursor_decode_shape(const char *shape_str) @@ -728,6 +836,8 @@ static void tui_scroll(UI *ui, Integer count) ugrid_scroll(grid, (int)count, &clear_top, &clear_bot); if (can_use_scroll(ui)) { + int saved_row = grid->row; + int saved_col = grid->col; bool scroll_clears_to_current_colour = unibi_get_bool(data->ut, unibi_back_color_erase); @@ -735,7 +845,7 @@ static void tui_scroll(UI *ui, Integer count) if (!data->scroll_region_is_full_screen) { set_scroll_region(ui); } - unibi_goto(ui, grid->top, grid->left); + cursor_goto(ui, grid->top, grid->left); // also set default color attributes or some terminals can become funny if (scroll_clears_to_current_colour) { HlAttrs clear_attrs = EMPTY_ATTRS; @@ -764,7 +874,7 @@ static void tui_scroll(UI *ui, Integer count) if (!data->scroll_region_is_full_screen) { reset_scroll_region(ui); } - unibi_goto(ui, grid->row, grid->col); + cursor_goto(ui, saved_row, saved_col); if (!scroll_clears_to_current_colour) { // This is required because scrolling will leave wrong background in the @@ -830,19 +940,19 @@ static void tui_flush(UI *ui) tui_busy_stop(ui); // avoid hidden cursor } + int saved_row = grid->row; + int saved_col = grid->col; + while (kv_size(data->invalid_regions)) { Rect r = kv_pop(data->invalid_regions); - int currow = -1; UGRID_FOREACH_CELL(grid, r.top, r.bot, r.left, r.right, { - if (currow != row) { - unibi_goto(ui, row, col); - currow = row; - } + cursor_goto(ui, row, col); print_cell(ui, cell); + ++grid->col; }); } - unibi_goto(ui, grid->row, grid->col); + cursor_goto(ui, saved_row, saved_col); flush_buf(ui, true); } @@ -1190,6 +1300,22 @@ end: data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, NULL, "\x1b[48;2;%p1%d;%p2%d;%p3%dm"); unibi_set_if_empty(ut, unibi_cursor_address, "\x1b[%i%p1%d;%p2%dH"); + unibi_set_if_empty(ut, unibi_cursor_home, "\x1b[H"); + unibi_set_if_empty(ut, unibi_parm_left_cursor, "\x1b[%p1%dD"); + unibi_set_if_empty(ut, unibi_parm_right_cursor, "\x1b[%p1%dC"); + unibi_set_if_empty(ut, unibi_parm_down_cursor, "\x1b[%p1%dB"); + unibi_set_if_empty(ut, unibi_parm_up_cursor, "\x1b[%p1%dA"); + unibi_set_if_empty(ut, unibi_cursor_left, "\x08"); + unibi_set_if_empty(ut, unibi_cursor_right, "\x1b[C"); +#if defined(WIN32) + unibi_set_if_empty(ut, unibi_cursor_down, "\x1b[B"); +#else + // N.B. This relies upon the terminal really being in cfmakeraw() mode, + // which libuv's RAW mode is in fact not. + unibi_set_if_empty(ut, unibi_cursor_down, "\x0a"); +#endif + unibi_set_if_empty(ut, unibi_cursor_up, "\x1b[A"); + unibi_set_if_empty(ut, unibi_carriage_return, "\x0d"); unibi_set_if_empty(ut, unibi_exit_attribute_mode, "\x1b[0;10m"); unibi_set_if_empty(ut, unibi_set_a_foreground, XTERM_SETAF_16); unibi_set_if_empty(ut, unibi_set_a_background, XTERM_SETAB_16); -- cgit From 5b07ca1dfde4d44a11e3052b552f48fe61034247 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Mon, 22 May 2017 22:46:56 +0100 Subject: tui: Use what scrolling PuTTY has. PuTTY does not implement DECLRMM or DECSLRM, but it does implement DECSTBM. So allow using PuTTY terminal scrolling when the scroll rectangle is the full width of the terminal. --- src/nvim/tui/tui.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index abe0e17d8a..23096725be 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -56,6 +56,7 @@ typedef enum TermType { kTermDTTerm, kTermXTerm, kTermTeraTerm, + kTermPuTTY, } TermType; typedef struct { @@ -1172,6 +1173,9 @@ static TermType detect_term(const char *term, const char *colorterm) if (STARTS_WITH(term, "teraterm")) { return kTermTeraTerm; } + if (STARTS_WITH(term, "putty")) { + return kTermPuTTY; + } return kTermUnknown; } @@ -1220,13 +1224,15 @@ static void fix_terminfo(TUIData *data) unibi_set_if_empty(ut, unibi_cursor_invisible, "\x1b[?25l"); unibi_set_if_empty(ut, unibi_flash_screen, "\x1b[?5h$<100/>\x1b[?5l"); unibi_set_if_empty(ut, unibi_exit_attribute_mode, "\x1b(B\x1b[m"); + unibi_set_if_empty(ut, unibi_from_status_line, "\x07"); unibi_set_if_empty(ut, unibi_set_tb_margin, "\x1b[%i%p1%d;%p2%dr"); unibi_set_if_empty(ut, unibi_set_lr_margin, "\x1b[%i%p1%d;%p2%ds"); unibi_set_if_empty(ut, unibi_set_left_margin_parm, "\x1b[%i%p1%ds"); unibi_set_if_empty(ut, unibi_set_right_margin_parm, "\x1b[%i;%p2%ds"); + } + if (data->term == kTermXTerm || data->term == kTermRxvt || data->term == kTermPuTTY) { unibi_set_if_empty(ut, unibi_change_scroll_region, "\x1b[%i%p1%d;%p2%dr"); unibi_set_if_empty(ut, unibi_clear_screen, "\x1b[H\x1b[2J"); - unibi_set_if_empty(ut, unibi_from_status_line, "\x07"); unibi_set_bool(ut, unibi_back_color_erase, true); } @@ -1271,7 +1277,7 @@ static void fix_terminfo(TUIData *data) "\x1b[8;%p1%d;%p2%dt"); } - if (data->term == kTermXTerm || data->term == kTermRxvt) { + if (data->term == kTermXTerm || data->term == kTermRxvt || data->term == kTermPuTTY) { data->unibi_ext.reset_scroll_region = (int)unibi_add_ext_str(ut, NULL, "\x1b[r"); } -- cgit From e826ec0b0ef36e48d2628b1a64226676e3c49eed Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Tue, 23 May 2017 01:09:17 +0100 Subject: tui: Optimize more cursor motions A slight improvement on the CR optimization for some edge cases. --- src/nvim/tui/tui.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 23096725be..8f1647803f 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -446,9 +446,14 @@ static void cursor_goto(UI *ui, int row, int col) ugrid_goto(&data->grid, row, col); return; } - if (0 == col && 0 != grid->col) { + if (0 == col ? col != grid->col : + 1 == col ? 2 < grid->col && cheap_to_print(ui, grid->row, 0, col) : + 2 == col ? 5 < grid->col && cheap_to_print(ui, grid->row, 0, col) : + false) { + // Motion to left margin from anywhere else, or CR + printing chars is + // even less expensive than using BSes or CUB. unibi_out(ui, unibi_carriage_return); - ugrid_goto(&data->grid, grid->row, col); + ugrid_goto(&data->grid, grid->row, 0); } else if (col > grid->col) { int n = col - grid->col; if (n <= (row == grid->row ? 4 : 2) && cheap_to_print(ui, grid->row, grid->col, n)) { -- cgit From d077a161eea19e50ecd4a757004071e2329166e0 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Tue, 23 May 2017 15:38:51 +0100 Subject: tui: Coding style changes only Per warnings about house style from automated tools. --- src/nvim/tui/tui.c | 60 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 8f1647803f..0146d7d65d 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -415,7 +415,7 @@ static bool cheap_to_print(UI *ui, int row, int col, int next) --next; if (attrs_differ(cell->attrs, data->print_attrs)) { if (data->default_attr) { - return false; + return false; } } if (strlen(cell->data) > 1) { @@ -439,8 +439,9 @@ static void cursor_goto(UI *ui, int row, int col) { TUIData *data = ui->data; UGrid *grid = &data->grid; - if (row == grid->row && col == grid->col) + if (row == grid->row && col == grid->col) { return; + } if (0 == row && 0 == col) { unibi_out(ui, unibi_cursor_home); ugrid_goto(&data->grid, row, col); @@ -456,34 +457,37 @@ static void cursor_goto(UI *ui, int row, int col) ugrid_goto(&data->grid, grid->row, 0); } else if (col > grid->col) { int n = col - grid->col; - if (n <= (row == grid->row ? 4 : 2) && cheap_to_print(ui, grid->row, grid->col, n)) { - UGRID_FOREACH_CELL(grid, grid->row, grid->row, - grid->col, col - 1, { - print_cell(ui, cell); - ++grid->col; - }); + if (n <= (row == grid->row ? 4 : 2) + && cheap_to_print(ui, grid->row, grid->col, n)) { + UGRID_FOREACH_CELL(grid, grid->row, grid->row, + grid->col, col - 1, { + print_cell(ui, cell); + ++grid->col; + }); } } if (row == grid->row) { if (col < grid->col) { int n = grid->col - col; if (n <= 4) { // This might be just BS, so it is considered really cheap. - while (n--) - unibi_out(ui, unibi_cursor_left); + while (n--) { + unibi_out(ui, unibi_cursor_left); + } } else { - data->params[0].i = n; - unibi_out(ui, unibi_parm_left_cursor); + data->params[0].i = n; + unibi_out(ui, unibi_parm_left_cursor); } ugrid_goto(&data->grid, row, col); return; } else if (col > grid->col) { int n = col - grid->col; if (n <= 2) { - while (n--) - unibi_out(ui, unibi_cursor_right); + while (n--) { + unibi_out(ui, unibi_cursor_right); + } } else { - data->params[0].i = n; - unibi_out(ui, unibi_parm_right_cursor); + data->params[0].i = n; + unibi_out(ui, unibi_parm_right_cursor); } ugrid_goto(&data->grid, row, col); return; @@ -493,22 +497,24 @@ static void cursor_goto(UI *ui, int row, int col) if (row > grid->row) { int n = row - grid->row; if (n <= 4) { // This might be just LF, so it is considered really cheap. - while (n--) - unibi_out(ui, unibi_cursor_down); + while (n--) { + unibi_out(ui, unibi_cursor_down); + } } else { - data->params[0].i = n; - unibi_out(ui, unibi_parm_down_cursor); + data->params[0].i = n; + unibi_out(ui, unibi_parm_down_cursor); } ugrid_goto(&data->grid, row, col); return; } else if (row < grid->row) { int n = grid->row - row; if (n <= 2) { - while (n--) - unibi_out(ui, unibi_cursor_up); + while (n--) { + unibi_out(ui, unibi_cursor_up); + } } else { - data->params[0].i = n; - unibi_out(ui, unibi_parm_up_cursor); + data->params[0].i = n; + unibi_out(ui, unibi_parm_up_cursor); } ugrid_goto(&data->grid, row, col); return; @@ -1235,7 +1241,8 @@ static void fix_terminfo(TUIData *data) unibi_set_if_empty(ut, unibi_set_left_margin_parm, "\x1b[%i%p1%ds"); unibi_set_if_empty(ut, unibi_set_right_margin_parm, "\x1b[%i;%p2%ds"); } - if (data->term == kTermXTerm || data->term == kTermRxvt || data->term == kTermPuTTY) { + if (data->term == kTermXTerm || data->term == kTermRxvt + || data->term == kTermPuTTY) { unibi_set_if_empty(ut, unibi_change_scroll_region, "\x1b[%i%p1%d;%p2%dr"); unibi_set_if_empty(ut, unibi_clear_screen, "\x1b[H\x1b[2J"); unibi_set_bool(ut, unibi_back_color_erase, true); @@ -1282,7 +1289,8 @@ static void fix_terminfo(TUIData *data) "\x1b[8;%p1%d;%p2%dt"); } - if (data->term == kTermXTerm || data->term == kTermRxvt || data->term == kTermPuTTY) { + if (data->term == kTermXTerm || data->term == kTermRxvt + || data->term == kTermPuTTY) { data->unibi_ext.reset_scroll_region = (int)unibi_add_ext_str(ut, NULL, "\x1b[r"); } -- cgit From ede4d620def191af984befecd0386e8cc92ba740 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Tue, 23 May 2017 16:55:22 +0100 Subject: tui: Fix cursor motion clear screen bug visible on line #1 in redraws. The clear_screen capability moves the cursor position. This needs to be accounted for. --- src/nvim/tui/tui.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 0146d7d65d..650b1b0fa2 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -543,6 +543,7 @@ static void clear_region(UI *ui, int top, int bot, int left, int right) if (bot == ui->height - 1) { if (top == 0) { unibi_out(ui, unibi_clear_screen); + ugrid_goto(&data->grid, top, left); } else { cursor_goto(ui, top, 0); unibi_out(ui, unibi_clr_eos); -- cgit From 3d8e0594e495c42dbdf3871ef3c3023e128f748c Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Wed, 24 May 2017 21:36:52 +0100 Subject: tui: Split fix_terminfo() up and refactor. There are now a few built-in terminfo entries, taken either from unibilium or ncurses terminfo, for falling back upon when there is no terminfo database or when it is missing stuff. In an ideal world, these would be in unibilium itself. The ultimate fallback, for no terminfo database and no built-in terminfo record that matches the terminal type, is now the "ansi" terminal type; so unknown terminal types are now considered to have at minimum the basic ECMA-48 colour, motion, and editing capabilities. The terminfo records are just blobs, raw images of the equivalent terminfo file created with the od command. No longer are incomplete terminfo records built up with code. These blobs are the full, real, records; already built. The post-processing of the terminfo record, once found, is split into the part where we fix known errors and deficiencies in terminfo, and the part where we add extensions that we need that terminfo does not define capabilities for. In an ideal world, the former would be a no-op. No part of the TUI layer apart from these is aware of terminal type or has conditional code based upon checking environment variables at runtime. It is all pre-calculated and written into unibilium (or the TUIData object) at initialization time. This is fairly aggressive about turning on 256-colour and true colour support. This also positively decodes genuine xterm for turning on DECSLRM use, rather than assuming that anything that says that it is xterm is actually xterm, fixing scrolling problems with vertically split windows. --- src/nvim/tui/tui.c | 1112 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 903 insertions(+), 209 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 650b1b0fa2..8f8f388eb8 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -45,19 +45,7 @@ #define TOO_MANY_EVENTS 1000000 #define STARTS_WITH(str, prefix) (!memcmp(str, prefix, sizeof(prefix) - 1)) -#define TMUX_WRAP(seq) (is_tmux ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq) - -typedef enum TermType { - kTermUnknown, - kTermGnome, - kTermiTerm, - kTermKonsole, - kTermRxvt, - kTermDTTerm, - kTermXTerm, - kTermTeraTerm, - kTermPuTTY, -} TermType; +#define TMUX_WRAP(is_tmux,seq) ((is_tmux) ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq) typedef struct { int top, bot, left, right; @@ -93,7 +81,6 @@ typedef struct { HlAttrs print_attrs; bool default_attr; ModeShape showing_mode; - TermType term; struct { int enable_mouse, disable_mouse; int enable_bracketed_paste, disable_bracketed_paste; @@ -103,12 +90,12 @@ typedef struct { int enable_focus_reporting, disable_focus_reporting; int resize_screen; int reset_scroll_region; + int konsole_cursor_shape, dec_cursor_shape; } unibi_ext; } TUIData; static bool volatile got_winch = false; static bool cursor_style_enabled = false; -static bool is_tmux = false; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "tui/tui.c.generated.h" @@ -170,16 +157,25 @@ static void terminfo_start(UI *ui) data->unibi_ext.disable_focus_reporting = -1; data->unibi_ext.resize_screen = -1; data->unibi_ext.reset_scroll_region = -1; + data->unibi_ext.konsole_cursor_shape = -1; + data->unibi_ext.dec_cursor_shape = -1; data->out_fd = 1; data->out_isatty = os_isatty(data->out_fd); // setup unibilium + const char *term = os_getenv("TERM"); data->ut = unibi_from_env(); if (!data->ut) { - // For some reason could not read terminfo file, use a dummy entry that - // will be populated with common values by fix_terminfo below - data->ut = unibi_dummy(); + data->ut = load_builtin_terminfo(term); } - fix_terminfo(data); + const char *colorterm = os_getenv("COLORTERM"); + const char *termprg = os_getenv("TERM_PROGRAM"); + const char *vte_version_env = os_getenv("VTE_VERSION"); + long vte_version = vte_version_env ? strtol(vte_version_env, NULL, 10) : 0; + bool iterm = termprg && strstr(termprg, "iTerm.app"); + bool konsole = os_getenv("KONSOLE_PROFILE_NAME") + || os_getenv("KONSOLE_DBUS_SESSION"); + patch_terminfo_bugs(data->ut, term, colorterm, vte_version, konsole, iterm); + augment_terminfo(data, term, colorterm, vte_version, konsole, iterm); data->can_change_scroll_region = !!unibi_get_str(data->ut, unibi_change_scroll_region); data->can_set_lr_margin = @@ -472,7 +468,7 @@ static void cursor_goto(UI *ui, int row, int col) if (n <= 4) { // This might be just BS, so it is considered really cheap. while (n--) { unibi_out(ui, unibi_cursor_left); - } + } } else { data->params[0].i = n; unibi_out(ui, unibi_parm_left_cursor); @@ -484,7 +480,7 @@ static void cursor_goto(UI *ui, int row, int col) if (n <= 2) { while (n--) { unibi_out(ui, unibi_cursor_right); - } + } } else { data->params[0].i = n; unibi_out(ui, unibi_parm_right_cursor); @@ -499,7 +495,7 @@ static void cursor_goto(UI *ui, int row, int col) if (n <= 4) { // This might be just LF, so it is considered really cheap. while (n--) { unibi_out(ui, unibi_cursor_down); - } + } } else { data->params[0].i = n; unibi_out(ui, unibi_parm_down_cursor); @@ -511,7 +507,7 @@ static void cursor_goto(UI *ui, int row, int col) if (n <= 2) { while (n--) { unibi_out(ui, unibi_cursor_up); - } + } } else { data->params[0].i = n; unibi_out(ui, unibi_parm_up_cursor); @@ -775,10 +771,8 @@ static void tui_set_mode(UI *ui, ModeShape mode) TUIData *data = ui->data; cursorentry_T c = data->cursor_shapes[mode]; int shape = c.shape; - unibi_var_t vars[26 + 26] = { { 0 } }; // Support changing cursor shape on some popular terminals. - const char *vte_version = os_getenv("VTE_VERSION"); if (c.id != 0 && ui->rgb) { int attr = syn_id2attr(c.id); @@ -789,37 +783,24 @@ static void tui_set_mode(UI *ui, ModeShape mode) } } - if (data->term == kTermKonsole) { - // Konsole uses a proprietary escape code to set the cursor shape - // and does not support DECSCUSR. - switch (shape) { - case SHAPE_BLOCK: shape = 0; break; - case SHAPE_VER: shape = 1; break; - case SHAPE_HOR: shape = 2; break; - default: WLOG("Unknown shape value %d", shape); break; - } - data->params[0].i = shape; - data->params[1].i = (c.blinkon != 0); - - unibi_format(vars, vars + 26, - TMUX_WRAP("\x1b]50;CursorShape=%p1%d;BlinkingCursorEnabled=%p2%d\x07"), - data->params, out, ui, NULL, NULL); - } else if (!vte_version || atoi(vte_version) >= 3900) { - // Assume that the terminal supports DECSCUSR unless it is an - // old VTE based terminal. This should not get wrapped for tmux, - // which will handle it via its Ss/Se terminfo extension - usually - // according to its terminal-overrides. + switch (shape) { + case SHAPE_BLOCK: shape = 0; break; + case SHAPE_VER: shape = 1; break; + case SHAPE_HOR: shape = 2; break; + default: WLOG("Unknown shape value %d", shape); break; + } + data->params[0].i = shape; + data->params[1].i = (c.blinkon != 0); + unibi_out(ui, data->unibi_ext.konsole_cursor_shape); - switch (shape) { - case SHAPE_BLOCK: shape = 1; break; - case SHAPE_HOR: shape = 3; break; - case SHAPE_VER: shape = 5; break; - default: WLOG("Unknown shape value %d", shape); break; - } - data->params[0].i = shape + (int)(c.blinkon == 0); - unibi_format(vars, vars + 26, "\x1b[%p1%d q", - data->params, out, ui, NULL, NULL); + switch (shape) { + case SHAPE_BLOCK: shape = 1; break; + case SHAPE_HOR: shape = 3; break; + case SHAPE_VER: shape = 5; break; + default: WLOG("Unknown shape value %d", shape); break; } + data->params[0].i = shape + (int)(c.blinkon == 0); + unibi_out(ui, data->unibi_ext.dec_cursor_shape); } /// @param mode editor mode @@ -1161,197 +1142,910 @@ static void unibi_set_if_empty(unibi_term *ut, enum unibi_string str, } } -static TermType detect_term(const char *term, const char *colorterm) +// Taken from unibilium/t/static_xterm.c as of 2015-08-14. +// This is an 8-colour terminfo description that lacks +// DECSTBN/DECSLRM/DECLRMM capabilities that xterm actually has. +static const char xterm_8colour_terminfo[] = { + 26, 1, 48, 0, 38, 0, 15, 0, -99, 1, 108, 5, 120, 116, 101, 114, 109, 124, 120, 116, + 101, 114, 109, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 101, 109, 117, 108, 97, 116, 111, + 114, 32, 40, 88, 32, 87, 105, 110, 100, 111, 119, 32, 83, 121, 115, 116, 101, 109, 41, 0, + 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 80, 0, + 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 8, 0, 64, 0, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, + 38, 0, 42, 0, 46, 0, -1, -1, 57, 0, 74, 0, 76, 0, 80, 0, 87, 0, -1, -1, + 89, 0, 102, 0, -1, -1, 106, 0, 110, 0, 120, 0, 124, 0, -1, -1, -1, -1, -128, 0, + -124, 0, -119, 0, -114, 0, -1, -1, -1, -1, -105, 0, -100, 0, -1, -1, -95, 0, -90, 0, + -85, 0, -80, 0, -71, 0, -67, 0, -60, 0, -1, -1, -51, 0, -46, 0, -40, 0, -34, 0, + -1, -1, -1, -1, -1, -1, -16, 0, -1, -1, -1, -1, -1, -1, 2, 1, -1, -1, 6, 1, + -1, -1, -1, -1, -1, -1, 8, 1, -1, -1, 13, 1, -1, -1, -1, -1, -1, -1, -1, -1, + 17, 1, 21, 1, 27, 1, 31, 1, 35, 1, 39, 1, 45, 1, 51, 1, 57, 1, 63, 1, + 69, 1, 73, 1, -1, -1, 78, 1, -1, -1, 82, 1, 87, 1, 92, 1, 96, 1, 103, 1, + -1, -1, 110, 1, 114, 1, 122, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -126, 1, -117, 1, -1, -1, -1, -1, -108, 1, + -99, 1, -90, 1, -81, 1, -72, 1, -63, 1, -54, 1, -45, 1, -36, 1, -27, 1, -1, -1, + -1, -1, -1, -1, -18, 1, -14, 1, -9, 1, -1, -1, -4, 1, -1, 1, -1, -1, -1, -1, + 17, 2, 20, 2, 31, 2, 34, 2, 36, 2, 39, 2, 121, 2, -1, -1, 124, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 126, 2, -1, -1, -1, -1, -1, -1, -1, -1, + -126, 2, -1, -1, -73, 2, -1, -1, -1, -1, -69, 2, -63, 2, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -57, 2, -53, 2, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -49, 2, -1, -1, -1, -1, -42, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -35, 2, -28, 2, -21, 2, -1, -1, -1, -1, -14, 2, -1, -1, + -7, 2, -1, -1, -1, -1, -1, -1, 0, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 7, 3, 13, 3, 19, 3, 26, 3, 33, 3, 40, 3, 47, 3, 55, 3, 63, 3, 71, 3, + 79, 3, 87, 3, 95, 3, 103, 3, 111, 3, 118, 3, 125, 3, -124, 3, -117, 3, -109, 3, + -101, 3, -93, 3, -85, 3, -77, 3, -69, 3, -61, 3, -53, 3, -46, 3, -39, 3, -32, 3, + -25, 3, -17, 3, -9, 3, -1, 3, 7, 4, 15, 4, 23, 4, 31, 4, 39, 4, 46, 4, + 53, 4, 60, 4, 67, 4, 75, 4, 83, 4, 91, 4, 99, 4, 107, 4, 115, 4, 123, 4, + -125, 4, -118, 4, -111, 4, -104, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -99, 4, -88, 4, -83, 4, + -75, 4, -71, 4, -1, -1, -1, -1, -1, -1, -1, -1, -62, 4, 8, 5, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 78, 5, + -1, -1, -1, -1, -1, -1, 82, 5, 92, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 102, 5, 105, 5, 27, 91, 90, 0, 7, 0, + 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, + 91, 51, 103, 0, 27, 91, 72, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, + 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, + 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, + 0, 8, 0, 27, 91, 63, 49, 50, 108, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, + 27, 91, 65, 0, 27, 91, 63, 49, 50, 59, 50, 53, 104, 0, 27, 91, 80, 0, 27, 91, + 77, 0, 27, 40, 48, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, + 48, 52, 57, 104, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, + 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 27, + 40, 66, 0, 27, 40, 66, 27, 91, 109, 0, 27, 91, 63, 49, 48, 52, 57, 108, 0, 27, + 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, + 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 27, 91, 33, 112, 27, 91, + 63, 51, 59, 52, 108, 27, 91, 52, 108, 27, 62, 0, 27, 91, 76, 0, 8, 0, 27, 91, + 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, + 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, + 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, + 79, 72, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, + 126, 0, 27, 79, 67, 0, 27, 91, 49, 59, 50, 66, 0, 27, 91, 49, 59, 50, 65, 0, + 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, + 27, 91, 63, 49, 48, 51, 52, 108, 0, 27, 91, 63, 49, 48, 51, 52, 104, 0, 27, 91, + 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, + 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, + 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, + 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, + 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 105, 0, 27, 91, 52, 105, 0, 27, 91, 53, + 105, 0, 27, 99, 0, 27, 91, 33, 112, 27, 91, 63, 51, 59, 52, 108, 27, 91, 52, 108, + 27, 62, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, + 10, 0, 27, 77, 0, 37, 63, 37, 112, 57, 37, 116, 27, 40, 48, 37, 101, 27, 40, 66, + 37, 59, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, + 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, + 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 55, 37, + 116, 59, 56, 37, 59, 109, 0, 27, 72, 0, 9, 0, 27, 79, 69, 0, 96, 96, 97, 97, + 102, 102, 103, 103, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, + 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, + 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 91, 63, 55, 104, 0, 27, + 91, 63, 55, 108, 0, 27, 79, 70, 0, 27, 79, 77, 0, 27, 91, 51, 59, 50, 126, 0, + 27, 91, 49, 59, 50, 70, 0, 27, 91, 49, 59, 50, 72, 0, 27, 91, 50, 59, 50, 126, + 0, 27, 91, 49, 59, 50, 68, 0, 27, 91, 54, 59, 50, 126, 0, 27, 91, 53, 59, 50, + 126, 0, 27, 91, 49, 59, 50, 67, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, + 0, 27, 91, 49, 59, 50, 80, 0, 27, 91, 49, 59, 50, 81, 0, 27, 91, 49, 59, 50, + 82, 0, 27, 91, 49, 59, 50, 83, 0, 27, 91, 49, 53, 59, 50, 126, 0, 27, 91, 49, + 55, 59, 50, 126, 0, 27, 91, 49, 56, 59, 50, 126, 0, 27, 91, 49, 57, 59, 50, 126, + 0, 27, 91, 50, 48, 59, 50, 126, 0, 27, 91, 50, 49, 59, 50, 126, 0, 27, 91, 50, + 51, 59, 50, 126, 0, 27, 91, 50, 52, 59, 50, 126, 0, 27, 91, 49, 59, 53, 80, 0, + 27, 91, 49, 59, 53, 81, 0, 27, 91, 49, 59, 53, 82, 0, 27, 91, 49, 59, 53, 83, + 0, 27, 91, 49, 53, 59, 53, 126, 0, 27, 91, 49, 55, 59, 53, 126, 0, 27, 91, 49, + 56, 59, 53, 126, 0, 27, 91, 49, 57, 59, 53, 126, 0, 27, 91, 50, 48, 59, 53, 126, + 0, 27, 91, 50, 49, 59, 53, 126, 0, 27, 91, 50, 51, 59, 53, 126, 0, 27, 91, 50, + 52, 59, 53, 126, 0, 27, 91, 49, 59, 54, 80, 0, 27, 91, 49, 59, 54, 81, 0, 27, + 91, 49, 59, 54, 82, 0, 27, 91, 49, 59, 54, 83, 0, 27, 91, 49, 53, 59, 54, 126, + 0, 27, 91, 49, 55, 59, 54, 126, 0, 27, 91, 49, 56, 59, 54, 126, 0, 27, 91, 49, + 57, 59, 54, 126, 0, 27, 91, 50, 48, 59, 54, 126, 0, 27, 91, 50, 49, 59, 54, 126, + 0, 27, 91, 50, 51, 59, 54, 126, 0, 27, 91, 50, 52, 59, 54, 126, 0, 27, 91, 49, + 59, 51, 80, 0, 27, 91, 49, 59, 51, 81, 0, 27, 91, 49, 59, 51, 82, 0, 27, 91, + 49, 59, 51, 83, 0, 27, 91, 49, 53, 59, 51, 126, 0, 27, 91, 49, 55, 59, 51, 126, + 0, 27, 91, 49, 56, 59, 51, 126, 0, 27, 91, 49, 57, 59, 51, 126, 0, 27, 91, 50, + 48, 59, 51, 126, 0, 27, 91, 50, 49, 59, 51, 126, 0, 27, 91, 50, 51, 59, 51, 126, + 0, 27, 91, 50, 52, 59, 51, 126, 0, 27, 91, 49, 59, 52, 80, 0, 27, 91, 49, 59, + 52, 81, 0, 27, 91, 49, 59, 52, 82, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, + 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 49, 59, 50, 99, 0, 27, + 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 37, 63, 37, 112, 49, + 37, 123, 49, 125, 37, 61, 37, 116, 52, 37, 101, 37, 112, 49, 37, 123, 51, 125, 37, 61, + 37, 116, 54, 37, 101, 37, 112, 49, 37, 123, 52, 125, 37, 61, 37, 116, 49, 37, 101, 37, + 112, 49, 37, 123, 54, 125, 37, 61, 37, 116, 51, 37, 101, 37, 112, 49, 37, 100, 37, 59, + 109, 0, 27, 91, 52, 37, 63, 37, 112, 49, 37, 123, 49, 125, 37, 61, 37, 116, 52, 37, + 101, 37, 112, 49, 37, 123, 51, 125, 37, 61, 37, 116, 54, 37, 101, 37, 112, 49, 37, 123, + 52, 125, 37, 61, 37, 116, 49, 37, 101, 37, 112, 49, 37, 123, 54, 125, 37, 61, 37, 116, + 51, 37, 101, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 77, 0, 27, 91, 51, 37, + 112, 49, 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0, 27, 108, 0, 27, + 109, 0, 2, 0, 1, 0, 57, 0, 117, 0, -88, 2, 1, 0, -1, -1, -1, -1, 0, 0, + 7, 0, 14, 0, 21, 0, 28, 0, 35, 0, 42, 0, 49, 0, 56, 0, 63, 0, 70, 0, + 77, 0, 84, 0, 91, 0, 98, 0, 105, 0, 112, 0, 119, 0, 126, 0, -123, 0, -116, 0, + -109, 0, -102, 0, -95, 0, -88, 0, -81, 0, -74, 0, -67, 0, -60, 0, -53, 0, -46, 0, + -39, 0, -32, 0, -25, 0, -18, 0, -11, 0, -4, 0, 3, 1, 10, 1, 17, 1, 24, 1, + 31, 1, 38, 1, 45, 1, 52, 1, 59, 1, 66, 1, 73, 1, 80, 1, 87, 1, 94, 1, + 101, 1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 3, 0, 6, 0, 9, 0, 12, 0, + 17, 0, 22, 0, 27, 0, 32, 0, 37, 0, 41, 0, 46, 0, 51, 0, 56, 0, 61, 0, + 66, 0, 72, 0, 78, 0, 84, 0, 90, 0, 96, 0, 102, 0, 108, 0, 114, 0, 120, 0, + 126, 0, -125, 0, -120, 0, -115, 0, -110, 0, -105, 0, -99, 0, -93, 0, -87, 0, -81, 0, + -75, 0, -69, 0, -63, 0, -57, 0, -51, 0, -45, 0, -39, 0, -33, 0, -27, 0, -21, 0, + -15, 0, -9, 0, -3, 0, 3, 1, 9, 1, 15, 1, 19, 1, 24, 1, 29, 1, 34, 1, + 39, 1, 44, 1, 48, 1, 52, 1, 56, 1, 27, 91, 51, 59, 51, 126, 0, 27, 91, 51, + 59, 52, 126, 0, 27, 91, 51, 59, 53, 126, 0, 27, 91, 51, 59, 54, 126, 0, 27, 91, + 51, 59, 55, 126, 0, 27, 91, 49, 59, 50, 66, 0, 27, 91, 49, 59, 51, 66, 0, 27, + 91, 49, 59, 52, 66, 0, 27, 91, 49, 59, 53, 66, 0, 27, 91, 49, 59, 54, 66, 0, + 27, 91, 49, 59, 55, 66, 0, 27, 91, 49, 59, 51, 70, 0, 27, 91, 49, 59, 52, 70, + 0, 27, 91, 49, 59, 53, 70, 0, 27, 91, 49, 59, 54, 70, 0, 27, 91, 49, 59, 55, + 70, 0, 27, 91, 49, 59, 51, 72, 0, 27, 91, 49, 59, 52, 72, 0, 27, 91, 49, 59, + 53, 72, 0, 27, 91, 49, 59, 54, 72, 0, 27, 91, 49, 59, 55, 72, 0, 27, 91, 50, + 59, 51, 126, 0, 27, 91, 50, 59, 52, 126, 0, 27, 91, 50, 59, 53, 126, 0, 27, 91, + 50, 59, 54, 126, 0, 27, 91, 50, 59, 55, 126, 0, 27, 91, 49, 59, 51, 68, 0, 27, + 91, 49, 59, 52, 68, 0, 27, 91, 49, 59, 53, 68, 0, 27, 91, 49, 59, 54, 68, 0, + 27, 91, 49, 59, 55, 68, 0, 27, 91, 54, 59, 51, 126, 0, 27, 91, 54, 59, 52, 126, + 0, 27, 91, 54, 59, 53, 126, 0, 27, 91, 54, 59, 54, 126, 0, 27, 91, 54, 59, 55, + 126, 0, 27, 91, 53, 59, 51, 126, 0, 27, 91, 53, 59, 52, 126, 0, 27, 91, 53, 59, + 53, 126, 0, 27, 91, 53, 59, 54, 126, 0, 27, 91, 53, 59, 55, 126, 0, 27, 91, 49, + 59, 51, 67, 0, 27, 91, 49, 59, 52, 67, 0, 27, 91, 49, 59, 53, 67, 0, 27, 91, + 49, 59, 54, 67, 0, 27, 91, 49, 59, 55, 67, 0, 27, 91, 49, 59, 50, 65, 0, 27, + 91, 49, 59, 51, 65, 0, 27, 91, 49, 59, 52, 65, 0, 27, 91, 49, 59, 53, 65, 0, + 27, 91, 49, 59, 54, 65, 0, 27, 91, 49, 59, 55, 65, 0, 65, 88, 0, 88, 84, 0, + 85, 56, 0, 88, 77, 0, 107, 68, 67, 51, 0, 107, 68, 67, 52, 0, 107, 68, 67, 53, + 0, 107, 68, 67, 54, 0, 107, 68, 67, 55, 0, 107, 68, 78, 0, 107, 68, 78, 51, 0, + 107, 68, 78, 52, 0, 107, 68, 78, 53, 0, 107, 68, 78, 54, 0, 107, 68, 78, 55, 0, + 107, 69, 78, 68, 51, 0, 107, 69, 78, 68, 52, 0, 107, 69, 78, 68, 53, 0, 107, 69, + 78, 68, 54, 0, 107, 69, 78, 68, 55, 0, 107, 72, 79, 77, 51, 0, 107, 72, 79, 77, + 52, 0, 107, 72, 79, 77, 53, 0, 107, 72, 79, 77, 54, 0, 107, 72, 79, 77, 55, 0, + 107, 73, 67, 51, 0, 107, 73, 67, 52, 0, 107, 73, 67, 53, 0, 107, 73, 67, 54, 0, + 107, 73, 67, 55, 0, 107, 76, 70, 84, 51, 0, 107, 76, 70, 84, 52, 0, 107, 76, 70, + 84, 53, 0, 107, 76, 70, 84, 54, 0, 107, 76, 70, 84, 55, 0, 107, 78, 88, 84, 51, + 0, 107, 78, 88, 84, 52, 0, 107, 78, 88, 84, 53, 0, 107, 78, 88, 84, 54, 0, 107, + 78, 88, 84, 55, 0, 107, 80, 82, 86, 51, 0, 107, 80, 82, 86, 52, 0, 107, 80, 82, + 86, 53, 0, 107, 80, 82, 86, 54, 0, 107, 80, 82, 86, 55, 0, 107, 82, 73, 84, 51, + 0, 107, 82, 73, 84, 52, 0, 107, 82, 73, 84, 53, 0, 107, 82, 73, 84, 54, 0, 107, + 82, 73, 84, 55, 0, 107, 85, 80, 0, 107, 85, 80, 51, 0, 107, 85, 80, 52, 0, 107, + 85, 80, 53, 0, 107, 85, 80, 54, 0, 107, 85, 80, 55, 0, 107, 97, 50, 0, 107, 98, + 49, 0, 107, 98, 51, 0, 107, 99, 50, 0 +}; +// Taken from unibilium/t/static_tmux.c as of 2015-08-14. +// This is an 256-colour terminfo description that lacks +// status line capabilities that tmux actually has. +static const char tmux_256colour_terminfo[] = { + 26, 1, 56, 0, 15, 0, 15, 0, 105, 1, -48, 2, 116, 109, 117, 120, 124, 86, 84, 32, + 49, 48, 48, 47, 65, 78, 83, 73, 32, 88, 51, 46, 54, 52, 32, 118, 105, 114, 116, 117, + 97, 108, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 119, 105, 116, 104, 32, 50, 53, 54, + 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, + 0, 1, 1, 0, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, + 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, -1, -1, -1, -1, 45, 0, 62, 0, 64, 0, + 68, 0, 75, 0, -1, -1, 77, 0, 89, 0, -1, -1, 93, 0, 96, 0, 102, 0, 106, 0, + -1, -1, -1, -1, 110, 0, 112, 0, 117, 0, 122, 0, -1, -1, -1, -1, 123, 0, -1, -1, + -1, -1, -128, 0, -123, 0, -118, 0, -1, -1, -113, 0, -111, 0, -106, 0, -1, -1, -105, 0, + -100, 0, -94, 0, -88, 0, -1, -1, -1, -1, -1, -1, -85, 0, -1, -1, -1, -1, -1, -1, + -81, 0, -1, -1, -77, 0, -1, -1, -1, -1, -1, -1, -75, 0, -1, -1, -70, 0, -1, -1, + -1, -1, -1, -1, -1, -1, -66, 0, -62, 0, -56, 0, -52, 0, -48, 0, -44, 0, -38, 0, + -32, 0, -26, 0, -20, 0, -14, 0, -9, 0, -1, -1, -4, 0, -1, -1, 0, 1, 5, 1, + 10, 1, -1, -1, -1, -1, -1, -1, 14, 1, 18, 1, 26, 1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 34, 1, -1, -1, 37, 1, 46, 1, 55, 1, 64, 1, -1, -1, 73, 1, 82, 1, 91, 1, + -1, -1, 100, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 109, 1, -1, -1, -1, -1, 126, 1, -1, -1, -127, 1, -124, 1, -122, 1, -119, 1, -46, 1, + -1, -1, -43, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -41, 1, -1, -1, 24, 2, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 28, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 35, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 40, 2, 46, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 52, 2, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 57, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 66, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 71, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 77, 2, -1, -1, -1, -1, -1, -1, 81, 2, -112, 2, 27, 91, 90, 0, + 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, + 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, + 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, + 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 51, 52, 104, 27, 91, + 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 51, 52, 108, 0, 27, 91, + 80, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 0, 27, + 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 15, + 0, 27, 91, 109, 15, 0, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, + 50, 52, 109, 0, 27, 103, 0, 27, 41, 48, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, + 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, + 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, + 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, + 49, 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, + 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, + 63, 49, 104, 27, 61, 0, 27, 69, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, + 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, + 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, + 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, + 0, 27, 99, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, + 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, + 49, 37, 59, 37, 63, 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, + 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, + 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, + 59, 0, 27, 72, 0, 9, 0, 43, 43, 44, 44, 45, 45, 46, 46, 48, 48, 96, 96, 97, + 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, + 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, + 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, + 41, 48, 0, 27, 91, 52, 126, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, + 27, 91, 49, 75, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 109, 0, 27, + 91, 50, 51, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, + 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, + 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, + 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, + 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, + 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, + 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 +}; +// Taken from unibilium/t/static_screen-256color.c as of 2015-08-14. +// This is an 256-colour terminfo description that lacks +// status line capabilities that screen actually has. +static const char screen_256colour_terminfo[] = { + 26, 1, 43, 0, 43, 0, 15, 0, 105, 1, -43, 2, 115, 99, 114, 101, 101, 110, 45, 50, + 53, 54, 99, 111, 108, 111, 114, 124, 71, 78, 85, 32, 83, 99, 114, 101, 101, 110, 32, 119, + 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, + 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 80, 0, + 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, + 37, 0, 41, 0, -1, -1, -1, -1, 45, 0, 62, 0, 64, 0, 68, 0, 75, 0, -1, -1, + 77, 0, 89, 0, -1, -1, 93, 0, 96, 0, 102, 0, 106, 0, -1, -1, -1, -1, 110, 0, + 112, 0, 117, 0, 122, 0, -1, -1, -1, -1, -125, 0, -1, -1, -1, -1, -120, 0, -115, 0, + -110, 0, -1, -1, -105, 0, -103, 0, -98, 0, -1, -1, -89, 0, -84, 0, -78, 0, -72, 0, + -1, -1, -1, -1, -1, -1, -69, 0, -1, -1, -1, -1, -1, -1, -65, 0, -1, -1, -61, 0, + -1, -1, -1, -1, -1, -1, -59, 0, -1, -1, -54, 0, -1, -1, -1, -1, -1, -1, -1, -1, + -50, 0, -46, 0, -40, 0, -36, 0, -32, 0, -28, 0, -22, 0, -16, 0, -10, 0, -4, 0, + 2, 1, 7, 1, -1, -1, 12, 1, -1, -1, 16, 1, 21, 1, 26, 1, -1, -1, -1, -1, + -1, -1, 30, 1, 34, 1, 42, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 1, -1, -1, 53, 1, + 62, 1, 71, 1, 80, 1, -1, -1, 89, 1, 98, 1, 107, 1, -1, -1, 116, 1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 125, 1, -1, -1, -1, -1, + -114, 1, -1, -1, -111, 1, -108, 1, -106, 1, -103, 1, -30, 1, -1, -1, -27, 1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -25, 1, -1, -1, 40, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 2, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 51, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 56, 2, 62, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 68, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 73, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 82, 2, + -1, -1, -1, -1, -1, -1, 86, 2, -107, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, + 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, + 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, + 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, + 63, 50, 53, 108, 0, 8, 0, 27, 91, 51, 52, 104, 27, 91, 63, 50, 53, 104, 0, 27, + 91, 67, 0, 27, 77, 0, 27, 91, 51, 52, 108, 0, 27, 91, 80, 0, 27, 91, 77, 0, + 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, 48, 52, 57, 104, + 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 51, 109, 0, 27, 91, 52, 109, + 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 63, 49, 48, 52, 57, 108, 0, 27, 91, 52, + 108, 0, 27, 91, 50, 51, 109, 0, 27, 91, 50, 52, 109, 0, 27, 103, 0, 27, 41, 48, + 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, + 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, + 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, + 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 79, + 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, + 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 69, 0, 27, + 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, + 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, + 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, + 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 91, 63, 49, 48, 48, 48, + 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, + 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 49, 37, 116, + 59, 51, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, + 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, + 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 43, 43, 44, + 44, 45, 45, 46, 46, 48, 48, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, + 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, + 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, + 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, 41, 48, 0, 27, 91, 52, 126, 0, 27, 91, + 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 51, 57, 59, + 52, 57, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, + 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, + 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, + 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, + 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, + 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, + 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 0, 3, 0, 1, 0, + 24, 0, 52, 0, -112, 0, 1, 1, 0, 0, 1, 0, 0, 0, 4, 0, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 0, 0, 3, 0, 6, 0, 9, 0, 12, 0, 15, 0, 18, 0, 23, 0, 28, 0, 32, 0, + 37, 0, 43, 0, 49, 0, 55, 0, 61, 0, 66, 0, 71, 0, 77, 0, 83, 0, 89, 0, + 95, 0, 101, 0, 107, 0, 111, 0, 116, 0, 120, 0, 124, 0, -128, 0, 27, 40, 66, 0, + 27, 40, 37, 112, 49, 37, 99, 0, 65, 88, 0, 71, 48, 0, 88, 84, 0, 85, 56, 0, + 69, 48, 0, 83, 48, 0, 107, 68, 67, 53, 0, 107, 68, 67, 54, 0, 107, 68, 78, 0, + 107, 68, 78, 53, 0, 107, 69, 78, 68, 53, 0, 107, 69, 78, 68, 54, 0, 107, 72, 79, + 77, 53, 0, 107, 72, 79, 77, 54, 0, 107, 73, 67, 53, 0, 107, 73, 67, 54, 0, 107, + 76, 70, 84, 53, 0, 107, 78, 88, 84, 53, 0, 107, 78, 88, 84, 54, 0, 107, 80, 82, + 86, 53, 0, 107, 80, 82, 86, 54, 0, 107, 82, 73, 84, 53, 0, 107, 85, 80, 0, 107, + 85, 80, 53, 0, 107, 97, 50, 0, 107, 98, 49, 0, 107, 98, 51, 0, 107, 99, 50, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +static const char iterm_16colour_terminfo[] = { + 26, 1, 57, 0, 29, 0, 15, 0, 105, 1, 73, 3, 105, 84, 101, 114, 109, 46, 97, 112, 112, 124, 105, 116, 101, 114, 109, 124, 105, 84, 101, 114, +109, 46, 97, 112, 112, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 101, 109, 117, 108, 97, 116, 111, 114, 32, 102, 111, 114, 32, 77, 97, 99, 32, + 79, 83, 32, 88, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, + 0, 1, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, 50, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, + -1, -1, 0, 0, 2, 0, -2, -1, 4, 0, 9, 0, 16, 0, 20, 0, 24, 0, -1, -1, 35, 0, 52, 0, 54, 0, 58, 0, 65, 0, -1, -1, + 67, 0, 74, 0, -1, -1, 78, 0, -1, -1, 82, 0, 86, 0, 90, 0, -1, -1, 96, 0, 98, 0, 103, 0, 108, 0, -1, -1, -2, -1, 117, 0, +122, 0, -1, -1, 127, 0,-124, 0,-119, 0, -1, -1,-114, 0,-112, 0,-107, 0, -1, -1, -94, 0, -89, 0, -85, 0, -81, 0, -1, -1, -63, 0, + -1, -1, -1, -1, -1, -1, -1, -1, -61, 0, -57, 0, -1, -1, -53, 0, -1, -1, -1, -1, -1, -1, -51, 0, -1, -1, -46, 0, -1, -1, -1, -1, + -1, -1, -1, -1, -42, 0, -38, 0, -32, 0, -28, 0, -24, 0, -20, 0, -14, 0, -8, 0, -2, 0, 4, 1, 10, 1, -1, -1, -1, -1, 14, 1, + -1, -1, 18, 1, 23, 1, 28, 1, -1, -1, -1, -1, -1, -1, 32, 1, 36, 1, 44, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 52, 1, 61, 1, 70, 1, 79, 1, -1, -1, 88, 1, 97, 1, +106, 1, -1, -1, 115, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 124, 1, -1, -1, -1, -1,-104, 1,-101, 1, +-90, 1, -87, 1, -85, 1, -82, 1, -4, 1, -1, -1, -1, 1, 1, 2, -1, -1, -1, -1, -1, -1, 6, 2, 10, 2, 14, 2, 18, 2, 22, 2, + -1, -1, -1, -1, 26, 2, -1, -1, -1, -1, -1, -1, -1, -1, 77, 2, 83, 2, -1, -1, -1, -1, 89, 2, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 96, 2, 100, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, 2, 110, 2, 116, 2, 122, 2,-128, 2,-122, 2,-116, 2,-110, 2, +104, 2, -98, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -92, 2, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -87, 2, -76, 2, -71, 2, -63, 2, -59, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -54, 2, 9, 3, 7, 0, 13, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, + 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, +112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, + 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 93, 50, 59, 7, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 55, + 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, + 15, 0, 27, 91, 109, 15, 0, 27, 91, 50, 74, 27, 91, 63, 52, 55, 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, 91, 109, 0, 27, 91, 109, + 0, 27, 91, 63, 53, 104, 36, 60, 50, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 7, 0, 27, 91, 64, 0, 27, 91, 76, 0, 127, 0, 27, + 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, + 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 79, 72, 0, + 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, + 63, 49, 104, 27, 61, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, + 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, + 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 62, 27, 91, 63, 51, 108, 27, 91, 63, 52, 108, 27, 91, 63, 53, 108, 27, + 91, 63, 55, 104, 27, 91, 63, 56, 104, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, + 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, + 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 109, + 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 93, 50, 59, 0, 27, 79, 113, 0, 27, 79, 115, 0, + 27, 79, 114, 0, 27, 79, 112, 0, 27, 79, 110, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, +112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, + 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 40, 66, 27, 41, 48, 0, 27, 79, 70, 0, 27, 79, 77, 0, 27, 91, 50, 51, 126, 0, + 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, 0, 27, 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, + 51, 49, 126, 0, 27, 91, 50, 50, 126, 0, 27, 91, 51, 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, +100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 49, 59, 50, 99, 0, 27, 91, 99, 0, 27, 91, 48, 109, 0, 27, 91, 37, 63, + 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, + 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, +112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, + 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +static const char rxvt_256colour_terminfo[] = { + 26, 1, 47, 0, 29, 0, 15, 0, 110, 1, -31, 4, 114, 120, 118, 116, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 114, 120, 118, 116, 32, 50, + 46, 55, 46, 57, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, 32, 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 80, 0, 8, 0, 24, 0, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, -1, -1, 0, 0, 2, 0, 4, 0, 21, 0, + 26, 0, 34, 0, 38, 0, 42, 0, -1, -1, 53, 0, 70, 0, 72, 0, 76, 0, 83, 0, -1, -1, 85, 0, 92, 0, -1, -1, 96, 0, -1, -1, + -1, -1, 100, 0, -1, -1, -1, -1, 104, 0, 106, 0, 111, 0, 116, 0, -1, -1, -1, -1, 125, 0, -1, -1, -1, -1,-126, 0,-121, 0,-116, 0, + -1, -1,-111, 0,-109, 0,-104, 0, -1, -1, -91, 0, -86, 0, -80, 0, -74, 0, -1, -1, -1, -1, -56, 0, -42, 0, -1, -1, -1, -1, -8, 0, + -4, 0, -1, -1, 0, 1, -1, -1, -1, -1, -1, -1, 2, 1, -1, -1, 7, 1, -1, -1, 11, 1, -1, -1, 16, 1, 22, 1, 28, 1, 34, 1, + 40, 1, 46, 1, 52, 1, 58, 1, 64, 1, 70, 1, 76, 1, 82, 1, 87, 1, -1, -1, 92, 1, -1, -1, 96, 1, 101, 1, 106, 1, 110, 1, +114, 1, -1, -1, 118, 1, 122, 1, 125, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-128, 1,-119, 1,-110, 1, -1, -1,-101, 1, -92, 1, -83, 1, -1, -1, -74, 1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -65, 1, -32, 1, -1, -1, -1, -1, 18, 2, 21, 2, 32, 2, 35, 2, 37, 2, 40, 2, 107, 2, + -1, -1, 110, 2, -1, -1, -1, -1, -1, -1, -1, -1, 112, 2, 116, 2, 120, 2, 124, 2,-128, 2, -1, -1, -1, -1,-124, 2, -1, -1, -73, 2, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -69, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -62, 2, +-57, 2, -1, -1, -53, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -48, 2, -1, -1, -43, 2, -38, 2, -1, -1, -1, -1, + -1, -1, -1, -1, -33, 2, -28, 2, -23, 2, -1, -1, -1, -1, -19, 2, -1, -1, -14, 2, -1, -1, -1, -1, -1, -1, -9, 2, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -5, 2, 1, 3, 7, 3, 13, 3, 19, 3, 25, 3, 31, 3, 37, 3, 43, 3, 49, 3, 55, 3, 61, 3, 67, 3, + 73, 3, 79, 3, 85, 3, 91, 3, 97, 3, 103, 3, 109, 3, 115, 3, 121, 3, 127, 3,-123, 3,-117, 3,-111, 3,-105, 3, -99, 3, -93, 3, +-87, 3, -81, 3, -75, 3, -69, 3, -63, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -57, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +-52, 3, -41, 3, -36, 3, -28, 3, -24, 3, -15, 3, -8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, 4, -1, -1, + -1, -1, -1, -1, 90, 4,-103, 4, -1, -1, -1, -1, -1, -1, -39, 4, -35, 4, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, + 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, + 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, + 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, + 0, 27, 91, 49, 109, 0, 27, 55, 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, + 52, 109, 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 50, 74, 27, 91, 63, 52, 55, 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, +109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 27, 91, 63, 52, 55, 108, + 27, 61, 27, 91, 63, 49, 108, 0, 27, 91, 114, 27, 91, 109, 27, 91, 50, 74, 27, 91, 72, 27, 91, 63, 55, 104, 27, 91, 63, 49, 59, 51, + 59, 52, 59, 54, 108, 27, 91, 52, 108, 0, 27, 91, 64, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 91, 66, 0, 27, 91, 56, + 94, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, 49, 126, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, 50, 126, 0, 27, 91, 49, 51, 126, 0, + 27, 91, 49, 52, 126, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, + 50, 48, 126, 0, 27, 91, 55, 126, 0, 27, 91, 50, 126, 0, 27, 91, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 91, 67, 0, + 27, 91, 97, 0, 27, 91, 98, 0, 27, 91, 65, 0, 27, 62, 0, 27, 61, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, + 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, + 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 62, 27, 91, 49, 59, 51, 59, 52, 59, 53, 59, 54, 108, 27, + 91, 63, 55, 104, 27, 91, 109, 27, 91, 114, 27, 91, 50, 74, 27, 91, 72, 0, 27, 91, 114, 27, 91, 109, 27, 91, 50, 74, 27, 91, 72, 27, + 91, 63, 55, 104, 27, 91, 63, 49, 59, 51, 59, 52, 59, 54, 108, 27, 91, 52, 108, 27, 62, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, + 50, 53, 104, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, +112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, + 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, + 9, 0, 27, 79, 119, 0, 27, 79, 121, 0, 27, 79, 117, 0, 27, 79, 113, 0, 27, 79, 115, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, +107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, +123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, 41, 48, 0, 27, 91, 56, 126, 0, 27, 79, 77, 0, 27, 91, 49, +126, 0, 27, 91, 51, 36, 0, 27, 91, 52, 126, 0, 27, 91, 56, 36, 0, 27, 91, 55, 36, 0, 27, 91, 50, 36, 0, 27, 91, 100, 0, 27, + 91, 54, 36, 0, 27, 91, 53, 36, 0, 27, 91, 99, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, 0, 27, + 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, 51, 49, 126, 0, 27, 91, 51, 50, 126, 0, 27, 91, 51, + 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 50, 51, 36, 0, 27, 91, 50, 52, 36, 0, 27, 91, 49, 49, 94, 0, 27, 91, 49, 50, 94, + 0, 27, 91, 49, 51, 94, 0, 27, 91, 49, 52, 94, 0, 27, 91, 49, 53, 94, 0, 27, 91, 49, 55, 94, 0, 27, 91, 49, 56, 94, 0, 27, + 91, 49, 57, 94, 0, 27, 91, 50, 48, 94, 0, 27, 91, 50, 49, 94, 0, 27, 91, 50, 51, 94, 0, 27, 91, 50, 52, 94, 0, 27, 91, 50, + 53, 94, 0, 27, 91, 50, 54, 94, 0, 27, 91, 50, 56, 94, 0, 27, 91, 50, 57, 94, 0, 27, 91, 51, 49, 94, 0, 27, 91, 51, 50, 94, + 0, 27, 91, 51, 51, 94, 0, 27, 91, 51, 52, 94, 0, 27, 91, 50, 51, 64, 0, 27, 91, 50, 52, 64, 0, 27, 91, 49, 75, 0, 27, 91, + 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 49, 59, 50, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, + 57, 109, 0, 27, 93, 49, 48, 52, 7, 0, 27, 93, 52, 59, 37, 112, 49, 37, 100, 59, 114, 103, 98, 58, 37, 112, 50, 37, 123, 50, 53, 53, +125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, + 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 52, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, + 37, 50, 46, 50, 88, 27, 92, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, +100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, + 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, + 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, + 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 40, 66, 0, 27, 40, 48, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +static const char linux_16colour_terminfo[] = { + 26, 1, 43, 0, 29, 0, 16, 0, 125, 1, 125, 3, 108, 105, 110, 117, 120, 45, 49, 54, 99, 111, 108, 111, 114, 124, 108, 105, 110, 117, 120, 32, + 99, 111, 110, 115, 111, 108, 101, 32, 119, 105, 116, 104, 32, 49, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, -1, -1, 8, 0, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, 0, 0, 1, 42, 0, -1, -1, 0, 0, 2, 0, 4, 0, 21, 0, 26, 0, + 33, 0, 37, 0, 41, 0, -1, -1, 52, 0, 69, 0, 71, 0, 75, 0, 87, 0, -1, -1, 89, 0, 101, 0, -1, -1, 105, 0, 109, 0, 121, 0, +125, 0, -1, -1, -1, -1,-127, 0,-125, 0,-120, 0, -1, -1, -1, -1,-115, 0,-110, 0, -1, -1, -1, -1,-105, 0,-100, 0, -95, 0, -90, 0, +-81, 0, -79, 0, -1, -1, -1, -1, -74, 0, -69, 0, -63, 0, -57, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -39, 0, -35, 0, + -1, -1, -31, 0, -1, -1, -1, -1, -1, -1, -29, 0, -1, -1, -24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -20, 0, -15, 0, -9, 0, -4, 0, + 1, 1, 6, 1, 11, 1, 17, 1, 23, 1, 29, 1, 35, 1, 40, 1, -1, -1, 45, 1, -1, -1, 49, 1, 54, 1, 59, 1, -1, -1, -1, -1, + -1, -1, 63, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 67, 1, -1, -1, 70, 1, 79, 1, 88, 1, 97, 1, -1, -1, 106, 1, 115, 1, 124, 1, -1, -1,-123, 1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1,-114, 1, -1, -1, -1, -1, -1, -1,-108, 1,-105, 1, -94, 1, -91, 1, -89, 1, -86, 1, 1, 2, -1, -1, + 4, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, 10, 2, -1, -1, 77, 2, -1, -1, + -1, -1, 81, 2, 87, 2, -1, -1, -1, -1, 93, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 97, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 102, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 104, 2, 110, 2, 116, 2, 122, 2,-128, 2,-122, 2,-116, 2,-110, 2,-104, 2, -98, 2, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -92, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -87, 2, +-76, 2, -71, 2, -65, 2, -61, 2, -52, 2, -48, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 3, -1, -1, -1, -1, + -1, -1, 37, 3, 75, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 113, 3, 119, 3, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, +100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, + 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 27, + 91, 63, 49, 99, 0, 8, 0, 27, 91, 63, 50, 53, 104, 27, 91, 63, 48, 99, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 63, 50, 53, +104, 27, 91, 63, 56, 99, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 50, 109, 0, + 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 15, 0, 27, + 91, 109, 15, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 50, 48, 48, 47, + 62, 27, 91, 63, 53, 108, 0, 27, 91, 64, 0, 27, 91, 76, 0, 127, 0, 27, 91, 51, 126, 0, 27, 91, 66, 0, 27, 91, 91, 65, 0, 27, + 91, 50, 49, 126, 0, 27, 91, 91, 66, 0, 27, 91, 91, 67, 0, 27, 91, 91, 68, 0, 27, 91, 91, 69, 0, 27, 91, 49, 55, 126, 0, 27, + 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 91, 68, 0, 27, + 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, +112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, + 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 93, + 82, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 59, 49, 48, 37, 63, + 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, + 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 53, 37, 116, 59, 50, 37, 59, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, +109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 91, 71, 0, 43, 43, 44, 44, 45, 45, 46, 46, + 48, 48, 95, 95, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, +114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 99, 126, 126, 0, 27, 91, 90, 0, 27, + 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 41, 48, 0, 27, 91, 52, 126, 0, 26, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, +126, 0, 27, 91, 50, 53, 126, 0, 27, 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, 51, 49, 126, 0, + 27, 91, 51, 50, 126, 0, 27, 91, 51, 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, + 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 54, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 93, 82, 0, 27, 93, + 80, 37, 112, 49, 37, 120, 37, 112, 50, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 37, 112, + 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 37, 112, 52, 37, 123, 50, 53, 53, 125, 37, + 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 0, 27, 91, 77, 0, 27, 91, 51, 37, 112, 49, 37, 123, 56, 125, 37, 109, 37, +100, 37, 63, 37, 112, 49, 37, 123, 55, 125, 37, 62, 37, 116, 59, 49, 37, 101, 59, 50, 49, 37, 59, 109, 0, 27, 91, 52, 37, 112, 49, 37, +123, 56, 125, 37, 109, 37, 100, 37, 63, 37, 112, 49, 37, 123, 55, 125, 37, 62, 37, 116, 59, 53, 37, 101, 59, 50, 53, 37, 59, 109, 0, 27, + 91, 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +static const char putty_256colour_terminfo[] = { + 26, 1, 48, 0, 29, 0, 16, 0, 125, 1,-106, 4, 112, 117, 116, 116, 121, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 80, 117, 84, 84, 89, + 32, 48, 46, 53, 56, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, 32, 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, 1, 1, 0, 0, + 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, -1, -1, 8, 0, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 22, 0, 0, 0, 4, 0, 6, 0, + 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, 45, 0, -1, -1, 56, 0, 73, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, 96, 0, -1, -1, + 100, 0, -1, -1, 103, 0, 107, 0, 111, 0, -1, -1, 117, 0, 119, 0, 124, 0,-127, 0, -1, -1, -1, -1,-120, 0, -1, -1, -1, -1,-115, 0, +-110, 0,-105, 0,-100, 0, -91, 0, -89, 0, -84, 0, -1, -1, -73, 0, -68, 0, -62, 0, -56, 0, -1, -1, -38, 0, -1, -1, -36, 0, -1, -1, + -1, -1, -1, -1, -2, 0, -1, -1, 2, 1, -1, -1, -1, -1, -1, -1, 4, 1, -1, -1, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, 13, 1, + 19, 1, 25, 1, 31, 1, 37, 1, 43, 1, 49, 1, 55, 1, 61, 1, 67, 1, 73, 1, 78, 1, -1, -1, 83, 1, -1, -1, 87, 1, 92, 1, + 97, 1, 101, 1, 105, 1, -1, -1, 109, 1, 113, 1, 121, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1,-127, 1, -1, -1,-124, 1,-115, 1,-106, 1, -1, -1, -97, 1, -88, 1, -79, 1, -70, 1, -61, 1, -52, 1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -43, 1, -1, -1, -1, -1, -10, 1, -7, 1, 4, 2, 7, 2, 9, 2, + 12, 2, 84, 2, -1, -1, 87, 2, 89, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 94, 2, -1, -1, -1, -1, -1, -1, -1, -1, 98, 2, + -1, -1,-107, 2, -1, -1, -1, -1,-103, 2, -97, 2, -1, -1, -1, -1, -91, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -84, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -79, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -77, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -73, 2, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -69, 2, -63, 2, -57, 2, -51, 2, -45, 2, -39, 2, -33, 2, -27, 2, -21, 2, -15, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -4, 2, 7, 3, 12, 3, 18, 3, 22, 3, 31, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 35, 3, -1, -1, -1, -1, -1, -1, 39, 3, 102, 3, -1, -1, -1, -1, -1, -1, -90, 3, -84, 3, -78, 3, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -72, 3,-118, 4,-112, 4, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, + 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, + 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 27, 68, 0, + 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 80, 0, 27, + 91, 77, 0, 27, 93, 48, 59, 7, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, + 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 15, 0, 27, 91, 109, 15, 0, + 27, 91, 50, 74, 27, 91, 63, 52, 55, 108, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, + 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 7, 0, 27, 55, 27, 91, 114, 27, 91, 109, 27, 91, 63, 55, 104, 27, 91, 63, + 49, 59, 52, 59, 54, 108, 27, 91, 52, 108, 27, 56, 27, 62, 27, 93, 82, 0, 27, 91, 76, 0, 127, 0, 27, 91, 51, 126, 0, 27, 79, 66, + 0, 27, 91, 49, 49, 126, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, 50, 126, 0, 27, 91, 49, 51, 126, 0, 27, 91, 49, 52, 126, 0, 27, + 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, + 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 91, 66, 0, 27, 91, 65, + 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 80, + 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, + 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, + 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 60, 27, 91, 34, 112, 27, 91, 53, 48, 59, 54, 34, 112, 27, 99, 27, 91, 63, 51, 108, 27, 93, + 82, 27, 91, 63, 49, 48, 48, 48, 108, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, + 27, 91, 48, 37, 63, 37, 112, 49, 37, 112, 54, 37, 124, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, + 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, + 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 93, 48, 59, 0, 27, 91, 71, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, + 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, + 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 40, 66, 27, 41, 48, 0, + 27, 91, 52, 126, 0, 26, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, + 0, 27, 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, 51, 49, 126, 0, 27, 91, 51, 50, 126, 0, 27, + 91, 51, 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, + 27, 91, 63, 54, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 93, 82, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, + 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, + 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, + 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, + 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 49, 48, 109, 0, + 27, 91, 49, 49, 109, 0, 27, 91, 49, 50, 109, 0, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-105,-104, + 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 48, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-105,-103, 27, 37, 37, 64, 37, 101, 37, + 112, 49, 37, 123, 49, 50, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-103,-128, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 51, 125, + 37, 61, 37, 116, 27, 37, 37, 71, -30,-103, -86, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 52, 125, 37, 61, 37, 116, 27, 37, 37, + 71, -30,-103, -85, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 53, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-104, -68, 27, 37, 37, + 64, 37, 101, 37, 112, 49, 37, 123, 50, 55, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-122,-112, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, + 123, 49, 53, 53, 125, 37, 61, 37, 116, 27, 37, 37, 71, -32,-126, -94, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 99, 37, 59, 0, 27, 91, + 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +static const char interix_8colour_terminfo[] = { + 26, 1, 82, 0, 15, 0, 16, 0, 105, 1, 123, 2, 105, 110, 116, 101, 114, 105, 120, 124, 111, 112, 101, 110, 110, 116, 124, 111, 112, 101, 110, 110, + 116, 45, 50, 53, 124, 110, 116, 99, 111, 110, 115, 111, 108, 101, 124, 110, 116, 99, 111, 110, 115, 111, 108, 101, 45, 50, 53, 124, 79, 112, 101, 110, + 78, 84, 45, 116, 101, 114, 109, 32, 99, 111, 109, 112, 97, 116, 105, 98, 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, 108, 111, 114, 0, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 80, 0, -1, -1, 25, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 8, 0, 64, 0, 3, 0, 0, 0, 4, 0, -1, -1, -1, -1, -1, -1, 6, 0, 11, 0, 15, 0, -1, -1, + -1, -1, 19, 0, 36, 0, 38, 0, -1, -1, 42, 0, -1, -1, -1, -1, 46, 0, 50, 0, 54, 0, -1, -1, -1, -1, 58, 0, -1, -1, -1, -1, + -1, -1, -1, -1, 62, 0, 67, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 75, 0, 80, 0, 85, 0, -1, -1, -1, -1, 90, 0, 95, 0, + -1, -1, -1, -1, 107, 0, 111, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, 0, -1, -1, 119, 0, -1, -1, + -1, -1, -1, -1, 121, 0, -1, -1, 125, 0, -1, -1, -1, -1, -1, -1,-127, 0,-123, 0,-119, 0,-115, 0,-111, 0,-107, 0,-103, 0, -99, 0, + -95, 0, -91, 0, -87, 0, -1, -1, -83, 0, -1, -1, -79, 0, -75, 0, -71, 0, -67, 0, -63, 0, -1, -1, -1, -1, -1, -1, -59, 0, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -55, 0, -1, -1, + -1, -1, -52, 0, -43, 0, -1, -1, -34, 0, -25, 0, -16, 0, -7, 0, 2, 1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 20, 1, -1, -1, -1, -1, -1, -1, 23, 1, -1, -1, 27, 1, 31, 1, 35, 1, -1, -1, -1, -1, -1, -1, 39, 1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, 1, -1, -1, 104, 1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 108, 1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 112, 1, + 116, 1, 120, 1, 124, 1,-128, 1,-124, 1,-120, 1,-116, 1,-112, 1,-108, 1,-104, 1,-100, 1, -96, 1, -92, 1, -88, 1, -84, 1, -80, 1, + -76, 1, -72, 1, -68, 1, -64, 1, -60, 1, -56, 1, -52, 1, -48, 1, -44, 1, -40, 1, -36, 1, -32, 1, -28, 1, -24, 1, -20, 1, -16, 1, + -12, 1, -8, 1, -4, 1, 0, 2, 4, 2, 8, 2, 12, 2, 16, 2, 20, 2, 24, 2, 28, 2, 32, 2, 36, 2, 40, 2, 44, 2, 48, 2, + 52, 2, 56, 2, 60, 2, 64, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 68, 2, -1, -1, -1, -1, -1, -1, -1, -1, 72, 2, 88, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, 2, 113, 2, + 27, 91, 90, 0, 7, 0, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, + 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 85, 0, 27, 91, 65, 0, 27, 91, 77, 0, 27, 91, + 49, 109, 0, 27, 91, 115, 27, 91, 49, 98, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 48, 109, 0, 27, + 91, 50, 98, 27, 91, 117, 13, 27, 91, 75, 0, 27, 91, 109, 0, 27, 91, 109, 0, 27, 91, 76, 0, 8, 0, 27, 91, 77, 0, 27, 91, 66, + 0, 27, 70, 65, 0, 27, 70, 49, 0, 27, 70, 65, 0, 27, 70, 50, 0, 27, 70, 51, 0, 27, 70, 52, 0, 27, 70, 53, 0, 27, 70, 54, + 0, 27, 70, 55, 0, 27, 70, 56, 0, 27, 70, 57, 0, 27, 91, 76, 0, 27, 91, 68, 0, 27, 91, 85, 0, 27, 91, 84, 0, 27, 91, 83, + 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, + 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, + 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 0, 27, 91, 117, 0, 27, 91, 115, 0, 27, + 91, 83, 0, 27, 91, 84, 0, 9, 0, 43, 16, 44, 17, 45, 24, 46, 25, 48, -37, 96, 4, 97, -79, 102, -8, 103, -15, 104, -80, 106, -39, 107, + -65, 108, -38, 109, -64, 110, -59, 111, 126, 112, -60, 113, -60, 114, -60, 115, 95, 116, -61, 117, -76, 118, -63, 119, -62, 120, -77, 121, -13, 122, -14, 123, + -29, 124, -40, 125,-100, 126, -2, 0, 27, 91, 90, 0, 27, 91, 85, 0, 27, 70, 66, 0, 27, 70, 67, 0, 27, 70, 68, 0, 27, 70, 69, 0, + 27, 70, 70, 0, 27, 70, 71, 0, 27, 70, 72, 0, 27, 70, 73, 0, 27, 70, 74, 0, 27, 70, 75, 0, 27, 70, 76, 0, 27, 70, 77, 0, + 27, 70, 78, 0, 27, 70, 79, 0, 27, 70, 80, 0, 27, 70, 81, 0, 27, 70, 82, 0, 27, 70, 83, 0, 27, 70, 84, 0, 27, 70, 85, 0, + 27, 70, 86, 0, 27, 70, 87, 0, 27, 70, 88, 0, 27, 70, 89, 0, 27, 70, 90, 0, 27, 70, 97, 0, 27, 70, 98, 0, 27, 70, 99, 0, + 27, 70, 100, 0, 27, 70, 101, 0, 27, 70, 102, 0, 27, 70, 103, 0, 27, 70, 104, 0, 27, 70, 105, 0, 27, 70, 106, 0, 27, 70, 107, 0, + 27, 70, 109, 0, 27, 70, 110, 0, 27, 70, 111, 0, 27, 70, 112, 0, 27, 70, 113, 0, 27, 70, 114, 0, 27, 70, 115, 0, 27, 70, 116, 0, + 27, 70, 117, 0, 27, 70, 118, 0, 27, 70, 119, 0, 27, 70, 120, 0, 27, 70, 121, 0, 27, 70, 122, 0, 27, 70, 43, 0, 27, 70, 45, 0, + 27, 70, 12, 0, 27, 91, 109, 0, 27, 91, 37, 112, 49, 37, 123, 51, 48, 125, 37, 43, 37, 100, 109, 0, 27, 91, 37, 112, 49, 37, 39, 40, + 39, 37, 43, 37, 100, 109, 0, 27, 91, 51, 37, 112, 49, 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +static const char ansi_terminfo[] = { + 26, 1, 40, 0, 23, 0, 16, 0, 125, 1, 68, 2, 97, 110, 115, 105, 124, 97, 110, 115, 105, 47, 112, 99, 45, 116, 101, 114, 109, 32, 99, 111, + 109, 112, 97, 116, 105, 98, 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, 108, 111, 114, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 8, 0, 64, 0, 3, 0, 0, 0, 4, 0, 6, 0, -1, -1, 8, 0, 13, 0, 20, 0, 24, 0, 28, 0, -1, -1, + 39, 0, 56, 0, 60, 0, -1, -1, 64, 0, -1, -1, -1, -1, 68, 0, -1, -1, 72, 0, -1, -1, 76, 0, 80, 0, -1, -1, -1, -1, 84, 0, + 90, 0, 95, 0, -1, -1, -1, -1, -1, -1, -1, -1, 100, 0, -1, -1, 105, 0, 110, 0, 115, 0, 120, 0,-127, 0,-121, 0, -1, -1, -1, -1, + -1, -1,-113, 0,-109, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-105, 0, -1, -1,-101, 0, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -99, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -95, 0, -91, 0, -1, -1, -87, 0, -1, -1, -1, -1, -1, -1, -83, 0, -1, -1, -1, -1, -1, -1, -79, 0, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -75, 0, -1, -1, -70, 0, + -61, 0, -52, 0, -43, 0, -34, 0, -25, 0, -16, 0, -7, 0, 2, 1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 1, 25, 1, 30, 1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 1, -1, -1, 61, 1, -1, -1, 63, 1,-107, 1, -1, -1,-104, 1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-100, 1, -1, -1, -37, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -33, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -28, 1, -17, 1, -12, 1, 7, 2, 11, 2, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 2, 30, 2, -1, -1, + -1, -1, -1, -1, 40, 2, 44, 2, 48, 2, 52, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 56, 2, 62, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, + 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 27, 91, + 66, 0, 27, 91, 72, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 91, 49, 49, 109, 0, + 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, + 37, 112, 49, 37, 100, 88, 0, 27, 91, 49, 48, 109, 0, 27, 91, 48, 59, 49, 48, 109, 0, 27, 91, 109, 0, 27, 91, 109, 0, 27, 91, 76, + 0, 8, 0, 27, 91, 66, 0, 27, 91, 72, 0, 27, 91, 76, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 27, 91, 83, 0, + 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, + 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, + 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 52, 105, 0, 27, + 91, 53, 105, 0, 37, 112, 49, 37, 99, 27, 91, 37, 112, 50, 37, 123, 49, 125, 37, 45, 37, 100, 98, 0, 27, 91, 37, 105, 37, 112, 49, 37, + 100, 100, 0, 10, 0, 27, 91, 48, 59, 49, 48, 37, 63, 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, + 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 54, 37, 116, 59, 49, + 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 37, 63, 37, 112, 57, 37, 116, 59, 49, 49, 37, 59, 109, 0, 27, 72, 0, 27, 91, + 73, 0, 43, 16, 44, 17, 45, 24, 46, 25, 48, -37, 96, 4, 97, -79, 102, -8, 103, -15, 104, -80, 106, -39, 107, -65, 108, -38, 109, -64, 110, -59, + 111, 126, 112, -60, 113, -60, 114, -60, 115, 95, 116, -61, 117, -76, 118, -63, 119, -62, 120, -77, 121, -13, 122, -14, 123, -29, 124, -40, 125,-100, 126, -2, + 0, 27, 91, 90, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 37, 91, 59, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 93, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 37, 112, 49, + 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0, 27, 40, 66, 0, 27, 41, 66, 0, 27, 42, 66, 0, 27, 43, 66, 0, 27, 91, + 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 +}; + +/// Load one of the built-in terminfo entries when unibilium has failed to +/// load a terminfo record from an external database, as it does on termcap- +/// -only systems. We do not do any fancy recognition of xterm pretenders +/// here. An external terminfo database would not do that, and we want to +/// behave as much like an external terminfo database as possible. +static unibi_term *load_builtin_terminfo(const char * term) { - if (STARTS_WITH(term, "rxvt")) { - return kTermRxvt; - } - if (os_getenv("KONSOLE_PROFILE_NAME") || os_getenv("KONSOLE_DBUS_SESSION")) { - return kTermKonsole; - } - const char *termprg = os_getenv("TERM_PROGRAM"); - if (termprg && strstr(termprg, "iTerm.app")) { - return kTermiTerm; - } - if (colorterm && strstr(colorterm, "gnome-terminal")) { - return kTermGnome; - } - if (STARTS_WITH(term, "xterm")) { - return kTermXTerm; - } - if (STARTS_WITH(term, "dtterm")) { - return kTermDTTerm; - } - if (STARTS_WITH(term, "teraterm")) { - return kTermTeraTerm; - } - if (STARTS_WITH(term, "putty")) { - return kTermPuTTY; + if (term && STARTS_WITH(term, "xterm")) { + return unibi_from_mem(xterm_8colour_terminfo, sizeof xterm_8colour_terminfo); + } else if (term && STARTS_WITH(term, "screen")) { + return unibi_from_mem(screen_256colour_terminfo, sizeof screen_256colour_terminfo); + } else if (term && STARTS_WITH(term, "tmux")) { + return unibi_from_mem(tmux_256colour_terminfo, sizeof tmux_256colour_terminfo); + } else if (term && STARTS_WITH(term, "rxvt")) { + return unibi_from_mem(rxvt_256colour_terminfo, sizeof rxvt_256colour_terminfo); + } else if (term && STARTS_WITH(term, "putty")) { + return unibi_from_mem(putty_256colour_terminfo, sizeof putty_256colour_terminfo); + } else if (term && STARTS_WITH(term, "linux")) { + return unibi_from_mem(linux_16colour_terminfo, sizeof linux_16colour_terminfo); + } else if (term && STARTS_WITH(term, "interix")) { + return unibi_from_mem(interix_8colour_terminfo, sizeof interix_8colour_terminfo); + } else if (term && (STARTS_WITH(term, "iterm") || STARTS_WITH(term, "iTerm"))) { + return unibi_from_mem(iterm_16colour_terminfo, sizeof iterm_16colour_terminfo); + } else { + return unibi_from_mem(ansi_terminfo, sizeof ansi_terminfo); } - return kTermUnknown; } -/// This has three tasks. -/// 1. On termcap-only systems, it reads $TERM and fills in all of the things -/// that unibilium (which uses terminfo) will not have. -/// 2. It fills in extra capabilities that unibilium and terminfo do not know -/// anything about, such as bracketed paste control. Some of these are -/// (wrongly) assumed to be universal. Others are dependent from $TERM . -/// 3. It fills in capabilities that might have been missing from the termcap -/// entry that we nonetheless need, which are also worked out from $TERM . -static void fix_terminfo(TUIData *data) +/// Several entries in terminfo are known to be deficient or outright wrong, +/// unfortunately; and several terminal emulators falsely announce incorrect +/// terminal types. So patch the terminfo records after loading from an +/// external or a built-in database. In an ideal world, the real terminfo data +/// would be correct and complete, and this function would be almost empty. +static void patch_terminfo_bugs(unibi_term *ut, const char *term, + const char *colorterm, long vte_version, bool konsole, bool iterm) { - unibi_term *ut = data->ut; - is_tmux = os_getenv("TMUX") != NULL; - - const char *term = os_getenv("TERM"); - const char *colorterm = os_getenv("COLORTERM"); - if (!term) { - goto end; - } - data->term = detect_term(term, colorterm); - - if (data->term == kTermRxvt) { - unibi_set_if_empty(ut, unibi_flash_screen, "\x1b[?5h$<20/>\x1b[?5l"); - unibi_set_if_empty(ut, unibi_enter_italics_mode, "\x1b[3m"); - unibi_set_if_empty(ut, unibi_to_status_line, "\x1b]2"); - } else if (data->term == kTermXTerm) { - unibi_set_if_empty(ut, unibi_to_status_line, "\x1b]0;"); - } else if (STARTS_WITH(term, "screen") || STARTS_WITH(term, "tmux")) { - unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); - unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); - } - - if (data->term == kTermXTerm || data->term == kTermRxvt) { - const char *normal = unibi_get_str(ut, unibi_cursor_normal); - if (!normal) { - unibi_set_str(ut, unibi_cursor_normal, "\x1b[?25h"); - } else if (STARTS_WITH(normal, "\x1b[?12l")) { + bool xterm = term && STARTS_WITH(term, "xterm"); + bool mate = colorterm && strstr(colorterm, "mate-terminal"); + bool gnome = colorterm && strstr(colorterm, "gnome-terminal"); + bool linux = term && STARTS_WITH(term, "linux"); + bool rxvt = term && STARTS_WITH(term, "rxvt"); + + const char *fix_normal = unibi_get_str(ut, unibi_cursor_normal); + if (fix_normal) { + if (STARTS_WITH(fix_normal, "\x1b[?12l")) { // terminfo typically includes DECRST 12 as part of setting up the normal // cursor, which interferes with the user's control via // NVIM_TUI_ENABLE_CURSOR_SHAPE. When DECRST 12 is present, skip over // it, but honor the rest of the TI setting. - unibi_set_str(ut, unibi_cursor_normal, normal + strlen("\x1b[?12l")); + fix_normal += strlen("\x1b[?12l"); + unibi_set_str(ut, unibi_cursor_normal, fix_normal); + } + } + + if (xterm) { + // Termit, LXTerminal, GTKTerm2, GNOME Terminal, MATE Terminal, roxterm, + // and EvilVTE falsely claim to be xterm and do not support important xterm + // control sequences that we use. In an ideal world, these would have + // their own terminal types and terminfo entries, like PuTTY does, and not + // claim to be xterm. Or they would mimic xterm properly enough to be + // treatable as xterm. +#if 0 // We don't need to identify this specifically, for now. + bool roxterm = !!os_getenv("ROXTERM_ID"); +#endif + bool true_xterm = !!os_getenv("XTERM_VERSION"); + unibi_set_if_empty(ut, unibi_to_status_line, "\x1b]0;"); + unibi_set_if_empty(ut, unibi_from_status_line, "\x07"); + unibi_set_if_empty(ut, unibi_set_tb_margin, "\x1b[%i%p1%d;%p2%dr"); + if (true_xterm) { + unibi_set_if_empty(ut, unibi_set_lr_margin, "\x1b[%i%p1%d;%p2%ds"); + unibi_set_if_empty(ut, unibi_set_left_margin_parm, "\x1b[%i%p1%ds"); + unibi_set_if_empty(ut, unibi_set_right_margin_parm, "\x1b[%i;%p2%ds"); } - unibi_set_if_empty(ut, unibi_cursor_invisible, "\x1b[?25l"); - unibi_set_if_empty(ut, unibi_flash_screen, "\x1b[?5h$<100/>\x1b[?5l"); - unibi_set_if_empty(ut, unibi_exit_attribute_mode, "\x1b(B\x1b[m"); + } else if (rxvt) { + unibi_set_if_empty(ut, unibi_enter_italics_mode, "\x1b[3m"); + unibi_set_if_empty(ut, unibi_to_status_line, "\x1b]2"); unibi_set_if_empty(ut, unibi_from_status_line, "\x07"); unibi_set_if_empty(ut, unibi_set_tb_margin, "\x1b[%i%p1%d;%p2%dr"); - unibi_set_if_empty(ut, unibi_set_lr_margin, "\x1b[%i%p1%d;%p2%ds"); - unibi_set_if_empty(ut, unibi_set_left_margin_parm, "\x1b[%i%p1%ds"); - unibi_set_if_empty(ut, unibi_set_right_margin_parm, "\x1b[%i;%p2%ds"); - } - if (data->term == kTermXTerm || data->term == kTermRxvt - || data->term == kTermPuTTY) { - unibi_set_if_empty(ut, unibi_change_scroll_region, "\x1b[%i%p1%d;%p2%dr"); - unibi_set_if_empty(ut, unibi_clear_screen, "\x1b[H\x1b[2J"); - unibi_set_bool(ut, unibi_back_color_erase, true); + } else if (term && STARTS_WITH(term, "screen")) { + unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); + unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); + } else if (term && STARTS_WITH(term, "tmux")) { + unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); + unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); + } else if (linux) { + // No deviations from the vanilla terminfo. + } else if (term && STARTS_WITH(term, "putty")) { + // No deviations from the vanilla terminfo. + } else if (term && (STARTS_WITH(term, "iterm") || STARTS_WITH(term, "iTerm"))) { + // No deviations from the vanilla terminfo. } - data->unibi_ext.enable_lr_margin = (int)unibi_add_ext_str(ut, NULL, - "\x1b[?69h"); - data->unibi_ext.disable_lr_margin = (int)unibi_add_ext_str(ut, NULL, - "\x1b[?69l"); - - data->unibi_ext.enable_bracketed_paste = (int)unibi_add_ext_str(ut, NULL, - "\x1b[?2004h"); - data->unibi_ext.disable_bracketed_paste = (int)unibi_add_ext_str(ut, NULL, - "\x1b[?2004l"); - - data->unibi_ext.enable_focus_reporting = (int)unibi_add_ext_str(ut, NULL, - "\x1b[?1004h"); - data->unibi_ext.disable_focus_reporting = (int)unibi_add_ext_str(ut, NULL, - "\x1b[?1004l"); - #define XTERM_SETAF_256 \ "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m" #define XTERM_SETAB_256 \ "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m" +#define XTERM_SETAF_16 \ + "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e39%;m" +#define XTERM_SETAB_16 \ + "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e39%;m" - if ((colorterm && strstr(colorterm, "256")) - || STARTS_WITH(term, "linux") - || strstr(term, "256") - || strstr(term, "xterm")) { - // Linux 4.8+ supports 256-color SGR, but terminfo has 8-color setaf/setab. - // Assume TERM=~xterm|linux or COLORTERM=~256 supports 256 colors. - unibi_set_num(ut, unibi_max_colors, 256); - unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); - unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); + // Terminals where there is actually 256-colour SGR support despite what + // the terminfo record may say. + if (unibi_get_num(ut, unibi_max_colors) < 256) { + // See http://fedoraproject.org/wiki/Features/256_Color_Terminals for + // more on this. + if (konsole || mate || xterm || gnome || rxvt + || linux // Linux 4.8+ supports 256-colour SGR. + || (colorterm && strstr(colorterm, "256")) + || (term && strstr(term, "256")) + ) { + unibi_set_num(ut, unibi_max_colors, 256); + unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); + unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); + } } + // Terminals where there is actually 16-colour SGR support despite what + // the terminfo record may say. + if (unibi_get_num(ut, unibi_max_colors) < 16) { + if (colorterm) { + unibi_set_num(ut, unibi_max_colors, 16); + unibi_set_if_empty(ut, unibi_set_a_foreground, XTERM_SETAF_16); + unibi_set_if_empty(ut, unibi_set_a_background, XTERM_SETAB_16); + } + } +} + +/// This adds stuff that is not in standard terminfo as extended unibilium +/// capabilities. +static void augment_terminfo(TUIData *data, const char *term, + const char *colorterm, long vte_version, bool konsole, bool iterm) +{ + unibi_term *ut = data->ut; + bool putty = term && STARTS_WITH(term, "putty"); + bool xterm = term && STARTS_WITH(term, "xterm"); + bool dtterm = term && STARTS_WITH(term, "dtterm"); + bool teraterm = term && STARTS_WITH(term, "teraterm"); + bool rxvt = term && STARTS_WITH(term, "rxvt"); + bool linux = term && STARTS_WITH(term, "linux"); + bool tmux_wrap = !!os_getenv("TMUX"); + bool truecolor = colorterm + && (STRCMP(colorterm, "truecolor") || STRCMP(colorterm, "24bit")); // Only define this capability for terminal types that we know understand it. - if (data->term == kTermDTTerm // originated this extension - || data->term == kTermXTerm // per xterm ctlseqs doco - || data->term == kTermKonsole // per commentary in VT102Emulation.cpp - || data->term == kTermTeraTerm // per TeraTerm "Supported Control Functions" doco - || data->term == kTermRxvt) { // per command.C + if (dtterm // originated this extension + || xterm // per xterm ctlseqs doco + || konsole // per commentary in VT102Emulation.cpp + || teraterm // per TeraTerm "Supported Control Functions" doco + || rxvt) { // per command.C data->unibi_ext.resize_screen = (int)unibi_add_ext_str(ut, NULL, "\x1b[8;%p1%d;%p2%dt"); } - - if (data->term == kTermXTerm || data->term == kTermRxvt - || data->term == kTermPuTTY) { + if (putty || xterm || rxvt) { data->unibi_ext.reset_scroll_region = (int)unibi_add_ext_str(ut, NULL, "\x1b[r"); } - -end: - -#define XTERM_SETAF_16 \ - "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e39%;m" -#define XTERM_SETAB_16 \ - "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e39%;m" - - // Fill some empty slots with common terminal strings - if (data->term == kTermiTerm) { + // See https://gist.github.com/XVilka/8346728 for more about this. + if (putty || xterm || rxvt || linux || konsole || iterm || truecolor) { + data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, NULL, + "\x1b[38;2;%p1%d;%p2%d;%p3%dm"); + data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, NULL, + "\x1b[48;2;%p1%d;%p2%d;%p3%dm"); + } + if (iterm) { data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( - ut, NULL, TMUX_WRAP("\033]Pl%p1%06x\033\\")); - } else { + ut, NULL, TMUX_WRAP(tmux_wrap, "\033]Pl%p1%06x\033\\")); + } else if (xterm) { data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( ut, NULL, "\033]12;#%p1%06x\007"); } + if (konsole) { + // Konsole uses a proprietary escape code to set the cursor shape + // and does not support DECSCUSR. + data->unibi_ext.konsole_cursor_shape = (int)unibi_add_ext_str(ut, NULL, + TMUX_WRAP(tmux_wrap, "\x1b]50;CursorShape=%p1%d;BlinkingCursorEnabled=%p2%d\x07")); + } else if (0 == vte_version || vte_version >= 3900) { + // Assume that the terminal supports DECSCUSR unless it is an + // old VTE based terminal. This should not get wrapped for tmux, + // which will handle it via its Ss/Se terminfo extension - usually + // according to its terminal-overrides. + data->unibi_ext.dec_cursor_shape = (int)unibi_add_ext_str(ut, NULL, + "\x1b[%p1%d q"); + } + + /// Terminals generally ignore private modes that they do not recognize, + /// and there is no known ambiguity with these modes from terminal type to + /// terminal type, so we can afford to just set these unconditionally. + data->unibi_ext.enable_lr_margin = (int)unibi_add_ext_str(ut, NULL, + "\x1b[?69h"); + data->unibi_ext.disable_lr_margin = (int)unibi_add_ext_str(ut, NULL, + "\x1b[?69l"); + data->unibi_ext.enable_bracketed_paste = (int)unibi_add_ext_str(ut, NULL, + "\x1b[?2004h"); + data->unibi_ext.disable_bracketed_paste = (int)unibi_add_ext_str(ut, NULL, + "\x1b[?2004l"); + data->unibi_ext.enable_focus_reporting = (int)unibi_add_ext_str(ut, NULL, + "\x1b[?1004h"); + data->unibi_ext.disable_focus_reporting = (int)unibi_add_ext_str(ut, NULL, + "\x1b[?1004l"); data->unibi_ext.enable_mouse = (int)unibi_add_ext_str(ut, NULL, "\x1b[?1002h\x1b[?1006h"); data->unibi_ext.disable_mouse = (int)unibi_add_ext_str(ut, NULL, "\x1b[?1002l\x1b[?1006l"); - data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, NULL, - "\x1b[38;2;%p1%d;%p2%d;%p3%dm"); - data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, NULL, - "\x1b[48;2;%p1%d;%p2%d;%p3%dm"); - unibi_set_if_empty(ut, unibi_cursor_address, "\x1b[%i%p1%d;%p2%dH"); - unibi_set_if_empty(ut, unibi_cursor_home, "\x1b[H"); - unibi_set_if_empty(ut, unibi_parm_left_cursor, "\x1b[%p1%dD"); - unibi_set_if_empty(ut, unibi_parm_right_cursor, "\x1b[%p1%dC"); - unibi_set_if_empty(ut, unibi_parm_down_cursor, "\x1b[%p1%dB"); - unibi_set_if_empty(ut, unibi_parm_up_cursor, "\x1b[%p1%dA"); - unibi_set_if_empty(ut, unibi_cursor_left, "\x08"); - unibi_set_if_empty(ut, unibi_cursor_right, "\x1b[C"); -#if defined(WIN32) - unibi_set_if_empty(ut, unibi_cursor_down, "\x1b[B"); -#else - // N.B. This relies upon the terminal really being in cfmakeraw() mode, - // which libuv's RAW mode is in fact not. - unibi_set_if_empty(ut, unibi_cursor_down, "\x0a"); -#endif - unibi_set_if_empty(ut, unibi_cursor_up, "\x1b[A"); - unibi_set_if_empty(ut, unibi_carriage_return, "\x0d"); - unibi_set_if_empty(ut, unibi_exit_attribute_mode, "\x1b[0;10m"); - unibi_set_if_empty(ut, unibi_set_a_foreground, XTERM_SETAF_16); - unibi_set_if_empty(ut, unibi_set_a_background, XTERM_SETAB_16); - unibi_set_if_empty(ut, unibi_enter_bold_mode, "\x1b[1m"); - unibi_set_if_empty(ut, unibi_enter_underline_mode, "\x1b[4m"); - unibi_set_if_empty(ut, unibi_enter_reverse_mode, "\x1b[7m"); - unibi_set_if_empty(ut, unibi_bell, "\x07"); - unibi_set_if_empty(ut, unibi_enter_ca_mode, "\x1b[?1049h"); - unibi_set_if_empty(ut, unibi_exit_ca_mode, "\x1b[?1049l"); - unibi_set_if_empty(ut, unibi_delete_line, "\x1b[M"); - unibi_set_if_empty(ut, unibi_parm_delete_line, "\x1b[%p1%dM"); - unibi_set_if_empty(ut, unibi_insert_line, "\x1b[L"); - unibi_set_if_empty(ut, unibi_parm_insert_line, "\x1b[%p1%dL"); - unibi_set_if_empty(ut, unibi_clear_screen, "\x1b[H\x1b[J"); - unibi_set_if_empty(ut, unibi_clr_eol, "\x1b[K"); - unibi_set_if_empty(ut, unibi_clr_eos, "\x1b[J"); } static void flush_buf(UI *ui, bool toggle_cursor) -- cgit From 03683c375cb3ded56f7edbcc70619bab1e8dd4f9 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Thu, 25 May 2017 17:39:27 +0100 Subject: tui: Disable interference in guicursor by higher layers. Ironically, higher layers trying to be "smart" about the terminal type but not actually being very smart at all, makes it more difficult rather than less to correct the TUI layer. Note that this orphans the os_term_is_nice() function and down the road, presuming that we do not have to revert this, that function can be removed. It incorporates knowledge of terminal types and behaviours in the wrong place. --- src/nvim/option.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 392a2f3908..0c423c900f 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -969,10 +969,12 @@ void set_init_2(bool headless) p_window = Rows - 1; } set_number_default("window", Rows - 1); +#if 0 // This bodges around problems that should properly be fixed in the TUI layer. if (!headless && !os_term_is_nice()) { set_string_option_direct((char_u *)"guicursor", -1, (char_u *)"", OPT_GLOBAL, SID_NONE); } +#endif parse_shape_opt(SHAPE_CURSOR); // set cursor shapes from 'guicursor' (void)parse_printoptions(); // parse 'printoptions' default value } -- cgit From 76a6509c594df118c76381b821e5259f149bd93e Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Thu, 25 May 2017 19:12:52 +0100 Subject: tui: More refactoring, and improvements to cursor shape support. The details are in the on-line help under :help cursor-shape . The brief precis is that nvim is following the lead of tmux, and going beyond what tmux does to make cursor shape changes work on a broad range of terminals. This includes on tmux itself, which is no longer bypassed. --- src/nvim/tui/tui.c | 181 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 137 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 8f8f388eb8..cdb68f0ec4 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -44,8 +44,9 @@ #define OUTBUF_SIZE 0xffff #define TOO_MANY_EVENTS 1000000 -#define STARTS_WITH(str, prefix) (!memcmp(str, prefix, sizeof(prefix) - 1)) +#define STARTS_WITH(str, prefix) (!memcmp((str), (prefix), sizeof(prefix) - 1)) #define TMUX_WRAP(is_tmux,seq) ((is_tmux) ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq) +#define LINUXRESETC "\x1b[?0c" typedef struct { int top, bot, left, right; @@ -90,7 +91,7 @@ typedef struct { int enable_focus_reporting, disable_focus_reporting; int resize_screen; int reset_scroll_region; - int konsole_cursor_shape, dec_cursor_shape; + int set_cursor_style, reset_cursor_style; } unibi_ext; } TUIData; @@ -157,8 +158,8 @@ static void terminfo_start(UI *ui) data->unibi_ext.disable_focus_reporting = -1; data->unibi_ext.resize_screen = -1; data->unibi_ext.reset_scroll_region = -1; - data->unibi_ext.konsole_cursor_shape = -1; - data->unibi_ext.dec_cursor_shape = -1; + data->unibi_ext.set_cursor_style = -1; + data->unibi_ext.reset_cursor_style = -1; data->out_fd = 1; data->out_isatty = os_isatty(data->out_fd); // setup unibilium @@ -174,7 +175,7 @@ static void terminfo_start(UI *ui) bool iterm = termprg && strstr(termprg, "iTerm.app"); bool konsole = os_getenv("KONSOLE_PROFILE_NAME") || os_getenv("KONSOLE_DBUS_SESSION"); - patch_terminfo_bugs(data->ut, term, colorterm, vte_version, konsole, iterm); + patch_terminfo_bugs(data, term, colorterm, vte_version, konsole, iterm); augment_terminfo(data, term, colorterm, vte_version, konsole, iterm); data->can_change_scroll_region = !!unibi_get_str(data->ut, unibi_change_scroll_region); @@ -783,16 +784,6 @@ static void tui_set_mode(UI *ui, ModeShape mode) } } - switch (shape) { - case SHAPE_BLOCK: shape = 0; break; - case SHAPE_VER: shape = 1; break; - case SHAPE_HOR: shape = 2; break; - default: WLOG("Unknown shape value %d", shape); break; - } - data->params[0].i = shape; - data->params[1].i = (c.blinkon != 0); - unibi_out(ui, data->unibi_ext.konsole_cursor_shape); - switch (shape) { case SHAPE_BLOCK: shape = 1; break; case SHAPE_HOR: shape = 3; break; @@ -800,7 +791,7 @@ static void tui_set_mode(UI *ui, ModeShape mode) default: WLOG("Unknown shape value %d", shape); break; } data->params[0].i = shape + (int)(c.blinkon == 0); - unibi_out(ui, data->unibi_ext.dec_cursor_shape); + unibi_out(ui, data->unibi_ext.set_cursor_style); } /// @param mode editor mode @@ -1142,6 +1133,22 @@ static void unibi_set_if_empty(unibi_term *ut, enum unibi_string str, } } +static int unibi_find_ext_str(unibi_term *ut, const char *name) +{ + size_t max = unibi_count_ext_bool(ut); + for (size_t i = 0; i < max; ++i) { + const char * n = unibi_get_ext_str_name(ut, i); + if (0 == strcmp(n, name)) { + return (int)i; + } + } + return -1; +} + +// One creates the dumps from terminfo.src by using +// od -t d1 -w +// on the compiled files. + // Taken from unibilium/t/static_xterm.c as of 2015-08-14. // This is an 8-colour terminfo description that lacks // DECSTBN/DECSLRM/DECLRMM capabilities that xterm actually has. @@ -1876,25 +1883,39 @@ static unibi_term *load_builtin_terminfo(const char * term) /// terminal types. So patch the terminfo records after loading from an /// external or a built-in database. In an ideal world, the real terminfo data /// would be correct and complete, and this function would be almost empty. -static void patch_terminfo_bugs(unibi_term *ut, const char *term, +static void patch_terminfo_bugs(TUIData *data, const char *term, const char *colorterm, long vte_version, bool konsole, bool iterm) { + unibi_term *ut = data->ut; + bool true_xterm = !!os_getenv("XTERM_VERSION"); bool xterm = term && STARTS_WITH(term, "xterm"); bool mate = colorterm && strstr(colorterm, "mate-terminal"); bool gnome = colorterm && strstr(colorterm, "gnome-terminal"); bool linux = term && STARTS_WITH(term, "linux"); bool rxvt = term && STARTS_WITH(term, "rxvt"); + bool teraterm = term && STARTS_WITH(term, "teraterm"); + bool putty = term && STARTS_WITH(term, "putty"); + bool screen = term && STARTS_WITH(term, "screen"); + bool tmux_wrap = screen && !!os_getenv("TMUX"); - const char *fix_normal = unibi_get_str(ut, unibi_cursor_normal); + char *fix_normal = (char *)unibi_get_str(ut, unibi_cursor_normal); if (fix_normal) { if (STARTS_WITH(fix_normal, "\x1b[?12l")) { - // terminfo typically includes DECRST 12 as part of setting up the normal - // cursor, which interferes with the user's control via - // NVIM_TUI_ENABLE_CURSOR_SHAPE. When DECRST 12 is present, skip over - // it, but honor the rest of the TI setting. - fix_normal += strlen("\x1b[?12l"); + // terminfo typically includes DECRST 12 as part of setting up the + // normal cursor, which interferes with the user's control via + // set_cursor_style. When DECRST 12 is present, skip over it, but honor + // the rest of the cnorm setting. + fix_normal += sizeof "\x1b[?12l" - 1; unibi_set_str(ut, unibi_cursor_normal, fix_normal); } + if (linux + && (strlen(fix_normal) + 1) >= (sizeof LINUXRESETC - 1) + && !memcmp(strchr(fix_normal,0) - (sizeof LINUXRESETC - 1), LINUXRESETC, sizeof LINUXRESETC - 1)) { + // The Linux terminfo entry similarly includes a Linux-idiosyncractic + // cursor shape reset in cnorm, which similarly interferes with + // set_cursor_style. + fix_normal[strlen(fix_normal) - (sizeof LINUXRESETC - 1)] = 0; + } } if (xterm) { @@ -1904,10 +1925,9 @@ static void patch_terminfo_bugs(unibi_term *ut, const char *term, // their own terminal types and terminfo entries, like PuTTY does, and not // claim to be xterm. Or they would mimic xterm properly enough to be // treatable as xterm. -#if 0 // We don't need to identify this specifically, for now. +#if 0 // We don't need to identify this specifically, for now. bool roxterm = !!os_getenv("ROXTERM_ID"); #endif - bool true_xterm = !!os_getenv("XTERM_VERSION"); unibi_set_if_empty(ut, unibi_to_status_line, "\x1b]0;"); unibi_set_if_empty(ut, unibi_from_status_line, "\x07"); unibi_set_if_empty(ut, unibi_set_tb_margin, "\x1b[%i%p1%d;%p2%dr"); @@ -1921,7 +1941,7 @@ static void patch_terminfo_bugs(unibi_term *ut, const char *term, unibi_set_if_empty(ut, unibi_to_status_line, "\x1b]2"); unibi_set_if_empty(ut, unibi_from_status_line, "\x07"); unibi_set_if_empty(ut, unibi_set_tb_margin, "\x1b[%i%p1%d;%p2%dr"); - } else if (term && STARTS_WITH(term, "screen")) { + } else if (screen) { unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); } else if (term && STARTS_WITH(term, "tmux")) { @@ -1968,6 +1988,91 @@ static void patch_terminfo_bugs(unibi_term *ut, const char *term, unibi_set_if_empty(ut, unibi_set_a_background, XTERM_SETAB_16); } } + + // Dickey ncurses terminfo has included the Ss and Se capabilities, pioneered + // by tmux, since 2011-07-14. So adding them to terminal types, that do + // actually have such control sequences but lack the currect definitions in + // terminfo, is a fixup, not an augmentation. + data->unibi_ext.reset_cursor_style = unibi_find_ext_str(ut, "Se"); + data->unibi_ext.set_cursor_style = unibi_find_ext_str(ut, "Ss"); + if (-1 == data->unibi_ext.set_cursor_style) { + // The DECSCUSR sequence to change the cursor shape is widely + // supported by several terminal types and should be in many + // teminfo entries. See + // https://github.com/gnachman/iTerm2/pull/92 for more. + // xterm even has an extended version that has a vertical bar. + if (true_xterm // per xterm ctlseqs doco (since version 282) + // Allows forcing the use of DECSCUSR on linux type terminals, such as + // console-terminal-emulator from the nosh toolset, which does indeed + // implement the xterm extension: + || (linux && (true_xterm || (vte_version > 0) || colorterm))) { + data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", + "\x1b[%p1%d q"); + if (-1 == data->unibi_ext.reset_cursor_style) { + data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", + ""); + } + unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[ q"); + } else if (putty // per MinTTY 0.4.3-1 release notes from 2009 + || teraterm // per TeraTerm "Supported Control Functions" doco + || (vte_version >= 3900) // VTE-based terminals since this version. + // per tmux manual page and per + // https://lists.gnu.org/archive/html/screen-devel/2013-03/msg00000.html + || screen) { + // Since we use the xterm extension, we have to map it to the unextended + // form. + data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", + "\x1b[%?" + "%p1%{4}%>" "%t%p1%{2}%-" // a bit of a bodge for extension values + "%e%p1" // the conventional codes are just passed through + "%;%d q"); + if (-1 == data->unibi_ext.reset_cursor_style) { + data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", + ""); + } + unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[ q"); + } else if (linux) { + // Linux uses an idiosyncratic escape code to set the cursor shape and does + // not support DECSCUSR. + data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", + "\x1b[?" + "%?" + // The parameter passed to Ss is the DECSCUSR parameter, so the + // terminal capability has to translate into the Linux idiosyncratic + // parameter. + "%p1%{2}%<" "%t%{8}" // blink block + "%p1%{2}%=" "%t%{24}" // steady block + "%p1%{3}%=" "%t%{1}" // blink underline + "%p1%{4}%=" "%t%{17}" // steady underline + "%p1%{5}%=" "%t%{1}" // blink bar + "%p1%{6}%=" "%t%{17}" // steady bar + "%e%{0}" // anything else + "%;" "%dc"); + if (-1 == data->unibi_ext.reset_cursor_style) { + data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", + ""); + } + unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[?c"); + } else if (konsole) { + // Konsole uses an idiosyncratic escape code to set the cursor shape and does + // not support DECSCUSR. The tmux wrapping is unused, now. + data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", + TMUX_WRAP(tmux_wrap, "\x1b]50;CursorShape=%?" + "%p1%{3}%<" "%t%{0}" // block + "%e%p1%{4}%<" "%t%{2}" // underline + "%e%{1}" // everything else is bar + "%;%d;BlinkingCursorEnabled=%?" + "%p1%{1}%<" "%t%{1}" // Fortunately if we exclude zero as special, + "%e%p1%{1}%&" // in all other cases we can teeat bit #0 as a flag. + "%;%d\x07")); + if (-1 == data->unibi_ext.reset_cursor_style) { + data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", + ""); + } + unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, + TMUX_WRAP(tmux_wrap, "\x1b]50;CursorShape=0;BlinkingCursorEnabled=1\x07")); + } + } } /// This adds stuff that is not in standard terminfo as extended unibilium @@ -1976,15 +2081,16 @@ static void augment_terminfo(TUIData *data, const char *term, const char *colorterm, long vte_version, bool konsole, bool iterm) { unibi_term *ut = data->ut; - bool putty = term && STARTS_WITH(term, "putty"); bool xterm = term && STARTS_WITH(term, "xterm"); bool dtterm = term && STARTS_WITH(term, "dtterm"); - bool teraterm = term && STARTS_WITH(term, "teraterm"); - bool rxvt = term && STARTS_WITH(term, "rxvt"); bool linux = term && STARTS_WITH(term, "linux"); - bool tmux_wrap = !!os_getenv("TMUX"); + bool rxvt = term && STARTS_WITH(term, "rxvt"); + bool teraterm = term && STARTS_WITH(term, "teraterm"); + bool putty = term && STARTS_WITH(term, "putty"); + bool screen = term && STARTS_WITH(term, "screen"); + bool tmux_wrap = screen && !!os_getenv("TMUX"); bool truecolor = colorterm - && (STRCMP(colorterm, "truecolor") || STRCMP(colorterm, "24bit")); + && (0 == strcmp(colorterm, "truecolor") || 0 == strcmp(colorterm, "24bit")); // Only define this capability for terminal types that we know understand it. if (dtterm // originated this extension @@ -2013,19 +2119,6 @@ static void augment_terminfo(TUIData *data, const char *term, data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( ut, NULL, "\033]12;#%p1%06x\007"); } - if (konsole) { - // Konsole uses a proprietary escape code to set the cursor shape - // and does not support DECSCUSR. - data->unibi_ext.konsole_cursor_shape = (int)unibi_add_ext_str(ut, NULL, - TMUX_WRAP(tmux_wrap, "\x1b]50;CursorShape=%p1%d;BlinkingCursorEnabled=%p2%d\x07")); - } else if (0 == vte_version || vte_version >= 3900) { - // Assume that the terminal supports DECSCUSR unless it is an - // old VTE based terminal. This should not get wrapped for tmux, - // which will handle it via its Ss/Se terminfo extension - usually - // according to its terminal-overrides. - data->unibi_ext.dec_cursor_shape = (int)unibi_add_ext_str(ut, NULL, - "\x1b[%p1%d q"); - } /// Terminals generally ignore private modes that they do not recognize, /// and there is no known ambiguity with these modes from terminal type to -- cgit From 74472f7b2bf354dbffcaca3738dacba5dfaefd6d Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Thu, 25 May 2017 22:25:42 +0100 Subject: tui: Fix conflict with predefined "linux" macro. --- src/nvim/tui/tui.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index cdb68f0ec4..5a0381c072 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1891,7 +1891,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool xterm = term && STARTS_WITH(term, "xterm"); bool mate = colorterm && strstr(colorterm, "mate-terminal"); bool gnome = colorterm && strstr(colorterm, "gnome-terminal"); - bool linux = term && STARTS_WITH(term, "linux"); + bool linuxvt = term && STARTS_WITH(term, "linux"); bool rxvt = term && STARTS_WITH(term, "rxvt"); bool teraterm = term && STARTS_WITH(term, "teraterm"); bool putty = term && STARTS_WITH(term, "putty"); @@ -1908,7 +1908,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, fix_normal += sizeof "\x1b[?12l" - 1; unibi_set_str(ut, unibi_cursor_normal, fix_normal); } - if (linux + if (linuxvt && (strlen(fix_normal) + 1) >= (sizeof LINUXRESETC - 1) && !memcmp(strchr(fix_normal,0) - (sizeof LINUXRESETC - 1), LINUXRESETC, sizeof LINUXRESETC - 1)) { // The Linux terminfo entry similarly includes a Linux-idiosyncractic @@ -1947,7 +1947,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } else if (term && STARTS_WITH(term, "tmux")) { unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); - } else if (linux) { + } else if (linuxvt) { // No deviations from the vanilla terminfo. } else if (term && STARTS_WITH(term, "putty")) { // No deviations from the vanilla terminfo. @@ -1970,7 +1970,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // See http://fedoraproject.org/wiki/Features/256_Color_Terminals for // more on this. if (konsole || mate || xterm || gnome || rxvt - || linux // Linux 4.8+ supports 256-colour SGR. + || linuxvt // Linux 4.8+ supports 256-colour SGR. || (colorterm && strstr(colorterm, "256")) || (term && strstr(term, "256")) ) { @@ -2005,7 +2005,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // Allows forcing the use of DECSCUSR on linux type terminals, such as // console-terminal-emulator from the nosh toolset, which does indeed // implement the xterm extension: - || (linux && (true_xterm || (vte_version > 0) || colorterm))) { + || (linuxvt && (true_xterm || (vte_version > 0) || colorterm))) { data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", "\x1b[%p1%d q"); if (-1 == data->unibi_ext.reset_cursor_style) { @@ -2031,7 +2031,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, ""); } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[ q"); - } else if (linux) { + } else if (linuxvt) { // Linux uses an idiosyncratic escape code to set the cursor shape and does // not support DECSCUSR. data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", @@ -2083,7 +2083,7 @@ static void augment_terminfo(TUIData *data, const char *term, unibi_term *ut = data->ut; bool xterm = term && STARTS_WITH(term, "xterm"); bool dtterm = term && STARTS_WITH(term, "dtterm"); - bool linux = term && STARTS_WITH(term, "linux"); + bool linuxvt = term && STARTS_WITH(term, "linux"); bool rxvt = term && STARTS_WITH(term, "rxvt"); bool teraterm = term && STARTS_WITH(term, "teraterm"); bool putty = term && STARTS_WITH(term, "putty"); @@ -2106,7 +2106,7 @@ static void augment_terminfo(TUIData *data, const char *term, "\x1b[r"); } // See https://gist.github.com/XVilka/8346728 for more about this. - if (putty || xterm || rxvt || linux || konsole || iterm || truecolor) { + if (putty || xterm || rxvt || linuxvt || konsole || iterm || truecolor) { data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, NULL, "\x1b[38;2;%p1%d;%p2%d;%p3%dm"); data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, NULL, -- cgit From 503a5c458bf8b8458c18d45f1d1558987b15fc2d Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Fri, 26 May 2017 00:18:24 +0100 Subject: tui: Spelling corrections in doco and commentary --- src/nvim/tui/tui.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 5a0381c072..994c15d960 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -773,8 +773,6 @@ static void tui_set_mode(UI *ui, ModeShape mode) cursorentry_T c = data->cursor_shapes[mode]; int shape = c.shape; - // Support changing cursor shape on some popular terminals. - if (c.id != 0 && ui->rgb) { int attr = syn_id2attr(c.id); if (attr > 0) { @@ -2063,7 +2061,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, "%e%{1}" // everything else is bar "%;%d;BlinkingCursorEnabled=%?" "%p1%{1}%<" "%t%{1}" // Fortunately if we exclude zero as special, - "%e%p1%{1}%&" // in all other cases we can teeat bit #0 as a flag. + "%e%p1%{1}%&" // in all other cases we can treat bit #0 as a flag. "%;%d\x07")); if (-1 == data->unibi_ext.reset_cursor_style) { data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", -- cgit From 9e9ffeb5eb811ff225d7b6bb7cc7ee51f7a9b7d4 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 27 May 2017 10:32:46 +0100 Subject: tui: Update fallback terminfo records. Replace the 8-color xterm from unibilium with the 256-colour one from terminfo. Add a fallback record for suckless terminal. --- src/nvim/tui/tui.c | 464 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 296 insertions(+), 168 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 994c15d960..0f3b046dc6 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1147,174 +1147,156 @@ static int unibi_find_ext_str(unibi_term *ut, const char *name) // od -t d1 -w // on the compiled files. -// Taken from unibilium/t/static_xterm.c as of 2015-08-14. -// This is an 8-colour terminfo description that lacks +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +// This is a 256-colour terminfo description that lacks // DECSTBN/DECSLRM/DECLRMM capabilities that xterm actually has. -static const char xterm_8colour_terminfo[] = { - 26, 1, 48, 0, 38, 0, 15, 0, -99, 1, 108, 5, 120, 116, 101, 114, 109, 124, 120, 116, - 101, 114, 109, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 101, 109, 117, 108, 97, 116, 111, - 114, 32, 40, 88, 32, 87, 105, 110, 100, 111, 119, 32, 83, 121, 115, 116, 101, 109, 41, 0, - 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 80, 0, - 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 8, 0, 64, 0, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, - 38, 0, 42, 0, 46, 0, -1, -1, 57, 0, 74, 0, 76, 0, 80, 0, 87, 0, -1, -1, - 89, 0, 102, 0, -1, -1, 106, 0, 110, 0, 120, 0, 124, 0, -1, -1, -1, -1, -128, 0, - -124, 0, -119, 0, -114, 0, -1, -1, -1, -1, -105, 0, -100, 0, -1, -1, -95, 0, -90, 0, - -85, 0, -80, 0, -71, 0, -67, 0, -60, 0, -1, -1, -51, 0, -46, 0, -40, 0, -34, 0, - -1, -1, -1, -1, -1, -1, -16, 0, -1, -1, -1, -1, -1, -1, 2, 1, -1, -1, 6, 1, - -1, -1, -1, -1, -1, -1, 8, 1, -1, -1, 13, 1, -1, -1, -1, -1, -1, -1, -1, -1, - 17, 1, 21, 1, 27, 1, 31, 1, 35, 1, 39, 1, 45, 1, 51, 1, 57, 1, 63, 1, - 69, 1, 73, 1, -1, -1, 78, 1, -1, -1, 82, 1, 87, 1, 92, 1, 96, 1, 103, 1, - -1, -1, 110, 1, 114, 1, 122, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -126, 1, -117, 1, -1, -1, -1, -1, -108, 1, - -99, 1, -90, 1, -81, 1, -72, 1, -63, 1, -54, 1, -45, 1, -36, 1, -27, 1, -1, -1, - -1, -1, -1, -1, -18, 1, -14, 1, -9, 1, -1, -1, -4, 1, -1, 1, -1, -1, -1, -1, - 17, 2, 20, 2, 31, 2, 34, 2, 36, 2, 39, 2, 121, 2, -1, -1, 124, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 126, 2, -1, -1, -1, -1, -1, -1, -1, -1, - -126, 2, -1, -1, -73, 2, -1, -1, -1, -1, -69, 2, -63, 2, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -57, 2, -53, 2, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -49, 2, -1, -1, -1, -1, -42, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -35, 2, -28, 2, -21, 2, -1, -1, -1, -1, -14, 2, -1, -1, - -7, 2, -1, -1, -1, -1, -1, -1, 0, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 7, 3, 13, 3, 19, 3, 26, 3, 33, 3, 40, 3, 47, 3, 55, 3, 63, 3, 71, 3, - 79, 3, 87, 3, 95, 3, 103, 3, 111, 3, 118, 3, 125, 3, -124, 3, -117, 3, -109, 3, - -101, 3, -93, 3, -85, 3, -77, 3, -69, 3, -61, 3, -53, 3, -46, 3, -39, 3, -32, 3, - -25, 3, -17, 3, -9, 3, -1, 3, 7, 4, 15, 4, 23, 4, 31, 4, 39, 4, 46, 4, - 53, 4, 60, 4, 67, 4, 75, 4, 83, 4, 91, 4, 99, 4, 107, 4, 115, 4, 123, 4, - -125, 4, -118, 4, -111, 4, -104, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -99, 4, -88, 4, -83, 4, - -75, 4, -71, 4, -1, -1, -1, -1, -1, -1, -1, -1, -62, 4, 8, 5, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 78, 5, - -1, -1, -1, -1, -1, -1, 82, 5, 92, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 102, 5, 105, 5, 27, 91, 90, 0, 7, 0, - 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, - 91, 51, 103, 0, 27, 91, 72, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, - 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, - 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, - 0, 8, 0, 27, 91, 63, 49, 50, 108, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, - 27, 91, 65, 0, 27, 91, 63, 49, 50, 59, 50, 53, 104, 0, 27, 91, 80, 0, 27, 91, - 77, 0, 27, 40, 48, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, - 48, 52, 57, 104, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, - 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 27, - 40, 66, 0, 27, 40, 66, 27, 91, 109, 0, 27, 91, 63, 49, 48, 52, 57, 108, 0, 27, - 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, - 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 27, 91, 33, 112, 27, 91, - 63, 51, 59, 52, 108, 27, 91, 52, 108, 27, 62, 0, 27, 91, 76, 0, 8, 0, 27, 91, - 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, - 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, - 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, - 79, 72, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, - 126, 0, 27, 79, 67, 0, 27, 91, 49, 59, 50, 66, 0, 27, 91, 49, 59, 50, 65, 0, - 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, - 27, 91, 63, 49, 48, 51, 52, 108, 0, 27, 91, 63, 49, 48, 51, 52, 104, 0, 27, 91, - 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, - 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, - 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, - 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, - 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 105, 0, 27, 91, 52, 105, 0, 27, 91, 53, - 105, 0, 27, 99, 0, 27, 91, 33, 112, 27, 91, 63, 51, 59, 52, 108, 27, 91, 52, 108, - 27, 62, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, - 10, 0, 27, 77, 0, 37, 63, 37, 112, 57, 37, 116, 27, 40, 48, 37, 101, 27, 40, 66, - 37, 59, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, - 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, - 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 55, 37, - 116, 59, 56, 37, 59, 109, 0, 27, 72, 0, 9, 0, 27, 79, 69, 0, 96, 96, 97, 97, - 102, 102, 103, 103, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, - 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, - 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 91, 63, 55, 104, 0, 27, - 91, 63, 55, 108, 0, 27, 79, 70, 0, 27, 79, 77, 0, 27, 91, 51, 59, 50, 126, 0, - 27, 91, 49, 59, 50, 70, 0, 27, 91, 49, 59, 50, 72, 0, 27, 91, 50, 59, 50, 126, - 0, 27, 91, 49, 59, 50, 68, 0, 27, 91, 54, 59, 50, 126, 0, 27, 91, 53, 59, 50, - 126, 0, 27, 91, 49, 59, 50, 67, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, - 0, 27, 91, 49, 59, 50, 80, 0, 27, 91, 49, 59, 50, 81, 0, 27, 91, 49, 59, 50, - 82, 0, 27, 91, 49, 59, 50, 83, 0, 27, 91, 49, 53, 59, 50, 126, 0, 27, 91, 49, - 55, 59, 50, 126, 0, 27, 91, 49, 56, 59, 50, 126, 0, 27, 91, 49, 57, 59, 50, 126, - 0, 27, 91, 50, 48, 59, 50, 126, 0, 27, 91, 50, 49, 59, 50, 126, 0, 27, 91, 50, - 51, 59, 50, 126, 0, 27, 91, 50, 52, 59, 50, 126, 0, 27, 91, 49, 59, 53, 80, 0, - 27, 91, 49, 59, 53, 81, 0, 27, 91, 49, 59, 53, 82, 0, 27, 91, 49, 59, 53, 83, - 0, 27, 91, 49, 53, 59, 53, 126, 0, 27, 91, 49, 55, 59, 53, 126, 0, 27, 91, 49, - 56, 59, 53, 126, 0, 27, 91, 49, 57, 59, 53, 126, 0, 27, 91, 50, 48, 59, 53, 126, - 0, 27, 91, 50, 49, 59, 53, 126, 0, 27, 91, 50, 51, 59, 53, 126, 0, 27, 91, 50, - 52, 59, 53, 126, 0, 27, 91, 49, 59, 54, 80, 0, 27, 91, 49, 59, 54, 81, 0, 27, - 91, 49, 59, 54, 82, 0, 27, 91, 49, 59, 54, 83, 0, 27, 91, 49, 53, 59, 54, 126, - 0, 27, 91, 49, 55, 59, 54, 126, 0, 27, 91, 49, 56, 59, 54, 126, 0, 27, 91, 49, - 57, 59, 54, 126, 0, 27, 91, 50, 48, 59, 54, 126, 0, 27, 91, 50, 49, 59, 54, 126, - 0, 27, 91, 50, 51, 59, 54, 126, 0, 27, 91, 50, 52, 59, 54, 126, 0, 27, 91, 49, - 59, 51, 80, 0, 27, 91, 49, 59, 51, 81, 0, 27, 91, 49, 59, 51, 82, 0, 27, 91, - 49, 59, 51, 83, 0, 27, 91, 49, 53, 59, 51, 126, 0, 27, 91, 49, 55, 59, 51, 126, - 0, 27, 91, 49, 56, 59, 51, 126, 0, 27, 91, 49, 57, 59, 51, 126, 0, 27, 91, 50, - 48, 59, 51, 126, 0, 27, 91, 50, 49, 59, 51, 126, 0, 27, 91, 50, 51, 59, 51, 126, - 0, 27, 91, 50, 52, 59, 51, 126, 0, 27, 91, 49, 59, 52, 80, 0, 27, 91, 49, 59, - 52, 81, 0, 27, 91, 49, 59, 52, 82, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, - 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 49, 59, 50, 99, 0, 27, - 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 37, 63, 37, 112, 49, - 37, 123, 49, 125, 37, 61, 37, 116, 52, 37, 101, 37, 112, 49, 37, 123, 51, 125, 37, 61, - 37, 116, 54, 37, 101, 37, 112, 49, 37, 123, 52, 125, 37, 61, 37, 116, 49, 37, 101, 37, - 112, 49, 37, 123, 54, 125, 37, 61, 37, 116, 51, 37, 101, 37, 112, 49, 37, 100, 37, 59, - 109, 0, 27, 91, 52, 37, 63, 37, 112, 49, 37, 123, 49, 125, 37, 61, 37, 116, 52, 37, - 101, 37, 112, 49, 37, 123, 51, 125, 37, 61, 37, 116, 54, 37, 101, 37, 112, 49, 37, 123, - 52, 125, 37, 61, 37, 116, 49, 37, 101, 37, 112, 49, 37, 123, 54, 125, 37, 61, 37, 116, - 51, 37, 101, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 77, 0, 27, 91, 51, 37, - 112, 49, 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0, 27, 108, 0, 27, - 109, 0, 2, 0, 1, 0, 57, 0, 117, 0, -88, 2, 1, 0, -1, -1, -1, -1, 0, 0, - 7, 0, 14, 0, 21, 0, 28, 0, 35, 0, 42, 0, 49, 0, 56, 0, 63, 0, 70, 0, - 77, 0, 84, 0, 91, 0, 98, 0, 105, 0, 112, 0, 119, 0, 126, 0, -123, 0, -116, 0, - -109, 0, -102, 0, -95, 0, -88, 0, -81, 0, -74, 0, -67, 0, -60, 0, -53, 0, -46, 0, - -39, 0, -32, 0, -25, 0, -18, 0, -11, 0, -4, 0, 3, 1, 10, 1, 17, 1, 24, 1, - 31, 1, 38, 1, 45, 1, 52, 1, 59, 1, 66, 1, 73, 1, 80, 1, 87, 1, 94, 1, - 101, 1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 3, 0, 6, 0, 9, 0, 12, 0, - 17, 0, 22, 0, 27, 0, 32, 0, 37, 0, 41, 0, 46, 0, 51, 0, 56, 0, 61, 0, - 66, 0, 72, 0, 78, 0, 84, 0, 90, 0, 96, 0, 102, 0, 108, 0, 114, 0, 120, 0, - 126, 0, -125, 0, -120, 0, -115, 0, -110, 0, -105, 0, -99, 0, -93, 0, -87, 0, -81, 0, - -75, 0, -69, 0, -63, 0, -57, 0, -51, 0, -45, 0, -39, 0, -33, 0, -27, 0, -21, 0, - -15, 0, -9, 0, -3, 0, 3, 1, 9, 1, 15, 1, 19, 1, 24, 1, 29, 1, 34, 1, - 39, 1, 44, 1, 48, 1, 52, 1, 56, 1, 27, 91, 51, 59, 51, 126, 0, 27, 91, 51, - 59, 52, 126, 0, 27, 91, 51, 59, 53, 126, 0, 27, 91, 51, 59, 54, 126, 0, 27, 91, - 51, 59, 55, 126, 0, 27, 91, 49, 59, 50, 66, 0, 27, 91, 49, 59, 51, 66, 0, 27, - 91, 49, 59, 52, 66, 0, 27, 91, 49, 59, 53, 66, 0, 27, 91, 49, 59, 54, 66, 0, - 27, 91, 49, 59, 55, 66, 0, 27, 91, 49, 59, 51, 70, 0, 27, 91, 49, 59, 52, 70, - 0, 27, 91, 49, 59, 53, 70, 0, 27, 91, 49, 59, 54, 70, 0, 27, 91, 49, 59, 55, - 70, 0, 27, 91, 49, 59, 51, 72, 0, 27, 91, 49, 59, 52, 72, 0, 27, 91, 49, 59, - 53, 72, 0, 27, 91, 49, 59, 54, 72, 0, 27, 91, 49, 59, 55, 72, 0, 27, 91, 50, - 59, 51, 126, 0, 27, 91, 50, 59, 52, 126, 0, 27, 91, 50, 59, 53, 126, 0, 27, 91, - 50, 59, 54, 126, 0, 27, 91, 50, 59, 55, 126, 0, 27, 91, 49, 59, 51, 68, 0, 27, - 91, 49, 59, 52, 68, 0, 27, 91, 49, 59, 53, 68, 0, 27, 91, 49, 59, 54, 68, 0, - 27, 91, 49, 59, 55, 68, 0, 27, 91, 54, 59, 51, 126, 0, 27, 91, 54, 59, 52, 126, - 0, 27, 91, 54, 59, 53, 126, 0, 27, 91, 54, 59, 54, 126, 0, 27, 91, 54, 59, 55, - 126, 0, 27, 91, 53, 59, 51, 126, 0, 27, 91, 53, 59, 52, 126, 0, 27, 91, 53, 59, - 53, 126, 0, 27, 91, 53, 59, 54, 126, 0, 27, 91, 53, 59, 55, 126, 0, 27, 91, 49, - 59, 51, 67, 0, 27, 91, 49, 59, 52, 67, 0, 27, 91, 49, 59, 53, 67, 0, 27, 91, - 49, 59, 54, 67, 0, 27, 91, 49, 59, 55, 67, 0, 27, 91, 49, 59, 50, 65, 0, 27, - 91, 49, 59, 51, 65, 0, 27, 91, 49, 59, 52, 65, 0, 27, 91, 49, 59, 53, 65, 0, - 27, 91, 49, 59, 54, 65, 0, 27, 91, 49, 59, 55, 65, 0, 65, 88, 0, 88, 84, 0, - 85, 56, 0, 88, 77, 0, 107, 68, 67, 51, 0, 107, 68, 67, 52, 0, 107, 68, 67, 53, - 0, 107, 68, 67, 54, 0, 107, 68, 67, 55, 0, 107, 68, 78, 0, 107, 68, 78, 51, 0, - 107, 68, 78, 52, 0, 107, 68, 78, 53, 0, 107, 68, 78, 54, 0, 107, 68, 78, 55, 0, - 107, 69, 78, 68, 51, 0, 107, 69, 78, 68, 52, 0, 107, 69, 78, 68, 53, 0, 107, 69, - 78, 68, 54, 0, 107, 69, 78, 68, 55, 0, 107, 72, 79, 77, 51, 0, 107, 72, 79, 77, - 52, 0, 107, 72, 79, 77, 53, 0, 107, 72, 79, 77, 54, 0, 107, 72, 79, 77, 55, 0, - 107, 73, 67, 51, 0, 107, 73, 67, 52, 0, 107, 73, 67, 53, 0, 107, 73, 67, 54, 0, - 107, 73, 67, 55, 0, 107, 76, 70, 84, 51, 0, 107, 76, 70, 84, 52, 0, 107, 76, 70, - 84, 53, 0, 107, 76, 70, 84, 54, 0, 107, 76, 70, 84, 55, 0, 107, 78, 88, 84, 51, - 0, 107, 78, 88, 84, 52, 0, 107, 78, 88, 84, 53, 0, 107, 78, 88, 84, 54, 0, 107, - 78, 88, 84, 55, 0, 107, 80, 82, 86, 51, 0, 107, 80, 82, 86, 52, 0, 107, 80, 82, - 86, 53, 0, 107, 80, 82, 86, 54, 0, 107, 80, 82, 86, 55, 0, 107, 82, 73, 84, 51, - 0, 107, 82, 73, 84, 52, 0, 107, 82, 73, 84, 53, 0, 107, 82, 73, 84, 54, 0, 107, - 82, 73, 84, 55, 0, 107, 85, 80, 0, 107, 85, 80, 51, 0, 107, 85, 80, 52, 0, 107, - 85, 80, 53, 0, 107, 85, 80, 54, 0, 107, 85, 80, 55, 0, 107, 97, 50, 0, 107, 98, - 49, 0, 107, 98, 51, 0, 107, 99, 50, 0 +static const char xterm_256colour_terminfo[] = { + 26, 1, 37, 0, 29, 0, 15, 0, 105, 1, -42, 5, 120, 116, 101, 114, + 109, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 120, 116, 101, 114, 109, + 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, + 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 80, 0, + 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, + 6, 0, 8, 0, 25, 0, 30, 0, 38, 0, 42, 0, 46, 0, -1, -1, + 57, 0, 74, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, 102, 0, + -1, -1, 106, 0, 110, 0, 120, 0, 124, 0, -1, -1, -1, -1,-128, 0, +-124, 0,-119, 0,-114, 0, -1, -1,-105, 0,-100, 0, -95, 0, -1, -1, + -90, 0, -85, 0, -80, 0, -75, 0, -66, 0, -62, 0, -55, 0, -1, -1, + -46, 0, -41, 0, -35, 0, -29, 0, -1, -1, -1, -1, -1, -1, -11, 0, + -1, -1, -1, -1, -1, -1, 7, 1, -1, -1, 11, 1, -1, -1, -1, -1, + -1, -1, 13, 1, -1, -1, 18, 1, -1, -1, -1, -1, -1, -1, -1, -1, + 22, 1, 26, 1, 32, 1, 36, 1, 40, 1, 44, 1, 50, 1, 56, 1, + 62, 1, 68, 1, 74, 1, 78, 1, -1, -1, 83, 1, -1, -1, 87, 1, + 92, 1, 97, 1, 101, 1, 108, 1, -1, -1, 115, 1, 119, 1, 127, 1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1,-121, 1,-112, 1, -1, -1, -1, -1,-103, 1, + -94, 1, -85, 1, -76, 1, -67, 1, -58, 1, -49, 1, -40, 1, -31, 1, + -22, 1, -1, -1, -1, -1, -1, -1, -13, 1, -9, 1, -4, 1, -1, -1, + 1, 2, 10, 2, -1, -1, -1, -1, 28, 2, 31, 2, 42, 2, 45, 2, + 47, 2, 50, 2,-113, 2, -1, -1,-110, 2, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1,-108, 2, -1, -1, -1, -1, -1, -1, -1, -1, +-104, 2, -1, -1, -51, 2, -1, -1, -1, -1, -47, 2, -41, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -35, 2, -31, 2, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -27, 2, -1, -1, -1, -1, + -20, 2, -1, -1, -1, -1, -1, -1, -1, -1, -13, 2, -6, 2, 1, 3, + -1, -1, -1, -1, 8, 3, -1, -1, 15, 3, -1, -1, -1, -1, -1, -1, + 22, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, 3, 35, 3, + 41, 3, 48, 3, 55, 3, 62, 3, 69, 3, 77, 3, 85, 3, 93, 3, + 101, 3, 109, 3, 117, 3, 125, 3,-123, 3,-116, 3,-109, 3,-102, 3, + -95, 3, -87, 3, -79, 3, -71, 3, -63, 3, -55, 3, -47, 3, -39, 3, + -31, 3, -24, 3, -17, 3, -10, 3, -3, 3, 5, 4, 13, 4, 21, 4, + 29, 4, 37, 4, 45, 4, 53, 4, 61, 4, 68, 4, 75, 4, 82, 4, + 89, 4, 97, 4, 105, 4, 113, 4, 121, 4,-127, 4,-119, 4,-111, 4, +-103, 4, -96, 4, -89, 4, -82, 4, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -77, 4, -66, 4, -61, 4, -42, 4, -38, 4, + -29, 4, -22, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 72, 5, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, 5, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 83, 5, -1, -1, -1, -1, -1, -1, 87, 5,-106, 5, 27, 91, + 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, + 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, + 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, + 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, + 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, + 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 49, 50, 108, 27, 91, 63, + 50, 53, 104, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 63, 49, + 50, 59, 50, 53, 104, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 40, + 48, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, + 48, 52, 57, 104, 0, 27, 91, 50, 109, 0, 27, 91, 52, 104, 0, 27, + 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, + 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 27, 40, 66, 0, + 27, 40, 66, 27, 91, 109, 0, 27, 91, 63, 49, 48, 52, 57, 108, 0, + 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, + 0, 27, 91, 63, 53, 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, + 53, 108, 0, 27, 91, 33, 112, 27, 91, 63, 51, 59, 52, 108, 27, 91, + 52, 108, 27, 62, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, + 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, + 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, + 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, + 126, 0, 27, 91, 50, 48, 126, 0, 27, 79, 72, 0, 27, 91, 50, 126, + 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, + 79, 67, 0, 27, 91, 49, 59, 50, 66, 0, 27, 91, 49, 59, 50, 65, + 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, + 49, 104, 27, 61, 0, 27, 91, 63, 49, 48, 51, 52, 108, 0, 27, 91, + 63, 49, 48, 51, 52, 104, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, + 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, + 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, + 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, + 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, + 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, + 0, 27, 91, 105, 0, 27, 91, 52, 105, 0, 27, 91, 53, 105, 0, 27, + 99, 27, 93, 49, 48, 52, 7, 0, 27, 91, 33, 112, 27, 91, 63, 51, + 59, 52, 108, 27, 91, 52, 108, 27, 62, 0, 27, 56, 0, 27, 91, 37, + 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, + 37, 63, 37, 112, 57, 37, 116, 27, 40, 48, 37, 101, 27, 40, 66, 37, + 59, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, + 63, 37, 112, 53, 37, 116, 59, 50, 37, 59, 37, 63, 37, 112, 50, 37, + 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, + 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, + 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 109, 0, 27, 72, 0, + 9, 0, 27, 79, 69, 0, 96, 96, 97, 97, 102, 102, 103, 103, 105, 105, + 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, + 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, + 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, + 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 79, 70, 0, 27, + 79, 77, 0, 27, 91, 51, 59, 50, 126, 0, 27, 91, 49, 59, 50, 70, + 0, 27, 91, 49, 59, 50, 72, 0, 27, 91, 50, 59, 50, 126, 0, 27, + 91, 49, 59, 50, 68, 0, 27, 91, 54, 59, 50, 126, 0, 27, 91, 53, + 59, 50, 126, 0, 27, 91, 49, 59, 50, 67, 0, 27, 91, 50, 51, 126, + 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 59, 50, 80, 0, 27, 91, + 49, 59, 50, 81, 0, 27, 91, 49, 59, 50, 82, 0, 27, 91, 49, 59, + 50, 83, 0, 27, 91, 49, 53, 59, 50, 126, 0, 27, 91, 49, 55, 59, + 50, 126, 0, 27, 91, 49, 56, 59, 50, 126, 0, 27, 91, 49, 57, 59, + 50, 126, 0, 27, 91, 50, 48, 59, 50, 126, 0, 27, 91, 50, 49, 59, + 50, 126, 0, 27, 91, 50, 51, 59, 50, 126, 0, 27, 91, 50, 52, 59, + 50, 126, 0, 27, 91, 49, 59, 53, 80, 0, 27, 91, 49, 59, 53, 81, + 0, 27, 91, 49, 59, 53, 82, 0, 27, 91, 49, 59, 53, 83, 0, 27, + 91, 49, 53, 59, 53, 126, 0, 27, 91, 49, 55, 59, 53, 126, 0, 27, + 91, 49, 56, 59, 53, 126, 0, 27, 91, 49, 57, 59, 53, 126, 0, 27, + 91, 50, 48, 59, 53, 126, 0, 27, 91, 50, 49, 59, 53, 126, 0, 27, + 91, 50, 51, 59, 53, 126, 0, 27, 91, 50, 52, 59, 53, 126, 0, 27, + 91, 49, 59, 54, 80, 0, 27, 91, 49, 59, 54, 81, 0, 27, 91, 49, + 59, 54, 82, 0, 27, 91, 49, 59, 54, 83, 0, 27, 91, 49, 53, 59, + 54, 126, 0, 27, 91, 49, 55, 59, 54, 126, 0, 27, 91, 49, 56, 59, + 54, 126, 0, 27, 91, 49, 57, 59, 54, 126, 0, 27, 91, 50, 48, 59, + 54, 126, 0, 27, 91, 50, 49, 59, 54, 126, 0, 27, 91, 50, 51, 59, + 54, 126, 0, 27, 91, 50, 52, 59, 54, 126, 0, 27, 91, 49, 59, 51, + 80, 0, 27, 91, 49, 59, 51, 81, 0, 27, 91, 49, 59, 51, 82, 0, + 27, 91, 49, 59, 51, 83, 0, 27, 91, 49, 53, 59, 51, 126, 0, 27, + 91, 49, 55, 59, 51, 126, 0, 27, 91, 49, 56, 59, 51, 126, 0, 27, + 91, 49, 57, 59, 51, 126, 0, 27, 91, 50, 48, 59, 51, 126, 0, 27, + 91, 50, 49, 59, 51, 126, 0, 27, 91, 50, 51, 59, 51, 126, 0, 27, + 91, 50, 52, 59, 51, 126, 0, 27, 91, 49, 59, 52, 80, 0, 27, 91, + 49, 59, 52, 81, 0, 27, 91, 49, 59, 52, 82, 0, 27, 91, 49, 75, + 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, + 0, 27, 91, 63, 37, 91, 59, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 93, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, + 0, 27, 93, 49, 48, 52, 7, 0, 27, 93, 52, 59, 37, 112, 49, 37, + 100, 59, 114, 103, 98, 58, 37, 112, 50, 37, 123, 50, 53, 53, 125, 37, + 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, + 37, 112, 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, + 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 52, 37, 123, 50, + 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, + 46, 50, 88, 27, 92, 0, 27, 91, 51, 109, 0, 27, 91, 50, 51, 109, + 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, + 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, + 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, + 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, + 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, + 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, + 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, + 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, + 37, 59, 109, 0 }; // Taken from unibilium/t/static_tmux.c as of 2015-08-14. // This is an 256-colour terminfo description that lacks @@ -1799,6 +1781,150 @@ static const char interix_8colour_terminfo[] = { 39, 37, 43, 37, 100, 109, 0, 27, 91, 51, 37, 112, 49, 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. +static const char st_256colour_terminfo[] = { + 26, 1, 55, 0, 29, 0, 15, 0, 105, 1, 117, 5, 115, 116, 45, 50, + 53, 54, 99, 111, 108, 111, 114, 124, 115, 116, 116, 101, 114, 109, 45, 50, + 53, 54, 99, 111, 108, 111, 114, 124, 115, 105, 109, 112, 108, 101, 116, 101, + 114, 109, 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, + 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, + 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, + 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, 38, 0, 42, 0, 46, 0, + -1, -1, 57, 0, 74, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, + 102, 0, -1, -1, 106, 0, 110, 0, 117, 0, 121, 0, -1, -1, -1, -1, + 125, 0,-127, 0,-122, 0,-117, 0, -1, -1, -1, -1,-108, 0,-103, 0, + -1, -1, -98, 0, -93, 0, -88, 0, -83, 0, -74, 0, -70, 0, -65, 0, + -1, -1, -56, 0, -51, 0, -45, 0, -39, 0, -1, -1, -21, 0, -1, -1, + -19, 0, -1, -1, -1, -1, -1, -1, -4, 0, -1, -1, 0, 1, -1, -1, + 2, 1, -1, -1, 9, 1, 14, 1, 21, 1, 25, 1, 32, 1, 39, 1, + -1, -1, 46, 1, 50, 1, 56, 1, 60, 1, 64, 1, 68, 1, 74, 1, + 80, 1, 86, 1, 92, 1, 98, 1, 103, 1, 108, 1, 115, 1, -1, -1, + 119, 1, 124, 1,-127, 1,-123, 1,-116, 1, -1, -1,-109, 1,-105, 1, + -97, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -89, 1, -80, 1, -71, 1, -62, 1, -53, 1, -44, 1, -35, 1, -26, 1, + -1, -1, -17, 1, -1, -1, -1, -1, -1, -1, -8, 1, -4, 1, 1, 2, + -1, -1, 6, 2, 9, 2, -1, -1, -1, -1, 24, 2, 27, 2, 38, 2, + 41, 2, 43, 2, 46, 2,-128, 2, -1, -1,-125, 2,-123, 2, -1, -1, + -1, -1, -1, -1,-118, 2,-113, 2,-108, 2,-104, 2, -99, 2, -1, -1, + -1, -1, -94, 2, -1, -1, -29, 2, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -25, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -21, 2, -16, 2, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -12, 2, -1, -1, + -1, -1, -5, 2, -1, -1, -1, -1, -1, -1, -1, -1, 2, 3, 9, 3, + 16, 3, -1, -1, -1, -1, 23, 3, -1, -1, 30, 3, -1, -1, -1, -1, + -1, -1, 37, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 3, + 50, 3, 56, 3, 63, 3, 70, 3, 77, 3, 84, 3, 92, 3, 100, 3, + 108, 3, 116, 3, 124, 3,-124, 3,-116, 3,-108, 3,-101, 3, -94, 3, + -87, 3, -80, 3, -72, 3, -64, 3, -56, 3, -48, 3, -40, 3, -32, 3, + -24, 3, -16, 3, -9, 3, -2, 3, 5, 4, 12, 4, 20, 4, 28, 4, + 36, 4, 44, 4, 52, 4, 60, 4, 68, 4, 76, 4, 83, 4, 90, 4, + 97, 4, 104, 4, 112, 4, 120, 4,-128, 4,-120, 4,-112, 4,-104, 4, + -96, 4, -88, 4, -81, 4, -74, 4, -67, 4, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -62, 4, -51, 4, -46, 4, -38, 4, + -34, 4, -2, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -25, 4, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -20, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -14, 4, -1, -1, -1, -1, -1, -1, -10, 4, 53, 5, + 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, + 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, + 72, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, + 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, + 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, + 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 49, 50, 108, 27, + 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, + 63, 50, 53, 104, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 40, 48, + 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, 48, + 52, 57, 104, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, 0, 27, 91, + 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, + 112, 49, 37, 100, 88, 0, 27, 40, 66, 0, 27, 91, 48, 109, 0, 27, + 91, 63, 49, 48, 52, 57, 108, 0, 27, 91, 52, 108, 0, 27, 91, 50, + 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, + 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 7, 0, 27, 91, 52, + 108, 27, 62, 27, 91, 63, 49, 48, 51, 52, 108, 0, 27, 91, 76, 0, + 127, 0, 27, 91, 51, 59, 53, 126, 0, 27, 91, 51, 126, 0, 27, 91, + 51, 59, 50, 126, 0, 27, 79, 66, 0, 27, 91, 50, 59, 50, 126, 0, + 27, 91, 49, 59, 50, 70, 0, 27, 91, 49, 59, 53, 70, 0, 27, 79, + 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, + 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, + 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, + 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 91, 50, 59, + 53, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, + 0, 27, 79, 67, 0, 27, 91, 49, 59, 50, 66, 0, 27, 91, 49, 59, + 50, 65, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, + 91, 63, 49, 104, 27, 61, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, + 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, + 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, + 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, + 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, + 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 105, 0, 27, 91, 52, 105, + 0, 27, 91, 53, 105, 0, 27, 99, 0, 27, 91, 52, 108, 27, 62, 27, + 91, 63, 49, 48, 51, 52, 108, 0, 27, 56, 0, 27, 91, 37, 105, 37, + 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 37, 63, + 37, 112, 57, 37, 116, 27, 40, 48, 37, 101, 27, 40, 66, 37, 59, 27, + 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, + 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, + 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, + 53, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 109, 0, + 27, 72, 0, 9, 0, 27, 93, 48, 59, 0, 27, 91, 49, 126, 0, 27, + 91, 53, 126, 0, 27, 79, 117, 0, 27, 91, 52, 126, 0, 27, 91, 54, + 126, 0, 43, 67, 44, 68, 45, 65, 46, 66, 48, 69, 96, 96, 97, 97, + 102, 102, 103, 103, 104, 70, 105, 71, 106, 106, 107, 107, 108, 108, 109, 109, + 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, + 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, + 126, 126, 0, 27, 91, 90, 0, 27, 41, 48, 0, 27, 91, 52, 126, 0, + 27, 79, 77, 0, 27, 91, 51, 59, 50, 126, 0, 27, 91, 49, 59, 50, + 70, 0, 27, 91, 49, 59, 50, 72, 0, 27, 91, 50, 59, 50, 126, 0, + 27, 91, 49, 59, 50, 68, 0, 27, 91, 54, 59, 50, 126, 0, 27, 91, + 53, 59, 50, 126, 0, 27, 91, 49, 59, 50, 67, 0, 27, 91, 50, 51, + 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 59, 50, 80, 0, 27, + 91, 49, 59, 50, 81, 0, 27, 91, 49, 59, 50, 82, 0, 27, 91, 49, + 59, 50, 83, 0, 27, 91, 49, 53, 59, 50, 126, 0, 27, 91, 49, 55, + 59, 50, 126, 0, 27, 91, 49, 56, 59, 50, 126, 0, 27, 91, 49, 57, + 59, 50, 126, 0, 27, 91, 50, 48, 59, 50, 126, 0, 27, 91, 50, 49, + 59, 50, 126, 0, 27, 91, 50, 51, 59, 50, 126, 0, 27, 91, 50, 52, + 59, 50, 126, 0, 27, 91, 49, 59, 53, 80, 0, 27, 91, 49, 59, 53, + 81, 0, 27, 91, 49, 59, 53, 82, 0, 27, 91, 49, 59, 53, 83, 0, + 27, 91, 49, 53, 59, 53, 126, 0, 27, 91, 49, 55, 59, 53, 126, 0, + 27, 91, 49, 56, 59, 53, 126, 0, 27, 91, 49, 57, 59, 53, 126, 0, + 27, 91, 50, 48, 59, 53, 126, 0, 27, 91, 50, 49, 59, 53, 126, 0, + 27, 91, 50, 51, 59, 53, 126, 0, 27, 91, 50, 52, 59, 53, 126, 0, + 27, 91, 49, 59, 54, 80, 0, 27, 91, 49, 59, 54, 81, 0, 27, 91, + 49, 59, 54, 82, 0, 27, 91, 49, 59, 54, 83, 0, 27, 91, 49, 53, + 59, 54, 126, 0, 27, 91, 49, 55, 59, 54, 126, 0, 27, 91, 49, 56, + 59, 54, 126, 0, 27, 91, 49, 57, 59, 54, 126, 0, 27, 91, 50, 48, + 59, 54, 126, 0, 27, 91, 50, 49, 59, 54, 126, 0, 27, 91, 50, 51, + 59, 54, 126, 0, 27, 91, 50, 52, 59, 54, 126, 0, 27, 91, 49, 59, + 51, 80, 0, 27, 91, 49, 59, 51, 81, 0, 27, 91, 49, 59, 51, 82, + 0, 27, 91, 49, 59, 51, 83, 0, 27, 91, 49, 53, 59, 51, 126, 0, + 27, 91, 49, 55, 59, 51, 126, 0, 27, 91, 49, 56, 59, 51, 126, 0, + 27, 91, 49, 57, 59, 51, 126, 0, 27, 91, 50, 48, 59, 51, 126, 0, + 27, 91, 50, 49, 59, 51, 126, 0, 27, 91, 50, 51, 59, 51, 126, 0, + 27, 91, 50, 52, 59, 51, 126, 0, 27, 91, 49, 59, 52, 80, 0, 27, + 91, 49, 59, 52, 81, 0, 27, 91, 49, 59, 52, 82, 0, 27, 91, 49, + 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, + 110, 0, 27, 91, 63, 49, 59, 50, 99, 0, 27, 91, 99, 0, 27, 91, + 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 109, 0, 27, 91, 50, 51, + 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, + 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, + 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, + 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, + 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, + 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, + 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, + 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, + 100, 37, 59, 109, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. static const char ansi_terminfo[] = { 26, 1, 40, 0, 23, 0, 16, 0, 125, 1, 68, 2, 97, 110, 115, 105, 124, 97, 110, 115, 105, 47, 112, 99, 45, 116, 101, 114, 109, 32, 99, 111, 109, 112, 97, 116, 105, 98, 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, 108, 111, 114, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1856,7 +1982,7 @@ static const char ansi_terminfo[] = { static unibi_term *load_builtin_terminfo(const char * term) { if (term && STARTS_WITH(term, "xterm")) { - return unibi_from_mem(xterm_8colour_terminfo, sizeof xterm_8colour_terminfo); + return unibi_from_mem(xterm_256colour_terminfo, sizeof xterm_256colour_terminfo); } else if (term && STARTS_WITH(term, "screen")) { return unibi_from_mem(screen_256colour_terminfo, sizeof screen_256colour_terminfo); } else if (term && STARTS_WITH(term, "tmux")) { @@ -1871,6 +1997,8 @@ static unibi_term *load_builtin_terminfo(const char * term) return unibi_from_mem(interix_8colour_terminfo, sizeof interix_8colour_terminfo); } else if (term && (STARTS_WITH(term, "iterm") || STARTS_WITH(term, "iTerm"))) { return unibi_from_mem(iterm_16colour_terminfo, sizeof iterm_16colour_terminfo); + } else if (term && STARTS_WITH(term, "st")) { + return unibi_from_mem(st_256colour_terminfo, sizeof st_256colour_terminfo); } else { return unibi_from_mem(ansi_terminfo, sizeof ansi_terminfo); } -- cgit From 67e2120459268494c589cc5be6a20b05fdd9ca84 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 27 May 2017 10:36:20 +0100 Subject: tui: Refactor built-in teminfo records. No change to their contents, but make the Big Blocks Of Numbers half as wide but twice as deep, in order to accomodate house style. --- src/nvim/tui/tui.c | 992 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 661 insertions(+), 331 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 0f3b046dc6..58c9e75de8 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1480,305 +1480,590 @@ static const char screen_256colour_terminfo[] = { }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. static const char iterm_16colour_terminfo[] = { - 26, 1, 57, 0, 29, 0, 15, 0, 105, 1, 73, 3, 105, 84, 101, 114, 109, 46, 97, 112, 112, 124, 105, 116, 101, 114, 109, 124, 105, 84, 101, 114, -109, 46, 97, 112, 112, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 101, 109, 117, 108, 97, 116, 111, 114, 32, 102, 111, 114, 32, 77, 97, 99, 32, - 79, 83, 32, 88, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, - 0, 1, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, 50, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, - -1, -1, 0, 0, 2, 0, -2, -1, 4, 0, 9, 0, 16, 0, 20, 0, 24, 0, -1, -1, 35, 0, 52, 0, 54, 0, 58, 0, 65, 0, -1, -1, - 67, 0, 74, 0, -1, -1, 78, 0, -1, -1, 82, 0, 86, 0, 90, 0, -1, -1, 96, 0, 98, 0, 103, 0, 108, 0, -1, -1, -2, -1, 117, 0, -122, 0, -1, -1, 127, 0,-124, 0,-119, 0, -1, -1,-114, 0,-112, 0,-107, 0, -1, -1, -94, 0, -89, 0, -85, 0, -81, 0, -1, -1, -63, 0, - -1, -1, -1, -1, -1, -1, -1, -1, -61, 0, -57, 0, -1, -1, -53, 0, -1, -1, -1, -1, -1, -1, -51, 0, -1, -1, -46, 0, -1, -1, -1, -1, - -1, -1, -1, -1, -42, 0, -38, 0, -32, 0, -28, 0, -24, 0, -20, 0, -14, 0, -8, 0, -2, 0, 4, 1, 10, 1, -1, -1, -1, -1, 14, 1, - -1, -1, 18, 1, 23, 1, 28, 1, -1, -1, -1, -1, -1, -1, 32, 1, 36, 1, 44, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 52, 1, 61, 1, 70, 1, 79, 1, -1, -1, 88, 1, 97, 1, -106, 1, -1, -1, 115, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 124, 1, -1, -1, -1, -1,-104, 1,-101, 1, --90, 1, -87, 1, -85, 1, -82, 1, -4, 1, -1, -1, -1, 1, 1, 2, -1, -1, -1, -1, -1, -1, 6, 2, 10, 2, 14, 2, 18, 2, 22, 2, - -1, -1, -1, -1, 26, 2, -1, -1, -1, -1, -1, -1, -1, -1, 77, 2, 83, 2, -1, -1, -1, -1, 89, 2, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 96, 2, 100, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, 2, 110, 2, 116, 2, 122, 2,-128, 2,-122, 2,-116, 2,-110, 2, -104, 2, -98, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -92, 2, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -87, 2, -76, 2, -71, 2, -63, 2, -59, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -54, 2, 9, 3, 7, 0, 13, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, - 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, -112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, - 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 93, 50, 59, 7, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 55, - 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, - 15, 0, 27, 91, 109, 15, 0, 27, 91, 50, 74, 27, 91, 63, 52, 55, 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, 91, 109, 0, 27, 91, 109, - 0, 27, 91, 63, 53, 104, 36, 60, 50, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 7, 0, 27, 91, 64, 0, 27, 91, 76, 0, 127, 0, 27, - 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, - 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 79, 72, 0, - 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, - 63, 49, 104, 27, 61, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, - 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, - 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 62, 27, 91, 63, 51, 108, 27, 91, 63, 52, 108, 27, 91, 63, 53, 108, 27, - 91, 63, 55, 104, 27, 91, 63, 56, 104, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, - 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, - 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 109, - 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 93, 50, 59, 0, 27, 79, 113, 0, 27, 79, 115, 0, - 27, 79, 114, 0, 27, 79, 112, 0, 27, 79, 110, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, -112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, - 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 40, 66, 27, 41, 48, 0, 27, 79, 70, 0, 27, 79, 77, 0, 27, 91, 50, 51, 126, 0, - 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, 0, 27, 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, - 51, 49, 126, 0, 27, 91, 50, 50, 126, 0, 27, 91, 51, 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, -100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 49, 59, 50, 99, 0, 27, 91, 99, 0, 27, 91, 48, 109, 0, 27, 91, 37, 63, - 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, - 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, -112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, - 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 + 26, 1, 57, 0, 29, 0, 15, 0, 105, 1, 73, 3, 105, 84, 101, 114, + 109, 46, 97, 112, 112, 124, 105, 116, 101, 114, 109, 124, 105, 84, 101, 114, + 109, 46, 97, 112, 112, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 101, + 109, 117, 108, 97, 116, 111, 114, 32, 102, 111, 114, 32, 77, 97, 99, 32, + 79, 83, 32, 88, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, + 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, + 0, 1, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, + 50, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, + -1, -1, 0, 0, 2, 0, -2, -1, 4, 0, 9, 0, 16, 0, 20, 0, + 24, 0, -1, -1, 35, 0, 52, 0, 54, 0, 58, 0, 65, 0, -1, -1, + 67, 0, 74, 0, -1, -1, 78, 0, -1, -1, 82, 0, 86, 0, 90, 0, + -1, -1, 96, 0, 98, 0, 103, 0, 108, 0, -1, -1, -2, -1, 117, 0, + 122, 0, -1, -1, 127, 0,-124, 0,-119, 0, -1, -1,-114, 0,-112, 0, +-107, 0, -1, -1, -94, 0, -89, 0, -85, 0, -81, 0, -1, -1, -63, 0, + -1, -1, -1, -1, -1, -1, -1, -1, -61, 0, -57, 0, -1, -1, -53, 0, + -1, -1, -1, -1, -1, -1, -51, 0, -1, -1, -46, 0, -1, -1, -1, -1, + -1, -1, -1, -1, -42, 0, -38, 0, -32, 0, -28, 0, -24, 0, -20, 0, + -14, 0, -8, 0, -2, 0, 4, 1, 10, 1, -1, -1, -1, -1, 14, 1, + -1, -1, 18, 1, 23, 1, 28, 1, -1, -1, -1, -1, -1, -1, 32, 1, + 36, 1, 44, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 52, 1, 61, 1, 70, 1, 79, 1, -1, -1, 88, 1, 97, 1, + 106, 1, -1, -1, 115, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 124, 1, -1, -1, -1, -1,-104, 1,-101, 1, + -90, 1, -87, 1, -85, 1, -82, 1, -4, 1, -1, -1, -1, 1, 1, 2, + -1, -1, -1, -1, -1, -1, 6, 2, 10, 2, 14, 2, 18, 2, 22, 2, + -1, -1, -1, -1, 26, 2, -1, -1, -1, -1, -1, -1, -1, -1, 77, 2, + 83, 2, -1, -1, -1, -1, 89, 2, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 96, 2, 100, 2, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 104, 2, 110, 2, 116, 2, 122, 2,-128, 2,-122, 2,-116, 2,-110, 2, + 104, 2, -98, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -92, 2, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -87, 2, -76, 2, -71, 2, + -63, 2, -59, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -54, 2, + 9, 3, 7, 0, 13, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, + 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, + 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, + 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, + 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, + 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 93, 50, 59, + 7, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 55, + 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, + 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, + 15, 0, 27, 91, 109, 15, 0, 27, 91, 50, 74, 27, 91, 63, 52, 55, + 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, 91, 109, 0, 27, 91, 109, + 0, 27, 91, 63, 53, 104, 36, 60, 50, 48, 48, 47, 62, 27, 91, 63, + 53, 108, 0, 7, 0, 27, 91, 64, 0, 27, 91, 76, 0, 127, 0, 27, + 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, + 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, + 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, + 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 79, 72, 0, + 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, + 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, + 63, 49, 104, 27, 61, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, + 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, + 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, + 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, + 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 62, + 27, 91, 63, 51, 108, 27, 91, 63, 52, 108, 27, 91, 63, 53, 108, 27, + 91, 63, 55, 104, 27, 91, 63, 56, 104, 0, 27, 56, 0, 27, 91, 37, + 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, + 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, + 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, + 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, + 59, 53, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 109, + 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, + 0, 9, 0, 27, 93, 50, 59, 0, 27, 79, 113, 0, 27, 79, 115, 0, + 27, 79, 114, 0, 27, 79, 112, 0, 27, 79, 110, 0, 96, 96, 97, 97, + 102, 102, 103, 103, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, + 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, + 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, + 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 40, 66, 27, 41, + 48, 0, 27, 79, 70, 0, 27, 79, 77, 0, 27, 91, 50, 51, 126, 0, + 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, 0, 27, 91, 50, 54, + 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, + 51, 49, 126, 0, 27, 91, 50, 50, 126, 0, 27, 91, 51, 51, 126, 0, + 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, + 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 49, 59, + 50, 99, 0, 27, 91, 99, 0, 27, 91, 48, 109, 0, 27, 91, 37, 63, + 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, + 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, + 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, + 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, + 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, + 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, + 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, + 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. static const char rxvt_256colour_terminfo[] = { - 26, 1, 47, 0, 29, 0, 15, 0, 110, 1, -31, 4, 114, 120, 118, 116, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 114, 120, 118, 116, 32, 50, - 46, 55, 46, 57, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, 32, 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, - 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 80, 0, 8, 0, 24, 0, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, -1, -1, 0, 0, 2, 0, 4, 0, 21, 0, - 26, 0, 34, 0, 38, 0, 42, 0, -1, -1, 53, 0, 70, 0, 72, 0, 76, 0, 83, 0, -1, -1, 85, 0, 92, 0, -1, -1, 96, 0, -1, -1, - -1, -1, 100, 0, -1, -1, -1, -1, 104, 0, 106, 0, 111, 0, 116, 0, -1, -1, -1, -1, 125, 0, -1, -1, -1, -1,-126, 0,-121, 0,-116, 0, - -1, -1,-111, 0,-109, 0,-104, 0, -1, -1, -91, 0, -86, 0, -80, 0, -74, 0, -1, -1, -1, -1, -56, 0, -42, 0, -1, -1, -1, -1, -8, 0, - -4, 0, -1, -1, 0, 1, -1, -1, -1, -1, -1, -1, 2, 1, -1, -1, 7, 1, -1, -1, 11, 1, -1, -1, 16, 1, 22, 1, 28, 1, 34, 1, - 40, 1, 46, 1, 52, 1, 58, 1, 64, 1, 70, 1, 76, 1, 82, 1, 87, 1, -1, -1, 92, 1, -1, -1, 96, 1, 101, 1, 106, 1, 110, 1, -114, 1, -1, -1, 118, 1, 122, 1, 125, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-128, 1,-119, 1,-110, 1, -1, -1,-101, 1, -92, 1, -83, 1, -1, -1, -74, 1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -65, 1, -32, 1, -1, -1, -1, -1, 18, 2, 21, 2, 32, 2, 35, 2, 37, 2, 40, 2, 107, 2, - -1, -1, 110, 2, -1, -1, -1, -1, -1, -1, -1, -1, 112, 2, 116, 2, 120, 2, 124, 2,-128, 2, -1, -1, -1, -1,-124, 2, -1, -1, -73, 2, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -69, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -62, 2, --57, 2, -1, -1, -53, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -48, 2, -1, -1, -43, 2, -38, 2, -1, -1, -1, -1, - -1, -1, -1, -1, -33, 2, -28, 2, -23, 2, -1, -1, -1, -1, -19, 2, -1, -1, -14, 2, -1, -1, -1, -1, -1, -1, -9, 2, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -5, 2, 1, 3, 7, 3, 13, 3, 19, 3, 25, 3, 31, 3, 37, 3, 43, 3, 49, 3, 55, 3, 61, 3, 67, 3, - 73, 3, 79, 3, 85, 3, 91, 3, 97, 3, 103, 3, 109, 3, 115, 3, 121, 3, 127, 3,-123, 3,-117, 3,-111, 3,-105, 3, -99, 3, -93, 3, --87, 3, -81, 3, -75, 3, -69, 3, -63, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -57, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, --52, 3, -41, 3, -36, 3, -28, 3, -24, 3, -15, 3, -8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, 4, -1, -1, - -1, -1, -1, -1, 90, 4,-103, 4, -1, -1, -1, -1, -1, -1, -39, 4, -35, 4, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, - 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, - 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, - 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, - 0, 27, 91, 49, 109, 0, 27, 55, 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, - 52, 109, 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 50, 74, 27, 91, 63, 52, 55, 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, -109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 27, 91, 63, 52, 55, 108, - 27, 61, 27, 91, 63, 49, 108, 0, 27, 91, 114, 27, 91, 109, 27, 91, 50, 74, 27, 91, 72, 27, 91, 63, 55, 104, 27, 91, 63, 49, 59, 51, - 59, 52, 59, 54, 108, 27, 91, 52, 108, 0, 27, 91, 64, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 91, 66, 0, 27, 91, 56, - 94, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, 49, 126, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, 50, 126, 0, 27, 91, 49, 51, 126, 0, - 27, 91, 49, 52, 126, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, - 50, 48, 126, 0, 27, 91, 55, 126, 0, 27, 91, 50, 126, 0, 27, 91, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 91, 67, 0, - 27, 91, 97, 0, 27, 91, 98, 0, 27, 91, 65, 0, 27, 62, 0, 27, 61, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, - 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, - 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 62, 27, 91, 49, 59, 51, 59, 52, 59, 53, 59, 54, 108, 27, - 91, 63, 55, 104, 27, 91, 109, 27, 91, 114, 27, 91, 50, 74, 27, 91, 72, 0, 27, 91, 114, 27, 91, 109, 27, 91, 50, 74, 27, 91, 72, 27, - 91, 63, 55, 104, 27, 91, 63, 49, 59, 51, 59, 52, 59, 54, 108, 27, 91, 52, 108, 27, 62, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, - 50, 53, 104, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, -112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, - 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, - 9, 0, 27, 79, 119, 0, 27, 79, 121, 0, 27, 79, 117, 0, 27, 79, 113, 0, 27, 79, 115, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, -107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, -123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, 41, 48, 0, 27, 91, 56, 126, 0, 27, 79, 77, 0, 27, 91, 49, -126, 0, 27, 91, 51, 36, 0, 27, 91, 52, 126, 0, 27, 91, 56, 36, 0, 27, 91, 55, 36, 0, 27, 91, 50, 36, 0, 27, 91, 100, 0, 27, - 91, 54, 36, 0, 27, 91, 53, 36, 0, 27, 91, 99, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, 0, 27, - 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, 51, 49, 126, 0, 27, 91, 51, 50, 126, 0, 27, 91, 51, - 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 50, 51, 36, 0, 27, 91, 50, 52, 36, 0, 27, 91, 49, 49, 94, 0, 27, 91, 49, 50, 94, - 0, 27, 91, 49, 51, 94, 0, 27, 91, 49, 52, 94, 0, 27, 91, 49, 53, 94, 0, 27, 91, 49, 55, 94, 0, 27, 91, 49, 56, 94, 0, 27, - 91, 49, 57, 94, 0, 27, 91, 50, 48, 94, 0, 27, 91, 50, 49, 94, 0, 27, 91, 50, 51, 94, 0, 27, 91, 50, 52, 94, 0, 27, 91, 50, - 53, 94, 0, 27, 91, 50, 54, 94, 0, 27, 91, 50, 56, 94, 0, 27, 91, 50, 57, 94, 0, 27, 91, 51, 49, 94, 0, 27, 91, 51, 50, 94, - 0, 27, 91, 51, 51, 94, 0, 27, 91, 51, 52, 94, 0, 27, 91, 50, 51, 64, 0, 27, 91, 50, 52, 64, 0, 27, 91, 49, 75, 0, 27, 91, - 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 49, 59, 50, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, - 57, 109, 0, 27, 93, 49, 48, 52, 7, 0, 27, 93, 52, 59, 37, 112, 49, 37, 100, 59, 114, 103, 98, 58, 37, 112, 50, 37, 123, 50, 53, 53, -125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, - 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 52, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, - 37, 50, 46, 50, 88, 27, 92, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, -100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, - 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, - 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, - 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 40, 66, 0, 27, 40, 48, 0 + 26, 1, 47, 0, 29, 0, 15, 0, 110, 1, -31, 4, 114, 120, 118, 116, + 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 114, 120, 118, 116, 32, 50, + 46, 55, 46, 57, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, 32, + 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, + 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 1, 1, 80, 0, 8, 0, 24, 0, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 0, 1, -1, 127, -1, -1, 0, 0, 2, 0, 4, 0, 21, 0, + 26, 0, 34, 0, 38, 0, 42, 0, -1, -1, 53, 0, 70, 0, 72, 0, + 76, 0, 83, 0, -1, -1, 85, 0, 92, 0, -1, -1, 96, 0, -1, -1, + -1, -1, 100, 0, -1, -1, -1, -1, 104, 0, 106, 0, 111, 0, 116, 0, + -1, -1, -1, -1, 125, 0, -1, -1, -1, -1,-126, 0,-121, 0,-116, 0, + -1, -1,-111, 0,-109, 0,-104, 0, -1, -1, -91, 0, -86, 0, -80, 0, + -74, 0, -1, -1, -1, -1, -56, 0, -42, 0, -1, -1, -1, -1, -8, 0, + -4, 0, -1, -1, 0, 1, -1, -1, -1, -1, -1, -1, 2, 1, -1, -1, + 7, 1, -1, -1, 11, 1, -1, -1, 16, 1, 22, 1, 28, 1, 34, 1, + 40, 1, 46, 1, 52, 1, 58, 1, 64, 1, 70, 1, 76, 1, 82, 1, + 87, 1, -1, -1, 92, 1, -1, -1, 96, 1, 101, 1, 106, 1, 110, 1, + 114, 1, -1, -1, 118, 1, 122, 1, 125, 1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-128, 1,-119, 1,-110, 1, + -1, -1,-101, 1, -92, 1, -83, 1, -1, -1, -74, 1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -65, 1, -32, 1, -1, -1, + -1, -1, 18, 2, 21, 2, 32, 2, 35, 2, 37, 2, 40, 2, 107, 2, + -1, -1, 110, 2, -1, -1, -1, -1, -1, -1, -1, -1, 112, 2, 116, 2, + 120, 2, 124, 2,-128, 2, -1, -1, -1, -1,-124, 2, -1, -1, -73, 2, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -69, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -62, 2, + -57, 2, -1, -1, -53, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -48, 2, -1, -1, -43, 2, -38, 2, -1, -1, -1, -1, + -1, -1, -1, -1, -33, 2, -28, 2, -23, 2, -1, -1, -1, -1, -19, 2, + -1, -1, -14, 2, -1, -1, -1, -1, -1, -1, -9, 2, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -5, 2, 1, 3, 7, 3, 13, 3, 19, 3, + 25, 3, 31, 3, 37, 3, 43, 3, 49, 3, 55, 3, 61, 3, 67, 3, + 73, 3, 79, 3, 85, 3, 91, 3, 97, 3, 103, 3, 109, 3, 115, 3, + 121, 3, 127, 3,-123, 3,-117, 3,-111, 3,-105, 3, -99, 3, -93, 3, + -87, 3, -81, 3, -75, 3, -69, 3, -63, 3, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -57, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -52, 3, -41, 3, -36, 3, -28, 3, -24, 3, -15, 3, -8, 3, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, 4, -1, -1, + -1, -1, -1, -1, 90, 4,-103, 4, -1, -1, -1, -1, -1, -1, -39, 4, + -35, 4, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, + 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, + 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, + 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, + 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, + 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, + 67, 0, 27, 91, 65, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, + 0, 27, 91, 49, 109, 0, 27, 55, 27, 91, 63, 52, 55, 104, 0, 27, + 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, + 52, 109, 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 50, 74, 27, 91, + 63, 52, 55, 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, + 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 49, + 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 27, 91, 63, 52, 55, 108, + 27, 61, 27, 91, 63, 49, 108, 0, 27, 91, 114, 27, 91, 109, 27, 91, + 50, 74, 27, 91, 72, 27, 91, 63, 55, 104, 27, 91, 63, 49, 59, 51, + 59, 52, 59, 54, 108, 27, 91, 52, 108, 0, 27, 91, 64, 0, 27, 91, + 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 91, 66, 0, 27, 91, 56, + 94, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, 49, 126, 0, 27, 91, + 50, 49, 126, 0, 27, 91, 49, 50, 126, 0, 27, 91, 49, 51, 126, 0, + 27, 91, 49, 52, 126, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, + 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, + 50, 48, 126, 0, 27, 91, 55, 126, 0, 27, 91, 50, 126, 0, 27, 91, + 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 91, 67, 0, + 27, 91, 97, 0, 27, 91, 98, 0, 27, 91, 65, 0, 27, 62, 0, 27, + 61, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, + 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, + 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, + 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, + 0, 27, 62, 27, 91, 49, 59, 51, 59, 52, 59, 53, 59, 54, 108, 27, + 91, 63, 55, 104, 27, 91, 109, 27, 91, 114, 27, 91, 50, 74, 27, 91, + 72, 0, 27, 91, 114, 27, 91, 109, 27, 91, 50, 74, 27, 91, 72, 27, + 91, 63, 55, 104, 27, 91, 63, 49, 59, 51, 59, 52, 59, 54, 108, 27, + 91, 52, 108, 27, 62, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, + 50, 53, 104, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, + 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, + 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, + 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, + 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, + 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, + 9, 0, 27, 79, 119, 0, 27, 79, 121, 0, 27, 79, 117, 0, 27, 79, + 113, 0, 27, 79, 115, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, + 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, + 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, + 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, + 27, 41, 48, 0, 27, 91, 56, 126, 0, 27, 79, 77, 0, 27, 91, 49, + 126, 0, 27, 91, 51, 36, 0, 27, 91, 52, 126, 0, 27, 91, 56, 36, + 0, 27, 91, 55, 36, 0, 27, 91, 50, 36, 0, 27, 91, 100, 0, 27, + 91, 54, 36, 0, 27, 91, 53, 36, 0, 27, 91, 99, 0, 27, 91, 50, + 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, 0, 27, + 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, + 0, 27, 91, 51, 49, 126, 0, 27, 91, 51, 50, 126, 0, 27, 91, 51, + 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 50, 51, 36, 0, 27, + 91, 50, 52, 36, 0, 27, 91, 49, 49, 94, 0, 27, 91, 49, 50, 94, + 0, 27, 91, 49, 51, 94, 0, 27, 91, 49, 52, 94, 0, 27, 91, 49, + 53, 94, 0, 27, 91, 49, 55, 94, 0, 27, 91, 49, 56, 94, 0, 27, + 91, 49, 57, 94, 0, 27, 91, 50, 48, 94, 0, 27, 91, 50, 49, 94, + 0, 27, 91, 50, 51, 94, 0, 27, 91, 50, 52, 94, 0, 27, 91, 50, + 53, 94, 0, 27, 91, 50, 54, 94, 0, 27, 91, 50, 56, 94, 0, 27, + 91, 50, 57, 94, 0, 27, 91, 51, 49, 94, 0, 27, 91, 51, 50, 94, + 0, 27, 91, 51, 51, 94, 0, 27, 91, 51, 52, 94, 0, 27, 91, 50, + 51, 64, 0, 27, 91, 50, 52, 64, 0, 27, 91, 49, 75, 0, 27, 91, + 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, + 63, 49, 59, 50, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, + 57, 109, 0, 27, 93, 49, 48, 52, 7, 0, 27, 93, 52, 59, 37, 112, + 49, 37, 100, 59, 114, 103, 98, 58, 37, 112, 50, 37, 123, 50, 53, 53, + 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, + 88, 47, 37, 112, 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, + 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 52, 37, + 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, + 37, 50, 46, 50, 88, 27, 92, 0, 27, 91, 77, 0, 27, 91, 37, 63, + 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, + 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, + 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, + 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, + 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, + 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, + 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, + 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 40, 66, 0, 27, + 40, 48, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. static const char linux_16colour_terminfo[] = { - 26, 1, 43, 0, 29, 0, 16, 0, 125, 1, 125, 3, 108, 105, 110, 117, 120, 45, 49, 54, 99, 111, 108, 111, 114, 124, 108, 105, 110, 117, 120, 32, - 99, 111, 110, 115, 111, 108, 101, 32, 119, 105, 116, 104, 32, 49, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, -1, -1, 8, 0, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, 0, 0, 1, 42, 0, -1, -1, 0, 0, 2, 0, 4, 0, 21, 0, 26, 0, - 33, 0, 37, 0, 41, 0, -1, -1, 52, 0, 69, 0, 71, 0, 75, 0, 87, 0, -1, -1, 89, 0, 101, 0, -1, -1, 105, 0, 109, 0, 121, 0, -125, 0, -1, -1, -1, -1,-127, 0,-125, 0,-120, 0, -1, -1, -1, -1,-115, 0,-110, 0, -1, -1, -1, -1,-105, 0,-100, 0, -95, 0, -90, 0, --81, 0, -79, 0, -1, -1, -1, -1, -74, 0, -69, 0, -63, 0, -57, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -39, 0, -35, 0, - -1, -1, -31, 0, -1, -1, -1, -1, -1, -1, -29, 0, -1, -1, -24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -20, 0, -15, 0, -9, 0, -4, 0, - 1, 1, 6, 1, 11, 1, 17, 1, 23, 1, 29, 1, 35, 1, 40, 1, -1, -1, 45, 1, -1, -1, 49, 1, 54, 1, 59, 1, -1, -1, -1, -1, - -1, -1, 63, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 67, 1, -1, -1, 70, 1, 79, 1, 88, 1, 97, 1, -1, -1, 106, 1, 115, 1, 124, 1, -1, -1,-123, 1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1,-114, 1, -1, -1, -1, -1, -1, -1,-108, 1,-105, 1, -94, 1, -91, 1, -89, 1, -86, 1, 1, 2, -1, -1, - 4, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, 10, 2, -1, -1, 77, 2, -1, -1, - -1, -1, 81, 2, 87, 2, -1, -1, -1, -1, 93, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 97, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 102, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 104, 2, 110, 2, 116, 2, 122, 2,-128, 2,-122, 2,-116, 2,-110, 2,-104, 2, -98, 2, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -92, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -87, 2, --76, 2, -71, 2, -65, 2, -61, 2, -52, 2, -48, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 3, -1, -1, -1, -1, - -1, -1, 37, 3, 75, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 113, 3, 119, 3, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, -100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, - 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 27, - 91, 63, 49, 99, 0, 8, 0, 27, 91, 63, 50, 53, 104, 27, 91, 63, 48, 99, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 63, 50, 53, -104, 27, 91, 63, 56, 99, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 50, 109, 0, - 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 15, 0, 27, - 91, 109, 15, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 50, 48, 48, 47, - 62, 27, 91, 63, 53, 108, 0, 27, 91, 64, 0, 27, 91, 76, 0, 127, 0, 27, 91, 51, 126, 0, 27, 91, 66, 0, 27, 91, 91, 65, 0, 27, - 91, 50, 49, 126, 0, 27, 91, 91, 66, 0, 27, 91, 91, 67, 0, 27, 91, 91, 68, 0, 27, 91, 91, 69, 0, 27, 91, 49, 55, 126, 0, 27, - 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 91, 68, 0, 27, - 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, -112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, - 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 93, - 82, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 59, 49, 48, 37, 63, - 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, - 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 53, 37, 116, 59, 50, 37, 59, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, -109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 91, 71, 0, 43, 43, 44, 44, 45, 45, 46, 46, - 48, 48, 95, 95, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, -114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 99, 126, 126, 0, 27, 91, 90, 0, 27, - 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 41, 48, 0, 27, 91, 52, 126, 0, 26, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, -126, 0, 27, 91, 50, 53, 126, 0, 27, 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, 51, 49, 126, 0, - 27, 91, 51, 50, 126, 0, 27, 91, 51, 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, - 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 54, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 93, 82, 0, 27, 93, - 80, 37, 112, 49, 37, 120, 37, 112, 50, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 37, 112, - 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 37, 112, 52, 37, 123, 50, 53, 53, 125, 37, - 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 0, 27, 91, 77, 0, 27, 91, 51, 37, 112, 49, 37, 123, 56, 125, 37, 109, 37, -100, 37, 63, 37, 112, 49, 37, 123, 55, 125, 37, 62, 37, 116, 59, 49, 37, 101, 59, 50, 49, 37, 59, 109, 0, 27, 91, 52, 37, 112, 49, 37, -123, 56, 125, 37, 109, 37, 100, 37, 63, 37, 112, 49, 37, 123, 55, 125, 37, 62, 37, 116, 59, 53, 37, 101, 59, 50, 53, 37, 59, 109, 0, 27, - 91, 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 + 26, 1, 43, 0, 29, 0, 16, 0, 125, 1, 125, 3, 108, 105, 110, 117, + 120, 45, 49, 54, 99, 111, 108, 111, 114, 124, 108, 105, 110, 117, 120, 32, + 99, 111, 110, 115, 111, 108, 101, 32, 119, 105, 116, 104, 32, 49, 54, 32, + 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 1, 1, -1, -1, 8, 0, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, 0, + 0, 1, 42, 0, -1, -1, 0, 0, 2, 0, 4, 0, 21, 0, 26, 0, + 33, 0, 37, 0, 41, 0, -1, -1, 52, 0, 69, 0, 71, 0, 75, 0, + 87, 0, -1, -1, 89, 0, 101, 0, -1, -1, 105, 0, 109, 0, 121, 0, + 125, 0, -1, -1, -1, -1,-127, 0,-125, 0,-120, 0, -1, -1, -1, -1, +-115, 0,-110, 0, -1, -1, -1, -1,-105, 0,-100, 0, -95, 0, -90, 0, + -81, 0, -79, 0, -1, -1, -1, -1, -74, 0, -69, 0, -63, 0, -57, 0, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -39, 0, -35, 0, + -1, -1, -31, 0, -1, -1, -1, -1, -1, -1, -29, 0, -1, -1, -24, 0, + -1, -1, -1, -1, -1, -1, -1, -1, -20, 0, -15, 0, -9, 0, -4, 0, + 1, 1, 6, 1, 11, 1, 17, 1, 23, 1, 29, 1, 35, 1, 40, 1, + -1, -1, 45, 1, -1, -1, 49, 1, 54, 1, 59, 1, -1, -1, -1, -1, + -1, -1, 63, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 67, 1, -1, -1, 70, 1, 79, 1, 88, 1, 97, 1, -1, -1, + 106, 1, 115, 1, 124, 1, -1, -1,-123, 1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1,-114, 1, -1, -1, -1, -1, -1, -1, +-108, 1,-105, 1, -94, 1, -91, 1, -89, 1, -86, 1, 1, 2, -1, -1, + 4, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 2, + -1, -1, -1, -1, -1, -1, -1, -1, 10, 2, -1, -1, 77, 2, -1, -1, + -1, -1, 81, 2, 87, 2, -1, -1, -1, -1, 93, 2, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 97, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 102, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 104, 2, 110, 2, 116, 2, 122, 2,-128, 2,-122, 2, +-116, 2,-110, 2,-104, 2, -98, 2, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -92, 2, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -87, 2, + -76, 2, -71, 2, -65, 2, -61, 2, -52, 2, -48, 2, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 3, -1, -1, -1, -1, + -1, -1, 37, 3, 75, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 113, 3, 119, 3, 7, 0, + 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, + 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, + 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, + 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, + 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 27, + 91, 63, 49, 99, 0, 8, 0, 27, 91, 63, 50, 53, 104, 27, 91, 63, + 48, 99, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 63, 50, 53, + 104, 27, 91, 63, 56, 99, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, + 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 50, 109, 0, + 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, + 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 15, 0, 27, + 91, 109, 15, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, + 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 50, 48, 48, 47, + 62, 27, 91, 63, 53, 108, 0, 27, 91, 64, 0, 27, 91, 76, 0, 127, + 0, 27, 91, 51, 126, 0, 27, 91, 66, 0, 27, 91, 91, 65, 0, 27, + 91, 50, 49, 126, 0, 27, 91, 91, 66, 0, 27, 91, 91, 67, 0, 27, + 91, 91, 68, 0, 27, 91, 91, 69, 0, 27, 91, 49, 55, 126, 0, 27, + 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, + 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 91, 68, 0, 27, + 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 91, 67, 0, 27, 91, 65, + 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, + 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, + 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, + 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, + 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 93, + 82, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, + 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 59, 49, 48, 37, 63, + 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, + 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, + 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 53, 37, + 116, 59, 50, 37, 59, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, + 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, + 72, 0, 9, 0, 27, 91, 71, 0, 43, 43, 44, 44, 45, 45, 46, 46, + 48, 48, 95, 95, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, + 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, + 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, + 122, 122, 123, 123, 124, 124, 125, 99, 126, 126, 0, 27, 91, 90, 0, 27, + 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 41, 48, 0, 27, + 91, 52, 126, 0, 26, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, + 126, 0, 27, 91, 50, 53, 126, 0, 27, 91, 50, 54, 126, 0, 27, 91, + 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, 51, 49, 126, 0, + 27, 91, 51, 50, 126, 0, 27, 91, 51, 51, 126, 0, 27, 91, 51, 52, + 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, + 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 54, 99, 0, 27, 91, 99, + 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 93, 82, 0, 27, 93, + 80, 37, 112, 49, 37, 120, 37, 112, 50, 37, 123, 50, 53, 53, 125, 37, + 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 37, 112, + 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, + 37, 47, 37, 48, 50, 120, 37, 112, 52, 37, 123, 50, 53, 53, 125, 37, + 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 0, 27, + 91, 77, 0, 27, 91, 51, 37, 112, 49, 37, 123, 56, 125, 37, 109, 37, + 100, 37, 63, 37, 112, 49, 37, 123, 55, 125, 37, 62, 37, 116, 59, 49, + 37, 101, 59, 50, 49, 37, 59, 109, 0, 27, 91, 52, 37, 112, 49, 37, + 123, 56, 125, 37, 109, 37, 100, 37, 63, 37, 112, 49, 37, 123, 55, 125, + 37, 62, 37, 116, 59, 53, 37, 101, 59, 50, 53, 37, 59, 109, 0, 27, + 91, 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. static const char putty_256colour_terminfo[] = { - 26, 1, 48, 0, 29, 0, 16, 0, 125, 1,-106, 4, 112, 117, 116, 116, 121, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 80, 117, 84, 84, 89, - 32, 48, 46, 53, 56, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, 32, 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, 1, 1, 0, 0, - 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, -1, -1, 8, 0, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 22, 0, 0, 0, 4, 0, 6, 0, - 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, 45, 0, -1, -1, 56, 0, 73, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, 96, 0, -1, -1, - 100, 0, -1, -1, 103, 0, 107, 0, 111, 0, -1, -1, 117, 0, 119, 0, 124, 0,-127, 0, -1, -1, -1, -1,-120, 0, -1, -1, -1, -1,-115, 0, --110, 0,-105, 0,-100, 0, -91, 0, -89, 0, -84, 0, -1, -1, -73, 0, -68, 0, -62, 0, -56, 0, -1, -1, -38, 0, -1, -1, -36, 0, -1, -1, - -1, -1, -1, -1, -2, 0, -1, -1, 2, 1, -1, -1, -1, -1, -1, -1, 4, 1, -1, -1, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, 13, 1, - 19, 1, 25, 1, 31, 1, 37, 1, 43, 1, 49, 1, 55, 1, 61, 1, 67, 1, 73, 1, 78, 1, -1, -1, 83, 1, -1, -1, 87, 1, 92, 1, - 97, 1, 101, 1, 105, 1, -1, -1, 109, 1, 113, 1, 121, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1,-127, 1, -1, -1,-124, 1,-115, 1,-106, 1, -1, -1, -97, 1, -88, 1, -79, 1, -70, 1, -61, 1, -52, 1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -43, 1, -1, -1, -1, -1, -10, 1, -7, 1, 4, 2, 7, 2, 9, 2, - 12, 2, 84, 2, -1, -1, 87, 2, 89, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 94, 2, -1, -1, -1, -1, -1, -1, -1, -1, 98, 2, - -1, -1,-107, 2, -1, -1, -1, -1,-103, 2, -97, 2, -1, -1, -1, -1, -91, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -84, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -79, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -77, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -73, 2, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -69, 2, -63, 2, -57, 2, -51, 2, -45, 2, -39, 2, -33, 2, -27, 2, -21, 2, -15, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -4, 2, 7, 3, 12, 3, 18, 3, 22, 3, 31, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 35, 3, -1, -1, -1, -1, -1, -1, 39, 3, 102, 3, -1, -1, -1, -1, -1, -1, -90, 3, -84, 3, -78, 3, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -72, 3,-118, 4,-112, 4, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, - 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, - 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 27, 68, 0, - 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 80, 0, 27, - 91, 77, 0, 27, 93, 48, 59, 7, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, - 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 15, 0, 27, 91, 109, 15, 0, - 27, 91, 50, 74, 27, 91, 63, 52, 55, 108, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, - 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 7, 0, 27, 55, 27, 91, 114, 27, 91, 109, 27, 91, 63, 55, 104, 27, 91, 63, - 49, 59, 52, 59, 54, 108, 27, 91, 52, 108, 27, 56, 27, 62, 27, 93, 82, 0, 27, 91, 76, 0, 127, 0, 27, 91, 51, 126, 0, 27, 79, 66, - 0, 27, 91, 49, 49, 126, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, 50, 126, 0, 27, 91, 49, 51, 126, 0, 27, 91, 49, 52, 126, 0, 27, - 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, - 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 91, 66, 0, 27, 91, 65, - 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 80, - 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, - 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, - 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 60, 27, 91, 34, 112, 27, 91, 53, 48, 59, 54, 34, 112, 27, 99, 27, 91, 63, 51, 108, 27, 93, - 82, 27, 91, 63, 49, 48, 48, 48, 108, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, - 27, 91, 48, 37, 63, 37, 112, 49, 37, 112, 54, 37, 124, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, - 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, - 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 93, 48, 59, 0, 27, 91, 71, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, - 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, - 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 40, 66, 27, 41, 48, 0, - 27, 91, 52, 126, 0, 26, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, - 0, 27, 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, 51, 49, 126, 0, 27, 91, 51, 50, 126, 0, 27, - 91, 51, 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, - 27, 91, 63, 54, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 93, 82, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, - 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, - 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, - 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, - 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 49, 48, 109, 0, - 27, 91, 49, 49, 109, 0, 27, 91, 49, 50, 109, 0, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-105,-104, - 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 48, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-105,-103, 27, 37, 37, 64, 37, 101, 37, - 112, 49, 37, 123, 49, 50, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-103,-128, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 51, 125, - 37, 61, 37, 116, 27, 37, 37, 71, -30,-103, -86, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 52, 125, 37, 61, 37, 116, 27, 37, 37, - 71, -30,-103, -85, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 53, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-104, -68, 27, 37, 37, - 64, 37, 101, 37, 112, 49, 37, 123, 50, 55, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-122,-112, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, - 123, 49, 53, 53, 125, 37, 61, 37, 116, 27, 37, 37, 71, -32,-126, -94, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 99, 37, 59, 0, 27, 91, + 26, 1, 48, 0, 29, 0, 16, 0, 125, 1,-106, 4, 112, 117, 116, 116, + 121, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 80, 117, 84, 84, 89, + 32, 48, 46, 53, 56, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, + 32, 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, 1, 1, 0, 0, + 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, -1, -1, 8, 0, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 0, 1, -1, 127, 22, 0, 0, 0, 4, 0, 6, 0, + 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, 45, 0, -1, -1, 56, 0, + 73, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, 96, 0, -1, -1, + 100, 0, -1, -1, 103, 0, 107, 0, 111, 0, -1, -1, 117, 0, 119, 0, + 124, 0,-127, 0, -1, -1, -1, -1,-120, 0, -1, -1, -1, -1,-115, 0, +-110, 0,-105, 0,-100, 0, -91, 0, -89, 0, -84, 0, -1, -1, -73, 0, + -68, 0, -62, 0, -56, 0, -1, -1, -38, 0, -1, -1, -36, 0, -1, -1, + -1, -1, -1, -1, -2, 0, -1, -1, 2, 1, -1, -1, -1, -1, -1, -1, + 4, 1, -1, -1, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, 13, 1, + 19, 1, 25, 1, 31, 1, 37, 1, 43, 1, 49, 1, 55, 1, 61, 1, + 67, 1, 73, 1, 78, 1, -1, -1, 83, 1, -1, -1, 87, 1, 92, 1, + 97, 1, 101, 1, 105, 1, -1, -1, 109, 1, 113, 1, 121, 1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1,-127, 1, -1, -1,-124, 1,-115, 1, +-106, 1, -1, -1, -97, 1, -88, 1, -79, 1, -70, 1, -61, 1, -52, 1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -43, 1, -1, -1, -1, -1, -10, 1, -7, 1, 4, 2, 7, 2, 9, 2, + 12, 2, 84, 2, -1, -1, 87, 2, 89, 2, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 94, 2, -1, -1, -1, -1, -1, -1, -1, -1, 98, 2, + -1, -1,-107, 2, -1, -1, -1, -1,-103, 2, -97, 2, -1, -1, -1, -1, + -91, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -84, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -79, 2, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -77, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -73, 2, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -69, 2, -63, 2, -57, 2, + -51, 2, -45, 2, -39, 2, -33, 2, -27, 2, -21, 2, -15, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -4, 2, 7, 3, 12, 3, 18, 3, 22, 3, 31, 3, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 35, 3, -1, -1, -1, -1, -1, -1, 39, 3, 102, 3, -1, -1, -1, -1, + -1, -1, -90, 3, -84, 3, -78, 3, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -72, 3, +-118, 4,-112, 4, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, + 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, + 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, + 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, + 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 27, 68, 0, + 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, + 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 80, 0, 27, + 91, 77, 0, 27, 93, 48, 59, 7, 0, 14, 0, 27, 91, 53, 109, 0, + 27, 91, 49, 109, 0, 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, + 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, + 27, 91, 37, 112, 49, 37, 100, 88, 0, 15, 0, 27, 91, 109, 15, 0, + 27, 91, 50, 74, 27, 91, 63, 52, 55, 108, 0, 27, 91, 52, 108, 0, + 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, + 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 7, 0, + 27, 55, 27, 91, 114, 27, 91, 109, 27, 91, 63, 55, 104, 27, 91, 63, + 49, 59, 52, 59, 54, 108, 27, 91, 52, 108, 27, 56, 27, 62, 27, 93, + 82, 0, 27, 91, 76, 0, 127, 0, 27, 91, 51, 126, 0, 27, 79, 66, + 0, 27, 91, 49, 49, 126, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, + 50, 126, 0, 27, 91, 49, 51, 126, 0, 27, 91, 49, 52, 126, 0, 27, + 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, + 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, + 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, + 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 91, 66, 0, 27, 91, 65, + 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, + 49, 104, 27, 61, 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 80, + 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, + 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, + 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, + 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, + 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 60, 27, 91, 34, 112, 27, + 91, 53, 48, 59, 54, 34, 112, 27, 99, 27, 91, 63, 51, 108, 27, 93, + 82, 27, 91, 63, 49, 48, 48, 48, 108, 0, 27, 56, 0, 27, 91, 37, + 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, + 27, 91, 48, 37, 63, 37, 112, 49, 37, 112, 54, 37, 124, 37, 116, 59, + 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, + 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, + 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, + 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 93, 48, + 59, 0, 27, 91, 71, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, + 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, + 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, + 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 91, 63, + 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 40, 66, 27, 41, 48, 0, + 27, 91, 52, 126, 0, 26, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, + 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, + 0, 27, 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, + 57, 126, 0, 27, 91, 51, 49, 126, 0, 27, 91, 51, 50, 126, 0, 27, + 91, 51, 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, + 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, + 27, 91, 63, 54, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, + 57, 109, 0, 27, 93, 82, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, + 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, + 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, + 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, + 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, + 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, + 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, + 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, + 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 49, 48, 109, 0, + 27, 91, 49, 49, 109, 0, 27, 91, 49, 50, 109, 0, 37, 63, 37, 112, + 49, 37, 123, 56, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-105,-104, + 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 48, 125, 37, 61, + 37, 116, 27, 37, 37, 71, -30,-105,-103, 27, 37, 37, 64, 37, 101, 37, + 112, 49, 37, 123, 49, 50, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30, +-103,-128, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 51, 125, + 37, 61, 37, 116, 27, 37, 37, 71, -30,-103, -86, 27, 37, 37, 64, 37, + 101, 37, 112, 49, 37, 123, 49, 52, 125, 37, 61, 37, 116, 27, 37, 37, + 71, -30,-103, -85, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, + 53, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-104, -68, 27, 37, 37, + 64, 37, 101, 37, 112, 49, 37, 123, 50, 55, 125, 37, 61, 37, 116, 27, + 37, 37, 71, -30,-122,-112, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, + 123, 49, 53, 53, 125, 37, 61, 37, 116, 27, 37, 37, 71, -32,-126, -94, + 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 99, 37, 59, 0, 27, 91, 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. static const char interix_8colour_terminfo[] = { - 26, 1, 82, 0, 15, 0, 16, 0, 105, 1, 123, 2, 105, 110, 116, 101, 114, 105, 120, 124, 111, 112, 101, 110, 110, 116, 124, 111, 112, 101, 110, 110, - 116, 45, 50, 53, 124, 110, 116, 99, 111, 110, 115, 111, 108, 101, 124, 110, 116, 99, 111, 110, 115, 111, 108, 101, 45, 50, 53, 124, 79, 112, 101, 110, - 78, 84, 45, 116, 101, 114, 109, 32, 99, 111, 109, 112, 97, 116, 105, 98, 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, 108, 111, 114, 0, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 80, 0, -1, -1, 25, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 8, 0, 64, 0, 3, 0, 0, 0, 4, 0, -1, -1, -1, -1, -1, -1, 6, 0, 11, 0, 15, 0, -1, -1, - -1, -1, 19, 0, 36, 0, 38, 0, -1, -1, 42, 0, -1, -1, -1, -1, 46, 0, 50, 0, 54, 0, -1, -1, -1, -1, 58, 0, -1, -1, -1, -1, - -1, -1, -1, -1, 62, 0, 67, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 75, 0, 80, 0, 85, 0, -1, -1, -1, -1, 90, 0, 95, 0, - -1, -1, -1, -1, 107, 0, 111, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, 0, -1, -1, 119, 0, -1, -1, - -1, -1, -1, -1, 121, 0, -1, -1, 125, 0, -1, -1, -1, -1, -1, -1,-127, 0,-123, 0,-119, 0,-115, 0,-111, 0,-107, 0,-103, 0, -99, 0, - -95, 0, -91, 0, -87, 0, -1, -1, -83, 0, -1, -1, -79, 0, -75, 0, -71, 0, -67, 0, -63, 0, -1, -1, -1, -1, -1, -1, -59, 0, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -55, 0, -1, -1, - -1, -1, -52, 0, -43, 0, -1, -1, -34, 0, -25, 0, -16, 0, -7, 0, 2, 1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 20, 1, -1, -1, -1, -1, -1, -1, 23, 1, -1, -1, 27, 1, 31, 1, 35, 1, -1, -1, -1, -1, -1, -1, 39, 1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, 1, -1, -1, 104, 1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 108, 1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 112, 1, - 116, 1, 120, 1, 124, 1,-128, 1,-124, 1,-120, 1,-116, 1,-112, 1,-108, 1,-104, 1,-100, 1, -96, 1, -92, 1, -88, 1, -84, 1, -80, 1, - -76, 1, -72, 1, -68, 1, -64, 1, -60, 1, -56, 1, -52, 1, -48, 1, -44, 1, -40, 1, -36, 1, -32, 1, -28, 1, -24, 1, -20, 1, -16, 1, - -12, 1, -8, 1, -4, 1, 0, 2, 4, 2, 8, 2, 12, 2, 16, 2, 20, 2, 24, 2, 28, 2, 32, 2, 36, 2, 40, 2, 44, 2, 48, 2, - 52, 2, 56, 2, 60, 2, 64, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 68, 2, -1, -1, -1, -1, -1, -1, -1, -1, 72, 2, 88, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, 2, 113, 2, - 27, 91, 90, 0, 7, 0, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, - 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 85, 0, 27, 91, 65, 0, 27, 91, 77, 0, 27, 91, - 49, 109, 0, 27, 91, 115, 27, 91, 49, 98, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 48, 109, 0, 27, - 91, 50, 98, 27, 91, 117, 13, 27, 91, 75, 0, 27, 91, 109, 0, 27, 91, 109, 0, 27, 91, 76, 0, 8, 0, 27, 91, 77, 0, 27, 91, 66, - 0, 27, 70, 65, 0, 27, 70, 49, 0, 27, 70, 65, 0, 27, 70, 50, 0, 27, 70, 51, 0, 27, 70, 52, 0, 27, 70, 53, 0, 27, 70, 54, - 0, 27, 70, 55, 0, 27, 70, 56, 0, 27, 70, 57, 0, 27, 91, 76, 0, 27, 91, 68, 0, 27, 91, 85, 0, 27, 91, 84, 0, 27, 91, 83, - 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, - 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, - 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 0, 27, 91, 117, 0, 27, 91, 115, 0, 27, - 91, 83, 0, 27, 91, 84, 0, 9, 0, 43, 16, 44, 17, 45, 24, 46, 25, 48, -37, 96, 4, 97, -79, 102, -8, 103, -15, 104, -80, 106, -39, 107, - -65, 108, -38, 109, -64, 110, -59, 111, 126, 112, -60, 113, -60, 114, -60, 115, 95, 116, -61, 117, -76, 118, -63, 119, -62, 120, -77, 121, -13, 122, -14, 123, - -29, 124, -40, 125,-100, 126, -2, 0, 27, 91, 90, 0, 27, 91, 85, 0, 27, 70, 66, 0, 27, 70, 67, 0, 27, 70, 68, 0, 27, 70, 69, 0, - 27, 70, 70, 0, 27, 70, 71, 0, 27, 70, 72, 0, 27, 70, 73, 0, 27, 70, 74, 0, 27, 70, 75, 0, 27, 70, 76, 0, 27, 70, 77, 0, - 27, 70, 78, 0, 27, 70, 79, 0, 27, 70, 80, 0, 27, 70, 81, 0, 27, 70, 82, 0, 27, 70, 83, 0, 27, 70, 84, 0, 27, 70, 85, 0, - 27, 70, 86, 0, 27, 70, 87, 0, 27, 70, 88, 0, 27, 70, 89, 0, 27, 70, 90, 0, 27, 70, 97, 0, 27, 70, 98, 0, 27, 70, 99, 0, - 27, 70, 100, 0, 27, 70, 101, 0, 27, 70, 102, 0, 27, 70, 103, 0, 27, 70, 104, 0, 27, 70, 105, 0, 27, 70, 106, 0, 27, 70, 107, 0, - 27, 70, 109, 0, 27, 70, 110, 0, 27, 70, 111, 0, 27, 70, 112, 0, 27, 70, 113, 0, 27, 70, 114, 0, 27, 70, 115, 0, 27, 70, 116, 0, - 27, 70, 117, 0, 27, 70, 118, 0, 27, 70, 119, 0, 27, 70, 120, 0, 27, 70, 121, 0, 27, 70, 122, 0, 27, 70, 43, 0, 27, 70, 45, 0, - 27, 70, 12, 0, 27, 91, 109, 0, 27, 91, 37, 112, 49, 37, 123, 51, 48, 125, 37, 43, 37, 100, 109, 0, 27, 91, 37, 112, 49, 37, 39, 40, - 39, 37, 43, 37, 100, 109, 0, 27, 91, 51, 37, 112, 49, 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0 + 26, 1, 82, 0, 15, 0, 16, 0, 105, 1, 123, 2, 105, 110, 116, 101, + 114, 105, 120, 124, 111, 112, 101, 110, 110, 116, 124, 111, 112, 101, 110, 110, + 116, 45, 50, 53, 124, 110, 116, 99, 111, 110, 115, 111, 108, 101, 124, 110, + 116, 99, 111, 110, 115, 111, 108, 101, 45, 50, 53, 124, 79, 112, 101, 110, + 78, 84, 45, 116, 101, 114, 109, 32, 99, 111, 109, 112, 97, 116, 105, 98, + 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, 108, 111, 114, 0, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 80, 0, + -1, -1, 25, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 8, 0, 64, 0, 3, 0, 0, 0, + 4, 0, -1, -1, -1, -1, -1, -1, 6, 0, 11, 0, 15, 0, -1, -1, + -1, -1, 19, 0, 36, 0, 38, 0, -1, -1, 42, 0, -1, -1, -1, -1, + 46, 0, 50, 0, 54, 0, -1, -1, -1, -1, 58, 0, -1, -1, -1, -1, + -1, -1, -1, -1, 62, 0, 67, 0, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 75, 0, 80, 0, 85, 0, -1, -1, -1, -1, 90, 0, 95, 0, + -1, -1, -1, -1, 107, 0, 111, 0, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 115, 0, -1, -1, 119, 0, -1, -1, + -1, -1, -1, -1, 121, 0, -1, -1, 125, 0, -1, -1, -1, -1, -1, -1, +-127, 0,-123, 0,-119, 0,-115, 0,-111, 0,-107, 0,-103, 0, -99, 0, + -95, 0, -91, 0, -87, 0, -1, -1, -83, 0, -1, -1, -79, 0, -75, 0, + -71, 0, -67, 0, -63, 0, -1, -1, -1, -1, -1, -1, -59, 0, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -55, 0, -1, -1, + -1, -1, -52, 0, -43, 0, -1, -1, -34, 0, -25, 0, -16, 0, -7, 0, + 2, 1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 20, 1, -1, -1, -1, -1, -1, -1, 23, 1, -1, -1, 27, 1, + 31, 1, 35, 1, -1, -1, -1, -1, -1, -1, 39, 1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 41, 1, -1, -1, 104, 1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 108, 1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 112, 1, + 116, 1, 120, 1, 124, 1,-128, 1,-124, 1,-120, 1,-116, 1,-112, 1, +-108, 1,-104, 1,-100, 1, -96, 1, -92, 1, -88, 1, -84, 1, -80, 1, + -76, 1, -72, 1, -68, 1, -64, 1, -60, 1, -56, 1, -52, 1, -48, 1, + -44, 1, -40, 1, -36, 1, -32, 1, -28, 1, -24, 1, -20, 1, -16, 1, + -12, 1, -8, 1, -4, 1, 0, 2, 4, 2, 8, 2, 12, 2, 16, 2, + 20, 2, 24, 2, 28, 2, 32, 2, 36, 2, 40, 2, 44, 2, 48, 2, + 52, 2, 56, 2, 60, 2, 64, 2, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 68, 2, -1, -1, -1, -1, -1, -1, -1, -1, 72, 2, 88, 2, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, 2, 113, 2, + 27, 91, 90, 0, 7, 0, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, + 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, + 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 68, 0, 27, 91, + 67, 0, 27, 91, 85, 0, 27, 91, 65, 0, 27, 91, 77, 0, 27, 91, + 49, 109, 0, 27, 91, 115, 27, 91, 49, 98, 0, 27, 91, 55, 109, 0, + 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 48, 109, 0, 27, + 91, 50, 98, 27, 91, 117, 13, 27, 91, 75, 0, 27, 91, 109, 0, 27, + 91, 109, 0, 27, 91, 76, 0, 8, 0, 27, 91, 77, 0, 27, 91, 66, + 0, 27, 70, 65, 0, 27, 70, 49, 0, 27, 70, 65, 0, 27, 70, 50, + 0, 27, 70, 51, 0, 27, 70, 52, 0, 27, 70, 53, 0, 27, 70, 54, + 0, 27, 70, 55, 0, 27, 70, 56, 0, 27, 70, 57, 0, 27, 91, 76, + 0, 27, 91, 68, 0, 27, 91, 85, 0, 27, 91, 84, 0, 27, 91, 83, + 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 10, 0, 27, 91, 37, 112, + 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, + 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, + 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, + 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, + 37, 100, 65, 0, 27, 99, 0, 27, 91, 117, 0, 27, 91, 115, 0, 27, + 91, 83, 0, 27, 91, 84, 0, 9, 0, 43, 16, 44, 17, 45, 24, 46, + 25, 48, -37, 96, 4, 97, -79, 102, -8, 103, -15, 104, -80, 106, -39, 107, + -65, 108, -38, 109, -64, 110, -59, 111, 126, 112, -60, 113, -60, 114, -60, 115, + 95, 116, -61, 117, -76, 118, -63, 119, -62, 120, -77, 121, -13, 122, -14, 123, + -29, 124, -40, 125,-100, 126, -2, 0, 27, 91, 90, 0, 27, 91, 85, 0, + 27, 70, 66, 0, 27, 70, 67, 0, 27, 70, 68, 0, 27, 70, 69, 0, + 27, 70, 70, 0, 27, 70, 71, 0, 27, 70, 72, 0, 27, 70, 73, 0, + 27, 70, 74, 0, 27, 70, 75, 0, 27, 70, 76, 0, 27, 70, 77, 0, + 27, 70, 78, 0, 27, 70, 79, 0, 27, 70, 80, 0, 27, 70, 81, 0, + 27, 70, 82, 0, 27, 70, 83, 0, 27, 70, 84, 0, 27, 70, 85, 0, + 27, 70, 86, 0, 27, 70, 87, 0, 27, 70, 88, 0, 27, 70, 89, 0, + 27, 70, 90, 0, 27, 70, 97, 0, 27, 70, 98, 0, 27, 70, 99, 0, + 27, 70, 100, 0, 27, 70, 101, 0, 27, 70, 102, 0, 27, 70, 103, 0, + 27, 70, 104, 0, 27, 70, 105, 0, 27, 70, 106, 0, 27, 70, 107, 0, + 27, 70, 109, 0, 27, 70, 110, 0, 27, 70, 111, 0, 27, 70, 112, 0, + 27, 70, 113, 0, 27, 70, 114, 0, 27, 70, 115, 0, 27, 70, 116, 0, + 27, 70, 117, 0, 27, 70, 118, 0, 27, 70, 119, 0, 27, 70, 120, 0, + 27, 70, 121, 0, 27, 70, 122, 0, 27, 70, 43, 0, 27, 70, 45, 0, + 27, 70, 12, 0, 27, 91, 109, 0, 27, 91, 37, 112, 49, 37, 123, 51, + 48, 125, 37, 43, 37, 100, 109, 0, 27, 91, 37, 112, 49, 37, 39, 40, + 39, 37, 43, 37, 100, 109, 0, 27, 91, 51, 37, 112, 49, 37, 100, 109, + 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. static const char st_256colour_terminfo[] = { @@ -1926,51 +2211,96 @@ static const char st_256colour_terminfo[] = { }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. static const char ansi_terminfo[] = { - 26, 1, 40, 0, 23, 0, 16, 0, 125, 1, 68, 2, 97, 110, 115, 105, 124, 97, 110, 115, 105, 47, 112, 99, 45, 116, 101, 114, 109, 32, 99, 111, - 109, 112, 97, 116, 105, 98, 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, 108, 111, 114, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 8, 0, 64, 0, 3, 0, 0, 0, 4, 0, 6, 0, -1, -1, 8, 0, 13, 0, 20, 0, 24, 0, 28, 0, -1, -1, - 39, 0, 56, 0, 60, 0, -1, -1, 64, 0, -1, -1, -1, -1, 68, 0, -1, -1, 72, 0, -1, -1, 76, 0, 80, 0, -1, -1, -1, -1, 84, 0, - 90, 0, 95, 0, -1, -1, -1, -1, -1, -1, -1, -1, 100, 0, -1, -1, 105, 0, 110, 0, 115, 0, 120, 0,-127, 0,-121, 0, -1, -1, -1, -1, - -1, -1,-113, 0,-109, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-105, 0, -1, -1,-101, 0, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -99, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -95, 0, -91, 0, -1, -1, -87, 0, -1, -1, -1, -1, -1, -1, -83, 0, -1, -1, -1, -1, -1, -1, -79, 0, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -75, 0, -1, -1, -70, 0, - -61, 0, -52, 0, -43, 0, -34, 0, -25, 0, -16, 0, -7, 0, 2, 1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 1, 25, 1, 30, 1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 1, -1, -1, 61, 1, -1, -1, 63, 1,-107, 1, -1, -1,-104, 1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-100, 1, -1, -1, -37, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -33, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -28, 1, -17, 1, -12, 1, 7, 2, 11, 2, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 2, 30, 2, -1, -1, - -1, -1, -1, -1, 40, 2, 44, 2, 48, 2, 52, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 56, 2, 62, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, - 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 27, 91, - 66, 0, 27, 91, 72, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 91, 49, 49, 109, 0, - 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, - 37, 112, 49, 37, 100, 88, 0, 27, 91, 49, 48, 109, 0, 27, 91, 48, 59, 49, 48, 109, 0, 27, 91, 109, 0, 27, 91, 109, 0, 27, 91, 76, - 0, 8, 0, 27, 91, 66, 0, 27, 91, 72, 0, 27, 91, 76, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 27, 91, 83, 0, - 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, - 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, - 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 52, 105, 0, 27, - 91, 53, 105, 0, 37, 112, 49, 37, 99, 27, 91, 37, 112, 50, 37, 123, 49, 125, 37, 45, 37, 100, 98, 0, 27, 91, 37, 105, 37, 112, 49, 37, - 100, 100, 0, 10, 0, 27, 91, 48, 59, 49, 48, 37, 63, 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, - 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 54, 37, 116, 59, 49, - 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 37, 63, 37, 112, 57, 37, 116, 59, 49, 49, 37, 59, 109, 0, 27, 72, 0, 27, 91, - 73, 0, 43, 16, 44, 17, 45, 24, 46, 25, 48, -37, 96, 4, 97, -79, 102, -8, 103, -15, 104, -80, 106, -39, 107, -65, 108, -38, 109, -64, 110, -59, - 111, 126, 112, -60, 113, -60, 114, -60, 115, 95, 116, -61, 117, -76, 118, -63, 119, -62, 120, -77, 121, -13, 122, -14, 123, -29, 124, -40, 125,-100, 126, -2, - 0, 27, 91, 90, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 37, 91, 59, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 93, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 37, 112, 49, - 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0, 27, 40, 66, 0, 27, 41, 66, 0, 27, 42, 66, 0, 27, 43, 66, 0, 27, 91, + 26, 1, 40, 0, 23, 0, 16, 0, 125, 1, 68, 2, 97, 110, 115, 105, + 124, 97, 110, 115, 105, 47, 112, 99, 45, 116, 101, 114, 109, 32, 99, 111, + 109, 112, 97, 116, 105, 98, 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, + 108, 111, 114, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 80, 0, 8, 0, + 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 8, 0, 64, 0, 3, 0, 0, 0, 4, 0, + 6, 0, -1, -1, 8, 0, 13, 0, 20, 0, 24, 0, 28, 0, -1, -1, + 39, 0, 56, 0, 60, 0, -1, -1, 64, 0, -1, -1, -1, -1, 68, 0, + -1, -1, 72, 0, -1, -1, 76, 0, 80, 0, -1, -1, -1, -1, 84, 0, + 90, 0, 95, 0, -1, -1, -1, -1, -1, -1, -1, -1, 100, 0, -1, -1, + 105, 0, 110, 0, 115, 0, 120, 0,-127, 0,-121, 0, -1, -1, -1, -1, + -1, -1,-113, 0,-109, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1,-105, 0, -1, -1,-101, 0, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -99, 0, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -95, 0, -91, 0, -1, -1, -87, 0, -1, -1, -1, -1, + -1, -1, -83, 0, -1, -1, -1, -1, -1, -1, -79, 0, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -75, 0, -1, -1, -70, 0, + -61, 0, -52, 0, -43, 0, -34, 0, -25, 0, -16, 0, -7, 0, 2, 1, + 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 1, 25, 1, 30, 1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 1, -1, -1, 61, 1, + -1, -1, 63, 1,-107, 1, -1, -1,-104, 1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +-100, 1, -1, -1, -37, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -33, 1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -28, 1, -17, 1, -12, 1, 7, 2, 11, 2, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 2, 30, 2, -1, -1, + -1, -1, -1, -1, 40, 2, 44, 2, 48, 2, 52, 2, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 56, 2, 62, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, + 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, + 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, + 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 27, 91, + 66, 0, 27, 91, 72, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, + 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 91, 49, 49, 109, 0, + 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 56, 109, 0, 27, + 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, + 37, 112, 49, 37, 100, 88, 0, 27, 91, 49, 48, 109, 0, 27, 91, 48, + 59, 49, 48, 109, 0, 27, 91, 109, 0, 27, 91, 109, 0, 27, 91, 76, + 0, 8, 0, 27, 91, 66, 0, 27, 91, 72, 0, 27, 91, 76, 0, 27, + 91, 68, 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 27, 91, 83, 0, + 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, + 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, + 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, + 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, + 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, + 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 52, 105, 0, 27, + 91, 53, 105, 0, 37, 112, 49, 37, 99, 27, 91, 37, 112, 50, 37, 123, + 49, 125, 37, 45, 37, 100, 98, 0, 27, 91, 37, 105, 37, 112, 49, 37, + 100, 100, 0, 10, 0, 27, 91, 48, 59, 49, 48, 37, 63, 37, 112, 49, + 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, + 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, + 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 54, 37, 116, 59, 49, + 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 37, 63, 37, + 112, 57, 37, 116, 59, 49, 49, 37, 59, 109, 0, 27, 72, 0, 27, 91, + 73, 0, 43, 16, 44, 17, 45, 24, 46, 25, 48, -37, 96, 4, 97, -79, + 102, -8, 103, -15, 104, -80, 106, -39, 107, -65, 108, -38, 109, -64, 110, -59, + 111, 126, 112, -60, 113, -60, 114, -60, 115, 95, 116, -61, 117, -76, 118, -63, + 119, -62, 120, -77, 121, -13, 122, -14, 123, -29, 124, -40, 125,-100, 126, -2, + 0, 27, 91, 90, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, + 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 37, 91, 59, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 93, 99, 0, 27, 91, 99, + 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 37, 112, 49, + 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0, 27, 40, + 66, 0, 27, 41, 66, 0, 27, 42, 66, 0, 27, 43, 66, 0, 27, 91, 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 }; -- cgit From 16300d02c7fbe95396697fc6c09012e2c2b47b69 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 27 May 2017 12:38:14 +0100 Subject: tui: Improvements to RGB colour support. The details are in the on-line help under :help true-color . The brief precis is that nvim is (I hope.) converging with tmux and libvte. It is taking the same approach with setrgbf and setrgbb terminfo capabilities that it does with the Ss and Se terminfo capabilities. --- src/nvim/tui/tui.c | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 58c9e75de8..3c985bcbcb 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -2447,7 +2447,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // Dickey ncurses terminfo has included the Ss and Se capabilities, pioneered // by tmux, since 2011-07-14. So adding them to terminal types, that do - // actually have such control sequences but lack the currect definitions in + // actually have such control sequences but lack the correct definitions in // terminfo, is a fixup, not an augmentation. data->unibi_ext.reset_cursor_style = unibi_find_ext_str(ut, "Se"); data->unibi_ext.set_cursor_style = unibi_find_ext_str(ut, "Ss"); @@ -2479,7 +2479,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // form. data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", "\x1b[%?" - "%p1%{4}%>" "%t%p1%{2}%-" // a bit of a bodge for extension values + "%p1%{4}%>" "%t%p1%{2}%-" // a bit of a bodge for extension values "%e%p1" // the conventional codes are just passed through "%;%d q"); if (-1 == data->unibi_ext.reset_cursor_style) { @@ -2537,6 +2537,7 @@ static void augment_terminfo(TUIData *data, const char *term, const char *colorterm, long vte_version, bool konsole, bool iterm) { unibi_term *ut = data->ut; + bool true_xterm = !!os_getenv("XTERM_VERSION"); bool xterm = term && STARTS_WITH(term, "xterm"); bool dtterm = term && STARTS_WITH(term, "dtterm"); bool linuxvt = term && STARTS_WITH(term, "linux"); @@ -2544,6 +2545,7 @@ static void augment_terminfo(TUIData *data, const char *term, bool teraterm = term && STARTS_WITH(term, "teraterm"); bool putty = term && STARTS_WITH(term, "putty"); bool screen = term && STARTS_WITH(term, "screen"); + bool st = term && STARTS_WITH(term, "st"); bool tmux_wrap = screen && !!os_getenv("TMUX"); bool truecolor = colorterm && (0 == strcmp(colorterm, "truecolor") || 0 == strcmp(colorterm, "24bit")); @@ -2561,13 +2563,43 @@ static void augment_terminfo(TUIData *data, const char *term, data->unibi_ext.reset_scroll_region = (int)unibi_add_ext_str(ut, NULL, "\x1b[r"); } - // See https://gist.github.com/XVilka/8346728 for more about this. - if (putty || xterm || rxvt || linuxvt || konsole || iterm || truecolor) { - data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, NULL, - "\x1b[38;2;%p1%d;%p2%d;%p3%dm"); - data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, NULL, - "\x1b[48;2;%p1%d;%p2%d;%p3%dm"); + + // Dickey ncurses terminfo does not include the setrgbf and setrgbb + // capabilities, proposed by Rüdiger Sonderfeld on 2013-10-15. So adding + // them to terminal types, that do actually have such control sequences but + // lack the correct definitions in terminfo, is an augmentation, not a + // fixup. See https://gist.github.com/XVilka/8346728 for more about this. + bool has_standard_rgb = vte_version >= 3600 // per GNOME bug #685759 + || true_xterm; + // "standard" means using colons like ISO 8613-6:1994/ITU T.416:1993 says. + bool has_non_standard_rgb = + linuxvt // Linux 4.8+ supports true-colour SGR. + || konsole // per commentary in VT102Emulation.cpp + // per http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html + || rxvt + || st // per experimentation + || iterm || truecolor; + data->unibi_ext.set_rgb_foreground = unibi_find_ext_str(ut, "setrgbf"); + if (-1 == data->unibi_ext.set_rgb_foreground) { + if (has_standard_rgb) { + data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, "setrgbf", + "\x1b[38:2:%p1%d:%p2%d:%p3%dm"); + } else if (has_non_standard_rgb) { + data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, "setrgbf", + "\x1b[38;2;%p1%d;%p2%d;%p3%dm"); + } + } + data->unibi_ext.set_rgb_background = unibi_find_ext_str(ut, "setrgbb"); + if (-1 == data->unibi_ext.set_rgb_background) { + if (has_standard_rgb) { + data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, "setrgbb", + "\x1b[48:2:%p1%d:%p2%d:%p3%dm"); + } else if (has_non_standard_rgb) { + data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, "setrgbb", + "\x1b[48;2;%p1%d;%p2%d;%p3%dm"); + } } + if (iterm) { data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( ut, NULL, TMUX_WRAP(tmux_wrap, "\033]Pl%p1%06x\033\\")); -- cgit From a2434aeddb6da97b034ddeb55d990c8838f5e664 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 27 May 2017 15:05:26 +0100 Subject: tui: Remove tmux wrapper from the Konsole path. tmux has its own code path, now; and the tmux wrapping was not the ideal thing to do in the first place. Also improve the commentary on the built-in terminfo records. --- src/nvim/tui/tui.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 3c985bcbcb..9b3aa1cf43 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1148,7 +1148,7 @@ static int unibi_find_ext_str(unibi_term *ut, const char *name) // on the compiled files. // Taken from Dickey ncurses terminfo.src dated 2017-04-22. -// This is a 256-colour terminfo description that lacks +// This is a 256-colour terminfo description that lacks true-colour and // DECSTBN/DECSLRM/DECLRMM capabilities that xterm actually has. static const char xterm_256colour_terminfo[] = { 26, 1, 37, 0, 29, 0, 15, 0, 105, 1, -42, 5, 120, 116, 101, 114, @@ -1588,6 +1588,8 @@ static const char iterm_16colour_terminfo[] = { 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. +// This is a 256-colour terminfo description that lacks true-colour +// capabilities that rxvt actually has. static const char rxvt_256colour_terminfo[] = { 26, 1, 47, 0, 29, 0, 15, 0, 110, 1, -31, 4, 114, 120, 118, 116, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 114, 120, 118, 116, 32, 50, @@ -1723,6 +1725,8 @@ static const char rxvt_256colour_terminfo[] = { 40, 48, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. +// This is a 16-colour terminfo description that lacks true-colour +// and 256-colour capabilities that linux (4.8+) actually has. static const char linux_16colour_terminfo[] = { 26, 1, 43, 0, 29, 0, 16, 0, 125, 1, 125, 3, 108, 105, 110, 117, 120, 45, 49, 54, 99, 111, 108, 111, 114, 124, 108, 105, 110, 117, 120, 32, @@ -2066,6 +2070,8 @@ static const char interix_8colour_terminfo[] = { 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. +// This is a 256-colour terminfo description that lacks true-colour +// capabilities that stterm actually has. static const char st_256colour_terminfo[] = { 26, 1, 55, 0, 29, 0, 15, 0, 105, 1, 117, 5, 115, 116, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 115, 116, 116, 101, 114, 109, 45, 50, @@ -2510,23 +2516,25 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[?c"); } else if (konsole) { - // Konsole uses an idiosyncratic escape code to set the cursor shape and does - // not support DECSCUSR. The tmux wrapping is unused, now. + // Konsole uses an idiosyncratic escape code to set the cursor shape and + // does not support DECSCUSR. This makes Konsole set up and apply a + // nonce profile, which has side-effects on temporary font resizing. + // In an ideal world, Konsole would just support DECSCUSR. data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", - TMUX_WRAP(tmux_wrap, "\x1b]50;CursorShape=%?" - "%p1%{3}%<" "%t%{0}" // block - "%e%p1%{4}%<" "%t%{2}" // underline - "%e%{1}" // everything else is bar - "%;%d;BlinkingCursorEnabled=%?" - "%p1%{1}%<" "%t%{1}" // Fortunately if we exclude zero as special, - "%e%p1%{1}%&" // in all other cases we can treat bit #0 as a flag. - "%;%d\x07")); + "\x1b]50;CursorShape=%?" + "%p1%{3}%<" "%t%{0}" // block + "%e%p1%{4}%<" "%t%{2}" // underline + "%e%{1}" // everything else is bar + "%;%d;BlinkingCursorEnabled=%?" + "%p1%{1}%<" "%t%{1}" // Fortunately if we exclude zero as special, + "%e%p1%{1}%&" // in all other cases we can treat bit #0 as a flag. + "%;%d\x07"); if (-1 == data->unibi_ext.reset_cursor_style) { data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", ""); } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, - TMUX_WRAP(tmux_wrap, "\x1b]50;CursorShape=0;BlinkingCursorEnabled=1\x07")); + "\x1b]50;\x07"); } } } @@ -2601,6 +2609,9 @@ static void augment_terminfo(TUIData *data, const char *term, } if (iterm) { + // FIXME: Bypassing tmux like this affects the cursor colour globally, in + // all panes, which is not particularly desirable. A better approach + // would use a tmux control sequence and an extra if(screen) test. data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( ut, NULL, TMUX_WRAP(tmux_wrap, "\033]Pl%p1%06x\033\\")); } else if (xterm) { -- cgit From 8768b7f4a045093001c55d12a85419bebe5869dc Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 27 May 2017 18:36:31 +0100 Subject: tui: Remove now-unused flag variable. Follows on from fcf0d13f48bffbd41749069ce383d01153dd960c. --- src/nvim/tui/tui.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 9b3aa1cf43..a687b3dc64 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -2358,7 +2358,6 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool teraterm = term && STARTS_WITH(term, "teraterm"); bool putty = term && STARTS_WITH(term, "putty"); bool screen = term && STARTS_WITH(term, "screen"); - bool tmux_wrap = screen && !!os_getenv("TMUX"); char *fix_normal = (char *)unibi_get_str(ut, unibi_cursor_normal); if (fix_normal) { -- cgit From 1f3b5e1a826fbff8ce2fa84e0e50d082d65a08bd Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 27 May 2017 19:04:06 +0100 Subject: tui: Correct error in terminfo extension processing. Using the wrong unibilium query function just happened to work with the various terminfo records used in local testing. --- src/nvim/tui/tui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index a687b3dc64..d71f4b6656 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1133,7 +1133,7 @@ static void unibi_set_if_empty(unibi_term *ut, enum unibi_string str, static int unibi_find_ext_str(unibi_term *ut, const char *name) { - size_t max = unibi_count_ext_bool(ut); + size_t max = unibi_count_ext_str(ut); for (size_t i = 0; i < max; ++i) { const char * n = unibi_get_ext_str_name(ut, i); if (0 == strcmp(n, name)) { -- cgit From 6910bfee0fb9470b0b30e5a46efeebfe760e6a2c Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 27 May 2017 19:11:00 +0100 Subject: tui: Correct error in terminfo extension processing. Using the right unibilium query function then revealed a latent NULL pointer problem. --- src/nvim/tui/tui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index d71f4b6656..15a0be0e42 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1136,7 +1136,7 @@ static int unibi_find_ext_str(unibi_term *ut, const char *name) size_t max = unibi_count_ext_str(ut); for (size_t i = 0; i < max; ++i) { const char * n = unibi_get_ext_str_name(ut, i); - if (0 == strcmp(n, name)) { + if (n && 0 == strcmp(n, name)) { return (int)i; } } -- cgit From 0d537672748bfd49674a21fdd9cac2b79c2085a9 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 27 May 2017 20:08:02 +0100 Subject: tui: Add iTerm and rxvt to the terminals that know extended DECSCUSR. --- src/nvim/tui/tui.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 15a0be0e42..5c191d94a8 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -2462,7 +2462,9 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // teminfo entries. See // https://github.com/gnachman/iTerm2/pull/92 for more. // xterm even has an extended version that has a vertical bar. - if (true_xterm // per xterm ctlseqs doco (since version 282) + if (true_xterm // per xterm ctlseqs doco (since version 282) + || rxvt // per command.C + || iterm // per analysis of VT100Terminal.m // Allows forcing the use of DECSCUSR on linux type terminals, such as // console-terminal-emulator from the nosh toolset, which does indeed // implement the xterm extension: -- cgit From 24db94b1a6d821699222564856f8e1d89841dfa6 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sun, 28 May 2017 00:55:04 +0100 Subject: tui: Fix Interix and account for deferred wrap. The Interix termcap entry is missing the carriage_return capability which nvim relies upon. And Interix is one of the few terminal emulators that does not defer automatic wrap at the right margin, which is now accounted for when moving the cursor left and when outputting whole lines at a time. --- src/nvim/tui/tui.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 5c191d94a8..3d27758b01 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -76,6 +76,7 @@ typedef struct { bool can_change_scroll_region; bool can_set_lr_margin; bool can_set_left_right_margin; + bool immediate_wrap_after_last_column; bool mouse_enabled; bool busy; cursorentry_T cursor_shapes[SHAPE_IDX_COUNT]; @@ -184,6 +185,8 @@ static void terminfo_start(UI *ui) data->can_set_left_right_margin = !!unibi_get_str(data->ut, unibi_set_left_margin_parm) && !!unibi_get_str(data->ut, unibi_set_right_margin_parm); + data->immediate_wrap_after_last_column = + term && STARTS_WITH(term, "interix"); // Set 't_Co' from the result of unibilium & fix_terminfo. t_colors = unibi_get_num(data->ut, unibi_max_colors); // Enter alternate screen and clear @@ -423,6 +426,23 @@ static bool cheap_to_print(UI *ui, int row, int col, int next) return true; } +/// The behaviour that this is checking for the absence of is undocumented, +/// but is implemented in the majority of terminals and terminal emulators. +/// Printing at the right margin does not cause an automatic wrap until the +/// next character is printed, holding the cursor in place until then. +static void check_final_column_wrap(UI *ui) +{ + TUIData *data = ui->data; + if (!data->immediate_wrap_after_last_column) { + return; + } + UGrid *grid = &data->grid; + if (grid->col == ui->width) { + grid->col = 0; + ++grid->row; + } +} + /// This optimizes several cases where it is cheaper to do something other /// than send a full cursor positioning control sequence. However, there are /// some further optimizations that may seem obvious but that will not work. @@ -460,6 +480,7 @@ static void cursor_goto(UI *ui, int row, int col) grid->col, col - 1, { print_cell(ui, cell); ++grid->col; + check_final_column_wrap(ui); }); } } @@ -471,6 +492,9 @@ static void cursor_goto(UI *ui, int row, int col) unibi_out(ui, unibi_cursor_left); } } else { + if (!data->immediate_wrap_after_last_column && grid->col >= ui->width) { + --n; // We have calculated one too many columns because of delayed wrap. + } data->params[0].i = n; unibi_out(ui, unibi_parm_left_cursor); } @@ -565,6 +589,7 @@ static void clear_region(UI *ui, int top, int bot, int left, int right) cursor_goto(ui, row, col); print_cell(ui, cell); ++grid->col; + check_final_column_wrap(ui); }); } @@ -879,6 +904,7 @@ static void tui_put(UI *ui, String text) { TUIData *data = ui->data; print_cell(ui, ugrid_put(&data->grid, (uint8_t *)text.data, text.size)); + check_final_column_wrap(ui); } static void tui_bell(UI *ui) @@ -932,6 +958,7 @@ static void tui_flush(UI *ui) cursor_goto(ui, row, col); print_cell(ui, cell); ++grid->col; + check_final_column_wrap(ui); }); } @@ -2408,6 +2435,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } else if (term && STARTS_WITH(term, "tmux")) { unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); + } else if (term && STARTS_WITH(term, "interix")) { + unibi_set_if_empty(ut, unibi_carriage_return, "\x0d"); } else if (linuxvt) { // No deviations from the vanilla terminfo. } else if (term && STARTS_WITH(term, "putty")) { -- cgit From 5377de33ac4adea54c9c9980c7a6bc8cc70c0c7a Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sun, 28 May 2017 12:18:01 +0100 Subject: tui: Add st to the always 256-colour capable list. Also comment and augment some terminal colour tests. --- src/nvim/tui/tui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 3d27758b01..5ea46c5ab7 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -2459,7 +2459,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, if (unibi_get_num(ut, unibi_max_colors) < 256) { // See http://fedoraproject.org/wiki/Features/256_Color_Terminals for // more on this. - if (konsole || mate || xterm || gnome || rxvt + if (konsole || mate || xterm || gnome || rxvt || st || linuxvt // Linux 4.8+ supports 256-colour SGR. || (colorterm && strstr(colorterm, "256")) || (term && strstr(term, "256")) -- cgit From 5265ac500064eecba3317ad8152cab14e9950db7 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sun, 28 May 2017 12:42:22 +0100 Subject: tui: Change terminal family recognition to avoid '+' entries. The terminfo commentary states that these are not standalone entries suitable for end-use. --- src/nvim/tui/tui.c | 63 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 5ea46c5ab7..d0ed3af897 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -48,6 +48,12 @@ #define TMUX_WRAP(is_tmux,seq) ((is_tmux) ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq) #define LINUXRESETC "\x1b[?0c" +// Per the commentary in terminfo, only a minus sign is a true suffix +// separator. +#define TERMINAL_FAMILY(term, prefix) ((term) \ + && (0 == memcmp((term), (prefix), sizeof(prefix) - 1)) \ + && ('\0' == (term)[sizeof(prefix) - 1] || '-' == (term)[sizeof(prefix) - 1])) + typedef struct { int top, bot, left, right; } Rect; @@ -186,7 +192,7 @@ static void terminfo_start(UI *ui) !!unibi_get_str(data->ut, unibi_set_left_margin_parm) && !!unibi_get_str(data->ut, unibi_set_right_margin_parm); data->immediate_wrap_after_last_column = - term && STARTS_WITH(term, "interix"); + TERMINAL_FAMILY(term, "interix"); // Set 't_Co' from the result of unibilium & fix_terminfo. t_colors = unibi_get_num(data->ut, unibi_max_colors); // Enter alternate screen and clear @@ -2344,23 +2350,23 @@ static const char ansi_terminfo[] = { /// behave as much like an external terminfo database as possible. static unibi_term *load_builtin_terminfo(const char * term) { - if (term && STARTS_WITH(term, "xterm")) { + if (TERMINAL_FAMILY(term, "xterm")) { return unibi_from_mem(xterm_256colour_terminfo, sizeof xterm_256colour_terminfo); - } else if (term && STARTS_WITH(term, "screen")) { + } else if (TERMINAL_FAMILY(term, "screen")) { return unibi_from_mem(screen_256colour_terminfo, sizeof screen_256colour_terminfo); - } else if (term && STARTS_WITH(term, "tmux")) { + } else if (TERMINAL_FAMILY(term, "tmux")) { return unibi_from_mem(tmux_256colour_terminfo, sizeof tmux_256colour_terminfo); - } else if (term && STARTS_WITH(term, "rxvt")) { + } else if (TERMINAL_FAMILY(term, "rxvt")) { return unibi_from_mem(rxvt_256colour_terminfo, sizeof rxvt_256colour_terminfo); - } else if (term && STARTS_WITH(term, "putty")) { + } else if (TERMINAL_FAMILY(term, "putty")) { return unibi_from_mem(putty_256colour_terminfo, sizeof putty_256colour_terminfo); - } else if (term && STARTS_WITH(term, "linux")) { + } else if (TERMINAL_FAMILY(term, "linux")) { return unibi_from_mem(linux_16colour_terminfo, sizeof linux_16colour_terminfo); - } else if (term && STARTS_WITH(term, "interix")) { + } else if (TERMINAL_FAMILY(term, "interix")) { return unibi_from_mem(interix_8colour_terminfo, sizeof interix_8colour_terminfo); - } else if (term && (STARTS_WITH(term, "iterm") || STARTS_WITH(term, "iTerm"))) { + } else if (TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app")) { return unibi_from_mem(iterm_16colour_terminfo, sizeof iterm_16colour_terminfo); - } else if (term && STARTS_WITH(term, "st")) { + } else if (TERMINAL_FAMILY(term, "st")) { return unibi_from_mem(st_256colour_terminfo, sizeof st_256colour_terminfo); } else { return unibi_from_mem(ansi_terminfo, sizeof ansi_terminfo); @@ -2377,14 +2383,15 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, { unibi_term *ut = data->ut; bool true_xterm = !!os_getenv("XTERM_VERSION"); - bool xterm = term && STARTS_WITH(term, "xterm"); + bool xterm = TERMINAL_FAMILY(term, "xterm"); bool mate = colorterm && strstr(colorterm, "mate-terminal"); bool gnome = colorterm && strstr(colorterm, "gnome-terminal"); - bool linuxvt = term && STARTS_WITH(term, "linux"); - bool rxvt = term && STARTS_WITH(term, "rxvt"); - bool teraterm = term && STARTS_WITH(term, "teraterm"); - bool putty = term && STARTS_WITH(term, "putty"); - bool screen = term && STARTS_WITH(term, "screen"); + bool linuxvt = TERMINAL_FAMILY(term, "linux"); + bool rxvt = TERMINAL_FAMILY(term, "rxvt"); + bool teraterm = TERMINAL_FAMILY(term, "teraterm"); + bool putty = TERMINAL_FAMILY(term, "putty"); + bool screen = TERMINAL_FAMILY(term, "screen"); + bool st = TERMINAL_FAMILY(term, "st"); char *fix_normal = (char *)unibi_get_str(ut, unibi_cursor_normal); if (fix_normal) { @@ -2432,16 +2439,16 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } else if (screen) { unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); - } else if (term && STARTS_WITH(term, "tmux")) { + } else if (TERMINAL_FAMILY(term, "tmux")) { unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); - } else if (term && STARTS_WITH(term, "interix")) { + } else if (TERMINAL_FAMILY(term, "interix")) { unibi_set_if_empty(ut, unibi_carriage_return, "\x0d"); } else if (linuxvt) { // No deviations from the vanilla terminfo. - } else if (term && STARTS_WITH(term, "putty")) { + } else if (TERMINAL_FAMILY(term, "putty")) { // No deviations from the vanilla terminfo. - } else if (term && (STARTS_WITH(term, "iterm") || STARTS_WITH(term, "iTerm"))) { + } else if (TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app")) { // No deviations from the vanilla terminfo. } @@ -2576,14 +2583,14 @@ static void augment_terminfo(TUIData *data, const char *term, { unibi_term *ut = data->ut; bool true_xterm = !!os_getenv("XTERM_VERSION"); - bool xterm = term && STARTS_WITH(term, "xterm"); - bool dtterm = term && STARTS_WITH(term, "dtterm"); - bool linuxvt = term && STARTS_WITH(term, "linux"); - bool rxvt = term && STARTS_WITH(term, "rxvt"); - bool teraterm = term && STARTS_WITH(term, "teraterm"); - bool putty = term && STARTS_WITH(term, "putty"); - bool screen = term && STARTS_WITH(term, "screen"); - bool st = term && STARTS_WITH(term, "st"); + bool xterm = TERMINAL_FAMILY(term, "xterm"); + bool dtterm = TERMINAL_FAMILY(term, "dtterm"); + bool linuxvt = TERMINAL_FAMILY(term, "linux"); + bool rxvt = TERMINAL_FAMILY(term, "rxvt"); + bool teraterm = TERMINAL_FAMILY(term, "teraterm"); + bool putty = TERMINAL_FAMILY(term, "putty"); + bool screen = TERMINAL_FAMILY(term, "screen"); + bool st = TERMINAL_FAMILY(term, "st"); bool tmux_wrap = screen && !!os_getenv("TMUX"); bool truecolor = colorterm && (0 == strcmp(colorterm, "truecolor") || 0 == strcmp(colorterm, "24bit")); -- cgit From 41403c6d25e00bfad004a85111abb3d88190fdbb Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sun, 28 May 2017 13:54:38 +0100 Subject: tui: Treat genuine Xterm and iTerm.app as standards-conformant. They both can handle SGR control sequences in the form set out in ISO 8613-6:1994/ITU T.416:1993. --- src/nvim/tui/tui.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index d0ed3af897..725310d645 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1512,7 +1512,7 @@ static const char screen_256colour_terminfo[] = { 85, 80, 53, 0, 107, 97, 50, 0, 107, 98, 49, 0, 107, 98, 51, 0, 107, 99, 50, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. -static const char iterm_16colour_terminfo[] = { +static const char iterm_256colour_terminfo[] = { 26, 1, 57, 0, 29, 0, 15, 0, 105, 1, 73, 3, 105, 84, 101, 114, 109, 46, 97, 112, 112, 124, 105, 116, 101, 114, 109, 124, 105, 84, 101, 114, 109, 46, 97, 112, 112, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 101, @@ -2365,7 +2365,7 @@ static unibi_term *load_builtin_terminfo(const char * term) } else if (TERMINAL_FAMILY(term, "interix")) { return unibi_from_mem(interix_8colour_terminfo, sizeof interix_8colour_terminfo); } else if (TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app")) { - return unibi_from_mem(iterm_16colour_terminfo, sizeof iterm_16colour_terminfo); + return unibi_from_mem(iterm_256colour_terminfo, sizeof iterm_256colour_terminfo); } else if (TERMINAL_FAMILY(term, "st")) { return unibi_from_mem(st_256colour_terminfo, sizeof st_256colour_terminfo); } else { @@ -2379,7 +2379,7 @@ static unibi_term *load_builtin_terminfo(const char * term) /// external or a built-in database. In an ideal world, the real terminfo data /// would be correct and complete, and this function would be almost empty. static void patch_terminfo_bugs(TUIData *data, const char *term, - const char *colorterm, long vte_version, bool konsole, bool iterm) + const char *colorterm, long vte_version, bool konsole, bool iterm_env) { unibi_term *ut = data->ut; bool true_xterm = !!os_getenv("XTERM_VERSION"); @@ -2392,6 +2392,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool putty = TERMINAL_FAMILY(term, "putty"); bool screen = TERMINAL_FAMILY(term, "screen"); bool st = TERMINAL_FAMILY(term, "st"); + bool iterm = TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app"); + bool iterm_pretending_xterm = xterm && iterm_env; char *fix_normal = (char *)unibi_get_str(ut, unibi_cursor_normal); if (fix_normal) { @@ -2446,15 +2448,22 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_if_empty(ut, unibi_carriage_return, "\x0d"); } else if (linuxvt) { // No deviations from the vanilla terminfo. - } else if (TERMINAL_FAMILY(term, "putty")) { + } else if (putty) { // No deviations from the vanilla terminfo. - } else if (TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app")) { + } else if (iterm) { + // No deviations from the vanilla terminfo. + } else if (st) { // No deviations from the vanilla terminfo. } #define XTERM_SETAF_256 \ - "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m" + "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;m" #define XTERM_SETAB_256 \ + "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48:5:%p1%d%;m" + // "standard" means using colons like ISO 8613-6:1994/ITU T.416:1993 says. +#define XTERM_SETAF_256_NONSTANDARD \ + "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m" +#define XTERM_SETAB_256_NONSTANDARD \ "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m" #define XTERM_SETAF_16 \ "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e39%;m" @@ -2466,14 +2475,18 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, if (unibi_get_num(ut, unibi_max_colors) < 256) { // See http://fedoraproject.org/wiki/Features/256_Color_Terminals for // more on this. - if (konsole || mate || xterm || gnome || rxvt || st + if (xterm && true_xterm) { + unibi_set_num(ut, unibi_max_colors, 256); + unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); + unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); + } else if (konsole || mate || xterm || gnome || rxvt || st || linuxvt // Linux 4.8+ supports 256-colour SGR. || (colorterm && strstr(colorterm, "256")) || (term && strstr(term, "256")) ) { unibi_set_num(ut, unibi_max_colors, 256); - unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); - unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); + unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256_NONSTANDARD); + unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256_NONSTANDARD); } } // Terminals where there is actually 16-colour SGR support despite what @@ -2500,7 +2513,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // xterm even has an extended version that has a vertical bar. if (true_xterm // per xterm ctlseqs doco (since version 282) || rxvt // per command.C - || iterm // per analysis of VT100Terminal.m + // per analysis of VT100Terminal.m + || iterm || iterm_pretending_xterm // Allows forcing the use of DECSCUSR on linux type terminals, such as // console-terminal-emulator from the nosh toolset, which does indeed // implement the xterm extension: @@ -2579,7 +2593,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, /// This adds stuff that is not in standard terminfo as extended unibilium /// capabilities. static void augment_terminfo(TUIData *data, const char *term, - const char *colorterm, long vte_version, bool konsole, bool iterm) + const char *colorterm, long vte_version, bool konsole, bool iterm_env) { unibi_term *ut = data->ut; bool true_xterm = !!os_getenv("XTERM_VERSION"); @@ -2591,6 +2605,8 @@ static void augment_terminfo(TUIData *data, const char *term, bool putty = TERMINAL_FAMILY(term, "putty"); bool screen = TERMINAL_FAMILY(term, "screen"); bool st = TERMINAL_FAMILY(term, "st"); + bool iterm = TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app"); + bool iterm_pretending_xterm = xterm && iterm_env; bool tmux_wrap = screen && !!os_getenv("TMUX"); bool truecolor = colorterm && (0 == strcmp(colorterm, "truecolor") || 0 == strcmp(colorterm, "24bit")); @@ -2615,6 +2631,7 @@ static void augment_terminfo(TUIData *data, const char *term, // lack the correct definitions in terminfo, is an augmentation, not a // fixup. See https://gist.github.com/XVilka/8346728 for more about this. bool has_standard_rgb = vte_version >= 3600 // per GNOME bug #685759 + || iterm || iterm_pretending_xterm // per analysis of VT100Terminal.m || true_xterm; // "standard" means using colons like ISO 8613-6:1994/ITU T.416:1993 says. bool has_non_standard_rgb = @@ -2623,7 +2640,7 @@ static void augment_terminfo(TUIData *data, const char *term, // per http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html || rxvt || st // per experimentation - || iterm || truecolor; + || truecolor; data->unibi_ext.set_rgb_foreground = unibi_find_ext_str(ut, "setrgbf"); if (-1 == data->unibi_ext.set_rgb_foreground) { if (has_standard_rgb) { @@ -2645,7 +2662,7 @@ static void augment_terminfo(TUIData *data, const char *term, } } - if (iterm) { + if (iterm || iterm_pretending_xterm) { // FIXME: Bypassing tmux like this affects the cursor colour globally, in // all panes, which is not particularly desirable. A better approach // would use a tmux control sequence and an extra if(screen) test. -- cgit From 32396b5879b429def1c48948069c55366d41b9be Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sun, 28 May 2017 15:30:46 +0100 Subject: tui: Perform length safety check in comparison macros. --- src/nvim/tui/tui.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 725310d645..16040cb5c5 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -44,14 +44,16 @@ #define OUTBUF_SIZE 0xffff #define TOO_MANY_EVENTS 1000000 -#define STARTS_WITH(str, prefix) (!memcmp((str), (prefix), sizeof(prefix) - 1)) +#define STARTS_WITH(str, prefix) (strlen(term) >= (sizeof(prefix) - 1) \ + && 0 == memcmp((str), (prefix), sizeof(prefix) - 1)) #define TMUX_WRAP(is_tmux,seq) ((is_tmux) ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq) #define LINUXRESETC "\x1b[?0c" // Per the commentary in terminfo, only a minus sign is a true suffix // separator. #define TERMINAL_FAMILY(term, prefix) ((term) \ - && (0 == memcmp((term), (prefix), sizeof(prefix) - 1)) \ + && strlen(term) >= (sizeof(prefix) - 1) \ + && 0 == memcmp((term), (prefix), sizeof(prefix) - 1) \ && ('\0' == (term)[sizeof(prefix) - 1] || '-' == (term)[sizeof(prefix) - 1])) typedef struct { -- cgit From 1c1231bf139943382df6cec9221f84708d4aea64 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Mon, 29 May 2017 07:51:06 +0100 Subject: tui: Add built-in terminfo entry for VTE. Also slightly refactor the way in which GNOME/MATE Terminal pretending to be xterm is detected. --- src/nvim/tui/tui.c | 183 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 170 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 16040cb5c5..5110e8797d 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1179,12 +1179,12 @@ static int unibi_find_ext_str(unibi_term *ut, const char *name) } // One creates the dumps from terminfo.src by using -// od -t d1 -w +// od -t d1 -w16 | cut -c9- | sed -e 's/\>/,/g' // on the compiled files. // Taken from Dickey ncurses terminfo.src dated 2017-04-22. // This is a 256-colour terminfo description that lacks true-colour and -// DECSTBN/DECSLRM/DECLRMM capabilities that xterm actually has. +// DECSTBM/DECSLRM/DECLRMM capabilities that xterm actually has. static const char xterm_256colour_terminfo[] = { 26, 1, 37, 0, 29, 0, 15, 0, 105, 1, -42, 5, 120, 116, 101, 114, 109, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 120, 116, 101, 114, 109, @@ -2251,6 +2251,157 @@ static const char st_256colour_terminfo[] = { 100, 37, 59, 109, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. +// This is a 256-colour terminfo description that lacks true-colour +// capabilities that gnome actually has. +static const char vte_256colour_terminfo[] = { + 26, 1, 52, 0, 29, 0, 15, 0, 105, 1, -55, 5, 103, 110, 111, 109, + 101, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 71, 78, 79, 77, 69, + 32, 84, 101, 114, 109, 105, 110, 97, 108, 32, 119, 105, 116, 104, 32, 120, + 116, 101, 114, 109, 32, 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, + 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 80, 0, + 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, + 6, 0, 8, 0, 25, 0, 30, 0, 38, 0, 42, 0, 46, 0, -1, -1, + 57, 0, 74, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, 96, 0, + -1, -1, 100, 0, -1, -1, 104, 0, 108, 0, -1, -1, -1, -1, 112, 0, + -1, -1, 114, 0, 119, 0, -1, -1, -128, 0, -123, 0, -118, 0, -1, -1, +-113, 0, -108, 0, -103, 0, -98, 0, -89, 0, -87, 0, -81, 0, -1, -1, + -68, 0, -63, 0, -57, 0, -51, 0, -1, -1, -1, -1, -1, -1, -33, 0, + -1, -1, -1, -1, -1, -1, 0, 1, -1, -1, 4, 1, -1, -1, -1, -1, + -1, -1, 6, 1, -1, -1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, + 15, 1, 19, 1, 25, 1, 29, 1, 33, 1, 37, 1, 43, 1, 49, 1, + 55, 1, 61, 1, 67, 1, 71, 1, -1, -1, 76, 1, -1, -1, 80, 1, + 85, 1, 90, 1, 94, 1, 101, 1, -1, -1, 108, 1, 112, 1, 120, 1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -128, 1, +-119, 1, -110, 1, -101, 1, -92, 1, -83, 1, -74, 1, -65, 1, -56, 1, + -47, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -38, 1, -35, 1, -1, -1, -1, -1, 16, 2, 19, 2, 30, 2, 33, 2, + 35, 2, 38, 2, 116, 2, -1, -1, 119, 2, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 121, 2, -1, -1, -1, -1, -1, -1, -1, -1, + 125, 2, -1, -1, -78, 2, -1, -1, -1, -1, -74, 2, -68, 2, -1, -1, + -1, -1, -62, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -58, 2, -54, 2, -1, -1, -50, 2, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -45, 2, -1, -1, -38, 2, + -33, 2, -1, -1, -1, -1, -1, -1, -1, -1, -26, 2, -19, 2, -12, 2, + -1, -1, -1, -1, -5, 2, -1, -1, 2, 3, -1, -1, -1, -1, -1, -1, + 9, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, 3, 22, 3, + 28, 3, 35, 3, 42, 3, 49, 3, 56, 3, 64, 3, 72, 3, 80, 3, + 88, 3, 96, 3, 104, 3, 112, 3, 120, 3, 127, 3, -122, 3, -115, 3, +-108, 3, -100, 3, -92, 3, -84, 3, -76, 3, -68, 3, -60, 3, -52, 3, + -44, 3, -37, 3, -30, 3, -23, 3, -16, 3, -8, 3, 0, 4, 8, 4, + 16, 4, 24, 4, 32, 4, 40, 4, 48, 4, 55, 4, 62, 4, 69, 4, + 76, 4, 84, 4, 92, 4, 100, 4, 108, 4, 116, 4, 124, 4, -124, 4, +-116, 4, -109, 4, -102, 4, -95, 4, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -90, 4, -79, 4, -74, 4, -55, 4, -51, 4, + -42, 4, -35, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, 5, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 64, 5, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 70, 5, -1, -1, -1, -1, -1, -1, 74, 5, -119, 5, 27, 91, + 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, + 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, + 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, + 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, + 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, + 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, + 67, 0, 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, 0, + 27, 91, 49, 109, 0, 27, 55, 27, 91, 63, 52, 55, 104, 0, 27, 91, + 50, 109, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, 0, 27, 91, 55, + 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, + 49, 37, 100, 88, 0, 15, 0, 27, 91, 48, 109, 15, 0, 27, 91, 50, + 74, 27, 91, 63, 52, 55, 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, + 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, + 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 27, 91, 109, + 27, 91, 63, 55, 104, 27, 91, 52, 108, 27, 62, 27, 55, 27, 91, 114, + 27, 91, 63, 49, 59, 51, 59, 52, 59, 54, 108, 27, 56, 0, 27, 91, + 76, 0, 127, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, + 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, + 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, + 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, + 0, 27, 79, 72, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, + 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 91, 49, 59, + 50, 66, 0, 27, 91, 49, 59, 50, 65, 0, 27, 79, 65, 0, 27, 91, + 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 91, + 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, + 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, + 64, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, + 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, + 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, + 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 0, 27, 55, 27, 91, 114, + 27, 56, 27, 91, 109, 27, 91, 63, 55, 104, 27, 91, 33, 112, 27, 91, + 63, 49, 59, 51, 59, 52, 59, 54, 108, 27, 91, 52, 108, 27, 62, 27, + 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, + 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, + 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, + 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, + 112, 53, 37, 116, 59, 50, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, + 56, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, + 55, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, + 59, 0, 27, 72, 0, 9, 0, 27, 91, 69, 0, 96, 96, 97, 97, 102, + 102, 103, 103, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, + 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, + 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, + 27, 91, 90, 0, 27, 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, + 27, 41, 48, 0, 27, 79, 70, 0, 27, 79, 77, 0, 27, 91, 49, 126, + 0, 27, 91, 51, 59, 50, 126, 0, 27, 91, 52, 126, 0, 27, 91, 49, + 59, 50, 70, 0, 27, 91, 49, 59, 50, 72, 0, 27, 91, 50, 59, 50, + 126, 0, 27, 91, 49, 59, 50, 68, 0, 27, 91, 54, 59, 50, 126, 0, + 27, 91, 53, 59, 50, 126, 0, 27, 91, 49, 59, 50, 67, 0, 27, 91, + 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 59, 50, 80, + 0, 27, 91, 49, 59, 50, 81, 0, 27, 91, 49, 59, 50, 82, 0, 27, + 91, 49, 59, 50, 83, 0, 27, 91, 49, 53, 59, 50, 126, 0, 27, 91, + 49, 55, 59, 50, 126, 0, 27, 91, 49, 56, 59, 50, 126, 0, 27, 91, + 49, 57, 59, 50, 126, 0, 27, 91, 50, 48, 59, 50, 126, 0, 27, 91, + 50, 49, 59, 50, 126, 0, 27, 91, 50, 51, 59, 50, 126, 0, 27, 91, + 50, 52, 59, 50, 126, 0, 27, 91, 49, 59, 53, 80, 0, 27, 91, 49, + 59, 53, 81, 0, 27, 91, 49, 59, 53, 82, 0, 27, 91, 49, 59, 53, + 83, 0, 27, 91, 49, 53, 59, 53, 126, 0, 27, 91, 49, 55, 59, 53, + 126, 0, 27, 91, 49, 56, 59, 53, 126, 0, 27, 91, 49, 57, 59, 53, + 126, 0, 27, 91, 50, 48, 59, 53, 126, 0, 27, 91, 50, 49, 59, 53, + 126, 0, 27, 91, 50, 51, 59, 53, 126, 0, 27, 91, 50, 52, 59, 53, + 126, 0, 27, 91, 49, 59, 54, 80, 0, 27, 91, 49, 59, 54, 81, 0, + 27, 91, 49, 59, 54, 82, 0, 27, 91, 49, 59, 54, 83, 0, 27, 91, + 49, 53, 59, 54, 126, 0, 27, 91, 49, 55, 59, 54, 126, 0, 27, 91, + 49, 56, 59, 54, 126, 0, 27, 91, 49, 57, 59, 54, 126, 0, 27, 91, + 50, 48, 59, 54, 126, 0, 27, 91, 50, 49, 59, 54, 126, 0, 27, 91, + 50, 51, 59, 54, 126, 0, 27, 91, 50, 52, 59, 54, 126, 0, 27, 91, + 49, 59, 51, 80, 0, 27, 91, 49, 59, 51, 81, 0, 27, 91, 49, 59, + 51, 82, 0, 27, 91, 49, 59, 51, 83, 0, 27, 91, 49, 53, 59, 51, + 126, 0, 27, 91, 49, 55, 59, 51, 126, 0, 27, 91, 49, 56, 59, 51, + 126, 0, 27, 91, 49, 57, 59, 51, 126, 0, 27, 91, 50, 48, 59, 51, + 126, 0, 27, 91, 50, 49, 59, 51, 126, 0, 27, 91, 50, 51, 59, 51, + 126, 0, 27, 91, 50, 52, 59, 51, 126, 0, 27, 91, 49, 59, 52, 80, + 0, 27, 91, 49, 59, 52, 81, 0, 27, 91, 49, 59, 52, 82, 0, 27, + 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, + 91, 54, 110, 0, 27, 91, 63, 37, 91, 59, 48, 49, 50, 51, 52, 53, + 54, 55, 56, 57, 93, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, + 52, 57, 109, 0, 27, 93, 49, 48, 52, 7, 0, 27, 93, 52, 59, 37, + 112, 49, 37, 100, 59, 114, 103, 98, 58, 37, 112, 50, 37, 123, 50, 53, + 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, + 50, 88, 47, 37, 112, 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, + 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 52, + 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, + 47, 37, 50, 46, 50, 88, 27, 92, 0, 27, 91, 51, 109, 0, 27, 91, + 50, 51, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, + 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, + 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, + 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, + 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, + 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, + 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, + 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, + 49, 37, 100, 37, 59, 109, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. static const char ansi_terminfo[] = { 26, 1, 40, 0, 23, 0, 16, 0, 125, 1, 68, 2, 97, 110, 115, 105, 124, 97, 110, 115, 105, 47, 112, 99, 45, 116, 101, 114, 109, 32, 99, 111, @@ -2370,6 +2521,8 @@ static unibi_term *load_builtin_terminfo(const char * term) return unibi_from_mem(iterm_256colour_terminfo, sizeof iterm_256colour_terminfo); } else if (TERMINAL_FAMILY(term, "st")) { return unibi_from_mem(st_256colour_terminfo, sizeof st_256colour_terminfo); + } else if (TERMINAL_FAMILY(term, "gnome") || TERMINAL_FAMILY(term, "vte")) { + return unibi_from_mem(vte_256colour_terminfo, sizeof vte_256colour_terminfo); } else { return unibi_from_mem(ansi_terminfo, sizeof ansi_terminfo); } @@ -2384,18 +2537,20 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, const char *colorterm, long vte_version, bool konsole, bool iterm_env) { unibi_term *ut = data->ut; - bool true_xterm = !!os_getenv("XTERM_VERSION"); + const char * xterm_version = os_getenv("XTERM_VERSION"); bool xterm = TERMINAL_FAMILY(term, "xterm"); - bool mate = colorterm && strstr(colorterm, "mate-terminal"); - bool gnome = colorterm && strstr(colorterm, "gnome-terminal"); bool linuxvt = TERMINAL_FAMILY(term, "linux"); bool rxvt = TERMINAL_FAMILY(term, "rxvt"); bool teraterm = TERMINAL_FAMILY(term, "teraterm"); bool putty = TERMINAL_FAMILY(term, "putty"); bool screen = TERMINAL_FAMILY(term, "screen"); bool st = TERMINAL_FAMILY(term, "st"); + bool gnome = TERMINAL_FAMILY(term, "gnome") || TERMINAL_FAMILY(term, "vte"); bool iterm = TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app"); bool iterm_pretending_xterm = xterm && iterm_env; + bool gnome_pretending_xterm = xterm && colorterm && strstr(colorterm, "gnome-terminal"); + bool mate_pretending_xterm = xterm && colorterm && strstr(colorterm, "mate-terminal"); + bool true_xterm = xterm && !!xterm_version; char *fix_normal = (char *)unibi_get_str(ut, unibi_cursor_normal); if (fix_normal) { @@ -2449,13 +2604,13 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } else if (TERMINAL_FAMILY(term, "interix")) { unibi_set_if_empty(ut, unibi_carriage_return, "\x0d"); } else if (linuxvt) { - // No deviations from the vanilla terminfo. + // No bugs in the vanilla terminfo for our purposes. } else if (putty) { - // No deviations from the vanilla terminfo. + // No bugs in the vanilla terminfo for our purposes. } else if (iterm) { - // No deviations from the vanilla terminfo. + unibi_set_if_empty(ut, unibi_enter_italics_mode, "\x1b[3m"); } else if (st) { - // No deviations from the vanilla terminfo. + // No bugs in the vanilla terminfo for our purposes. } #define XTERM_SETAF_256 \ @@ -2477,12 +2632,13 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, if (unibi_get_num(ut, unibi_max_colors) < 256) { // See http://fedoraproject.org/wiki/Features/256_Color_Terminals for // more on this. - if (xterm && true_xterm) { + if (true_xterm) { unibi_set_num(ut, unibi_max_colors, 256); unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); - } else if (konsole || mate || xterm || gnome || rxvt || st + } else if (konsole || iterm || xterm || gnome || rxvt || st || linuxvt // Linux 4.8+ supports 256-colour SGR. + || mate_pretending_xterm || gnome_pretending_xterm || (colorterm && strstr(colorterm, "256")) || (term && strstr(term, "256")) ) { @@ -2520,7 +2676,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // Allows forcing the use of DECSCUSR on linux type terminals, such as // console-terminal-emulator from the nosh toolset, which does indeed // implement the xterm extension: - || (linuxvt && (true_xterm || (vte_version > 0) || colorterm))) { + || (linuxvt && (xterm_version || (vte_version > 0) || colorterm))) { data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", "\x1b[%p1%d q"); if (-1 == data->unibi_ext.reset_cursor_style) { @@ -2598,7 +2754,7 @@ static void augment_terminfo(TUIData *data, const char *term, const char *colorterm, long vte_version, bool konsole, bool iterm_env) { unibi_term *ut = data->ut; - bool true_xterm = !!os_getenv("XTERM_VERSION"); + const char * xterm_version = os_getenv("XTERM_VERSION"); bool xterm = TERMINAL_FAMILY(term, "xterm"); bool dtterm = TERMINAL_FAMILY(term, "dtterm"); bool linuxvt = TERMINAL_FAMILY(term, "linux"); @@ -2609,6 +2765,7 @@ static void augment_terminfo(TUIData *data, const char *term, bool st = TERMINAL_FAMILY(term, "st"); bool iterm = TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app"); bool iterm_pretending_xterm = xterm && iterm_env; + bool true_xterm = xterm && !!xterm_version; bool tmux_wrap = screen && !!os_getenv("TMUX"); bool truecolor = colorterm && (0 == strcmp(colorterm, "truecolor") || 0 == strcmp(colorterm, "24bit")); -- cgit From 1b008be1e61139f1387dd6f23e77ff34291f2f97 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Mon, 29 May 2017 18:56:20 +0100 Subject: tui: Correct to_status_line for screen. PM...ST actually sends the string to screen's message area. Sending the string to the status line requires a different control sequence peculiar to screen. Also make iTerm2 SGR 38/48 consistent. --- src/nvim/tui/tui.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 5110e8797d..6666296487 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -177,6 +177,7 @@ static void terminfo_start(UI *ui) if (!data->ut) { data->ut = load_builtin_terminfo(term); } + // None of the following work over SSH; see :help TERM . const char *colorterm = os_getenv("COLORTERM"); const char *termprg = os_getenv("TERM_PROGRAM"); const char *vte_version_env = os_getenv("VTE_VERSION"); @@ -184,6 +185,7 @@ static void terminfo_start(UI *ui) bool iterm = termprg && strstr(termprg, "iTerm.app"); bool konsole = os_getenv("KONSOLE_PROFILE_NAME") || os_getenv("KONSOLE_DBUS_SESSION"); + patch_terminfo_bugs(data, term, colorterm, vte_version, konsole, iterm); augment_terminfo(data, term, colorterm, vte_version, konsole, iterm); data->can_change_scroll_region = @@ -2547,6 +2549,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool st = TERMINAL_FAMILY(term, "st"); bool gnome = TERMINAL_FAMILY(term, "gnome") || TERMINAL_FAMILY(term, "vte"); bool iterm = TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app"); + // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; bool gnome_pretending_xterm = xterm && colorterm && strstr(colorterm, "gnome-terminal"); bool mate_pretending_xterm = xterm && colorterm && strstr(colorterm, "mate-terminal"); @@ -2596,7 +2599,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_if_empty(ut, unibi_from_status_line, "\x07"); unibi_set_if_empty(ut, unibi_set_tb_margin, "\x1b[%i%p1%d;%p2%dr"); } else if (screen) { - unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); + // per the screen manual; 2017-04 terminfo.src lacks these. + unibi_set_if_empty(ut, unibi_to_status_line, "\x1bk"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); } else if (TERMINAL_FAMILY(term, "tmux")) { unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); @@ -2632,11 +2636,11 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, if (unibi_get_num(ut, unibi_max_colors) < 256) { // See http://fedoraproject.org/wiki/Features/256_Color_Terminals for // more on this. - if (true_xterm) { + if (true_xterm || iterm || iterm_pretending_xterm) { unibi_set_num(ut, unibi_max_colors, 256); unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); - } else if (konsole || iterm || xterm || gnome || rxvt || st + } else if (konsole || xterm || gnome || rxvt || st || linuxvt // Linux 4.8+ supports 256-colour SGR. || mate_pretending_xterm || gnome_pretending_xterm || (colorterm && strstr(colorterm, "256")) @@ -2673,6 +2677,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, || rxvt // per command.C // per analysis of VT100Terminal.m || iterm || iterm_pretending_xterm + || teraterm // per TeraTerm "Supported Control Functions" doco // Allows forcing the use of DECSCUSR on linux type terminals, such as // console-terminal-emulator from the nosh toolset, which does indeed // implement the xterm extension: @@ -2685,8 +2690,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[ q"); } else if (putty // per MinTTY 0.4.3-1 release notes from 2009 - || teraterm // per TeraTerm "Supported Control Functions" doco - || (vte_version >= 3900) // VTE-based terminals since this version. + || per https://bugzilla.gnome.org/show_bug.cgi?id=720821 + || (vte_version >= 3900) // per tmux manual page and per // https://lists.gnu.org/archive/html/screen-devel/2013-03/msg00000.html || screen) { @@ -2764,6 +2769,7 @@ static void augment_terminfo(TUIData *data, const char *term, bool screen = TERMINAL_FAMILY(term, "screen"); bool st = TERMINAL_FAMILY(term, "st"); bool iterm = TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app"); + // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; bool true_xterm = xterm && !!xterm_version; bool tmux_wrap = screen && !!os_getenv("TMUX"); -- cgit From 4408bd28cbf21a242855c53c7433268c7959ae48 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Mon, 29 May 2017 19:16:02 +0100 Subject: tui: Char signedness fix for the big blocks of (signed) numbers. --- src/nvim/tui/tui.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 6666296487..c39d1368e3 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1187,7 +1187,7 @@ static int unibi_find_ext_str(unibi_term *ut, const char *name) // Taken from Dickey ncurses terminfo.src dated 2017-04-22. // This is a 256-colour terminfo description that lacks true-colour and // DECSTBM/DECSLRM/DECLRMM capabilities that xterm actually has. -static const char xterm_256colour_terminfo[] = { +static const signed char xterm_256colour_terminfo[] = { 26, 1, 37, 0, 29, 0, 15, 0, 105, 1, -42, 5, 120, 116, 101, 114, 109, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 120, 116, 101, 114, 109, 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, @@ -1338,7 +1338,7 @@ static const char xterm_256colour_terminfo[] = { // Taken from unibilium/t/static_tmux.c as of 2015-08-14. // This is an 256-colour terminfo description that lacks // status line capabilities that tmux actually has. -static const char tmux_256colour_terminfo[] = { +static const signed char tmux_256colour_terminfo[] = { 26, 1, 56, 0, 15, 0, 15, 0, 105, 1, -48, 2, 116, 109, 117, 120, 124, 86, 84, 32, 49, 48, 48, 47, 65, 78, 83, 73, 32, 88, 51, 46, 54, 52, 32, 118, 105, 114, 116, 117, 97, 108, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 119, 105, 116, 104, 32, 50, 53, 54, @@ -1421,7 +1421,7 @@ static const char tmux_256colour_terminfo[] = { // Taken from unibilium/t/static_screen-256color.c as of 2015-08-14. // This is an 256-colour terminfo description that lacks // status line capabilities that screen actually has. -static const char screen_256colour_terminfo[] = { +static const signed char screen_256colour_terminfo[] = { 26, 1, 43, 0, 43, 0, 15, 0, 105, 1, -43, 2, 115, 99, 114, 101, 101, 110, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 71, 78, 85, 32, 83, 99, 114, 101, 101, 110, 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, @@ -1516,7 +1516,7 @@ static const char screen_256colour_terminfo[] = { 85, 80, 53, 0, 107, 97, 50, 0, 107, 98, 49, 0, 107, 98, 51, 0, 107, 99, 50, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. -static const char iterm_256colour_terminfo[] = { +static const signed char iterm_256colour_terminfo[] = { 26, 1, 57, 0, 29, 0, 15, 0, 105, 1, 73, 3, 105, 84, 101, 114, 109, 46, 97, 112, 112, 124, 105, 116, 101, 114, 109, 124, 105, 84, 101, 114, 109, 46, 97, 112, 112, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 101, @@ -1627,7 +1627,7 @@ static const char iterm_256colour_terminfo[] = { // Taken from Dickey ncurses terminfo.src dated 2017-04-22. // This is a 256-colour terminfo description that lacks true-colour // capabilities that rxvt actually has. -static const char rxvt_256colour_terminfo[] = { +static const signed char rxvt_256colour_terminfo[] = { 26, 1, 47, 0, 29, 0, 15, 0, 110, 1, -31, 4, 114, 120, 118, 116, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 114, 120, 118, 116, 32, 50, 46, 55, 46, 57, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, 32, @@ -1764,7 +1764,7 @@ static const char rxvt_256colour_terminfo[] = { // Taken from Dickey ncurses terminfo.src dated 2017-04-22. // This is a 16-colour terminfo description that lacks true-colour // and 256-colour capabilities that linux (4.8+) actually has. -static const char linux_16colour_terminfo[] = { +static const signed char linux_16colour_terminfo[] = { 26, 1, 43, 0, 29, 0, 16, 0, 125, 1, 125, 3, 108, 105, 110, 117, 120, 45, 49, 54, 99, 111, 108, 111, 114, 124, 108, 105, 110, 117, 120, 32, 99, 111, 110, 115, 111, 108, 101, 32, 119, 105, 116, 104, 32, 49, 54, 32, @@ -1878,7 +1878,7 @@ static const char linux_16colour_terminfo[] = { 91, 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. -static const char putty_256colour_terminfo[] = { +static const signed char putty_256colour_terminfo[] = { 26, 1, 48, 0, 29, 0, 16, 0, 125, 1,-106, 4, 112, 117, 116, 116, 121, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 80, 117, 84, 84, 89, 32, 48, 46, 53, 56, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, @@ -2010,7 +2010,7 @@ static const char putty_256colour_terminfo[] = { 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. -static const char interix_8colour_terminfo[] = { +static const signed char interix_8colour_terminfo[] = { 26, 1, 82, 0, 15, 0, 16, 0, 105, 1, 123, 2, 105, 110, 116, 101, 114, 105, 120, 124, 111, 112, 101, 110, 110, 116, 124, 111, 112, 101, 110, 110, 116, 45, 50, 53, 124, 110, 116, 99, 111, 110, 115, 111, 108, 101, 124, 110, @@ -2109,7 +2109,7 @@ static const char interix_8colour_terminfo[] = { // Taken from Dickey ncurses terminfo.src dated 2017-04-22. // This is a 256-colour terminfo description that lacks true-colour // capabilities that stterm actually has. -static const char st_256colour_terminfo[] = { +static const signed char st_256colour_terminfo[] = { 26, 1, 55, 0, 29, 0, 15, 0, 105, 1, 117, 5, 115, 116, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 115, 116, 116, 101, 114, 109, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 115, 105, 109, 112, 108, 101, 116, 101, @@ -2255,7 +2255,7 @@ static const char st_256colour_terminfo[] = { // Taken from Dickey ncurses terminfo.src dated 2017-04-22. // This is a 256-colour terminfo description that lacks true-colour // capabilities that gnome actually has. -static const char vte_256colour_terminfo[] = { +static const signed char vte_256colour_terminfo[] = { 26, 1, 52, 0, 29, 0, 15, 0, 105, 1, -55, 5, 103, 110, 111, 109, 101, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 71, 78, 79, 77, 69, 32, 84, 101, 114, 109, 105, 110, 97, 108, 32, 119, 105, 116, 104, 32, 120, @@ -2404,7 +2404,7 @@ static const char vte_256colour_terminfo[] = { 49, 37, 100, 37, 59, 109, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. -static const char ansi_terminfo[] = { +static const signed char ansi_terminfo[] = { 26, 1, 40, 0, 23, 0, 16, 0, 125, 1, 68, 2, 97, 110, 115, 105, 124, 97, 110, 115, 105, 47, 112, 99, 45, 116, 101, 114, 109, 32, 99, 111, 109, 112, 97, 116, 105, 98, 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, @@ -2506,27 +2506,27 @@ static const char ansi_terminfo[] = { static unibi_term *load_builtin_terminfo(const char * term) { if (TERMINAL_FAMILY(term, "xterm")) { - return unibi_from_mem(xterm_256colour_terminfo, sizeof xterm_256colour_terminfo); + return unibi_from_mem((const char *)xterm_256colour_terminfo, sizeof xterm_256colour_terminfo); } else if (TERMINAL_FAMILY(term, "screen")) { - return unibi_from_mem(screen_256colour_terminfo, sizeof screen_256colour_terminfo); + return unibi_from_mem((const char *)screen_256colour_terminfo, sizeof screen_256colour_terminfo); } else if (TERMINAL_FAMILY(term, "tmux")) { - return unibi_from_mem(tmux_256colour_terminfo, sizeof tmux_256colour_terminfo); + return unibi_from_mem((const char *)tmux_256colour_terminfo, sizeof tmux_256colour_terminfo); } else if (TERMINAL_FAMILY(term, "rxvt")) { - return unibi_from_mem(rxvt_256colour_terminfo, sizeof rxvt_256colour_terminfo); + return unibi_from_mem((const char *)rxvt_256colour_terminfo, sizeof rxvt_256colour_terminfo); } else if (TERMINAL_FAMILY(term, "putty")) { - return unibi_from_mem(putty_256colour_terminfo, sizeof putty_256colour_terminfo); + return unibi_from_mem((const char *)putty_256colour_terminfo, sizeof putty_256colour_terminfo); } else if (TERMINAL_FAMILY(term, "linux")) { - return unibi_from_mem(linux_16colour_terminfo, sizeof linux_16colour_terminfo); + return unibi_from_mem((const char *)linux_16colour_terminfo, sizeof linux_16colour_terminfo); } else if (TERMINAL_FAMILY(term, "interix")) { - return unibi_from_mem(interix_8colour_terminfo, sizeof interix_8colour_terminfo); + return unibi_from_mem((const char *)interix_8colour_terminfo, sizeof interix_8colour_terminfo); } else if (TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app")) { - return unibi_from_mem(iterm_256colour_terminfo, sizeof iterm_256colour_terminfo); + return unibi_from_mem((const char *)iterm_256colour_terminfo, sizeof iterm_256colour_terminfo); } else if (TERMINAL_FAMILY(term, "st")) { - return unibi_from_mem(st_256colour_terminfo, sizeof st_256colour_terminfo); + return unibi_from_mem((const char *)st_256colour_terminfo, sizeof st_256colour_terminfo); } else if (TERMINAL_FAMILY(term, "gnome") || TERMINAL_FAMILY(term, "vte")) { - return unibi_from_mem(vte_256colour_terminfo, sizeof vte_256colour_terminfo); + return unibi_from_mem((const char *)vte_256colour_terminfo, sizeof vte_256colour_terminfo); } else { - return unibi_from_mem(ansi_terminfo, sizeof ansi_terminfo); + return unibi_from_mem((const char *)ansi_terminfo, sizeof ansi_terminfo); } } @@ -2690,7 +2690,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[ q"); } else if (putty // per MinTTY 0.4.3-1 release notes from 2009 - || per https://bugzilla.gnome.org/show_bug.cgi?id=720821 + // per https://bugzilla.gnome.org/show_bug.cgi?id=720821 || (vte_version >= 3900) // per tmux manual page and per // https://lists.gnu.org/archive/html/screen-devel/2013-03/msg00000.html -- cgit From 1aba6c607be931d6e812a34a7f458f05c0007200 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Tue, 30 May 2017 01:59:06 +0100 Subject: tui: Change screen status line back to hardstatus. Reverse the change in c11c60325a2baba94abe6bdfa1c11afe28c16661. --- src/nvim/tui/tui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index c39d1368e3..4bfa5beb17 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -2600,7 +2600,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_if_empty(ut, unibi_set_tb_margin, "\x1b[%i%p1%d;%p2%dr"); } else if (screen) { // per the screen manual; 2017-04 terminfo.src lacks these. - unibi_set_if_empty(ut, unibi_to_status_line, "\x1bk"); + unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); } else if (TERMINAL_FAMILY(term, "tmux")) { unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); -- cgit From 63fd5618150ffa0ba6f9143395ef6bf56f642f64 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Tue, 30 May 2017 17:15:41 +0100 Subject: tui: Fix OBOE in linux cnorm capability fixup code. --- src/nvim/tui/tui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 4bfa5beb17..91615bcb01 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -2566,7 +2566,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_str(ut, unibi_cursor_normal, fix_normal); } if (linuxvt - && (strlen(fix_normal) + 1) >= (sizeof LINUXRESETC - 1) + && strlen(fix_normal) >= (sizeof LINUXRESETC - 1) && !memcmp(strchr(fix_normal,0) - (sizeof LINUXRESETC - 1), LINUXRESETC, sizeof LINUXRESETC - 1)) { // The Linux terminfo entry similarly includes a Linux-idiosyncractic // cursor shape reset in cnorm, which similarly interferes with -- cgit From 1903fb5de047c19955570b4cd838f552bd54f633 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Tue, 30 May 2017 17:33:07 +0100 Subject: tui: Make iTerm2 have no deferred wrap. Testing by Enrico Ghirardi and review of the source indicates that iTerm2 is a second terminal emulator that does not defer automatic wrap at the right margin. --- src/nvim/tui/tui.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 91615bcb01..b463f1dc5e 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -182,12 +182,12 @@ static void terminfo_start(UI *ui) const char *termprg = os_getenv("TERM_PROGRAM"); const char *vte_version_env = os_getenv("VTE_VERSION"); long vte_version = vte_version_env ? strtol(vte_version_env, NULL, 10) : 0; - bool iterm = termprg && strstr(termprg, "iTerm.app"); + bool iterm_env = termprg && strstr(termprg, "iTerm.app"); bool konsole = os_getenv("KONSOLE_PROFILE_NAME") || os_getenv("KONSOLE_DBUS_SESSION"); - patch_terminfo_bugs(data, term, colorterm, vte_version, konsole, iterm); - augment_terminfo(data, term, colorterm, vte_version, konsole, iterm); + patch_terminfo_bugs(data, term, colorterm, vte_version, konsole, iterm_env); + augment_terminfo(data, term, colorterm, vte_version, konsole, iterm_env); data->can_change_scroll_region = !!unibi_get_str(data->ut, unibi_change_scroll_region); data->can_set_lr_margin = @@ -196,7 +196,9 @@ static void terminfo_start(UI *ui) !!unibi_get_str(data->ut, unibi_set_left_margin_parm) && !!unibi_get_str(data->ut, unibi_set_right_margin_parm); data->immediate_wrap_after_last_column = - TERMINAL_FAMILY(term, "interix"); + TERMINAL_FAMILY(term, "iterm") + || TERMINAL_FAMILY(term, "interix") + || (TERMINAL_FAMILY(term, "xterm") && iterm_env); // Set 't_Co' from the result of unibilium & fix_terminfo. t_colors = unibi_get_num(data->ut, unibi_max_colors); // Enter alternate screen and clear -- cgit From a2aba3f2f156bc81adcc2ad8c84c8a0f1ffa55e0 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Tue, 30 May 2017 20:05:11 +0100 Subject: tui: Handle a corner case for rare terminals. Terminals that do not defer automatic right margin wrap cannot print characters in the bottom right corner without immediately scrolling. --- src/nvim/tui/tui.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index b463f1dc5e..e3612b5c06 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -414,8 +414,18 @@ static void update_attrs(UI *ui, HlAttrs attrs) static void print_cell(UI *ui, UCell *ptr) { + TUIData *data = ui->data; + UGrid *grid = &data->grid; + if (data->immediate_wrap_after_last_column + && grid->row >= ui->height - 1 + && grid->col >= ui->width - 1) { + // This (rare) kind of terminal simply cannot print in this corner without + // scrolling the entire screen up a line, which we do not want to happen. + return; + } update_attrs(ui, ptr->attrs); out(ui, ptr->data, strlen(ptr->data)); + ++grid->col; } static bool cheap_to_print(UI *ui, int row, int col, int next) @@ -451,7 +461,9 @@ static void check_final_column_wrap(UI *ui) UGrid *grid = &data->grid; if (grid->col == ui->width) { grid->col = 0; - ++grid->row; + if (grid->row < ui->height) { + ++grid->row; + } } } @@ -491,7 +503,6 @@ static void cursor_goto(UI *ui, int row, int col) UGRID_FOREACH_CELL(grid, grid->row, grid->row, grid->col, col - 1, { print_cell(ui, cell); - ++grid->col; check_final_column_wrap(ui); }); } @@ -600,7 +611,6 @@ static void clear_region(UI *ui, int top, int bot, int left, int right) UGRID_FOREACH_CELL(grid, top, bot, left, right, { cursor_goto(ui, row, col); print_cell(ui, cell); - ++grid->col; check_final_column_wrap(ui); }); } @@ -915,7 +925,15 @@ static void tui_highlight_set(UI *ui, HlAttrs attrs) static void tui_put(UI *ui, String text) { TUIData *data = ui->data; - print_cell(ui, ugrid_put(&data->grid, (uint8_t *)text.data, text.size)); + UGrid *grid = &data->grid; + UCell *cell; + + cell = ugrid_put(&data->grid, (uint8_t *)text.data, text.size); + // ugrid_put does not advance the cursor correctly, as the actual terminal + // will when we print. Its cursor motion model is simplistic and wrong. So + // we have to undo what it has just done before doing it right. + --grid->col; + print_cell(ui, cell); check_final_column_wrap(ui); } @@ -969,7 +987,6 @@ static void tui_flush(UI *ui) UGRID_FOREACH_CELL(grid, r.top, r.bot, r.left, r.right, { cursor_goto(ui, row, col); print_cell(ui, cell); - ++grid->col; check_final_column_wrap(ui); }); } -- cgit From 7cbf52db1bdfb0184ee1b1b8ba9c7df77615ca20 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Tue, 30 May 2017 23:08:47 +0100 Subject: tui: Separate out built-in terminfo records. They are now in their own nvim/tui/terminfo.c file. Also turn the TERMINAL_FAMILY macro into a function. Use the terminfo_ prefix for its name as other parts of the program are unlikely to want that namespace, and the prefix is already used for some other TUI functions. --- src/nvim/tui/terminfo.c | 108 ++++ src/nvim/tui/terminfo.h | 8 + src/nvim/tui/tui.c | 1410 ++--------------------------------------------- 3 files changed, 149 insertions(+), 1377 deletions(-) create mode 100644 src/nvim/tui/terminfo.c create mode 100644 src/nvim/tui/terminfo.h (limited to 'src') diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c new file mode 100644 index 0000000000..9492f3ddb1 --- /dev/null +++ b/src/nvim/tui/terminfo.c @@ -0,0 +1,108 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + +// Built-in fallback terminfo entries. + +#include + +#include "nvim/tui/terminfo.h" +#include "nvim/tui/tui.h" + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "tui/terminfo.c.generated.h" +#endif + +// One creates the dumps from terminfo.src by using +// od -t d1 -w | cut -c9- | sed -e 's/\>/,/g' +// on the compiled files. + +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +// This is a 256-colour terminfo description that lacks true-colour and +// DECSTBM/DECSLRM/DECLRMM capabilities that xterm actually has. +static const signed char xterm_256colour_terminfo[] = { + 26, 1, 37, 0, 29, 0, 15, 0, 105, 1, -42, 5, 120, 116, 101, 114, 109, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 120, 116, 101, 114, 109, 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, 38, 0, 42, 0, 46, 0, -1, -1, 57, 0, 74, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, 102, 0, -1, -1, 106, 0, 110, 0, 120, 0, 124, 0, -1, -1, -1, -1,-128, 0,-124, 0,-119, 0,-114, 0, -1, -1,-105, 0,-100, 0, -95, 0, -1, -1, -90, 0, -85, 0, -80, 0, -75, 0, -66, 0, -62, 0, -55, 0, -1, -1, -46, 0, -41, 0, -35, 0, -29, 0, -1, -1, -1, -1, -1, -1, -11, 0, -1, -1, -1, -1, -1, -1, 7, 1, -1, -1, 11, 1, -1, -1, -1, -1, -1, -1, 13, 1, -1, -1, 18, 1, -1, -1, -1, -1, -1, -1, -1, -1, 22, 1, 26, 1, 32, 1, 36, 1, 40, 1, 44, 1, 50, 1, 56, 1, 62, 1, 68, 1, 74, 1, 78, 1, -1, -1, 83, 1, -1, -1, 87, 1, 92, 1, 97, 1, 101, 1, 108, 1, -1, -1, 115, 1, 119, 1, 127, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-121, 1,-112, 1, -1, -1, -1, -1,-103, 1, -94, 1, -85, 1, -76, 1, -67, 1, -58, 1, -49, 1, -40, 1, -31, 1, -22, 1, -1, -1, -1, -1, -1, -1, -13, 1, -9, 1, -4, 1, -1, -1, 1, 2, 10, 2, -1, -1, -1, -1, 28, 2, 31, 2, 42, 2, 45, 2, 47, 2, 50, 2,-113, 2, -1, -1,-110, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-108, 2, -1, -1, -1, -1, -1, -1, -1, -1,-104, 2, -1, -1, -51, 2, -1, -1, -1, -1, -47, 2, -41, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -35, 2, -31, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -27, 2, -1, -1, -1, -1, -20, 2, -1, -1, -1, -1, -1, -1, -1, -1, -13, 2, -6, 2, 1, 3, -1, -1, -1, -1, 8, 3, -1, -1, 15, 3, -1, -1, -1, -1, -1, -1, 22, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, 3, 35, 3, 41, 3, 48, 3, 55, 3, 62, 3, 69, 3, 77, 3, 85, 3, 93, 3, 101, 3, 109, 3, 117, 3, 125, 3,-123, 3,-116, 3,-109, 3,-102, 3, -95, 3, -87, 3, -79, 3, -71, 3, -63, 3, -55, 3, -47, 3, -39, 3, -31, 3, -24, 3, -17, 3, -10, 3, -3, 3, 5, 4, 13, 4, 21, 4, 29, 4, 37, 4, 45, 4, 53, 4, 61, 4, 68, 4, 75, 4, 82, 4, 89, 4, 97, 4, 105, 4, 113, 4, 121, 4,-127, 4,-119, 4,-111, 4,-103, 4, -96, 4, -89, 4, -82, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -77, 4, -66, 4, -61, 4, -42, 4, -38, 4, -29, 4, -22, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 72, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 83, 5, -1, -1, -1, -1, -1, -1, 87, 5,-106, 5, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 49, 50, 108, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 63, 49, 50, 59, 50, 53, 104, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 40, 48, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, 48, 52, 57, 104, 0, 27, 91, 50, 109, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 27, 40, 66, 0, 27, 40, 66, 27, 91, 109, 0, 27, 91, 63, 49, 48, 52, 57, 108, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 27, 91, 33, 112, 27, 91, 63, 51, 59, 52, 108, 27, 91, 52, 108, 27, 62, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 79, 72, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 91, 49, 59, 50, 66, 0, 27, 91, 49, 59, 50, 65, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 91, 63, 49, 48, 51, 52, 108, 0, 27, 91, 63, 49, 48, 51, 52, 104, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 105, 0, 27, 91, 52, 105, 0, 27, 91, 53, 105, 0, 27, 99, 27, 93, 49, 48, 52, 7, 0, 27, 91, 33, 112, 27, 91, 63, 51, 59, 52, 108, 27, 91, 52, 108, 27, 62, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 37, 63, 37, 112, 57, 37, 116, 27, 40, 48, 37, 101, 27, 40, 66, 37, 59, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 53, 37, 116, 59, 50, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 109, 0, 27, 72, 0, 9, 0, 27, 79, 69, 0, 96, 96, 97, 97, 102, 102, 103, 103, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 79, 70, 0, 27, 79, 77, 0, 27, 91, 51, 59, 50, 126, 0, 27, 91, 49, 59, 50, 70, 0, 27, 91, 49, 59, 50, 72, 0, 27, 91, 50, 59, 50, 126, 0, 27, 91, 49, 59, 50, 68, 0, 27, 91, 54, 59, 50, 126, 0, 27, 91, 53, 59, 50, 126, 0, 27, 91, 49, 59, 50, 67, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 59, 50, 80, 0, 27, 91, 49, 59, 50, 81, 0, 27, 91, 49, 59, 50, 82, 0, 27, 91, 49, 59, 50, 83, 0, 27, 91, 49, 53, 59, 50, 126, 0, 27, 91, 49, 55, 59, 50, 126, 0, 27, 91, 49, 56, 59, 50, 126, 0, 27, 91, 49, 57, 59, 50, 126, 0, 27, 91, 50, 48, 59, 50, 126, 0, 27, 91, 50, 49, 59, 50, 126, 0, 27, 91, 50, 51, 59, 50, 126, 0, 27, 91, 50, 52, 59, 50, 126, 0, 27, 91, 49, 59, 53, 80, 0, 27, 91, 49, 59, 53, 81, 0, 27, 91, 49, 59, 53, 82, 0, 27, 91, 49, 59, 53, 83, 0, 27, 91, 49, 53, 59, 53, 126, 0, 27, 91, 49, 55, 59, 53, 126, 0, 27, 91, 49, 56, 59, 53, 126, 0, 27, 91, 49, 57, 59, 53, 126, 0, 27, 91, 50, 48, 59, 53, 126, 0, 27, 91, 50, 49, 59, 53, 126, 0, 27, 91, 50, 51, 59, 53, 126, 0, 27, 91, 50, 52, 59, 53, 126, 0, 27, 91, 49, 59, 54, 80, 0, 27, 91, 49, 59, 54, 81, 0, 27, 91, 49, 59, 54, 82, 0, 27, 91, 49, 59, 54, 83, 0, 27, 91, 49, 53, 59, 54, 126, 0, 27, 91, 49, 55, 59, 54, 126, 0, 27, 91, 49, 56, 59, 54, 126, 0, 27, 91, 49, 57, 59, 54, 126, 0, 27, 91, 50, 48, 59, 54, 126, 0, 27, 91, 50, 49, 59, 54, 126, 0, 27, 91, 50, 51, 59, 54, 126, 0, 27, 91, 50, 52, 59, 54, 126, 0, 27, 91, 49, 59, 51, 80, 0, 27, 91, 49, 59, 51, 81, 0, 27, 91, 49, 59, 51, 82, 0, 27, 91, 49, 59, 51, 83, 0, 27, 91, 49, 53, 59, 51, 126, 0, 27, 91, 49, 55, 59, 51, 126, 0, 27, 91, 49, 56, 59, 51, 126, 0, 27, 91, 49, 57, 59, 51, 126, 0, 27, 91, 50, 48, 59, 51, 126, 0, 27, 91, 50, 49, 59, 51, 126, 0, 27, 91, 50, 51, 59, 51, 126, 0, 27, 91, 50, 52, 59, 51, 126, 0, 27, 91, 49, 59, 52, 80, 0, 27, 91, 49, 59, 52, 81, 0, 27, 91, 49, 59, 52, 82, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 37, 91, 59, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 93, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 93, 49, 48, 52, 7, 0, 27, 93, 52, 59, 37, 112, 49, 37, 100, 59, 114, 103, 98, 58, 37, 112, 50, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 52, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 27, 92, 0, 27, 91, 51, 109, 0, 27, 91, 50, 51, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 +}; +// Taken from unibilium/t/static_tmux.c as of 2015-08-14. +// This is an 256-colour terminfo description that lacks +// status line capabilities that tmux actually has. +static const signed char tmux_256colour_terminfo[] = { + 26, 1, 56, 0, 15, 0, 15, 0, 105, 1, -48, 2, 116, 109, 117, 120, 124, 86, 84, 32, 49, 48, 48, 47, 65, 78, 83, 73, 32, 88, 51, 46, 54, 52, 32, 118, 105, 114, 116, 117, 97, 108, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, -1, -1, -1, -1, 45, 0, 62, 0, 64, 0, 68, 0, 75, 0, -1, -1, 77, 0, 89, 0, -1, -1, 93, 0, 96, 0, 102, 0, 106, 0, -1, -1, -1, -1, 110, 0, 112, 0, 117, 0, 122, 0, -1, -1, -1, -1, 123, 0, -1, -1, -1, -1, -128, 0, -123, 0, -118, 0, -1, -1, -113, 0, -111, 0, -106, 0, -1, -1, -105, 0, -100, 0, -94, 0, -88, 0, -1, -1, -1, -1, -1, -1, -85, 0, -1, -1, -1, -1, -1, -1, -81, 0, -1, -1, -77, 0, -1, -1, -1, -1, -1, -1, -75, 0, -1, -1, -70, 0, -1, -1, -1, -1, -1, -1, -1, -1, -66, 0, -62, 0, -56, 0, -52, 0, -48, 0, -44, 0, -38, 0, -32, 0, -26, 0, -20, 0, -14, 0, -9, 0, -1, -1, -4, 0, -1, -1, 0, 1, 5, 1, 10, 1, -1, -1, -1, -1, -1, -1, 14, 1, 18, 1, 26, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, 1, -1, -1, 37, 1, 46, 1, 55, 1, 64, 1, -1, -1, 73, 1, 82, 1, 91, 1, -1, -1, 100, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 109, 1, -1, -1, -1, -1, 126, 1, -1, -1, -127, 1, -124, 1, -122, 1, -119, 1, -46, 1, -1, -1, -43, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -41, 1, -1, -1, 24, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 35, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 40, 2, 46, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 52, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 57, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 66, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 71, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, 2, -1, -1, -1, -1, -1, -1, 81, 2, -112, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 51, 52, 104, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 51, 52, 108, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 15, 0, 27, 91, 109, 15, 0, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 103, 0, 27, 41, 48, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 69, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 43, 43, 44, 44, 45, 45, 46, 46, 48, 48, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, 41, 48, 0, 27, 91, 52, 126, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 109, 0, 27, 91, 50, 51, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 +}; +// Taken from unibilium/t/static_screen-256color.c as of 2015-08-14. +// This is an 256-colour terminfo description that lacks +// status line capabilities that screen actually has. +static const signed char screen_256colour_terminfo[] = { + 26, 1, 43, 0, 43, 0, 15, 0, 105, 1, -43, 2, 115, 99, 114, 101, 101, 110, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 71, 78, 85, 32, 83, 99, 114, 101, 101, 110, 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, -1, -1, -1, -1, 45, 0, 62, 0, 64, 0, 68, 0, 75, 0, -1, -1, 77, 0, 89, 0, -1, -1, 93, 0, 96, 0, 102, 0, 106, 0, -1, -1, -1, -1, 110, 0, 112, 0, 117, 0, 122, 0, -1, -1, -1, -1, -125, 0, -1, -1, -1, -1, -120, 0, -115, 0, -110, 0, -1, -1, -105, 0, -103, 0, -98, 0, -1, -1, -89, 0, -84, 0, -78, 0, -72, 0, -1, -1, -1, -1, -1, -1, -69, 0, -1, -1, -1, -1, -1, -1, -65, 0, -1, -1, -61, 0, -1, -1, -1, -1, -1, -1, -59, 0, -1, -1, -54, 0, -1, -1, -1, -1, -1, -1, -1, -1, -50, 0, -46, 0, -40, 0, -36, 0, -32, 0, -28, 0, -22, 0, -16, 0, -10, 0, -4, 0, 2, 1, 7, 1, -1, -1, 12, 1, -1, -1, 16, 1, 21, 1, 26, 1, -1, -1, -1, -1, -1, -1, 30, 1, 34, 1, 42, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 1, -1, -1, 53, 1, 62, 1, 71, 1, 80, 1, -1, -1, 89, 1, 98, 1, 107, 1, -1, -1, 116, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 125, 1, -1, -1, -1, -1, -114, 1, -1, -1, -111, 1, -108, 1, -106, 1, -103, 1, -30, 1, -1, -1, -27, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -25, 1, -1, -1, 40, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 51, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 56, 2, 62, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 73, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 82, 2, -1, -1, -1, -1, -1, -1, 86, 2, -107, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 51, 52, 104, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 51, 52, 108, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, 48, 52, 57, 104, 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 51, 109, 0, 27, 91, 52, 109, 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 63, 49, 48, 52, 57, 108, 0, 27, 91, 52, 108, 0, 27, 91, 50, 51, 109, 0, 27, 91, 50, 52, 109, 0, 27, 103, 0, 27, 41, 48, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 69, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 49, 37, 116, 59, 51, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 43, 43, 44, 44, 45, 45, 46, 46, 48, 48, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, 41, 48, 0, 27, 91, 52, 126, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 0, 3, 0, 1, 0, 24, 0, 52, 0, -112, 0, 1, 1, 0, 0, 1, 0, 0, 0, 4, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 3, 0, 6, 0, 9, 0, 12, 0, 15, 0, 18, 0, 23, 0, 28, 0, 32, 0, 37, 0, 43, 0, 49, 0, 55, 0, 61, 0, 66, 0, 71, 0, 77, 0, 83, 0, 89, 0, 95, 0, 101, 0, 107, 0, 111, 0, 116, 0, 120, 0, 124, 0, -128, 0, 27, 40, 66, 0, 27, 40, 37, 112, 49, 37, 99, 0, 65, 88, 0, 71, 48, 0, 88, 84, 0, 85, 56, 0, 69, 48, 0, 83, 48, 0, 107, 68, 67, 53, 0, 107, 68, 67, 54, 0, 107, 68, 78, 0, 107, 68, 78, 53, 0, 107, 69, 78, 68, 53, 0, 107, 69, 78, 68, 54, 0, 107, 72, 79, 77, 53, 0, 107, 72, 79, 77, 54, 0, 107, 73, 67, 53, 0, 107, 73, 67, 54, 0, 107, 76, 70, 84, 53, 0, 107, 78, 88, 84, 53, 0, 107, 78, 88, 84, 54, 0, 107, 80, 82, 86, 53, 0, 107, 80, 82, 86, 54, 0, 107, 82, 73, 84, 53, 0, 107, 85, 80, 0, 107, 85, 80, 53, 0, 107, 97, 50, 0, 107, 98, 49, 0, 107, 98, 51, 0, 107, 99, 50, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +static const signed char iterm_256colour_terminfo[] = { + 26, 1, 57, 0, 29, 0, 15, 0, 105, 1, 73, 3, 105, 84, 101, 114, 109, 46, 97, 112, 112, 124, 105, 116, 101, 114, 109, 124, 105, 84, 101, 114, 109, 46, 97, 112, 112, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 101, 109, 117, 108, 97, 116, 111, 114, 32, 102, 111, 114, 32, 77, 97, 99, 32, 79, 83, 32, 88, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, 50, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, -1, -1, 0, 0, 2, 0, -2, -1, 4, 0, 9, 0, 16, 0, 20, 0, 24, 0, -1, -1, 35, 0, 52, 0, 54, 0, 58, 0, 65, 0, -1, -1, 67, 0, 74, 0, -1, -1, 78, 0, -1, -1, 82, 0, 86, 0, 90, 0, -1, -1, 96, 0, 98, 0, 103, 0, 108, 0, -1, -1, -2, -1, 117, 0, 122, 0, -1, -1, 127, 0,-124, 0,-119, 0, -1, -1,-114, 0,-112, 0,-107, 0, -1, -1, -94, 0, -89, 0, -85, 0, -81, 0, -1, -1, -63, 0, -1, -1, -1, -1, -1, -1, -1, -1, -61, 0, -57, 0, -1, -1, -53, 0, -1, -1, -1, -1, -1, -1, -51, 0, -1, -1, -46, 0, -1, -1, -1, -1, -1, -1, -1, -1, -42, 0, -38, 0, -32, 0, -28, 0, -24, 0, -20, 0, -14, 0, -8, 0, -2, 0, 4, 1, 10, 1, -1, -1, -1, -1, 14, 1, -1, -1, 18, 1, 23, 1, 28, 1, -1, -1, -1, -1, -1, -1, 32, 1, 36, 1, 44, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 52, 1, 61, 1, 70, 1, 79, 1, -1, -1, 88, 1, 97, 1, 106, 1, -1, -1, 115, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 124, 1, -1, -1, -1, -1,-104, 1,-101, 1, -90, 1, -87, 1, -85, 1, -82, 1, -4, 1, -1, -1, -1, 1, 1, 2, -1, -1, -1, -1, -1, -1, 6, 2, 10, 2, 14, 2, 18, 2, 22, 2, -1, -1, -1, -1, 26, 2, -1, -1, -1, -1, -1, -1, -1, -1, 77, 2, 83, 2, -1, -1, -1, -1, 89, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 2, 100, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, 2, 110, 2, 116, 2, 122, 2,-128, 2,-122, 2,-116, 2,-110, 2, 104, 2, -98, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -92, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -87, 2, -76, 2, -71, 2, -63, 2, -59, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -54, 2, 9, 3, 7, 0, 13, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 93, 50, 59, 7, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 55, 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 50, 74, 27, 91, 63, 52, 55, 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, 91, 109, 0, 27, 91, 109, 0, 27, 91, 63, 53, 104, 36, 60, 50, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 7, 0, 27, 91, 64, 0, 27, 91, 76, 0, 127, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 79, 72, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 62, 27, 91, 63, 51, 108, 27, 91, 63, 52, 108, 27, 91, 63, 53, 108, 27, 91, 63, 55, 104, 27, 91, 63, 56, 104, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 93, 50, 59, 0, 27, 79, 113, 0, 27, 79, 115, 0, 27, 79, 114, 0, 27, 79, 112, 0, 27, 79, 110, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 40, 66, 27, 41, 48, 0, 27, 79, 70, 0, 27, 79, 77, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, 0, 27, 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, 51, 49, 126, 0, 27, 91, 50, 50, 126, 0, 27, 91, 51, 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 49, 59, 50, 99, 0, 27, 91, 99, 0, 27, 91, 48, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +// This is a 256-colour terminfo description that lacks true-colour +// capabilities that rxvt actually has. +static const signed char rxvt_256colour_terminfo[] = { + 26, 1, 47, 0, 29, 0, 15, 0, 110, 1, -31, 4, 114, 120, 118, 116, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 114, 120, 118, 116, 32, 50, 46, 55, 46, 57, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, 32, 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, -1, -1, 0, 0, 2, 0, 4, 0, 21, 0, 26, 0, 34, 0, 38, 0, 42, 0, -1, -1, 53, 0, 70, 0, 72, 0, 76, 0, 83, 0, -1, -1, 85, 0, 92, 0, -1, -1, 96, 0, -1, -1, -1, -1, 100, 0, -1, -1, -1, -1, 104, 0, 106, 0, 111, 0, 116, 0, -1, -1, -1, -1, 125, 0, -1, -1, -1, -1,-126, 0,-121, 0,-116, 0, -1, -1,-111, 0,-109, 0,-104, 0, -1, -1, -91, 0, -86, 0, -80, 0, -74, 0, -1, -1, -1, -1, -56, 0, -42, 0, -1, -1, -1, -1, -8, 0, -4, 0, -1, -1, 0, 1, -1, -1, -1, -1, -1, -1, 2, 1, -1, -1, 7, 1, -1, -1, 11, 1, -1, -1, 16, 1, 22, 1, 28, 1, 34, 1, 40, 1, 46, 1, 52, 1, 58, 1, 64, 1, 70, 1, 76, 1, 82, 1, 87, 1, -1, -1, 92, 1, -1, -1, 96, 1, 101, 1, 106, 1, 110, 1, 114, 1, -1, -1, 118, 1, 122, 1, 125, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-128, 1,-119, 1,-110, 1, -1, -1,-101, 1, -92, 1, -83, 1, -1, -1, -74, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -65, 1, -32, 1, -1, -1, -1, -1, 18, 2, 21, 2, 32, 2, 35, 2, 37, 2, 40, 2, 107, 2, -1, -1, 110, 2, -1, -1, -1, -1, -1, -1, -1, -1, 112, 2, 116, 2, 120, 2, 124, 2,-128, 2, -1, -1, -1, -1,-124, 2, -1, -1, -73, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -69, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -62, 2, -57, 2, -1, -1, -53, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -48, 2, -1, -1, -43, 2, -38, 2, -1, -1, -1, -1, -1, -1, -1, -1, -33, 2, -28, 2, -23, 2, -1, -1, -1, -1, -19, 2, -1, -1, -14, 2, -1, -1, -1, -1, -1, -1, -9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -5, 2, 1, 3, 7, 3, 13, 3, 19, 3, 25, 3, 31, 3, 37, 3, 43, 3, 49, 3, 55, 3, 61, 3, 67, 3, 73, 3, 79, 3, 85, 3, 91, 3, 97, 3, 103, 3, 109, 3, 115, 3, 121, 3, 127, 3,-123, 3,-117, 3,-111, 3,-105, 3, -99, 3, -93, 3, -87, 3, -81, 3, -75, 3, -69, 3, -63, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -57, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -52, 3, -41, 3, -36, 3, -28, 3, -24, 3, -15, 3, -8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, 4, -1, -1, -1, -1, -1, -1, 90, 4,-103, 4, -1, -1, -1, -1, -1, -1, -39, 4, -35, 4, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 55, 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 50, 74, 27, 91, 63, 52, 55, 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 27, 91, 63, 52, 55, 108, 27, 61, 27, 91, 63, 49, 108, 0, 27, 91, 114, 27, 91, 109, 27, 91, 50, 74, 27, 91, 72, 27, 91, 63, 55, 104, 27, 91, 63, 49, 59, 51, 59, 52, 59, 54, 108, 27, 91, 52, 108, 0, 27, 91, 64, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 91, 66, 0, 27, 91, 56, 94, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, 49, 126, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, 50, 126, 0, 27, 91, 49, 51, 126, 0, 27, 91, 49, 52, 126, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 55, 126, 0, 27, 91, 50, 126, 0, 27, 91, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 91, 67, 0, 27, 91, 97, 0, 27, 91, 98, 0, 27, 91, 65, 0, 27, 62, 0, 27, 61, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 62, 27, 91, 49, 59, 51, 59, 52, 59, 53, 59, 54, 108, 27, 91, 63, 55, 104, 27, 91, 109, 27, 91, 114, 27, 91, 50, 74, 27, 91, 72, 0, 27, 91, 114, 27, 91, 109, 27, 91, 50, 74, 27, 91, 72, 27, 91, 63, 55, 104, 27, 91, 63, 49, 59, 51, 59, 52, 59, 54, 108, 27, 91, 52, 108, 27, 62, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 79, 119, 0, 27, 79, 121, 0, 27, 79, 117, 0, 27, 79, 113, 0, 27, 79, 115, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, 41, 48, 0, 27, 91, 56, 126, 0, 27, 79, 77, 0, 27, 91, 49, 126, 0, 27, 91, 51, 36, 0, 27, 91, 52, 126, 0, 27, 91, 56, 36, 0, 27, 91, 55, 36, 0, 27, 91, 50, 36, 0, 27, 91, 100, 0, 27, 91, 54, 36, 0, 27, 91, 53, 36, 0, 27, 91, 99, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, 0, 27, 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, 51, 49, 126, 0, 27, 91, 51, 50, 126, 0, 27, 91, 51, 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 50, 51, 36, 0, 27, 91, 50, 52, 36, 0, 27, 91, 49, 49, 94, 0, 27, 91, 49, 50, 94, 0, 27, 91, 49, 51, 94, 0, 27, 91, 49, 52, 94, 0, 27, 91, 49, 53, 94, 0, 27, 91, 49, 55, 94, 0, 27, 91, 49, 56, 94, 0, 27, 91, 49, 57, 94, 0, 27, 91, 50, 48, 94, 0, 27, 91, 50, 49, 94, 0, 27, 91, 50, 51, 94, 0, 27, 91, 50, 52, 94, 0, 27, 91, 50, 53, 94, 0, 27, 91, 50, 54, 94, 0, 27, 91, 50, 56, 94, 0, 27, 91, 50, 57, 94, 0, 27, 91, 51, 49, 94, 0, 27, 91, 51, 50, 94, 0, 27, 91, 51, 51, 94, 0, 27, 91, 51, 52, 94, 0, 27, 91, 50, 51, 64, 0, 27, 91, 50, 52, 64, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 49, 59, 50, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 93, 49, 48, 52, 7, 0, 27, 93, 52, 59, 37, 112, 49, 37, 100, 59, 114, 103, 98, 58, 37, 112, 50, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 52, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 27, 92, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 40, 66, 0, 27, 40, 48, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +// This is a 16-colour terminfo description that lacks true-colour +// and 256-colour capabilities that linux (4.8+) actually has. +static const signed char linux_16colour_terminfo[] = { + 26, 1, 43, 0, 29, 0, 16, 0, 125, 1, 125, 3, 108, 105, 110, 117, 120, 45, 49, 54, 99, 111, 108, 111, 114, 124, 108, 105, 110, 117, 120, 32, 99, 111, 110, 115, 111, 108, 101, 32, 119, 105, 116, 104, 32, 49, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, -1, -1, 8, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, 0, 0, 1, 42, 0, -1, -1, 0, 0, 2, 0, 4, 0, 21, 0, 26, 0, 33, 0, 37, 0, 41, 0, -1, -1, 52, 0, 69, 0, 71, 0, 75, 0, 87, 0, -1, -1, 89, 0, 101, 0, -1, -1, 105, 0, 109, 0, 121, 0, 125, 0, -1, -1, -1, -1,-127, 0,-125, 0,-120, 0, -1, -1, -1, -1,-115, 0,-110, 0, -1, -1, -1, -1,-105, 0,-100, 0, -95, 0, -90, 0, -81, 0, -79, 0, -1, -1, -1, -1, -74, 0, -69, 0, -63, 0, -57, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -39, 0, -35, 0, -1, -1, -31, 0, -1, -1, -1, -1, -1, -1, -29, 0, -1, -1, -24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -20, 0, -15, 0, -9, 0, -4, 0, 1, 1, 6, 1, 11, 1, 17, 1, 23, 1, 29, 1, 35, 1, 40, 1, -1, -1, 45, 1, -1, -1, 49, 1, 54, 1, 59, 1, -1, -1, -1, -1, -1, -1, 63, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 67, 1, -1, -1, 70, 1, 79, 1, 88, 1, 97, 1, -1, -1, 106, 1, 115, 1, 124, 1, -1, -1,-123, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-114, 1, -1, -1, -1, -1, -1, -1,-108, 1,-105, 1, -94, 1, -91, 1, -89, 1, -86, 1, 1, 2, -1, -1, 4, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, 10, 2, -1, -1, 77, 2, -1, -1, -1, -1, 81, 2, 87, 2, -1, -1, -1, -1, 93, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 97, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 102, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 104, 2, 110, 2, 116, 2, 122, 2,-128, 2,-122, 2,-116, 2,-110, 2,-104, 2, -98, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -92, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -87, 2, -76, 2, -71, 2, -65, 2, -61, 2, -52, 2, -48, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 3, -1, -1, -1, -1, -1, -1, 37, 3, 75, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 113, 3, 119, 3, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 27, 91, 63, 49, 99, 0, 8, 0, 27, 91, 63, 50, 53, 104, 27, 91, 63, 48, 99, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 63, 50, 53, 104, 27, 91, 63, 56, 99, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 50, 109, 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 50, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 27, 91, 64, 0, 27, 91, 76, 0, 127, 0, 27, 91, 51, 126, 0, 27, 91, 66, 0, 27, 91, 91, 65, 0, 27, 91, 50, 49, 126, 0, 27, 91, 91, 66, 0, 27, 91, 91, 67, 0, 27, 91, 91, 68, 0, 27, 91, 91, 69, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 91, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 93, 82, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 59, 49, 48, 37, 63, 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 53, 37, 116, 59, 50, 37, 59, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 91, 71, 0, 43, 43, 44, 44, 45, 45, 46, 46, 48, 48, 95, 95, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 99, 126, 126, 0, 27, 91, 90, 0, 27, 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 41, 48, 0, 27, 91, 52, 126, 0, 26, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, 0, 27, 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, 51, 49, 126, 0, 27, 91, 51, 50, 126, 0, 27, 91, 51, 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 54, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 93, 82, 0, 27, 93, 80, 37, 112, 49, 37, 120, 37, 112, 50, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 37, 112, 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 37, 112, 52, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 0, 27, 91, 77, 0, 27, 91, 51, 37, 112, 49, 37, 123, 56, 125, 37, 109, 37, 100, 37, 63, 37, 112, 49, 37, 123, 55, 125, 37, 62, 37, 116, 59, 49, 37, 101, 59, 50, 49, 37, 59, 109, 0, 27, 91, 52, 37, 112, 49, 37, 123, 56, 125, 37, 109, 37, 100, 37, 63, 37, 112, 49, 37, 123, 55, 125, 37, 62, 37, 116, 59, 53, 37, 101, 59, 50, 53, 37, 59, 109, 0, 27, 91, 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +static const signed char putty_256colour_terminfo[] = { + 26, 1, 48, 0, 29, 0, 16, 0, 125, 1,-106, 4, 112, 117, 116, 116, 121, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 80, 117, 84, 84, 89, 32, 48, 46, 53, 56, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, 32, 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, -1, -1, 8, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 22, 0, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, 45, 0, -1, -1, 56, 0, 73, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, 96, 0, -1, -1, 100, 0, -1, -1, 103, 0, 107, 0, 111, 0, -1, -1, 117, 0, 119, 0, 124, 0,-127, 0, -1, -1, -1, -1,-120, 0, -1, -1, -1, -1,-115, 0,-110, 0,-105, 0,-100, 0, -91, 0, -89, 0, -84, 0, -1, -1, -73, 0, -68, 0, -62, 0, -56, 0, -1, -1, -38, 0, -1, -1, -36, 0, -1, -1, -1, -1, -1, -1, -2, 0, -1, -1, 2, 1, -1, -1, -1, -1, -1, -1, 4, 1, -1, -1, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, 13, 1, 19, 1, 25, 1, 31, 1, 37, 1, 43, 1, 49, 1, 55, 1, 61, 1, 67, 1, 73, 1, 78, 1, -1, -1, 83, 1, -1, -1, 87, 1, 92, 1, 97, 1, 101, 1, 105, 1, -1, -1, 109, 1, 113, 1, 121, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-127, 1, -1, -1,-124, 1,-115, 1,-106, 1, -1, -1, -97, 1, -88, 1, -79, 1, -70, 1, -61, 1, -52, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -43, 1, -1, -1, -1, -1, -10, 1, -7, 1, 4, 2, 7, 2, 9, 2, 12, 2, 84, 2, -1, -1, 87, 2, 89, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 94, 2, -1, -1, -1, -1, -1, -1, -1, -1, 98, 2, -1, -1,-107, 2, -1, -1, -1, -1,-103, 2, -97, 2, -1, -1, -1, -1, -91, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -84, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -79, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -77, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -73, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -69, 2, -63, 2, -57, 2, -51, 2, -45, 2, -39, 2, -33, 2, -27, 2, -21, 2, -15, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -4, 2, 7, 3, 12, 3, 18, 3, 22, 3, 31, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 35, 3, -1, -1, -1, -1, -1, -1, 39, 3, 102, 3, -1, -1, -1, -1, -1, -1, -90, 3, -84, 3, -78, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -72, 3,-118, 4,-112, 4, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 27, 68, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 93, 48, 59, 7, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 50, 74, 27, 91, 63, 52, 55, 108, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 7, 0, 27, 55, 27, 91, 114, 27, 91, 109, 27, 91, 63, 55, 104, 27, 91, 63, 49, 59, 52, 59, 54, 108, 27, 91, 52, 108, 27, 56, 27, 62, 27, 93, 82, 0, 27, 91, 76, 0, 127, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 91, 49, 49, 126, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, 50, 126, 0, 27, 91, 49, 51, 126, 0, 27, 91, 49, 52, 126, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 91, 66, 0, 27, 91, 65, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 60, 27, 91, 34, 112, 27, 91, 53, 48, 59, 54, 34, 112, 27, 99, 27, 91, 63, 51, 108, 27, 93, 82, 27, 91, 63, 49, 48, 48, 48, 108, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 49, 37, 112, 54, 37, 124, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 93, 48, 59, 0, 27, 91, 71, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 40, 66, 27, 41, 48, 0, 27, 91, 52, 126, 0, 26, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, 0, 27, 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, 51, 49, 126, 0, 27, 91, 51, 50, 126, 0, 27, 91, 51, 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 54, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 93, 82, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 49, 48, 109, 0, 27, 91, 49, 49, 109, 0, 27, 91, 49, 50, 109, 0, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-105,-104, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 48, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-105,-103, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 50, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-103,-128, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 51, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-103, -86, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 52, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-103, -85, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 53, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-104, -68, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 50, 55, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-122,-112, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 53, 53, 125, 37, 61, 37, 116, 27, 37, 37, 71, -32,-126, -94, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 99, 37, 59, 0, 27, 91, 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +static const signed char interix_8colour_terminfo[] = { + 26, 1, 82, 0, 15, 0, 16, 0, 105, 1, 123, 2, 105, 110, 116, 101, 114, 105, 120, 124, 111, 112, 101, 110, 110, 116, 124, 111, 112, 101, 110, 110, 116, 45, 50, 53, 124, 110, 116, 99, 111, 110, 115, 111, 108, 101, 124, 110, 116, 99, 111, 110, 115, 111, 108, 101, 45, 50, 53, 124, 79, 112, 101, 110, 78, 84, 45, 116, 101, 114, 109, 32, 99, 111, 109, 112, 97, 116, 105, 98, 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, 108, 111, 114, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 80, 0, -1, -1, 25, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, 0, 64, 0, 3, 0, 0, 0, 4, 0, -1, -1, -1, -1, -1, -1, 6, 0, 11, 0, 15, 0, -1, -1, -1, -1, 19, 0, 36, 0, 38, 0, -1, -1, 42, 0, -1, -1, -1, -1, 46, 0, 50, 0, 54, 0, -1, -1, -1, -1, 58, 0, -1, -1, -1, -1, -1, -1, -1, -1, 62, 0, 67, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 75, 0, 80, 0, 85, 0, -1, -1, -1, -1, 90, 0, 95, 0, -1, -1, -1, -1, 107, 0, 111, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 115, 0, -1, -1, 119, 0, -1, -1, -1, -1, -1, -1, 121, 0, -1, -1, 125, 0, -1, -1, -1, -1, -1, -1,-127, 0,-123, 0,-119, 0,-115, 0,-111, 0,-107, 0,-103, 0, -99, 0, -95, 0, -91, 0, -87, 0, -1, -1, -83, 0, -1, -1, -79, 0, -75, 0, -71, 0, -67, 0, -63, 0, -1, -1, -1, -1, -1, -1, -59, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -55, 0, -1, -1, -1, -1, -52, 0, -43, 0, -1, -1, -34, 0, -25, 0, -16, 0, -7, 0, 2, 1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 1, -1, -1, -1, -1, -1, -1, 23, 1, -1, -1, 27, 1, 31, 1, 35, 1, -1, -1, -1, -1, -1, -1, 39, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, 1, -1, -1, 104, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 108, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 112, 1, 116, 1, 120, 1, 124, 1,-128, 1,-124, 1,-120, 1,-116, 1,-112, 1,-108, 1,-104, 1,-100, 1, -96, 1, -92, 1, -88, 1, -84, 1, -80, 1, -76, 1, -72, 1, -68, 1, -64, 1, -60, 1, -56, 1, -52, 1, -48, 1, -44, 1, -40, 1, -36, 1, -32, 1, -28, 1, -24, 1, -20, 1, -16, 1, -12, 1, -8, 1, -4, 1, 0, 2, 4, 2, 8, 2, 12, 2, 16, 2, 20, 2, 24, 2, 28, 2, 32, 2, 36, 2, 40, 2, 44, 2, 48, 2, 52, 2, 56, 2, 60, 2, 64, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 2, -1, -1, -1, -1, -1, -1, -1, -1, 72, 2, 88, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, 2, 113, 2, 27, 91, 90, 0, 7, 0, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 85, 0, 27, 91, 65, 0, 27, 91, 77, 0, 27, 91, 49, 109, 0, 27, 91, 115, 27, 91, 49, 98, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 48, 109, 0, 27, 91, 50, 98, 27, 91, 117, 13, 27, 91, 75, 0, 27, 91, 109, 0, 27, 91, 109, 0, 27, 91, 76, 0, 8, 0, 27, 91, 77, 0, 27, 91, 66, 0, 27, 70, 65, 0, 27, 70, 49, 0, 27, 70, 65, 0, 27, 70, 50, 0, 27, 70, 51, 0, 27, 70, 52, 0, 27, 70, 53, 0, 27, 70, 54, 0, 27, 70, 55, 0, 27, 70, 56, 0, 27, 70, 57, 0, 27, 91, 76, 0, 27, 91, 68, 0, 27, 91, 85, 0, 27, 91, 84, 0, 27, 91, 83, 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 0, 27, 91, 117, 0, 27, 91, 115, 0, 27, 91, 83, 0, 27, 91, 84, 0, 9, 0, 43, 16, 44, 17, 45, 24, 46, 25, 48, -37, 96, 4, 97, -79, 102, -8, 103, -15, 104, -80, 106, -39, 107, -65, 108, -38, 109, -64, 110, -59, 111, 126, 112, -60, 113, -60, 114, -60, 115, 95, 116, -61, 117, -76, 118, -63, 119, -62, 120, -77, 121, -13, 122, -14, 123, -29, 124, -40, 125,-100, 126, -2, 0, 27, 91, 90, 0, 27, 91, 85, 0, 27, 70, 66, 0, 27, 70, 67, 0, 27, 70, 68, 0, 27, 70, 69, 0, 27, 70, 70, 0, 27, 70, 71, 0, 27, 70, 72, 0, 27, 70, 73, 0, 27, 70, 74, 0, 27, 70, 75, 0, 27, 70, 76, 0, 27, 70, 77, 0, 27, 70, 78, 0, 27, 70, 79, 0, 27, 70, 80, 0, 27, 70, 81, 0, 27, 70, 82, 0, 27, 70, 83, 0, 27, 70, 84, 0, 27, 70, 85, 0, 27, 70, 86, 0, 27, 70, 87, 0, 27, 70, 88, 0, 27, 70, 89, 0, 27, 70, 90, 0, 27, 70, 97, 0, 27, 70, 98, 0, 27, 70, 99, 0, 27, 70, 100, 0, 27, 70, 101, 0, 27, 70, 102, 0, 27, 70, 103, 0, 27, 70, 104, 0, 27, 70, 105, 0, 27, 70, 106, 0, 27, 70, 107, 0, 27, 70, 109, 0, 27, 70, 110, 0, 27, 70, 111, 0, 27, 70, 112, 0, 27, 70, 113, 0, 27, 70, 114, 0, 27, 70, 115, 0, 27, 70, 116, 0, 27, 70, 117, 0, 27, 70, 118, 0, 27, 70, 119, 0, 27, 70, 120, 0, 27, 70, 121, 0, 27, 70, 122, 0, 27, 70, 43, 0, 27, 70, 45, 0, 27, 70, 12, 0, 27, 91, 109, 0, 27, 91, 37, 112, 49, 37, 123, 51, 48, 125, 37, 43, 37, 100, 109, 0, 27, 91, 37, 112, 49, 37, 39, 40, 39, 37, 43, 37, 100, 109, 0, 27, 91, 51, 37, 112, 49, 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +// This is a 256-colour terminfo description that lacks true-colour +// capabilities that stterm actually has. +static const signed char st_256colour_terminfo[] = { + 26, 1, 55, 0, 29, 0, 15, 0, 105, 1, 117, 5, 115, 116, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 115, 116, 116, 101, 114, 109, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 115, 105, 109, 112, 108, 101, 116, 101, 114, 109, 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, 38, 0, 42, 0, 46, 0, -1, -1, 57, 0, 74, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, 102, 0, -1, -1, 106, 0, 110, 0, 117, 0, 121, 0, -1, -1, -1, -1, 125, 0,-127, 0,-122, 0,-117, 0, -1, -1, -1, -1,-108, 0,-103, 0, -1, -1, -98, 0, -93, 0, -88, 0, -83, 0, -74, 0, -70, 0, -65, 0, -1, -1, -56, 0, -51, 0, -45, 0, -39, 0, -1, -1, -21, 0, -1, -1, -19, 0, -1, -1, -1, -1, -1, -1, -4, 0, -1, -1, 0, 1, -1, -1, 2, 1, -1, -1, 9, 1, 14, 1, 21, 1, 25, 1, 32, 1, 39, 1, -1, -1, 46, 1, 50, 1, 56, 1, 60, 1, 64, 1, 68, 1, 74, 1, 80, 1, 86, 1, 92, 1, 98, 1, 103, 1, 108, 1, 115, 1, -1, -1, 119, 1, 124, 1,-127, 1,-123, 1,-116, 1, -1, -1,-109, 1,-105, 1, -97, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -89, 1, -80, 1, -71, 1, -62, 1, -53, 1, -44, 1, -35, 1, -26, 1, -1, -1, -17, 1, -1, -1, -1, -1, -1, -1, -8, 1, -4, 1, 1, 2, -1, -1, 6, 2, 9, 2, -1, -1, -1, -1, 24, 2, 27, 2, 38, 2, 41, 2, 43, 2, 46, 2,-128, 2, -1, -1,-125, 2,-123, 2, -1, -1, -1, -1, -1, -1,-118, 2,-113, 2,-108, 2,-104, 2, -99, 2, -1, -1, -1, -1, -94, 2, -1, -1, -29, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -25, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -21, 2, -16, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -12, 2, -1, -1, -1, -1, -5, 2, -1, -1, -1, -1, -1, -1, -1, -1, 2, 3, 9, 3, 16, 3, -1, -1, -1, -1, 23, 3, -1, -1, 30, 3, -1, -1, -1, -1, -1, -1, 37, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 3, 50, 3, 56, 3, 63, 3, 70, 3, 77, 3, 84, 3, 92, 3, 100, 3, 108, 3, 116, 3, 124, 3,-124, 3,-116, 3,-108, 3,-101, 3, -94, 3, -87, 3, -80, 3, -72, 3, -64, 3, -56, 3, -48, 3, -40, 3, -32, 3, -24, 3, -16, 3, -9, 3, -2, 3, 5, 4, 12, 4, 20, 4, 28, 4, 36, 4, 44, 4, 52, 4, 60, 4, 68, 4, 76, 4, 83, 4, 90, 4, 97, 4, 104, 4, 112, 4, 120, 4,-128, 4,-120, 4,-112, 4,-104, 4, -96, 4, -88, 4, -81, 4, -74, 4, -67, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -62, 4, -51, 4, -46, 4, -38, 4, -34, 4, -2, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -25, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -20, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -14, 4, -1, -1, -1, -1, -1, -1, -10, 4, 53, 5, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 49, 50, 108, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 40, 48, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, 48, 52, 57, 104, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 27, 40, 66, 0, 27, 91, 48, 109, 0, 27, 91, 63, 49, 48, 52, 57, 108, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 7, 0, 27, 91, 52, 108, 27, 62, 27, 91, 63, 49, 48, 51, 52, 108, 0, 27, 91, 76, 0, 127, 0, 27, 91, 51, 59, 53, 126, 0, 27, 91, 51, 126, 0, 27, 91, 51, 59, 50, 126, 0, 27, 79, 66, 0, 27, 91, 50, 59, 50, 126, 0, 27, 91, 49, 59, 50, 70, 0, 27, 91, 49, 59, 53, 70, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 91, 50, 59, 53, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 91, 49, 59, 50, 66, 0, 27, 91, 49, 59, 50, 65, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 105, 0, 27, 91, 52, 105, 0, 27, 91, 53, 105, 0, 27, 99, 0, 27, 91, 52, 108, 27, 62, 27, 91, 63, 49, 48, 51, 52, 108, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 37, 63, 37, 112, 57, 37, 116, 27, 40, 48, 37, 101, 27, 40, 66, 37, 59, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 109, 0, 27, 72, 0, 9, 0, 27, 93, 48, 59, 0, 27, 91, 49, 126, 0, 27, 91, 53, 126, 0, 27, 79, 117, 0, 27, 91, 52, 126, 0, 27, 91, 54, 126, 0, 43, 67, 44, 68, 45, 65, 46, 66, 48, 69, 96, 96, 97, 97, 102, 102, 103, 103, 104, 70, 105, 71, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 41, 48, 0, 27, 91, 52, 126, 0, 27, 79, 77, 0, 27, 91, 51, 59, 50, 126, 0, 27, 91, 49, 59, 50, 70, 0, 27, 91, 49, 59, 50, 72, 0, 27, 91, 50, 59, 50, 126, 0, 27, 91, 49, 59, 50, 68, 0, 27, 91, 54, 59, 50, 126, 0, 27, 91, 53, 59, 50, 126, 0, 27, 91, 49, 59, 50, 67, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 59, 50, 80, 0, 27, 91, 49, 59, 50, 81, 0, 27, 91, 49, 59, 50, 82, 0, 27, 91, 49, 59, 50, 83, 0, 27, 91, 49, 53, 59, 50, 126, 0, 27, 91, 49, 55, 59, 50, 126, 0, 27, 91, 49, 56, 59, 50, 126, 0, 27, 91, 49, 57, 59, 50, 126, 0, 27, 91, 50, 48, 59, 50, 126, 0, 27, 91, 50, 49, 59, 50, 126, 0, 27, 91, 50, 51, 59, 50, 126, 0, 27, 91, 50, 52, 59, 50, 126, 0, 27, 91, 49, 59, 53, 80, 0, 27, 91, 49, 59, 53, 81, 0, 27, 91, 49, 59, 53, 82, 0, 27, 91, 49, 59, 53, 83, 0, 27, 91, 49, 53, 59, 53, 126, 0, 27, 91, 49, 55, 59, 53, 126, 0, 27, 91, 49, 56, 59, 53, 126, 0, 27, 91, 49, 57, 59, 53, 126, 0, 27, 91, 50, 48, 59, 53, 126, 0, 27, 91, 50, 49, 59, 53, 126, 0, 27, 91, 50, 51, 59, 53, 126, 0, 27, 91, 50, 52, 59, 53, 126, 0, 27, 91, 49, 59, 54, 80, 0, 27, 91, 49, 59, 54, 81, 0, 27, 91, 49, 59, 54, 82, 0, 27, 91, 49, 59, 54, 83, 0, 27, 91, 49, 53, 59, 54, 126, 0, 27, 91, 49, 55, 59, 54, 126, 0, 27, 91, 49, 56, 59, 54, 126, 0, 27, 91, 49, 57, 59, 54, 126, 0, 27, 91, 50, 48, 59, 54, 126, 0, 27, 91, 50, 49, 59, 54, 126, 0, 27, 91, 50, 51, 59, 54, 126, 0, 27, 91, 50, 52, 59, 54, 126, 0, 27, 91, 49, 59, 51, 80, 0, 27, 91, 49, 59, 51, 81, 0, 27, 91, 49, 59, 51, 82, 0, 27, 91, 49, 59, 51, 83, 0, 27, 91, 49, 53, 59, 51, 126, 0, 27, 91, 49, 55, 59, 51, 126, 0, 27, 91, 49, 56, 59, 51, 126, 0, 27, 91, 49, 57, 59, 51, 126, 0, 27, 91, 50, 48, 59, 51, 126, 0, 27, 91, 50, 49, 59, 51, 126, 0, 27, 91, 50, 51, 59, 51, 126, 0, 27, 91, 50, 52, 59, 51, 126, 0, 27, 91, 49, 59, 52, 80, 0, 27, 91, 49, 59, 52, 81, 0, 27, 91, 49, 59, 52, 82, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 49, 59, 50, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 109, 0, 27, 91, 50, 51, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +// This is a 256-colour terminfo description that lacks true-colour +// capabilities that gnome actually has. +static const signed char vte_256colour_terminfo[] = { + 26, 1, 52, 0, 29, 0, 15, 0, 105, 1, -55, 5, 103, 110, 111, 109, 101, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 71, 78, 79, 77, 69, 32, 84, 101, 114, 109, 105, 110, 97, 108, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, 32, 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, 38, 0, 42, 0, 46, 0, -1, -1, 57, 0, 74, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, 96, 0, -1, -1, 100, 0, -1, -1, 104, 0, 108, 0, -1, -1, -1, -1, 112, 0, -1, -1, 114, 0, 119, 0, -1, -1, -128, 0, -123, 0, -118, 0, -1, -1,-113, 0, -108, 0, -103, 0, -98, 0, -89, 0, -87, 0, -81, 0, -1, -1, -68, 0, -63, 0, -57, 0, -51, 0, -1, -1, -1, -1, -1, -1, -33, 0, -1, -1, -1, -1, -1, -1, 0, 1, -1, -1, 4, 1, -1, -1, -1, -1, -1, -1, 6, 1, -1, -1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, 15, 1, 19, 1, 25, 1, 29, 1, 33, 1, 37, 1, 43, 1, 49, 1, 55, 1, 61, 1, 67, 1, 71, 1, -1, -1, 76, 1, -1, -1, 80, 1, 85, 1, 90, 1, 94, 1, 101, 1, -1, -1, 108, 1, 112, 1, 120, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -128, 1,-119, 1, -110, 1, -101, 1, -92, 1, -83, 1, -74, 1, -65, 1, -56, 1, -47, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -38, 1, -35, 1, -1, -1, -1, -1, 16, 2, 19, 2, 30, 2, 33, 2, 35, 2, 38, 2, 116, 2, -1, -1, 119, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 121, 2, -1, -1, -1, -1, -1, -1, -1, -1, 125, 2, -1, -1, -78, 2, -1, -1, -1, -1, -74, 2, -68, 2, -1, -1, -1, -1, -62, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -58, 2, -54, 2, -1, -1, -50, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -45, 2, -1, -1, -38, 2, -33, 2, -1, -1, -1, -1, -1, -1, -1, -1, -26, 2, -19, 2, -12, 2, -1, -1, -1, -1, -5, 2, -1, -1, 2, 3, -1, -1, -1, -1, -1, -1, 9, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, 3, 22, 3, 28, 3, 35, 3, 42, 3, 49, 3, 56, 3, 64, 3, 72, 3, 80, 3, 88, 3, 96, 3, 104, 3, 112, 3, 120, 3, 127, 3, -122, 3, -115, 3,-108, 3, -100, 3, -92, 3, -84, 3, -76, 3, -68, 3, -60, 3, -52, 3, -44, 3, -37, 3, -30, 3, -23, 3, -16, 3, -8, 3, 0, 4, 8, 4, 16, 4, 24, 4, 32, 4, 40, 4, 48, 4, 55, 4, 62, 4, 69, 4, 76, 4, 84, 4, 92, 4, 100, 4, 108, 4, 116, 4, 124, 4, -124, 4,-116, 4, -109, 4, -102, 4, -95, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -90, 4, -79, 4, -74, 4, -55, 4, -51, 4, -42, 4, -35, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 64, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 5, -1, -1, -1, -1, -1, -1, 74, 5, -119, 5, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, 0, 27, 91, 49, 109, 0, 27, 55, 27, 91, 63, 52, 55, 104, 0, 27, 91, 50, 109, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 15, 0, 27, 91, 48, 109, 15, 0, 27, 91, 50, 74, 27, 91, 63, 52, 55, 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 27, 91, 109, 27, 91, 63, 55, 104, 27, 91, 52, 108, 27, 62, 27, 55, 27, 91, 114, 27, 91, 63, 49, 59, 51, 59, 52, 59, 54, 108, 27, 56, 0, 27, 91, 76, 0, 127, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 79, 72, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 91, 49, 59, 50, 66, 0, 27, 91, 49, 59, 50, 65, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 0, 27, 55, 27, 91, 114, 27, 56, 27, 91, 109, 27, 91, 63, 55, 104, 27, 91, 33, 112, 27, 91, 63, 49, 59, 51, 59, 52, 59, 54, 108, 27, 91, 52, 108, 27, 62, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 53, 37, 116, 59, 50, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, 55, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 91, 69, 0, 96, 96, 97, 97, 102, 102, 103, 103, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 41, 48, 0, 27, 79, 70, 0, 27, 79, 77, 0, 27, 91, 49, 126, 0, 27, 91, 51, 59, 50, 126, 0, 27, 91, 52, 126, 0, 27, 91, 49, 59, 50, 70, 0, 27, 91, 49, 59, 50, 72, 0, 27, 91, 50, 59, 50, 126, 0, 27, 91, 49, 59, 50, 68, 0, 27, 91, 54, 59, 50, 126, 0, 27, 91, 53, 59, 50, 126, 0, 27, 91, 49, 59, 50, 67, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 59, 50, 80, 0, 27, 91, 49, 59, 50, 81, 0, 27, 91, 49, 59, 50, 82, 0, 27, 91, 49, 59, 50, 83, 0, 27, 91, 49, 53, 59, 50, 126, 0, 27, 91, 49, 55, 59, 50, 126, 0, 27, 91, 49, 56, 59, 50, 126, 0, 27, 91, 49, 57, 59, 50, 126, 0, 27, 91, 50, 48, 59, 50, 126, 0, 27, 91, 50, 49, 59, 50, 126, 0, 27, 91, 50, 51, 59, 50, 126, 0, 27, 91, 50, 52, 59, 50, 126, 0, 27, 91, 49, 59, 53, 80, 0, 27, 91, 49, 59, 53, 81, 0, 27, 91, 49, 59, 53, 82, 0, 27, 91, 49, 59, 53, 83, 0, 27, 91, 49, 53, 59, 53, 126, 0, 27, 91, 49, 55, 59, 53, 126, 0, 27, 91, 49, 56, 59, 53, 126, 0, 27, 91, 49, 57, 59, 53, 126, 0, 27, 91, 50, 48, 59, 53, 126, 0, 27, 91, 50, 49, 59, 53, 126, 0, 27, 91, 50, 51, 59, 53, 126, 0, 27, 91, 50, 52, 59, 53, 126, 0, 27, 91, 49, 59, 54, 80, 0, 27, 91, 49, 59, 54, 81, 0, 27, 91, 49, 59, 54, 82, 0, 27, 91, 49, 59, 54, 83, 0, 27, 91, 49, 53, 59, 54, 126, 0, 27, 91, 49, 55, 59, 54, 126, 0, 27, 91, 49, 56, 59, 54, 126, 0, 27, 91, 49, 57, 59, 54, 126, 0, 27, 91, 50, 48, 59, 54, 126, 0, 27, 91, 50, 49, 59, 54, 126, 0, 27, 91, 50, 51, 59, 54, 126, 0, 27, 91, 50, 52, 59, 54, 126, 0, 27, 91, 49, 59, 51, 80, 0, 27, 91, 49, 59, 51, 81, 0, 27, 91, 49, 59, 51, 82, 0, 27, 91, 49, 59, 51, 83, 0, 27, 91, 49, 53, 59, 51, 126, 0, 27, 91, 49, 55, 59, 51, 126, 0, 27, 91, 49, 56, 59, 51, 126, 0, 27, 91, 49, 57, 59, 51, 126, 0, 27, 91, 50, 48, 59, 51, 126, 0, 27, 91, 50, 49, 59, 51, 126, 0, 27, 91, 50, 51, 59, 51, 126, 0, 27, 91, 50, 52, 59, 51, 126, 0, 27, 91, 49, 59, 52, 80, 0, 27, 91, 49, 59, 52, 81, 0, 27, 91, 49, 59, 52, 82, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 37, 91, 59, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 93, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 93, 49, 48, 52, 7, 0, 27, 93, 52, 59, 37, 112, 49, 37, 100, 59, 114, 103, 98, 58, 37, 112, 50, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 52, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 27, 92, 0, 27, 91, 51, 109, 0, 27, 91, 50, 51, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 +}; +// Taken from Dickey ncurses terminfo.src dated 2017-04-22. +static const signed char ansi_terminfo[] = { + 26, 1, 40, 0, 23, 0, 16, 0, 125, 1, 68, 2, 97, 110, 115, 105, 124, 97, 110, 115, 105, 47, 112, 99, 45, 116, 101, 114, 109, 32, 99, 111, 109, 112, 97, 116, 105, 98, 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, 108, 111, 114, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, 0, 64, 0, 3, 0, 0, 0, 4, 0, 6, 0, -1, -1, 8, 0, 13, 0, 20, 0, 24, 0, 28, 0, -1, -1, 39, 0, 56, 0, 60, 0, -1, -1, 64, 0, -1, -1, -1, -1, 68, 0, -1, -1, 72, 0, -1, -1, 76, 0, 80, 0, -1, -1, -1, -1, 84, 0, 90, 0, 95, 0, -1, -1, -1, -1, -1, -1, -1, -1, 100, 0, -1, -1, 105, 0, 110, 0, 115, 0, 120, 0,-127, 0,-121, 0, -1, -1, -1, -1, -1, -1,-113, 0,-109, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-105, 0, -1, -1,-101, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -99, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -95, 0, -91, 0, -1, -1, -87, 0, -1, -1, -1, -1, -1, -1, -83, 0, -1, -1, -1, -1, -1, -1, -79, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -75, 0, -1, -1, -70, 0, -61, 0, -52, 0, -43, 0, -34, 0, -25, 0, -16, 0, -7, 0, 2, 1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 1, 25, 1, 30, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 1, -1, -1, 61, 1, -1, -1, 63, 1,-107, 1, -1, -1,-104, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-100, 1, -1, -1, -37, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -33, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -28, 1, -17, 1, -12, 1, 7, 2, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 2, 30, 2, -1, -1, -1, -1, -1, -1, 40, 2, 44, 2, 48, 2, 52, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 56, 2, 62, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 27, 91, 66, 0, 27, 91, 72, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 91, 49, 49, 109, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 27, 91, 49, 48, 109, 0, 27, 91, 48, 59, 49, 48, 109, 0, 27, 91, 109, 0, 27, 91, 109, 0, 27, 91, 76, 0, 8, 0, 27, 91, 66, 0, 27, 91, 72, 0, 27, 91, 76, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 27, 91, 83, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 52, 105, 0, 27, 91, 53, 105, 0, 37, 112, 49, 37, 99, 27, 91, 37, 112, 50, 37, 123, 49, 125, 37, 45, 37, 100, 98, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 10, 0, 27, 91, 48, 59, 49, 48, 37, 63, 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 37, 63, 37, 112, 57, 37, 116, 59, 49, 49, 37, 59, 109, 0, 27, 72, 0, 27, 91, 73, 0, 43, 16, 44, 17, 45, 24, 46, 25, 48, -37, 96, 4, 97, -79, 102, -8, 103, -15, 104, -80, 106, -39, 107, -65, 108, -38, 109, -64, 110, -59, 111, 126, 112, -60, 113, -60, 114, -60, 115, 95, 116, -61, 117, -76, 118, -63, 119, -62, 120, -77, 121, -13, 122, -14, 123, -29, 124, -40, 125,-100, 126, -2, 0, 27, 91, 90, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 37, 91, 59, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 93, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 37, 112, 49, 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0, 27, 40, 66, 0, 27, 41, 66, 0, 27, 42, 66, 0, 27, 43, 66, 0, 27, 91, 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 +}; + +/// Load one of the built-in terminfo entries when unibilium has failed to +/// load a terminfo record from an external database, as it does on termcap- +/// -only systems. We do not do any fancy recognition of xterm pretenders +/// here. An external terminfo database would not do that, and we want to +/// behave as much like an external terminfo database as possible. +unibi_term *load_builtin_terminfo(const char * term) +{ + if (terminfo_is_term_family(term, "xterm")) { + return unibi_from_mem((const char *)xterm_256colour_terminfo, sizeof xterm_256colour_terminfo); + } else if (terminfo_is_term_family(term, "screen")) { + return unibi_from_mem((const char *)screen_256colour_terminfo, sizeof screen_256colour_terminfo); + } else if (terminfo_is_term_family(term, "tmux")) { + return unibi_from_mem((const char *)tmux_256colour_terminfo, sizeof tmux_256colour_terminfo); + } else if (terminfo_is_term_family(term, "rxvt")) { + return unibi_from_mem((const char *)rxvt_256colour_terminfo, sizeof rxvt_256colour_terminfo); + } else if (terminfo_is_term_family(term, "putty")) { + return unibi_from_mem((const char *)putty_256colour_terminfo, sizeof putty_256colour_terminfo); + } else if (terminfo_is_term_family(term, "linux")) { + return unibi_from_mem((const char *)linux_16colour_terminfo, sizeof linux_16colour_terminfo); + } else if (terminfo_is_term_family(term, "interix")) { + return unibi_from_mem((const char *)interix_8colour_terminfo, sizeof interix_8colour_terminfo); + } else if (terminfo_is_term_family(term, "iterm") || terminfo_is_term_family(term, "iTerm.app")) { + return unibi_from_mem((const char *)iterm_256colour_terminfo, sizeof iterm_256colour_terminfo); + } else if (terminfo_is_term_family(term, "st")) { + return unibi_from_mem((const char *)st_256colour_terminfo, sizeof st_256colour_terminfo); + } else if (terminfo_is_term_family(term, "gnome") || terminfo_is_term_family(term, "vte")) { + return unibi_from_mem((const char *)vte_256colour_terminfo, sizeof vte_256colour_terminfo); + } else { + return unibi_from_mem((const char *)ansi_terminfo, sizeof ansi_terminfo); + } +} diff --git a/src/nvim/tui/terminfo.h b/src/nvim/tui/terminfo.h new file mode 100644 index 0000000000..78f6b9c245 --- /dev/null +++ b/src/nvim/tui/terminfo.h @@ -0,0 +1,8 @@ +#ifndef NVIM_TUI_TERMINFO_H +#define NVIM_TUI_TERMINFO_H + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "tui/terminfo.h.generated.h" +#endif + +#endif // NVIM_TUI_TERMINFO_H diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index e3612b5c06..3ef2e2967b 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -34,6 +34,7 @@ #include "nvim/ugrid.h" #include "nvim/tui/input.h" #include "nvim/tui/tui.h" +#include "nvim/tui/terminfo.h" #include "nvim/cursor_shape.h" #include "nvim/syntax.h" #include "nvim/macros.h" @@ -51,10 +52,15 @@ // Per the commentary in terminfo, only a minus sign is a true suffix // separator. -#define TERMINAL_FAMILY(term, prefix) ((term) \ - && strlen(term) >= (sizeof(prefix) - 1) \ - && 0 == memcmp((term), (prefix), sizeof(prefix) - 1) \ - && ('\0' == (term)[sizeof(prefix) - 1] || '-' == (term)[sizeof(prefix) - 1])) +bool terminfo_is_term_family(const char *term, const char *family) +{ + if (!term) return false; + size_t tlen = strlen(term); + size_t flen = strlen(family); + return tlen >= flen + && 0 == memcmp(term, family, flen) \ + && ('\0' == term[flen] || '-' == term[flen]); +} typedef struct { int top, bot, left, right; @@ -196,9 +202,9 @@ static void terminfo_start(UI *ui) !!unibi_get_str(data->ut, unibi_set_left_margin_parm) && !!unibi_get_str(data->ut, unibi_set_right_margin_parm); data->immediate_wrap_after_last_column = - TERMINAL_FAMILY(term, "iterm") - || TERMINAL_FAMILY(term, "interix") - || (TERMINAL_FAMILY(term, "xterm") && iterm_env); + terminfo_is_term_family(term, "iterm") + || terminfo_is_term_family(term, "interix") + || (terminfo_is_term_family(term, "xterm") && iterm_env); // Set 't_Co' from the result of unibilium & fix_terminfo. t_colors = unibi_get_num(data->ut, unibi_max_colors); // Enter alternate screen and clear @@ -1199,1356 +1205,6 @@ static int unibi_find_ext_str(unibi_term *ut, const char *name) return -1; } -// One creates the dumps from terminfo.src by using -// od -t d1 -w16 | cut -c9- | sed -e 's/\>/,/g' -// on the compiled files. - -// Taken from Dickey ncurses terminfo.src dated 2017-04-22. -// This is a 256-colour terminfo description that lacks true-colour and -// DECSTBM/DECSLRM/DECLRMM capabilities that xterm actually has. -static const signed char xterm_256colour_terminfo[] = { - 26, 1, 37, 0, 29, 0, 15, 0, 105, 1, -42, 5, 120, 116, 101, 114, - 109, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 120, 116, 101, 114, 109, - 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, - 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 80, 0, - 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, - 6, 0, 8, 0, 25, 0, 30, 0, 38, 0, 42, 0, 46, 0, -1, -1, - 57, 0, 74, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, 102, 0, - -1, -1, 106, 0, 110, 0, 120, 0, 124, 0, -1, -1, -1, -1,-128, 0, --124, 0,-119, 0,-114, 0, -1, -1,-105, 0,-100, 0, -95, 0, -1, -1, - -90, 0, -85, 0, -80, 0, -75, 0, -66, 0, -62, 0, -55, 0, -1, -1, - -46, 0, -41, 0, -35, 0, -29, 0, -1, -1, -1, -1, -1, -1, -11, 0, - -1, -1, -1, -1, -1, -1, 7, 1, -1, -1, 11, 1, -1, -1, -1, -1, - -1, -1, 13, 1, -1, -1, 18, 1, -1, -1, -1, -1, -1, -1, -1, -1, - 22, 1, 26, 1, 32, 1, 36, 1, 40, 1, 44, 1, 50, 1, 56, 1, - 62, 1, 68, 1, 74, 1, 78, 1, -1, -1, 83, 1, -1, -1, 87, 1, - 92, 1, 97, 1, 101, 1, 108, 1, -1, -1, 115, 1, 119, 1, 127, 1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1,-121, 1,-112, 1, -1, -1, -1, -1,-103, 1, - -94, 1, -85, 1, -76, 1, -67, 1, -58, 1, -49, 1, -40, 1, -31, 1, - -22, 1, -1, -1, -1, -1, -1, -1, -13, 1, -9, 1, -4, 1, -1, -1, - 1, 2, 10, 2, -1, -1, -1, -1, 28, 2, 31, 2, 42, 2, 45, 2, - 47, 2, 50, 2,-113, 2, -1, -1,-110, 2, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1,-108, 2, -1, -1, -1, -1, -1, -1, -1, -1, --104, 2, -1, -1, -51, 2, -1, -1, -1, -1, -47, 2, -41, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -35, 2, -31, 2, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -27, 2, -1, -1, -1, -1, - -20, 2, -1, -1, -1, -1, -1, -1, -1, -1, -13, 2, -6, 2, 1, 3, - -1, -1, -1, -1, 8, 3, -1, -1, 15, 3, -1, -1, -1, -1, -1, -1, - 22, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, 3, 35, 3, - 41, 3, 48, 3, 55, 3, 62, 3, 69, 3, 77, 3, 85, 3, 93, 3, - 101, 3, 109, 3, 117, 3, 125, 3,-123, 3,-116, 3,-109, 3,-102, 3, - -95, 3, -87, 3, -79, 3, -71, 3, -63, 3, -55, 3, -47, 3, -39, 3, - -31, 3, -24, 3, -17, 3, -10, 3, -3, 3, 5, 4, 13, 4, 21, 4, - 29, 4, 37, 4, 45, 4, 53, 4, 61, 4, 68, 4, 75, 4, 82, 4, - 89, 4, 97, 4, 105, 4, 113, 4, 121, 4,-127, 4,-119, 4,-111, 4, --103, 4, -96, 4, -89, 4, -82, 4, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -77, 4, -66, 4, -61, 4, -42, 4, -38, 4, - -29, 4, -22, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 72, 5, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, 5, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 83, 5, -1, -1, -1, -1, -1, -1, 87, 5,-106, 5, 27, 91, - 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, - 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, - 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, - 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, - 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, - 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 49, 50, 108, 27, 91, 63, - 50, 53, 104, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 63, 49, - 50, 59, 50, 53, 104, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 40, - 48, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, - 48, 52, 57, 104, 0, 27, 91, 50, 109, 0, 27, 91, 52, 104, 0, 27, - 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, - 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 27, 40, 66, 0, - 27, 40, 66, 27, 91, 109, 0, 27, 91, 63, 49, 48, 52, 57, 108, 0, - 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, - 0, 27, 91, 63, 53, 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, - 53, 108, 0, 27, 91, 33, 112, 27, 91, 63, 51, 59, 52, 108, 27, 91, - 52, 108, 27, 62, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, - 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, - 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, - 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, - 126, 0, 27, 91, 50, 48, 126, 0, 27, 79, 72, 0, 27, 91, 50, 126, - 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, - 79, 67, 0, 27, 91, 49, 59, 50, 66, 0, 27, 91, 49, 59, 50, 65, - 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, - 49, 104, 27, 61, 0, 27, 91, 63, 49, 48, 51, 52, 108, 0, 27, 91, - 63, 49, 48, 51, 52, 104, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, - 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, - 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, - 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, - 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, - 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, - 0, 27, 91, 105, 0, 27, 91, 52, 105, 0, 27, 91, 53, 105, 0, 27, - 99, 27, 93, 49, 48, 52, 7, 0, 27, 91, 33, 112, 27, 91, 63, 51, - 59, 52, 108, 27, 91, 52, 108, 27, 62, 0, 27, 56, 0, 27, 91, 37, - 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, - 37, 63, 37, 112, 57, 37, 116, 27, 40, 48, 37, 101, 27, 40, 66, 37, - 59, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, - 63, 37, 112, 53, 37, 116, 59, 50, 37, 59, 37, 63, 37, 112, 50, 37, - 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, - 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, - 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 109, 0, 27, 72, 0, - 9, 0, 27, 79, 69, 0, 96, 96, 97, 97, 102, 102, 103, 103, 105, 105, - 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, - 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, - 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, - 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 79, 70, 0, 27, - 79, 77, 0, 27, 91, 51, 59, 50, 126, 0, 27, 91, 49, 59, 50, 70, - 0, 27, 91, 49, 59, 50, 72, 0, 27, 91, 50, 59, 50, 126, 0, 27, - 91, 49, 59, 50, 68, 0, 27, 91, 54, 59, 50, 126, 0, 27, 91, 53, - 59, 50, 126, 0, 27, 91, 49, 59, 50, 67, 0, 27, 91, 50, 51, 126, - 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 59, 50, 80, 0, 27, 91, - 49, 59, 50, 81, 0, 27, 91, 49, 59, 50, 82, 0, 27, 91, 49, 59, - 50, 83, 0, 27, 91, 49, 53, 59, 50, 126, 0, 27, 91, 49, 55, 59, - 50, 126, 0, 27, 91, 49, 56, 59, 50, 126, 0, 27, 91, 49, 57, 59, - 50, 126, 0, 27, 91, 50, 48, 59, 50, 126, 0, 27, 91, 50, 49, 59, - 50, 126, 0, 27, 91, 50, 51, 59, 50, 126, 0, 27, 91, 50, 52, 59, - 50, 126, 0, 27, 91, 49, 59, 53, 80, 0, 27, 91, 49, 59, 53, 81, - 0, 27, 91, 49, 59, 53, 82, 0, 27, 91, 49, 59, 53, 83, 0, 27, - 91, 49, 53, 59, 53, 126, 0, 27, 91, 49, 55, 59, 53, 126, 0, 27, - 91, 49, 56, 59, 53, 126, 0, 27, 91, 49, 57, 59, 53, 126, 0, 27, - 91, 50, 48, 59, 53, 126, 0, 27, 91, 50, 49, 59, 53, 126, 0, 27, - 91, 50, 51, 59, 53, 126, 0, 27, 91, 50, 52, 59, 53, 126, 0, 27, - 91, 49, 59, 54, 80, 0, 27, 91, 49, 59, 54, 81, 0, 27, 91, 49, - 59, 54, 82, 0, 27, 91, 49, 59, 54, 83, 0, 27, 91, 49, 53, 59, - 54, 126, 0, 27, 91, 49, 55, 59, 54, 126, 0, 27, 91, 49, 56, 59, - 54, 126, 0, 27, 91, 49, 57, 59, 54, 126, 0, 27, 91, 50, 48, 59, - 54, 126, 0, 27, 91, 50, 49, 59, 54, 126, 0, 27, 91, 50, 51, 59, - 54, 126, 0, 27, 91, 50, 52, 59, 54, 126, 0, 27, 91, 49, 59, 51, - 80, 0, 27, 91, 49, 59, 51, 81, 0, 27, 91, 49, 59, 51, 82, 0, - 27, 91, 49, 59, 51, 83, 0, 27, 91, 49, 53, 59, 51, 126, 0, 27, - 91, 49, 55, 59, 51, 126, 0, 27, 91, 49, 56, 59, 51, 126, 0, 27, - 91, 49, 57, 59, 51, 126, 0, 27, 91, 50, 48, 59, 51, 126, 0, 27, - 91, 50, 49, 59, 51, 126, 0, 27, 91, 50, 51, 59, 51, 126, 0, 27, - 91, 50, 52, 59, 51, 126, 0, 27, 91, 49, 59, 52, 80, 0, 27, 91, - 49, 59, 52, 81, 0, 27, 91, 49, 59, 52, 82, 0, 27, 91, 49, 75, - 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, - 0, 27, 91, 63, 37, 91, 59, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 93, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, - 0, 27, 93, 49, 48, 52, 7, 0, 27, 93, 52, 59, 37, 112, 49, 37, - 100, 59, 114, 103, 98, 58, 37, 112, 50, 37, 123, 50, 53, 53, 125, 37, - 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, - 37, 112, 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, - 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 52, 37, 123, 50, - 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, - 46, 50, 88, 27, 92, 0, 27, 91, 51, 109, 0, 27, 91, 50, 51, 109, - 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, - 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, - 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, - 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, - 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, - 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, - 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, - 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, - 37, 59, 109, 0 -}; -// Taken from unibilium/t/static_tmux.c as of 2015-08-14. -// This is an 256-colour terminfo description that lacks -// status line capabilities that tmux actually has. -static const signed char tmux_256colour_terminfo[] = { - 26, 1, 56, 0, 15, 0, 15, 0, 105, 1, -48, 2, 116, 109, 117, 120, 124, 86, 84, 32, - 49, 48, 48, 47, 65, 78, 83, 73, 32, 88, 51, 46, 54, 52, 32, 118, 105, 114, 116, 117, - 97, 108, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 119, 105, 116, 104, 32, 50, 53, 54, - 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, - 0, 1, 1, 0, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, - 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, -1, -1, -1, -1, 45, 0, 62, 0, 64, 0, - 68, 0, 75, 0, -1, -1, 77, 0, 89, 0, -1, -1, 93, 0, 96, 0, 102, 0, 106, 0, - -1, -1, -1, -1, 110, 0, 112, 0, 117, 0, 122, 0, -1, -1, -1, -1, 123, 0, -1, -1, - -1, -1, -128, 0, -123, 0, -118, 0, -1, -1, -113, 0, -111, 0, -106, 0, -1, -1, -105, 0, - -100, 0, -94, 0, -88, 0, -1, -1, -1, -1, -1, -1, -85, 0, -1, -1, -1, -1, -1, -1, - -81, 0, -1, -1, -77, 0, -1, -1, -1, -1, -1, -1, -75, 0, -1, -1, -70, 0, -1, -1, - -1, -1, -1, -1, -1, -1, -66, 0, -62, 0, -56, 0, -52, 0, -48, 0, -44, 0, -38, 0, - -32, 0, -26, 0, -20, 0, -14, 0, -9, 0, -1, -1, -4, 0, -1, -1, 0, 1, 5, 1, - 10, 1, -1, -1, -1, -1, -1, -1, 14, 1, 18, 1, 26, 1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 34, 1, -1, -1, 37, 1, 46, 1, 55, 1, 64, 1, -1, -1, 73, 1, 82, 1, 91, 1, - -1, -1, 100, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 109, 1, -1, -1, -1, -1, 126, 1, -1, -1, -127, 1, -124, 1, -122, 1, -119, 1, -46, 1, - -1, -1, -43, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -41, 1, -1, -1, 24, 2, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 28, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 35, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 40, 2, 46, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 52, 2, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 57, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 66, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 71, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 77, 2, -1, -1, -1, -1, -1, -1, 81, 2, -112, 2, 27, 91, 90, 0, - 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, - 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, - 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, - 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 51, 52, 104, 27, 91, - 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 51, 52, 108, 0, 27, 91, - 80, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 0, 27, - 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 15, - 0, 27, 91, 109, 15, 0, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, - 50, 52, 109, 0, 27, 103, 0, 27, 41, 48, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, - 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, - 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, - 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, - 49, 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, - 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, - 63, 49, 104, 27, 61, 0, 27, 69, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, - 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, - 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, - 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, - 0, 27, 99, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, - 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, - 49, 37, 59, 37, 63, 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, - 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, - 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, - 59, 0, 27, 72, 0, 9, 0, 43, 43, 44, 44, 45, 45, 46, 46, 48, 48, 96, 96, 97, - 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, - 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, - 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, - 41, 48, 0, 27, 91, 52, 126, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, - 27, 91, 49, 75, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 109, 0, 27, - 91, 50, 51, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, - 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, - 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, - 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, - 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, - 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, - 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 -}; -// Taken from unibilium/t/static_screen-256color.c as of 2015-08-14. -// This is an 256-colour terminfo description that lacks -// status line capabilities that screen actually has. -static const signed char screen_256colour_terminfo[] = { - 26, 1, 43, 0, 43, 0, 15, 0, 105, 1, -43, 2, 115, 99, 114, 101, 101, 110, 45, 50, - 53, 54, 99, 111, 108, 111, 114, 124, 71, 78, 85, 32, 83, 99, 114, 101, 101, 110, 32, 119, - 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, - 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 80, 0, - 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, - 37, 0, 41, 0, -1, -1, -1, -1, 45, 0, 62, 0, 64, 0, 68, 0, 75, 0, -1, -1, - 77, 0, 89, 0, -1, -1, 93, 0, 96, 0, 102, 0, 106, 0, -1, -1, -1, -1, 110, 0, - 112, 0, 117, 0, 122, 0, -1, -1, -1, -1, -125, 0, -1, -1, -1, -1, -120, 0, -115, 0, - -110, 0, -1, -1, -105, 0, -103, 0, -98, 0, -1, -1, -89, 0, -84, 0, -78, 0, -72, 0, - -1, -1, -1, -1, -1, -1, -69, 0, -1, -1, -1, -1, -1, -1, -65, 0, -1, -1, -61, 0, - -1, -1, -1, -1, -1, -1, -59, 0, -1, -1, -54, 0, -1, -1, -1, -1, -1, -1, -1, -1, - -50, 0, -46, 0, -40, 0, -36, 0, -32, 0, -28, 0, -22, 0, -16, 0, -10, 0, -4, 0, - 2, 1, 7, 1, -1, -1, 12, 1, -1, -1, 16, 1, 21, 1, 26, 1, -1, -1, -1, -1, - -1, -1, 30, 1, 34, 1, 42, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 1, -1, -1, 53, 1, - 62, 1, 71, 1, 80, 1, -1, -1, 89, 1, 98, 1, 107, 1, -1, -1, 116, 1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 125, 1, -1, -1, -1, -1, - -114, 1, -1, -1, -111, 1, -108, 1, -106, 1, -103, 1, -30, 1, -1, -1, -27, 1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -25, 1, -1, -1, 40, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 2, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 51, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 56, 2, 62, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 68, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 73, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 82, 2, - -1, -1, -1, -1, -1, -1, 86, 2, -107, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, - 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, - 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, - 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, - 63, 50, 53, 108, 0, 8, 0, 27, 91, 51, 52, 104, 27, 91, 63, 50, 53, 104, 0, 27, - 91, 67, 0, 27, 77, 0, 27, 91, 51, 52, 108, 0, 27, 91, 80, 0, 27, 91, 77, 0, - 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, 48, 52, 57, 104, - 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 51, 109, 0, 27, 91, 52, 109, - 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 63, 49, 48, 52, 57, 108, 0, 27, 91, 52, - 108, 0, 27, 91, 50, 51, 109, 0, 27, 91, 50, 52, 109, 0, 27, 103, 0, 27, 41, 48, - 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, - 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, - 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, - 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 79, - 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, - 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 69, 0, 27, - 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, - 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, - 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, - 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 91, 63, 49, 48, 48, 48, - 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, - 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 49, 37, 116, - 59, 51, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, - 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, - 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 43, 43, 44, - 44, 45, 45, 46, 46, 48, 48, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, - 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, - 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, - 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, 41, 48, 0, 27, 91, 52, 126, 0, 27, 91, - 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 51, 57, 59, - 52, 57, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, - 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, - 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, - 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, - 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, - 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, - 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 0, 3, 0, 1, 0, - 24, 0, 52, 0, -112, 0, 1, 1, 0, 0, 1, 0, 0, 0, 4, 0, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 0, 0, 3, 0, 6, 0, 9, 0, 12, 0, 15, 0, 18, 0, 23, 0, 28, 0, 32, 0, - 37, 0, 43, 0, 49, 0, 55, 0, 61, 0, 66, 0, 71, 0, 77, 0, 83, 0, 89, 0, - 95, 0, 101, 0, 107, 0, 111, 0, 116, 0, 120, 0, 124, 0, -128, 0, 27, 40, 66, 0, - 27, 40, 37, 112, 49, 37, 99, 0, 65, 88, 0, 71, 48, 0, 88, 84, 0, 85, 56, 0, - 69, 48, 0, 83, 48, 0, 107, 68, 67, 53, 0, 107, 68, 67, 54, 0, 107, 68, 78, 0, - 107, 68, 78, 53, 0, 107, 69, 78, 68, 53, 0, 107, 69, 78, 68, 54, 0, 107, 72, 79, - 77, 53, 0, 107, 72, 79, 77, 54, 0, 107, 73, 67, 53, 0, 107, 73, 67, 54, 0, 107, - 76, 70, 84, 53, 0, 107, 78, 88, 84, 53, 0, 107, 78, 88, 84, 54, 0, 107, 80, 82, - 86, 53, 0, 107, 80, 82, 86, 54, 0, 107, 82, 73, 84, 53, 0, 107, 85, 80, 0, 107, - 85, 80, 53, 0, 107, 97, 50, 0, 107, 98, 49, 0, 107, 98, 51, 0, 107, 99, 50, 0 -}; -// Taken from Dickey ncurses terminfo.src dated 2017-04-22. -static const signed char iterm_256colour_terminfo[] = { - 26, 1, 57, 0, 29, 0, 15, 0, 105, 1, 73, 3, 105, 84, 101, 114, - 109, 46, 97, 112, 112, 124, 105, 116, 101, 114, 109, 124, 105, 84, 101, 114, - 109, 46, 97, 112, 112, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 101, - 109, 117, 108, 97, 116, 111, 114, 32, 102, 111, 114, 32, 77, 97, 99, 32, - 79, 83, 32, 88, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, - 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, - 0, 1, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, - 50, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, - -1, -1, 0, 0, 2, 0, -2, -1, 4, 0, 9, 0, 16, 0, 20, 0, - 24, 0, -1, -1, 35, 0, 52, 0, 54, 0, 58, 0, 65, 0, -1, -1, - 67, 0, 74, 0, -1, -1, 78, 0, -1, -1, 82, 0, 86, 0, 90, 0, - -1, -1, 96, 0, 98, 0, 103, 0, 108, 0, -1, -1, -2, -1, 117, 0, - 122, 0, -1, -1, 127, 0,-124, 0,-119, 0, -1, -1,-114, 0,-112, 0, --107, 0, -1, -1, -94, 0, -89, 0, -85, 0, -81, 0, -1, -1, -63, 0, - -1, -1, -1, -1, -1, -1, -1, -1, -61, 0, -57, 0, -1, -1, -53, 0, - -1, -1, -1, -1, -1, -1, -51, 0, -1, -1, -46, 0, -1, -1, -1, -1, - -1, -1, -1, -1, -42, 0, -38, 0, -32, 0, -28, 0, -24, 0, -20, 0, - -14, 0, -8, 0, -2, 0, 4, 1, 10, 1, -1, -1, -1, -1, 14, 1, - -1, -1, 18, 1, 23, 1, 28, 1, -1, -1, -1, -1, -1, -1, 32, 1, - 36, 1, 44, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 52, 1, 61, 1, 70, 1, 79, 1, -1, -1, 88, 1, 97, 1, - 106, 1, -1, -1, 115, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 124, 1, -1, -1, -1, -1,-104, 1,-101, 1, - -90, 1, -87, 1, -85, 1, -82, 1, -4, 1, -1, -1, -1, 1, 1, 2, - -1, -1, -1, -1, -1, -1, 6, 2, 10, 2, 14, 2, 18, 2, 22, 2, - -1, -1, -1, -1, 26, 2, -1, -1, -1, -1, -1, -1, -1, -1, 77, 2, - 83, 2, -1, -1, -1, -1, 89, 2, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 96, 2, 100, 2, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 104, 2, 110, 2, 116, 2, 122, 2,-128, 2,-122, 2,-116, 2,-110, 2, - 104, 2, -98, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -92, 2, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -87, 2, -76, 2, -71, 2, - -63, 2, -59, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -54, 2, - 9, 3, 7, 0, 13, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, - 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, - 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, - 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, - 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, - 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 93, 50, 59, - 7, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 55, - 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, - 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, - 15, 0, 27, 91, 109, 15, 0, 27, 91, 50, 74, 27, 91, 63, 52, 55, - 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, 91, 109, 0, 27, 91, 109, - 0, 27, 91, 63, 53, 104, 36, 60, 50, 48, 48, 47, 62, 27, 91, 63, - 53, 108, 0, 7, 0, 27, 91, 64, 0, 27, 91, 76, 0, 127, 0, 27, - 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, - 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, - 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, - 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 79, 72, 0, - 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, - 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, - 63, 49, 104, 27, 61, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, - 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, - 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, - 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, - 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 62, - 27, 91, 63, 51, 108, 27, 91, 63, 52, 108, 27, 91, 63, 53, 108, 27, - 91, 63, 55, 104, 27, 91, 63, 56, 104, 0, 27, 56, 0, 27, 91, 37, - 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, - 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, - 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, - 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, - 59, 53, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 109, - 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, - 0, 9, 0, 27, 93, 50, 59, 0, 27, 79, 113, 0, 27, 79, 115, 0, - 27, 79, 114, 0, 27, 79, 112, 0, 27, 79, 110, 0, 96, 96, 97, 97, - 102, 102, 103, 103, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, - 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, - 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, - 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 40, 66, 27, 41, - 48, 0, 27, 79, 70, 0, 27, 79, 77, 0, 27, 91, 50, 51, 126, 0, - 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, 0, 27, 91, 50, 54, - 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, - 51, 49, 126, 0, 27, 91, 50, 50, 126, 0, 27, 91, 51, 51, 126, 0, - 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, - 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 49, 59, - 50, 99, 0, 27, 91, 99, 0, 27, 91, 48, 109, 0, 27, 91, 37, 63, - 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, - 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, - 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, - 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, - 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, - 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, - 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, - 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 -}; -// Taken from Dickey ncurses terminfo.src dated 2017-04-22. -// This is a 256-colour terminfo description that lacks true-colour -// capabilities that rxvt actually has. -static const signed char rxvt_256colour_terminfo[] = { - 26, 1, 47, 0, 29, 0, 15, 0, 110, 1, -31, 4, 114, 120, 118, 116, - 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 114, 120, 118, 116, 32, 50, - 46, 55, 46, 57, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, 32, - 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, - 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 0, 1, 1, 80, 0, 8, 0, 24, 0, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 0, 1, -1, 127, -1, -1, 0, 0, 2, 0, 4, 0, 21, 0, - 26, 0, 34, 0, 38, 0, 42, 0, -1, -1, 53, 0, 70, 0, 72, 0, - 76, 0, 83, 0, -1, -1, 85, 0, 92, 0, -1, -1, 96, 0, -1, -1, - -1, -1, 100, 0, -1, -1, -1, -1, 104, 0, 106, 0, 111, 0, 116, 0, - -1, -1, -1, -1, 125, 0, -1, -1, -1, -1,-126, 0,-121, 0,-116, 0, - -1, -1,-111, 0,-109, 0,-104, 0, -1, -1, -91, 0, -86, 0, -80, 0, - -74, 0, -1, -1, -1, -1, -56, 0, -42, 0, -1, -1, -1, -1, -8, 0, - -4, 0, -1, -1, 0, 1, -1, -1, -1, -1, -1, -1, 2, 1, -1, -1, - 7, 1, -1, -1, 11, 1, -1, -1, 16, 1, 22, 1, 28, 1, 34, 1, - 40, 1, 46, 1, 52, 1, 58, 1, 64, 1, 70, 1, 76, 1, 82, 1, - 87, 1, -1, -1, 92, 1, -1, -1, 96, 1, 101, 1, 106, 1, 110, 1, - 114, 1, -1, -1, 118, 1, 122, 1, 125, 1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-128, 1,-119, 1,-110, 1, - -1, -1,-101, 1, -92, 1, -83, 1, -1, -1, -74, 1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -65, 1, -32, 1, -1, -1, - -1, -1, 18, 2, 21, 2, 32, 2, 35, 2, 37, 2, 40, 2, 107, 2, - -1, -1, 110, 2, -1, -1, -1, -1, -1, -1, -1, -1, 112, 2, 116, 2, - 120, 2, 124, 2,-128, 2, -1, -1, -1, -1,-124, 2, -1, -1, -73, 2, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -69, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -62, 2, - -57, 2, -1, -1, -53, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -48, 2, -1, -1, -43, 2, -38, 2, -1, -1, -1, -1, - -1, -1, -1, -1, -33, 2, -28, 2, -23, 2, -1, -1, -1, -1, -19, 2, - -1, -1, -14, 2, -1, -1, -1, -1, -1, -1, -9, 2, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -5, 2, 1, 3, 7, 3, 13, 3, 19, 3, - 25, 3, 31, 3, 37, 3, 43, 3, 49, 3, 55, 3, 61, 3, 67, 3, - 73, 3, 79, 3, 85, 3, 91, 3, 97, 3, 103, 3, 109, 3, 115, 3, - 121, 3, 127, 3,-123, 3,-117, 3,-111, 3,-105, 3, -99, 3, -93, 3, - -87, 3, -81, 3, -75, 3, -69, 3, -63, 3, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -57, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -52, 3, -41, 3, -36, 3, -28, 3, -24, 3, -15, 3, -8, 3, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86, 4, -1, -1, - -1, -1, -1, -1, 90, 4,-103, 4, -1, -1, -1, -1, -1, -1, -39, 4, - -35, 4, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, - 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, - 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, - 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, - 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, - 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, - 67, 0, 27, 91, 65, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, - 0, 27, 91, 49, 109, 0, 27, 55, 27, 91, 63, 52, 55, 104, 0, 27, - 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, - 52, 109, 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 50, 74, 27, 91, - 63, 52, 55, 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, - 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 49, - 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 27, 91, 63, 52, 55, 108, - 27, 61, 27, 91, 63, 49, 108, 0, 27, 91, 114, 27, 91, 109, 27, 91, - 50, 74, 27, 91, 72, 27, 91, 63, 55, 104, 27, 91, 63, 49, 59, 51, - 59, 52, 59, 54, 108, 27, 91, 52, 108, 0, 27, 91, 64, 0, 27, 91, - 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 91, 66, 0, 27, 91, 56, - 94, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, 49, 126, 0, 27, 91, - 50, 49, 126, 0, 27, 91, 49, 50, 126, 0, 27, 91, 49, 51, 126, 0, - 27, 91, 49, 52, 126, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, - 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, - 50, 48, 126, 0, 27, 91, 55, 126, 0, 27, 91, 50, 126, 0, 27, 91, - 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 91, 67, 0, - 27, 91, 97, 0, 27, 91, 98, 0, 27, 91, 65, 0, 27, 62, 0, 27, - 61, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, - 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, - 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, - 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, - 0, 27, 62, 27, 91, 49, 59, 51, 59, 52, 59, 53, 59, 54, 108, 27, - 91, 63, 55, 104, 27, 91, 109, 27, 91, 114, 27, 91, 50, 74, 27, 91, - 72, 0, 27, 91, 114, 27, 91, 109, 27, 91, 50, 74, 27, 91, 72, 27, - 91, 63, 55, 104, 27, 91, 63, 49, 59, 51, 59, 52, 59, 54, 108, 27, - 91, 52, 108, 27, 62, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, - 50, 53, 104, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, - 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, - 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, - 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, - 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, - 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, - 9, 0, 27, 79, 119, 0, 27, 79, 121, 0, 27, 79, 117, 0, 27, 79, - 113, 0, 27, 79, 115, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, - 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, - 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, - 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, - 27, 41, 48, 0, 27, 91, 56, 126, 0, 27, 79, 77, 0, 27, 91, 49, - 126, 0, 27, 91, 51, 36, 0, 27, 91, 52, 126, 0, 27, 91, 56, 36, - 0, 27, 91, 55, 36, 0, 27, 91, 50, 36, 0, 27, 91, 100, 0, 27, - 91, 54, 36, 0, 27, 91, 53, 36, 0, 27, 91, 99, 0, 27, 91, 50, - 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, 0, 27, - 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, 57, 126, - 0, 27, 91, 51, 49, 126, 0, 27, 91, 51, 50, 126, 0, 27, 91, 51, - 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 50, 51, 36, 0, 27, - 91, 50, 52, 36, 0, 27, 91, 49, 49, 94, 0, 27, 91, 49, 50, 94, - 0, 27, 91, 49, 51, 94, 0, 27, 91, 49, 52, 94, 0, 27, 91, 49, - 53, 94, 0, 27, 91, 49, 55, 94, 0, 27, 91, 49, 56, 94, 0, 27, - 91, 49, 57, 94, 0, 27, 91, 50, 48, 94, 0, 27, 91, 50, 49, 94, - 0, 27, 91, 50, 51, 94, 0, 27, 91, 50, 52, 94, 0, 27, 91, 50, - 53, 94, 0, 27, 91, 50, 54, 94, 0, 27, 91, 50, 56, 94, 0, 27, - 91, 50, 57, 94, 0, 27, 91, 51, 49, 94, 0, 27, 91, 51, 50, 94, - 0, 27, 91, 51, 51, 94, 0, 27, 91, 51, 52, 94, 0, 27, 91, 50, - 51, 64, 0, 27, 91, 50, 52, 64, 0, 27, 91, 49, 75, 0, 27, 91, - 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, - 63, 49, 59, 50, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, - 57, 109, 0, 27, 93, 49, 48, 52, 7, 0, 27, 93, 52, 59, 37, 112, - 49, 37, 100, 59, 114, 103, 98, 58, 37, 112, 50, 37, 123, 50, 53, 53, - 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, - 88, 47, 37, 112, 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, - 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 52, 37, - 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, - 37, 50, 46, 50, 88, 27, 92, 0, 27, 91, 77, 0, 27, 91, 37, 63, - 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, - 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, - 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, - 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, - 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, - 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, - 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, - 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 40, 66, 0, 27, - 40, 48, 0 -}; -// Taken from Dickey ncurses terminfo.src dated 2017-04-22. -// This is a 16-colour terminfo description that lacks true-colour -// and 256-colour capabilities that linux (4.8+) actually has. -static const signed char linux_16colour_terminfo[] = { - 26, 1, 43, 0, 29, 0, 16, 0, 125, 1, 125, 3, 108, 105, 110, 117, - 120, 45, 49, 54, 99, 111, 108, 111, 114, 124, 108, 105, 110, 117, 120, 32, - 99, 111, 110, 115, 111, 108, 101, 32, 119, 105, 116, 104, 32, 49, 54, 32, - 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 1, 1, -1, -1, 8, 0, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, 0, - 0, 1, 42, 0, -1, -1, 0, 0, 2, 0, 4, 0, 21, 0, 26, 0, - 33, 0, 37, 0, 41, 0, -1, -1, 52, 0, 69, 0, 71, 0, 75, 0, - 87, 0, -1, -1, 89, 0, 101, 0, -1, -1, 105, 0, 109, 0, 121, 0, - 125, 0, -1, -1, -1, -1,-127, 0,-125, 0,-120, 0, -1, -1, -1, -1, --115, 0,-110, 0, -1, -1, -1, -1,-105, 0,-100, 0, -95, 0, -90, 0, - -81, 0, -79, 0, -1, -1, -1, -1, -74, 0, -69, 0, -63, 0, -57, 0, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -39, 0, -35, 0, - -1, -1, -31, 0, -1, -1, -1, -1, -1, -1, -29, 0, -1, -1, -24, 0, - -1, -1, -1, -1, -1, -1, -1, -1, -20, 0, -15, 0, -9, 0, -4, 0, - 1, 1, 6, 1, 11, 1, 17, 1, 23, 1, 29, 1, 35, 1, 40, 1, - -1, -1, 45, 1, -1, -1, 49, 1, 54, 1, 59, 1, -1, -1, -1, -1, - -1, -1, 63, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 67, 1, -1, -1, 70, 1, 79, 1, 88, 1, 97, 1, -1, -1, - 106, 1, 115, 1, 124, 1, -1, -1,-123, 1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1,-114, 1, -1, -1, -1, -1, -1, -1, --108, 1,-105, 1, -94, 1, -91, 1, -89, 1, -86, 1, 1, 2, -1, -1, - 4, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 2, - -1, -1, -1, -1, -1, -1, -1, -1, 10, 2, -1, -1, 77, 2, -1, -1, - -1, -1, 81, 2, 87, 2, -1, -1, -1, -1, 93, 2, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 97, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 102, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 104, 2, 110, 2, 116, 2, 122, 2,-128, 2,-122, 2, --116, 2,-110, 2,-104, 2, -98, 2, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -92, 2, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -87, 2, - -76, 2, -71, 2, -65, 2, -61, 2, -52, 2, -48, 2, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 3, -1, -1, -1, -1, - -1, -1, 37, 3, 75, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 113, 3, 119, 3, 7, 0, - 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, - 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, - 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, - 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, - 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 27, - 91, 63, 49, 99, 0, 8, 0, 27, 91, 63, 50, 53, 104, 27, 91, 63, - 48, 99, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 63, 50, 53, - 104, 27, 91, 63, 56, 99, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, - 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 50, 109, 0, - 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, - 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 15, 0, 27, - 91, 109, 15, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, - 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, 50, 48, 48, 47, - 62, 27, 91, 63, 53, 108, 0, 27, 91, 64, 0, 27, 91, 76, 0, 127, - 0, 27, 91, 51, 126, 0, 27, 91, 66, 0, 27, 91, 91, 65, 0, 27, - 91, 50, 49, 126, 0, 27, 91, 91, 66, 0, 27, 91, 91, 67, 0, 27, - 91, 91, 68, 0, 27, 91, 91, 69, 0, 27, 91, 49, 55, 126, 0, 27, - 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, - 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 91, 68, 0, 27, - 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 91, 67, 0, 27, 91, 65, - 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, - 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, - 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, - 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, - 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 93, - 82, 0, 27, 56, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, - 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 59, 49, 48, 37, 63, - 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, - 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, - 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 53, 37, - 116, 59, 50, 37, 59, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, - 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, - 72, 0, 9, 0, 27, 91, 71, 0, 43, 43, 44, 44, 45, 45, 46, 46, - 48, 48, 95, 95, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, - 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, - 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, - 122, 122, 123, 123, 124, 124, 125, 99, 126, 126, 0, 27, 91, 90, 0, 27, - 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 41, 48, 0, 27, - 91, 52, 126, 0, 26, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, - 126, 0, 27, 91, 50, 53, 126, 0, 27, 91, 50, 54, 126, 0, 27, 91, - 50, 56, 126, 0, 27, 91, 50, 57, 126, 0, 27, 91, 51, 49, 126, 0, - 27, 91, 51, 50, 126, 0, 27, 91, 51, 51, 126, 0, 27, 91, 51, 52, - 126, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, - 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 54, 99, 0, 27, 91, 99, - 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 93, 82, 0, 27, 93, - 80, 37, 112, 49, 37, 120, 37, 112, 50, 37, 123, 50, 53, 53, 125, 37, - 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 37, 112, - 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, - 37, 47, 37, 48, 50, 120, 37, 112, 52, 37, 123, 50, 53, 53, 125, 37, - 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 48, 50, 120, 0, 27, - 91, 77, 0, 27, 91, 51, 37, 112, 49, 37, 123, 56, 125, 37, 109, 37, - 100, 37, 63, 37, 112, 49, 37, 123, 55, 125, 37, 62, 37, 116, 59, 49, - 37, 101, 59, 50, 49, 37, 59, 109, 0, 27, 91, 52, 37, 112, 49, 37, - 123, 56, 125, 37, 109, 37, 100, 37, 63, 37, 112, 49, 37, 123, 55, 125, - 37, 62, 37, 116, 59, 53, 37, 101, 59, 50, 53, 37, 59, 109, 0, 27, - 91, 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 -}; -// Taken from Dickey ncurses terminfo.src dated 2017-04-22. -static const signed char putty_256colour_terminfo[] = { - 26, 1, 48, 0, 29, 0, 16, 0, 125, 1,-106, 4, 112, 117, 116, 116, - 121, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 80, 117, 84, 84, 89, - 32, 48, 46, 53, 56, 32, 119, 105, 116, 104, 32, 120, 116, 101, 114, 109, - 32, 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, 1, 1, 0, 0, - 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, -1, -1, 8, 0, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 0, 1, -1, 127, 22, 0, 0, 0, 4, 0, 6, 0, - 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, 45, 0, -1, -1, 56, 0, - 73, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, 96, 0, -1, -1, - 100, 0, -1, -1, 103, 0, 107, 0, 111, 0, -1, -1, 117, 0, 119, 0, - 124, 0,-127, 0, -1, -1, -1, -1,-120, 0, -1, -1, -1, -1,-115, 0, --110, 0,-105, 0,-100, 0, -91, 0, -89, 0, -84, 0, -1, -1, -73, 0, - -68, 0, -62, 0, -56, 0, -1, -1, -38, 0, -1, -1, -36, 0, -1, -1, - -1, -1, -1, -1, -2, 0, -1, -1, 2, 1, -1, -1, -1, -1, -1, -1, - 4, 1, -1, -1, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, 13, 1, - 19, 1, 25, 1, 31, 1, 37, 1, 43, 1, 49, 1, 55, 1, 61, 1, - 67, 1, 73, 1, 78, 1, -1, -1, 83, 1, -1, -1, 87, 1, 92, 1, - 97, 1, 101, 1, 105, 1, -1, -1, 109, 1, 113, 1, 121, 1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1,-127, 1, -1, -1,-124, 1,-115, 1, --106, 1, -1, -1, -97, 1, -88, 1, -79, 1, -70, 1, -61, 1, -52, 1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -43, 1, -1, -1, -1, -1, -10, 1, -7, 1, 4, 2, 7, 2, 9, 2, - 12, 2, 84, 2, -1, -1, 87, 2, 89, 2, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 94, 2, -1, -1, -1, -1, -1, -1, -1, -1, 98, 2, - -1, -1,-107, 2, -1, -1, -1, -1,-103, 2, -97, 2, -1, -1, -1, -1, - -91, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -84, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -79, 2, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -77, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -73, 2, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -69, 2, -63, 2, -57, 2, - -51, 2, -45, 2, -39, 2, -33, 2, -27, 2, -21, 2, -15, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -4, 2, 7, 3, 12, 3, 18, 3, 22, 3, 31, 3, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 35, 3, -1, -1, -1, -1, -1, -1, 39, 3, 102, 3, -1, -1, -1, -1, - -1, -1, -90, 3, -84, 3, -78, 3, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -72, 3, --118, 4,-112, 4, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, - 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, - 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, - 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, - 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 27, 68, 0, - 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, - 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 80, 0, 27, - 91, 77, 0, 27, 93, 48, 59, 7, 0, 14, 0, 27, 91, 53, 109, 0, - 27, 91, 49, 109, 0, 27, 91, 63, 52, 55, 104, 0, 27, 91, 52, 104, - 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, - 27, 91, 37, 112, 49, 37, 100, 88, 0, 15, 0, 27, 91, 109, 15, 0, - 27, 91, 50, 74, 27, 91, 63, 52, 55, 108, 0, 27, 91, 52, 108, 0, - 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, - 104, 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 7, 0, - 27, 55, 27, 91, 114, 27, 91, 109, 27, 91, 63, 55, 104, 27, 91, 63, - 49, 59, 52, 59, 54, 108, 27, 91, 52, 108, 27, 56, 27, 62, 27, 93, - 82, 0, 27, 91, 76, 0, 127, 0, 27, 91, 51, 126, 0, 27, 79, 66, - 0, 27, 91, 49, 49, 126, 0, 27, 91, 50, 49, 126, 0, 27, 91, 49, - 50, 126, 0, 27, 91, 49, 51, 126, 0, 27, 91, 49, 52, 126, 0, 27, - 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, - 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, - 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, - 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 91, 66, 0, 27, 91, 65, - 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, - 49, 104, 27, 61, 0, 13, 10, 0, 27, 91, 37, 112, 49, 37, 100, 80, - 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, - 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, - 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, - 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, - 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 60, 27, 91, 34, 112, 27, - 91, 53, 48, 59, 54, 34, 112, 27, 99, 27, 91, 63, 51, 108, 27, 93, - 82, 27, 91, 63, 49, 48, 48, 48, 108, 0, 27, 56, 0, 27, 91, 37, - 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, - 27, 91, 48, 37, 63, 37, 112, 49, 37, 112, 54, 37, 124, 37, 116, 59, - 49, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, - 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, - 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, - 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 27, 93, 48, - 59, 0, 27, 91, 71, 0, 96, 96, 97, 97, 102, 102, 103, 103, 106, 106, - 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, - 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, - 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 91, 63, - 55, 104, 0, 27, 91, 63, 55, 108, 0, 27, 40, 66, 27, 41, 48, 0, - 27, 91, 52, 126, 0, 26, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, - 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 50, 53, 126, - 0, 27, 91, 50, 54, 126, 0, 27, 91, 50, 56, 126, 0, 27, 91, 50, - 57, 126, 0, 27, 91, 51, 49, 126, 0, 27, 91, 51, 50, 126, 0, 27, - 91, 51, 51, 126, 0, 27, 91, 51, 52, 126, 0, 27, 91, 49, 75, 0, - 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, - 27, 91, 63, 54, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, - 57, 109, 0, 27, 93, 82, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, - 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, - 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, - 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, - 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, - 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, - 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, - 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, - 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 49, 48, 109, 0, - 27, 91, 49, 49, 109, 0, 27, 91, 49, 50, 109, 0, 37, 63, 37, 112, - 49, 37, 123, 56, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-105,-104, - 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 48, 125, 37, 61, - 37, 116, 27, 37, 37, 71, -30,-105,-103, 27, 37, 37, 64, 37, 101, 37, - 112, 49, 37, 123, 49, 50, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30, --103,-128, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, 51, 125, - 37, 61, 37, 116, 27, 37, 37, 71, -30,-103, -86, 27, 37, 37, 64, 37, - 101, 37, 112, 49, 37, 123, 49, 52, 125, 37, 61, 37, 116, 27, 37, 37, - 71, -30,-103, -85, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 123, 49, - 53, 125, 37, 61, 37, 116, 27, 37, 37, 71, -30,-104, -68, 27, 37, 37, - 64, 37, 101, 37, 112, 49, 37, 123, 50, 55, 125, 37, 61, 37, 116, 27, - 37, 37, 71, -30,-122,-112, 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, - 123, 49, 53, 53, 125, 37, 61, 37, 116, 27, 37, 37, 71, -32,-126, -94, - 27, 37, 37, 64, 37, 101, 37, 112, 49, 37, 99, 37, 59, 0, 27, 91, - 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 -}; -// Taken from Dickey ncurses terminfo.src dated 2017-04-22. -static const signed char interix_8colour_terminfo[] = { - 26, 1, 82, 0, 15, 0, 16, 0, 105, 1, 123, 2, 105, 110, 116, 101, - 114, 105, 120, 124, 111, 112, 101, 110, 110, 116, 124, 111, 112, 101, 110, 110, - 116, 45, 50, 53, 124, 110, 116, 99, 111, 110, 115, 111, 108, 101, 124, 110, - 116, 99, 111, 110, 115, 111, 108, 101, 45, 50, 53, 124, 79, 112, 101, 110, - 78, 84, 45, 116, 101, 114, 109, 32, 99, 111, 109, 112, 97, 116, 105, 98, - 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, 108, 111, 114, 0, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 80, 0, - -1, -1, 25, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 8, 0, 64, 0, 3, 0, 0, 0, - 4, 0, -1, -1, -1, -1, -1, -1, 6, 0, 11, 0, 15, 0, -1, -1, - -1, -1, 19, 0, 36, 0, 38, 0, -1, -1, 42, 0, -1, -1, -1, -1, - 46, 0, 50, 0, 54, 0, -1, -1, -1, -1, 58, 0, -1, -1, -1, -1, - -1, -1, -1, -1, 62, 0, 67, 0, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 75, 0, 80, 0, 85, 0, -1, -1, -1, -1, 90, 0, 95, 0, - -1, -1, -1, -1, 107, 0, 111, 0, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 115, 0, -1, -1, 119, 0, -1, -1, - -1, -1, -1, -1, 121, 0, -1, -1, 125, 0, -1, -1, -1, -1, -1, -1, --127, 0,-123, 0,-119, 0,-115, 0,-111, 0,-107, 0,-103, 0, -99, 0, - -95, 0, -91, 0, -87, 0, -1, -1, -83, 0, -1, -1, -79, 0, -75, 0, - -71, 0, -67, 0, -63, 0, -1, -1, -1, -1, -1, -1, -59, 0, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -55, 0, -1, -1, - -1, -1, -52, 0, -43, 0, -1, -1, -34, 0, -25, 0, -16, 0, -7, 0, - 2, 1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 20, 1, -1, -1, -1, -1, -1, -1, 23, 1, -1, -1, 27, 1, - 31, 1, 35, 1, -1, -1, -1, -1, -1, -1, 39, 1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 41, 1, -1, -1, 104, 1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 108, 1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 112, 1, - 116, 1, 120, 1, 124, 1,-128, 1,-124, 1,-120, 1,-116, 1,-112, 1, --108, 1,-104, 1,-100, 1, -96, 1, -92, 1, -88, 1, -84, 1, -80, 1, - -76, 1, -72, 1, -68, 1, -64, 1, -60, 1, -56, 1, -52, 1, -48, 1, - -44, 1, -40, 1, -36, 1, -32, 1, -28, 1, -24, 1, -20, 1, -16, 1, - -12, 1, -8, 1, -4, 1, 0, 2, 4, 2, 8, 2, 12, 2, 16, 2, - 20, 2, 24, 2, 28, 2, 32, 2, 36, 2, 40, 2, 44, 2, 48, 2, - 52, 2, 56, 2, 60, 2, 64, 2, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 68, 2, -1, -1, -1, -1, -1, -1, -1, -1, 72, 2, 88, 2, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 103, 2, 113, 2, - 27, 91, 90, 0, 7, 0, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, - 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, - 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 68, 0, 27, 91, - 67, 0, 27, 91, 85, 0, 27, 91, 65, 0, 27, 91, 77, 0, 27, 91, - 49, 109, 0, 27, 91, 115, 27, 91, 49, 98, 0, 27, 91, 55, 109, 0, - 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 48, 109, 0, 27, - 91, 50, 98, 27, 91, 117, 13, 27, 91, 75, 0, 27, 91, 109, 0, 27, - 91, 109, 0, 27, 91, 76, 0, 8, 0, 27, 91, 77, 0, 27, 91, 66, - 0, 27, 70, 65, 0, 27, 70, 49, 0, 27, 70, 65, 0, 27, 70, 50, - 0, 27, 70, 51, 0, 27, 70, 52, 0, 27, 70, 53, 0, 27, 70, 54, - 0, 27, 70, 55, 0, 27, 70, 56, 0, 27, 70, 57, 0, 27, 91, 76, - 0, 27, 91, 68, 0, 27, 91, 85, 0, 27, 91, 84, 0, 27, 91, 83, - 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 10, 0, 27, 91, 37, 112, - 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, - 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, - 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, - 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, - 37, 100, 65, 0, 27, 99, 0, 27, 91, 117, 0, 27, 91, 115, 0, 27, - 91, 83, 0, 27, 91, 84, 0, 9, 0, 43, 16, 44, 17, 45, 24, 46, - 25, 48, -37, 96, 4, 97, -79, 102, -8, 103, -15, 104, -80, 106, -39, 107, - -65, 108, -38, 109, -64, 110, -59, 111, 126, 112, -60, 113, -60, 114, -60, 115, - 95, 116, -61, 117, -76, 118, -63, 119, -62, 120, -77, 121, -13, 122, -14, 123, - -29, 124, -40, 125,-100, 126, -2, 0, 27, 91, 90, 0, 27, 91, 85, 0, - 27, 70, 66, 0, 27, 70, 67, 0, 27, 70, 68, 0, 27, 70, 69, 0, - 27, 70, 70, 0, 27, 70, 71, 0, 27, 70, 72, 0, 27, 70, 73, 0, - 27, 70, 74, 0, 27, 70, 75, 0, 27, 70, 76, 0, 27, 70, 77, 0, - 27, 70, 78, 0, 27, 70, 79, 0, 27, 70, 80, 0, 27, 70, 81, 0, - 27, 70, 82, 0, 27, 70, 83, 0, 27, 70, 84, 0, 27, 70, 85, 0, - 27, 70, 86, 0, 27, 70, 87, 0, 27, 70, 88, 0, 27, 70, 89, 0, - 27, 70, 90, 0, 27, 70, 97, 0, 27, 70, 98, 0, 27, 70, 99, 0, - 27, 70, 100, 0, 27, 70, 101, 0, 27, 70, 102, 0, 27, 70, 103, 0, - 27, 70, 104, 0, 27, 70, 105, 0, 27, 70, 106, 0, 27, 70, 107, 0, - 27, 70, 109, 0, 27, 70, 110, 0, 27, 70, 111, 0, 27, 70, 112, 0, - 27, 70, 113, 0, 27, 70, 114, 0, 27, 70, 115, 0, 27, 70, 116, 0, - 27, 70, 117, 0, 27, 70, 118, 0, 27, 70, 119, 0, 27, 70, 120, 0, - 27, 70, 121, 0, 27, 70, 122, 0, 27, 70, 43, 0, 27, 70, 45, 0, - 27, 70, 12, 0, 27, 91, 109, 0, 27, 91, 37, 112, 49, 37, 123, 51, - 48, 125, 37, 43, 37, 100, 109, 0, 27, 91, 37, 112, 49, 37, 39, 40, - 39, 37, 43, 37, 100, 109, 0, 27, 91, 51, 37, 112, 49, 37, 100, 109, - 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0 -}; -// Taken from Dickey ncurses terminfo.src dated 2017-04-22. -// This is a 256-colour terminfo description that lacks true-colour -// capabilities that stterm actually has. -static const signed char st_256colour_terminfo[] = { - 26, 1, 55, 0, 29, 0, 15, 0, 105, 1, 117, 5, 115, 116, 45, 50, - 53, 54, 99, 111, 108, 111, 114, 124, 115, 116, 116, 101, 114, 109, 45, 50, - 53, 54, 99, 111, 108, 111, 114, 124, 115, 105, 109, 112, 108, 101, 116, 101, - 114, 109, 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, - 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, - 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, - 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, 38, 0, 42, 0, 46, 0, - -1, -1, 57, 0, 74, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, - 102, 0, -1, -1, 106, 0, 110, 0, 117, 0, 121, 0, -1, -1, -1, -1, - 125, 0,-127, 0,-122, 0,-117, 0, -1, -1, -1, -1,-108, 0,-103, 0, - -1, -1, -98, 0, -93, 0, -88, 0, -83, 0, -74, 0, -70, 0, -65, 0, - -1, -1, -56, 0, -51, 0, -45, 0, -39, 0, -1, -1, -21, 0, -1, -1, - -19, 0, -1, -1, -1, -1, -1, -1, -4, 0, -1, -1, 0, 1, -1, -1, - 2, 1, -1, -1, 9, 1, 14, 1, 21, 1, 25, 1, 32, 1, 39, 1, - -1, -1, 46, 1, 50, 1, 56, 1, 60, 1, 64, 1, 68, 1, 74, 1, - 80, 1, 86, 1, 92, 1, 98, 1, 103, 1, 108, 1, 115, 1, -1, -1, - 119, 1, 124, 1,-127, 1,-123, 1,-116, 1, -1, -1,-109, 1,-105, 1, - -97, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -89, 1, -80, 1, -71, 1, -62, 1, -53, 1, -44, 1, -35, 1, -26, 1, - -1, -1, -17, 1, -1, -1, -1, -1, -1, -1, -8, 1, -4, 1, 1, 2, - -1, -1, 6, 2, 9, 2, -1, -1, -1, -1, 24, 2, 27, 2, 38, 2, - 41, 2, 43, 2, 46, 2,-128, 2, -1, -1,-125, 2,-123, 2, -1, -1, - -1, -1, -1, -1,-118, 2,-113, 2,-108, 2,-104, 2, -99, 2, -1, -1, - -1, -1, -94, 2, -1, -1, -29, 2, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -25, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -21, 2, -16, 2, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -12, 2, -1, -1, - -1, -1, -5, 2, -1, -1, -1, -1, -1, -1, -1, -1, 2, 3, 9, 3, - 16, 3, -1, -1, -1, -1, 23, 3, -1, -1, 30, 3, -1, -1, -1, -1, - -1, -1, 37, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 3, - 50, 3, 56, 3, 63, 3, 70, 3, 77, 3, 84, 3, 92, 3, 100, 3, - 108, 3, 116, 3, 124, 3,-124, 3,-116, 3,-108, 3,-101, 3, -94, 3, - -87, 3, -80, 3, -72, 3, -64, 3, -56, 3, -48, 3, -40, 3, -32, 3, - -24, 3, -16, 3, -9, 3, -2, 3, 5, 4, 12, 4, 20, 4, 28, 4, - 36, 4, 44, 4, 52, 4, 60, 4, 68, 4, 76, 4, 83, 4, 90, 4, - 97, 4, 104, 4, 112, 4, 120, 4,-128, 4,-120, 4,-112, 4,-104, 4, - -96, 4, -88, 4, -81, 4, -74, 4, -67, 4, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -62, 4, -51, 4, -46, 4, -38, 4, - -34, 4, -2, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -25, 4, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -20, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -14, 4, -1, -1, -1, -1, -1, -1, -10, 4, 53, 5, - 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, - 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, - 72, 27, 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, - 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, - 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, - 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 49, 50, 108, 27, - 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, - 63, 50, 53, 104, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 40, 48, - 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, 48, - 52, 57, 104, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, 0, 27, 91, - 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, - 112, 49, 37, 100, 88, 0, 27, 40, 66, 0, 27, 91, 48, 109, 0, 27, - 91, 63, 49, 48, 52, 57, 108, 0, 27, 91, 52, 108, 0, 27, 91, 50, - 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, 36, 60, - 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 7, 0, 27, 91, 52, - 108, 27, 62, 27, 91, 63, 49, 48, 51, 52, 108, 0, 27, 91, 76, 0, - 127, 0, 27, 91, 51, 59, 53, 126, 0, 27, 91, 51, 126, 0, 27, 91, - 51, 59, 50, 126, 0, 27, 79, 66, 0, 27, 91, 50, 59, 50, 126, 0, - 27, 91, 49, 59, 50, 70, 0, 27, 91, 49, 59, 53, 70, 0, 27, 79, - 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, - 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, - 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, - 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 91, 50, 59, - 53, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, - 0, 27, 79, 67, 0, 27, 91, 49, 59, 50, 66, 0, 27, 91, 49, 59, - 50, 65, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, - 91, 63, 49, 104, 27, 61, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, - 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, - 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, - 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, - 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, - 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 105, 0, 27, 91, 52, 105, - 0, 27, 91, 53, 105, 0, 27, 99, 0, 27, 91, 52, 108, 27, 62, 27, - 91, 63, 49, 48, 51, 52, 108, 0, 27, 56, 0, 27, 91, 37, 105, 37, - 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, 0, 27, 77, 0, 37, 63, - 37, 112, 57, 37, 116, 27, 40, 48, 37, 101, 27, 40, 66, 37, 59, 27, - 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, - 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, - 37, 124, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, - 53, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 109, 0, - 27, 72, 0, 9, 0, 27, 93, 48, 59, 0, 27, 91, 49, 126, 0, 27, - 91, 53, 126, 0, 27, 79, 117, 0, 27, 91, 52, 126, 0, 27, 91, 54, - 126, 0, 43, 67, 44, 68, 45, 65, 46, 66, 48, 69, 96, 96, 97, 97, - 102, 102, 103, 103, 104, 70, 105, 71, 106, 106, 107, 107, 108, 108, 109, 109, - 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, - 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, - 126, 126, 0, 27, 91, 90, 0, 27, 41, 48, 0, 27, 91, 52, 126, 0, - 27, 79, 77, 0, 27, 91, 51, 59, 50, 126, 0, 27, 91, 49, 59, 50, - 70, 0, 27, 91, 49, 59, 50, 72, 0, 27, 91, 50, 59, 50, 126, 0, - 27, 91, 49, 59, 50, 68, 0, 27, 91, 54, 59, 50, 126, 0, 27, 91, - 53, 59, 50, 126, 0, 27, 91, 49, 59, 50, 67, 0, 27, 91, 50, 51, - 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 59, 50, 80, 0, 27, - 91, 49, 59, 50, 81, 0, 27, 91, 49, 59, 50, 82, 0, 27, 91, 49, - 59, 50, 83, 0, 27, 91, 49, 53, 59, 50, 126, 0, 27, 91, 49, 55, - 59, 50, 126, 0, 27, 91, 49, 56, 59, 50, 126, 0, 27, 91, 49, 57, - 59, 50, 126, 0, 27, 91, 50, 48, 59, 50, 126, 0, 27, 91, 50, 49, - 59, 50, 126, 0, 27, 91, 50, 51, 59, 50, 126, 0, 27, 91, 50, 52, - 59, 50, 126, 0, 27, 91, 49, 59, 53, 80, 0, 27, 91, 49, 59, 53, - 81, 0, 27, 91, 49, 59, 53, 82, 0, 27, 91, 49, 59, 53, 83, 0, - 27, 91, 49, 53, 59, 53, 126, 0, 27, 91, 49, 55, 59, 53, 126, 0, - 27, 91, 49, 56, 59, 53, 126, 0, 27, 91, 49, 57, 59, 53, 126, 0, - 27, 91, 50, 48, 59, 53, 126, 0, 27, 91, 50, 49, 59, 53, 126, 0, - 27, 91, 50, 51, 59, 53, 126, 0, 27, 91, 50, 52, 59, 53, 126, 0, - 27, 91, 49, 59, 54, 80, 0, 27, 91, 49, 59, 54, 81, 0, 27, 91, - 49, 59, 54, 82, 0, 27, 91, 49, 59, 54, 83, 0, 27, 91, 49, 53, - 59, 54, 126, 0, 27, 91, 49, 55, 59, 54, 126, 0, 27, 91, 49, 56, - 59, 54, 126, 0, 27, 91, 49, 57, 59, 54, 126, 0, 27, 91, 50, 48, - 59, 54, 126, 0, 27, 91, 50, 49, 59, 54, 126, 0, 27, 91, 50, 51, - 59, 54, 126, 0, 27, 91, 50, 52, 59, 54, 126, 0, 27, 91, 49, 59, - 51, 80, 0, 27, 91, 49, 59, 51, 81, 0, 27, 91, 49, 59, 51, 82, - 0, 27, 91, 49, 59, 51, 83, 0, 27, 91, 49, 53, 59, 51, 126, 0, - 27, 91, 49, 55, 59, 51, 126, 0, 27, 91, 49, 56, 59, 51, 126, 0, - 27, 91, 49, 57, 59, 51, 126, 0, 27, 91, 50, 48, 59, 51, 126, 0, - 27, 91, 50, 49, 59, 51, 126, 0, 27, 91, 50, 51, 59, 51, 126, 0, - 27, 91, 50, 52, 59, 51, 126, 0, 27, 91, 49, 59, 52, 80, 0, 27, - 91, 49, 59, 52, 81, 0, 27, 91, 49, 59, 52, 82, 0, 27, 91, 49, - 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, - 110, 0, 27, 91, 63, 49, 59, 50, 99, 0, 27, 91, 99, 0, 27, 91, - 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 109, 0, 27, 91, 50, 51, - 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, - 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, - 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, - 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, - 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, - 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, - 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, - 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, - 100, 37, 59, 109, 0 -}; -// Taken from Dickey ncurses terminfo.src dated 2017-04-22. -// This is a 256-colour terminfo description that lacks true-colour -// capabilities that gnome actually has. -static const signed char vte_256colour_terminfo[] = { - 26, 1, 52, 0, 29, 0, 15, 0, 105, 1, -55, 5, 103, 110, 111, 109, - 101, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 71, 78, 79, 77, 69, - 32, 84, 101, 114, 109, 105, 110, 97, 108, 32, 119, 105, 116, 104, 32, 120, - 116, 101, 114, 109, 32, 50, 53, 54, 45, 99, 111, 108, 111, 114, 115, 0, - 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 80, 0, - 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, - 6, 0, 8, 0, 25, 0, 30, 0, 38, 0, 42, 0, 46, 0, -1, -1, - 57, 0, 74, 0, 76, 0, 80, 0, 87, 0, -1, -1, 89, 0, 96, 0, - -1, -1, 100, 0, -1, -1, 104, 0, 108, 0, -1, -1, -1, -1, 112, 0, - -1, -1, 114, 0, 119, 0, -1, -1, -128, 0, -123, 0, -118, 0, -1, -1, --113, 0, -108, 0, -103, 0, -98, 0, -89, 0, -87, 0, -81, 0, -1, -1, - -68, 0, -63, 0, -57, 0, -51, 0, -1, -1, -1, -1, -1, -1, -33, 0, - -1, -1, -1, -1, -1, -1, 0, 1, -1, -1, 4, 1, -1, -1, -1, -1, - -1, -1, 6, 1, -1, -1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, - 15, 1, 19, 1, 25, 1, 29, 1, 33, 1, 37, 1, 43, 1, 49, 1, - 55, 1, 61, 1, 67, 1, 71, 1, -1, -1, 76, 1, -1, -1, 80, 1, - 85, 1, 90, 1, 94, 1, 101, 1, -1, -1, 108, 1, 112, 1, 120, 1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -128, 1, --119, 1, -110, 1, -101, 1, -92, 1, -83, 1, -74, 1, -65, 1, -56, 1, - -47, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -38, 1, -35, 1, -1, -1, -1, -1, 16, 2, 19, 2, 30, 2, 33, 2, - 35, 2, 38, 2, 116, 2, -1, -1, 119, 2, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 121, 2, -1, -1, -1, -1, -1, -1, -1, -1, - 125, 2, -1, -1, -78, 2, -1, -1, -1, -1, -74, 2, -68, 2, -1, -1, - -1, -1, -62, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -58, 2, -54, 2, -1, -1, -50, 2, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -45, 2, -1, -1, -38, 2, - -33, 2, -1, -1, -1, -1, -1, -1, -1, -1, -26, 2, -19, 2, -12, 2, - -1, -1, -1, -1, -5, 2, -1, -1, 2, 3, -1, -1, -1, -1, -1, -1, - 9, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 16, 3, 22, 3, - 28, 3, 35, 3, 42, 3, 49, 3, 56, 3, 64, 3, 72, 3, 80, 3, - 88, 3, 96, 3, 104, 3, 112, 3, 120, 3, 127, 3, -122, 3, -115, 3, --108, 3, -100, 3, -92, 3, -84, 3, -76, 3, -68, 3, -60, 3, -52, 3, - -44, 3, -37, 3, -30, 3, -23, 3, -16, 3, -8, 3, 0, 4, 8, 4, - 16, 4, 24, 4, 32, 4, 40, 4, 48, 4, 55, 4, 62, 4, 69, 4, - 76, 4, 84, 4, 92, 4, 100, 4, 108, 4, 116, 4, 124, 4, -124, 4, --116, 4, -109, 4, -102, 4, -95, 4, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -90, 4, -79, 4, -74, 4, -55, 4, -51, 4, - -42, 4, -35, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 59, 5, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 64, 5, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 70, 5, -1, -1, -1, -1, -1, -1, 74, 5, -119, 5, 27, 91, - 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, - 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, - 91, 50, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, - 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, - 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, - 63, 50, 53, 108, 0, 8, 0, 27, 91, 63, 50, 53, 104, 0, 27, 91, - 67, 0, 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, 0, - 27, 91, 49, 109, 0, 27, 55, 27, 91, 63, 52, 55, 104, 0, 27, 91, - 50, 109, 0, 27, 91, 52, 104, 0, 27, 91, 56, 109, 0, 27, 91, 55, - 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, - 49, 37, 100, 88, 0, 15, 0, 27, 91, 48, 109, 15, 0, 27, 91, 50, - 74, 27, 91, 63, 52, 55, 108, 27, 56, 0, 27, 91, 52, 108, 0, 27, - 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 91, 63, 53, 104, - 36, 60, 49, 48, 48, 47, 62, 27, 91, 63, 53, 108, 0, 27, 91, 109, - 27, 91, 63, 55, 104, 27, 91, 52, 108, 27, 62, 27, 55, 27, 91, 114, - 27, 91, 63, 49, 59, 51, 59, 52, 59, 54, 108, 27, 56, 0, 27, 91, - 76, 0, 127, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, - 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, - 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, - 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, - 0, 27, 79, 72, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, - 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 91, 49, 59, - 50, 66, 0, 27, 91, 49, 59, 50, 65, 0, 27, 79, 65, 0, 27, 91, - 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 91, - 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, - 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, - 64, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, - 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, - 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, - 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 0, 27, 55, 27, 91, 114, - 27, 56, 27, 91, 109, 27, 91, 63, 55, 104, 27, 91, 33, 112, 27, 91, - 63, 49, 59, 51, 59, 52, 59, 54, 108, 27, 91, 52, 108, 27, 62, 27, - 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, - 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 27, 55, 0, 10, - 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, - 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, - 112, 53, 37, 116, 59, 50, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, - 56, 37, 59, 37, 63, 37, 112, 49, 37, 112, 51, 37, 124, 37, 116, 59, - 55, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, - 59, 0, 27, 72, 0, 9, 0, 27, 91, 69, 0, 96, 96, 97, 97, 102, - 102, 103, 103, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, - 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, - 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, - 27, 91, 90, 0, 27, 91, 63, 55, 104, 0, 27, 91, 63, 55, 108, 0, - 27, 41, 48, 0, 27, 79, 70, 0, 27, 79, 77, 0, 27, 91, 49, 126, - 0, 27, 91, 51, 59, 50, 126, 0, 27, 91, 52, 126, 0, 27, 91, 49, - 59, 50, 70, 0, 27, 91, 49, 59, 50, 72, 0, 27, 91, 50, 59, 50, - 126, 0, 27, 91, 49, 59, 50, 68, 0, 27, 91, 54, 59, 50, 126, 0, - 27, 91, 53, 59, 50, 126, 0, 27, 91, 49, 59, 50, 67, 0, 27, 91, - 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 59, 50, 80, - 0, 27, 91, 49, 59, 50, 81, 0, 27, 91, 49, 59, 50, 82, 0, 27, - 91, 49, 59, 50, 83, 0, 27, 91, 49, 53, 59, 50, 126, 0, 27, 91, - 49, 55, 59, 50, 126, 0, 27, 91, 49, 56, 59, 50, 126, 0, 27, 91, - 49, 57, 59, 50, 126, 0, 27, 91, 50, 48, 59, 50, 126, 0, 27, 91, - 50, 49, 59, 50, 126, 0, 27, 91, 50, 51, 59, 50, 126, 0, 27, 91, - 50, 52, 59, 50, 126, 0, 27, 91, 49, 59, 53, 80, 0, 27, 91, 49, - 59, 53, 81, 0, 27, 91, 49, 59, 53, 82, 0, 27, 91, 49, 59, 53, - 83, 0, 27, 91, 49, 53, 59, 53, 126, 0, 27, 91, 49, 55, 59, 53, - 126, 0, 27, 91, 49, 56, 59, 53, 126, 0, 27, 91, 49, 57, 59, 53, - 126, 0, 27, 91, 50, 48, 59, 53, 126, 0, 27, 91, 50, 49, 59, 53, - 126, 0, 27, 91, 50, 51, 59, 53, 126, 0, 27, 91, 50, 52, 59, 53, - 126, 0, 27, 91, 49, 59, 54, 80, 0, 27, 91, 49, 59, 54, 81, 0, - 27, 91, 49, 59, 54, 82, 0, 27, 91, 49, 59, 54, 83, 0, 27, 91, - 49, 53, 59, 54, 126, 0, 27, 91, 49, 55, 59, 54, 126, 0, 27, 91, - 49, 56, 59, 54, 126, 0, 27, 91, 49, 57, 59, 54, 126, 0, 27, 91, - 50, 48, 59, 54, 126, 0, 27, 91, 50, 49, 59, 54, 126, 0, 27, 91, - 50, 51, 59, 54, 126, 0, 27, 91, 50, 52, 59, 54, 126, 0, 27, 91, - 49, 59, 51, 80, 0, 27, 91, 49, 59, 51, 81, 0, 27, 91, 49, 59, - 51, 82, 0, 27, 91, 49, 59, 51, 83, 0, 27, 91, 49, 53, 59, 51, - 126, 0, 27, 91, 49, 55, 59, 51, 126, 0, 27, 91, 49, 56, 59, 51, - 126, 0, 27, 91, 49, 57, 59, 51, 126, 0, 27, 91, 50, 48, 59, 51, - 126, 0, 27, 91, 50, 49, 59, 51, 126, 0, 27, 91, 50, 51, 59, 51, - 126, 0, 27, 91, 50, 52, 59, 51, 126, 0, 27, 91, 49, 59, 52, 80, - 0, 27, 91, 49, 59, 52, 81, 0, 27, 91, 49, 59, 52, 82, 0, 27, - 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, - 91, 54, 110, 0, 27, 91, 63, 37, 91, 59, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 93, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, - 52, 57, 109, 0, 27, 93, 49, 48, 52, 7, 0, 27, 93, 52, 59, 37, - 112, 49, 37, 100, 59, 114, 103, 98, 58, 37, 112, 50, 37, 123, 50, 53, - 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, - 50, 88, 47, 37, 112, 51, 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, - 49, 48, 48, 48, 125, 37, 47, 37, 50, 46, 50, 88, 47, 37, 112, 52, - 37, 123, 50, 53, 53, 125, 37, 42, 37, 123, 49, 48, 48, 48, 125, 37, - 47, 37, 50, 46, 50, 88, 27, 92, 0, 27, 91, 51, 109, 0, 27, 91, - 50, 51, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, - 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, - 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, - 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, - 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, - 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, - 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, - 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, - 49, 37, 100, 37, 59, 109, 0 -}; -// Taken from Dickey ncurses terminfo.src dated 2017-04-22. -static const signed char ansi_terminfo[] = { - 26, 1, 40, 0, 23, 0, 16, 0, 125, 1, 68, 2, 97, 110, 115, 105, - 124, 97, 110, 115, 105, 47, 112, 99, 45, 116, 101, 114, 109, 32, 99, 111, - 109, 112, 97, 116, 105, 98, 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, - 108, 111, 114, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 80, 0, 8, 0, - 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 8, 0, 64, 0, 3, 0, 0, 0, 4, 0, - 6, 0, -1, -1, 8, 0, 13, 0, 20, 0, 24, 0, 28, 0, -1, -1, - 39, 0, 56, 0, 60, 0, -1, -1, 64, 0, -1, -1, -1, -1, 68, 0, - -1, -1, 72, 0, -1, -1, 76, 0, 80, 0, -1, -1, -1, -1, 84, 0, - 90, 0, 95, 0, -1, -1, -1, -1, -1, -1, -1, -1, 100, 0, -1, -1, - 105, 0, 110, 0, 115, 0, 120, 0,-127, 0,-121, 0, -1, -1, -1, -1, - -1, -1,-113, 0,-109, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1,-105, 0, -1, -1,-101, 0, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -99, 0, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -95, 0, -91, 0, -1, -1, -87, 0, -1, -1, -1, -1, - -1, -1, -83, 0, -1, -1, -1, -1, -1, -1, -79, 0, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -75, 0, -1, -1, -70, 0, - -61, 0, -52, 0, -43, 0, -34, 0, -25, 0, -16, 0, -7, 0, 2, 1, - 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 1, 25, 1, 30, 1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 1, -1, -1, 61, 1, - -1, -1, 63, 1,-107, 1, -1, -1,-104, 1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, --100, 1, -1, -1, -37, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -33, 1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -28, 1, -17, 1, -12, 1, 7, 2, 11, 2, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 2, 30, 2, -1, -1, - -1, -1, -1, -1, 40, 2, 44, 2, 48, 2, 52, 2, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 56, 2, 62, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, - 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, - 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, - 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 27, 91, - 66, 0, 27, 91, 72, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, - 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 91, 49, 49, 109, 0, - 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 56, 109, 0, 27, - 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, - 37, 112, 49, 37, 100, 88, 0, 27, 91, 49, 48, 109, 0, 27, 91, 48, - 59, 49, 48, 109, 0, 27, 91, 109, 0, 27, 91, 109, 0, 27, 91, 76, - 0, 8, 0, 27, 91, 66, 0, 27, 91, 72, 0, 27, 91, 76, 0, 27, - 91, 68, 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 27, 91, 83, 0, - 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, - 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, - 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, - 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, - 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, - 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 52, 105, 0, 27, - 91, 53, 105, 0, 37, 112, 49, 37, 99, 27, 91, 37, 112, 50, 37, 123, - 49, 125, 37, 45, 37, 100, 98, 0, 27, 91, 37, 105, 37, 112, 49, 37, - 100, 100, 0, 10, 0, 27, 91, 48, 59, 49, 48, 37, 63, 37, 112, 49, - 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, - 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, - 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 54, 37, 116, 59, 49, - 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 37, 63, 37, - 112, 57, 37, 116, 59, 49, 49, 37, 59, 109, 0, 27, 72, 0, 27, 91, - 73, 0, 43, 16, 44, 17, 45, 24, 46, 25, 48, -37, 96, 4, 97, -79, - 102, -8, 103, -15, 104, -80, 106, -39, 107, -65, 108, -38, 109, -64, 110, -59, - 111, 126, 112, -60, 113, -60, 114, -60, 115, 95, 116, -61, 117, -76, 118, -63, - 119, -62, 120, -77, 121, -13, 122, -14, 123, -29, 124, -40, 125,-100, 126, -2, - 0, 27, 91, 90, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, - 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 37, 91, 59, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 93, 99, 0, 27, 91, 99, - 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 37, 112, 49, - 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0, 27, 40, - 66, 0, 27, 41, 66, 0, 27, 42, 66, 0, 27, 43, 66, 0, 27, 91, - 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 -}; - -/// Load one of the built-in terminfo entries when unibilium has failed to -/// load a terminfo record from an external database, as it does on termcap- -/// -only systems. We do not do any fancy recognition of xterm pretenders -/// here. An external terminfo database would not do that, and we want to -/// behave as much like an external terminfo database as possible. -static unibi_term *load_builtin_terminfo(const char * term) -{ - if (TERMINAL_FAMILY(term, "xterm")) { - return unibi_from_mem((const char *)xterm_256colour_terminfo, sizeof xterm_256colour_terminfo); - } else if (TERMINAL_FAMILY(term, "screen")) { - return unibi_from_mem((const char *)screen_256colour_terminfo, sizeof screen_256colour_terminfo); - } else if (TERMINAL_FAMILY(term, "tmux")) { - return unibi_from_mem((const char *)tmux_256colour_terminfo, sizeof tmux_256colour_terminfo); - } else if (TERMINAL_FAMILY(term, "rxvt")) { - return unibi_from_mem((const char *)rxvt_256colour_terminfo, sizeof rxvt_256colour_terminfo); - } else if (TERMINAL_FAMILY(term, "putty")) { - return unibi_from_mem((const char *)putty_256colour_terminfo, sizeof putty_256colour_terminfo); - } else if (TERMINAL_FAMILY(term, "linux")) { - return unibi_from_mem((const char *)linux_16colour_terminfo, sizeof linux_16colour_terminfo); - } else if (TERMINAL_FAMILY(term, "interix")) { - return unibi_from_mem((const char *)interix_8colour_terminfo, sizeof interix_8colour_terminfo); - } else if (TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app")) { - return unibi_from_mem((const char *)iterm_256colour_terminfo, sizeof iterm_256colour_terminfo); - } else if (TERMINAL_FAMILY(term, "st")) { - return unibi_from_mem((const char *)st_256colour_terminfo, sizeof st_256colour_terminfo); - } else if (TERMINAL_FAMILY(term, "gnome") || TERMINAL_FAMILY(term, "vte")) { - return unibi_from_mem((const char *)vte_256colour_terminfo, sizeof vte_256colour_terminfo); - } else { - return unibi_from_mem((const char *)ansi_terminfo, sizeof ansi_terminfo); - } -} - /// Several entries in terminfo are known to be deficient or outright wrong, /// unfortunately; and several terminal emulators falsely announce incorrect /// terminal types. So patch the terminfo records after loading from an @@ -2559,15 +1215,15 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, { unibi_term *ut = data->ut; const char * xterm_version = os_getenv("XTERM_VERSION"); - bool xterm = TERMINAL_FAMILY(term, "xterm"); - bool linuxvt = TERMINAL_FAMILY(term, "linux"); - bool rxvt = TERMINAL_FAMILY(term, "rxvt"); - bool teraterm = TERMINAL_FAMILY(term, "teraterm"); - bool putty = TERMINAL_FAMILY(term, "putty"); - bool screen = TERMINAL_FAMILY(term, "screen"); - bool st = TERMINAL_FAMILY(term, "st"); - bool gnome = TERMINAL_FAMILY(term, "gnome") || TERMINAL_FAMILY(term, "vte"); - bool iterm = TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app"); + bool xterm = terminfo_is_term_family(term, "xterm"); + bool linuxvt = terminfo_is_term_family(term, "linux"); + bool rxvt = terminfo_is_term_family(term, "rxvt"); + bool teraterm = terminfo_is_term_family(term, "teraterm"); + bool putty = terminfo_is_term_family(term, "putty"); + bool screen = terminfo_is_term_family(term, "screen"); + bool st = terminfo_is_term_family(term, "st"); + bool gnome = terminfo_is_term_family(term, "gnome") || terminfo_is_term_family(term, "vte"); + bool iterm = terminfo_is_term_family(term, "iterm") || terminfo_is_term_family(term, "iTerm.app"); // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; bool gnome_pretending_xterm = xterm && colorterm && strstr(colorterm, "gnome-terminal"); @@ -2621,10 +1277,10 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // per the screen manual; 2017-04 terminfo.src lacks these. unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); - } else if (TERMINAL_FAMILY(term, "tmux")) { + } else if (terminfo_is_term_family(term, "tmux")) { unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); - } else if (TERMINAL_FAMILY(term, "interix")) { + } else if (terminfo_is_term_family(term, "interix")) { unibi_set_if_empty(ut, unibi_carriage_return, "\x0d"); } else if (linuxvt) { // No bugs in the vanilla terminfo for our purposes. @@ -2779,15 +1435,15 @@ static void augment_terminfo(TUIData *data, const char *term, { unibi_term *ut = data->ut; const char * xterm_version = os_getenv("XTERM_VERSION"); - bool xterm = TERMINAL_FAMILY(term, "xterm"); - bool dtterm = TERMINAL_FAMILY(term, "dtterm"); - bool linuxvt = TERMINAL_FAMILY(term, "linux"); - bool rxvt = TERMINAL_FAMILY(term, "rxvt"); - bool teraterm = TERMINAL_FAMILY(term, "teraterm"); - bool putty = TERMINAL_FAMILY(term, "putty"); - bool screen = TERMINAL_FAMILY(term, "screen"); - bool st = TERMINAL_FAMILY(term, "st"); - bool iterm = TERMINAL_FAMILY(term, "iterm") || TERMINAL_FAMILY(term, "iTerm.app"); + bool xterm = terminfo_is_term_family(term, "xterm"); + bool dtterm = terminfo_is_term_family(term, "dtterm"); + bool linuxvt = terminfo_is_term_family(term, "linux"); + bool rxvt = terminfo_is_term_family(term, "rxvt"); + bool teraterm = terminfo_is_term_family(term, "teraterm"); + bool putty = terminfo_is_term_family(term, "putty"); + bool screen = terminfo_is_term_family(term, "screen"); + bool st = terminfo_is_term_family(term, "st"); + bool iterm = terminfo_is_term_family(term, "iterm") || terminfo_is_term_family(term, "iTerm.app"); // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; bool true_xterm = xterm && !!xterm_version; -- cgit From b672035ff56d0068b8ff217dd8e59dfbaff8f445 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Wed, 31 May 2017 13:18:24 +0100 Subject: tui: Coding style changes only --- src/nvim/tui/tui.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 3ef2e2967b..7ad8dbe6aa 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -431,7 +431,7 @@ static void print_cell(UI *ui, UCell *ptr) } update_attrs(ui, ptr->attrs); out(ui, ptr->data, strlen(ptr->data)); - ++grid->col; + grid->col++; } static bool cheap_to_print(UI *ui, int row, int col, int next) @@ -440,7 +440,7 @@ static bool cheap_to_print(UI *ui, int row, int col, int next) UGrid *grid = &data->grid; UCell *cell = grid->cells[row] + col; while (next) { - --next; + next--; if (attrs_differ(cell->attrs, data->print_attrs)) { if (data->default_attr) { return false; @@ -449,7 +449,7 @@ static bool cheap_to_print(UI *ui, int row, int col, int next) if (strlen(cell->data) > 1) { return false; } - ++cell; + cell++; } return true; } @@ -468,7 +468,7 @@ static void check_final_column_wrap(UI *ui) if (grid->col == ui->width) { grid->col = 0; if (grid->row < ui->height) { - ++grid->row; + grid->row++; } } } @@ -522,7 +522,7 @@ static void cursor_goto(UI *ui, int row, int col) } } else { if (!data->immediate_wrap_after_last_column && grid->col >= ui->width) { - --n; // We have calculated one too many columns because of delayed wrap. + n--; // We have calculated one too many columns because of delayed wrap. } data->params[0].i = n; unibi_out(ui, unibi_parm_left_cursor); @@ -938,7 +938,7 @@ static void tui_put(UI *ui, String text) // ugrid_put does not advance the cursor correctly, as the actual terminal // will when we print. Its cursor motion model is simplistic and wrong. So // we have to undo what it has just done before doing it right. - --grid->col; + grid->col--; print_cell(ui, cell); check_final_column_wrap(ui); } -- cgit From 98907c57aedb449bfa96a6425608c1987d4defdf Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Wed, 31 May 2017 21:17:50 +0100 Subject: tui: Several minor tweaks per commentary and 256-colourize PuTTY. * Don't use &data->grid when we already have grid . * Consolidate into a single assignment to the default_attr flag. --- src/nvim/tui/tui.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 7ad8dbe6aa..1f44710a12 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -370,13 +370,16 @@ static void update_attrs(UI *ui, HlAttrs attrs) int fg = attrs.foreground != -1 ? attrs.foreground : grid->fg; int bg = attrs.background != -1 ? attrs.background : grid->bg; + data->default_attr = fg == -1 && bg == -1 + && !attrs.bold && !attrs.italic && !attrs.underline && !attrs.undercurl + && !attrs.reverse; + if (ui->rgb) { if (fg != -1) { data->params[0].i = (fg >> 16) & 0xff; // red data->params[1].i = (fg >> 8) & 0xff; // green data->params[2].i = fg & 0xff; // blue unibi_out(ui, data->unibi_ext.set_rgb_foreground); - data->default_attr = false; } if (bg != -1) { @@ -384,37 +387,30 @@ static void update_attrs(UI *ui, HlAttrs attrs) data->params[1].i = (bg >> 8) & 0xff; // green data->params[2].i = bg & 0xff; // blue unibi_out(ui, data->unibi_ext.set_rgb_background); - data->default_attr = false; } } else { if (fg != -1) { data->params[0].i = fg; unibi_out(ui, unibi_set_a_foreground); - data->default_attr = false; } if (bg != -1) { data->params[0].i = bg; unibi_out(ui, unibi_set_a_background); - data->default_attr = false; } } if (attrs.bold) { unibi_out(ui, unibi_enter_bold_mode); - data->default_attr = false; } if (attrs.italic) { unibi_out(ui, unibi_enter_italics_mode); - data->default_attr = false; } if (attrs.underline || attrs.undercurl) { unibi_out(ui, unibi_enter_underline_mode); - data->default_attr = false; } if (attrs.reverse) { unibi_out(ui, unibi_enter_reverse_mode); - data->default_attr = false; } } @@ -491,17 +487,18 @@ static void cursor_goto(UI *ui, int row, int col) } if (0 == row && 0 == col) { unibi_out(ui, unibi_cursor_home); - ugrid_goto(&data->grid, row, col); + ugrid_goto(grid, row, col); return; } if (0 == col ? col != grid->col : + row != grid->row ? false : 1 == col ? 2 < grid->col && cheap_to_print(ui, grid->row, 0, col) : 2 == col ? 5 < grid->col && cheap_to_print(ui, grid->row, 0, col) : false) { // Motion to left margin from anywhere else, or CR + printing chars is // even less expensive than using BSes or CUB. unibi_out(ui, unibi_carriage_return); - ugrid_goto(&data->grid, grid->row, 0); + ugrid_goto(grid, grid->row, 0); } else if (col > grid->col) { int n = col - grid->col; if (n <= (row == grid->row ? 4 : 2) @@ -527,7 +524,7 @@ static void cursor_goto(UI *ui, int row, int col) data->params[0].i = n; unibi_out(ui, unibi_parm_left_cursor); } - ugrid_goto(&data->grid, row, col); + ugrid_goto(grid, row, col); return; } else if (col > grid->col) { int n = col - grid->col; @@ -539,7 +536,7 @@ static void cursor_goto(UI *ui, int row, int col) data->params[0].i = n; unibi_out(ui, unibi_parm_right_cursor); } - ugrid_goto(&data->grid, row, col); + ugrid_goto(grid, row, col); return; } } @@ -554,7 +551,7 @@ static void cursor_goto(UI *ui, int row, int col) data->params[0].i = n; unibi_out(ui, unibi_parm_down_cursor); } - ugrid_goto(&data->grid, row, col); + ugrid_goto(grid, row, col); return; } else if (row < grid->row) { int n = grid->row - row; @@ -566,12 +563,12 @@ static void cursor_goto(UI *ui, int row, int col) data->params[0].i = n; unibi_out(ui, unibi_parm_up_cursor); } - ugrid_goto(&data->grid, row, col); + ugrid_goto(grid, row, col); return; } } unibi_goto(ui, row, col); - ugrid_goto(&data->grid, row, col); + ugrid_goto(grid, row, col); } static void clear_region(UI *ui, int top, int bot, int left, int right) @@ -1315,7 +1312,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_num(ut, unibi_max_colors, 256); unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); - } else if (konsole || xterm || gnome || rxvt || st + } else if (konsole || xterm || gnome || rxvt || st || putty || linuxvt // Linux 4.8+ supports 256-colour SGR. || mate_pretending_xterm || gnome_pretending_xterm || (colorterm && strstr(colorterm, "256")) -- cgit From 9475cf2cc6bd5594b00e7ee6755122f346940ebc Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Fri, 2 Jun 2017 21:45:28 +0100 Subject: screen: Correct commentary. This "trick" is not conditional upon the type of UI. --- src/nvim/screen.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 4f4363d121..61d0169226 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -4236,7 +4236,6 @@ win_line ( * (regardless of the xn,am settings). * Only do this if the cursor is on the current line * (something has been written in it). - * Don't do this for the GUI. * Don't do this for double-width characters. * Don't do this for a window not at the right screen border. */ -- cgit From 6fe839a6884e77230f81c6e5a76766e67d7dc3a3 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 3 Jun 2017 08:39:56 +0100 Subject: tui: Do some deferred wrap on iTerm2. Partly undo 8ab08a65ba3bc9a44741a2ec9aa81fbcc77467fb. Further testing by Enrico Ghirardi suggests limiting the non-deferred automatic wrap to only the bottom line, whose rightmost column is not printed for iTerm. --- src/nvim/tui/tui.c | 65 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 1f44710a12..80ace17160 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -91,6 +91,7 @@ typedef struct { bool can_set_lr_margin; bool can_set_left_right_margin; bool immediate_wrap_after_last_column; + bool no_bottom_right_corner; bool mouse_enabled; bool busy; cursorentry_T cursor_shapes[SHAPE_IDX_COUNT]; @@ -201,10 +202,11 @@ static void terminfo_start(UI *ui) data->can_set_left_right_margin = !!unibi_get_str(data->ut, unibi_set_left_margin_parm) && !!unibi_get_str(data->ut, unibi_set_right_margin_parm); - data->immediate_wrap_after_last_column = + data->no_bottom_right_corner = terminfo_is_term_family(term, "iterm") - || terminfo_is_term_family(term, "interix") || (terminfo_is_term_family(term, "xterm") && iterm_env); + data->immediate_wrap_after_last_column = + terminfo_is_term_family(term, "interix"); // Set 't_Co' from the result of unibilium & fix_terminfo. t_colors = unibi_get_num(data->ut, unibi_max_colors); // Enter alternate screen and clear @@ -414,20 +416,43 @@ static void update_attrs(UI *ui, HlAttrs attrs) } } +static void final_column_wrap(UI *ui) +{ + TUIData *data = ui->data; + UGrid *grid = &data->grid; + if (grid->col == ui->width) { + grid->col = 0; + if (grid->row < ui->height) { + grid->row++; + } + } +} + +/// It is undocumented, but in the majority of terminals and terminal emulators +/// printing at the right margin does not cause an automatic wrap until the +/// next character is printed, holding the cursor in place until then. static void print_cell(UI *ui, UCell *ptr) { TUIData *data = ui->data; UGrid *grid = &data->grid; - if (data->immediate_wrap_after_last_column + if (data->no_bottom_right_corner && grid->row >= ui->height - 1 && grid->col >= ui->width - 1) { // This (rare) kind of terminal simply cannot print in this corner without // scrolling the entire screen up a line, which we do not want to happen. return; } + if (!data->immediate_wrap_after_last_column) { + // Printing the next character finally advances the cursor. + final_column_wrap(ui); + } update_attrs(ui, ptr->attrs); out(ui, ptr->data, strlen(ptr->data)); grid->col++; + if (data->immediate_wrap_after_last_column) { + // Printing at the right margin immediately advances the cursor. + final_column_wrap(ui); + } } static bool cheap_to_print(UI *ui, int row, int col, int next) @@ -450,25 +475,6 @@ static bool cheap_to_print(UI *ui, int row, int col, int next) return true; } -/// The behaviour that this is checking for the absence of is undocumented, -/// but is implemented in the majority of terminals and terminal emulators. -/// Printing at the right margin does not cause an automatic wrap until the -/// next character is printed, holding the cursor in place until then. -static void check_final_column_wrap(UI *ui) -{ - TUIData *data = ui->data; - if (!data->immediate_wrap_after_last_column) { - return; - } - UGrid *grid = &data->grid; - if (grid->col == ui->width) { - grid->col = 0; - if (grid->row < ui->height) { - grid->row++; - } - } -} - /// This optimizes several cases where it is cheaper to do something other /// than send a full cursor positioning control sequence. However, there are /// some further optimizations that may seem obvious but that will not work. @@ -506,7 +512,6 @@ static void cursor_goto(UI *ui, int row, int col) UGRID_FOREACH_CELL(grid, grid->row, grid->row, grid->col, col - 1, { print_cell(ui, cell); - check_final_column_wrap(ui); }); } } @@ -614,7 +619,6 @@ static void clear_region(UI *ui, int top, int bot, int left, int right) UGRID_FOREACH_CELL(grid, top, bot, left, right, { cursor_goto(ui, row, col); print_cell(ui, cell); - check_final_column_wrap(ui); }); } @@ -937,7 +941,6 @@ static void tui_put(UI *ui, String text) // we have to undo what it has just done before doing it right. grid->col--; print_cell(ui, cell); - check_final_column_wrap(ui); } static void tui_bell(UI *ui) @@ -990,7 +993,6 @@ static void tui_flush(UI *ui) UGRID_FOREACH_CELL(grid, r.top, r.bot, r.left, r.right, { cursor_goto(ui, row, col); print_cell(ui, cell); - check_final_column_wrap(ui); }); } @@ -1265,6 +1267,9 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_if_empty(ut, unibi_set_left_margin_parm, "\x1b[%i%p1%ds"); unibi_set_if_empty(ut, unibi_set_right_margin_parm, "\x1b[%i;%p2%ds"); } + if (iterm_pretending_xterm) { + unibi_set_if_empty(ut, unibi_enter_italics_mode, "\x1b[3m"); + } } else if (rxvt) { unibi_set_if_empty(ut, unibi_enter_italics_mode, "\x1b[3m"); unibi_set_if_empty(ut, unibi_to_status_line, "\x1b]2"); @@ -1284,7 +1289,15 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } else if (putty) { // No bugs in the vanilla terminfo for our purposes. } else if (iterm) { + unibi_set_str(ut, unibi_enter_ca_mode, "\x1b[?1049h"); + unibi_set_str(ut, unibi_exit_ca_mode, "\x1b[?1049l"); + unibi_set_if_empty(ut, unibi_set_tb_margin, "\x1b[%i%p1%d;%p2%dr"); + unibi_set_if_empty(ut, unibi_orig_pair, "\x1b[39;49m"); + unibi_set_if_empty(ut, unibi_enter_dim_mode, "\x1b[2m"); unibi_set_if_empty(ut, unibi_enter_italics_mode, "\x1b[3m"); + unibi_set_if_empty(ut, unibi_exit_italics_mode, "\x1b[23m"); + unibi_set_if_empty(ut, unibi_exit_underline_mode, "\x1b[24m"); + unibi_set_if_empty(ut, unibi_exit_standout_mode, "\x1b[27m"); } else if (st) { // No bugs in the vanilla terminfo for our purposes. } -- cgit From ae7bb47b4f5587f8ac1118becc4e8f75eaa2c2f8 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 3 Jun 2017 13:50:46 +0100 Subject: tui: Coding style changes only. --- src/nvim/tui/tui.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 80ace17160..e68fb813ab 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1221,12 +1221,16 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool putty = terminfo_is_term_family(term, "putty"); bool screen = terminfo_is_term_family(term, "screen"); bool st = terminfo_is_term_family(term, "st"); - bool gnome = terminfo_is_term_family(term, "gnome") || terminfo_is_term_family(term, "vte"); - bool iterm = terminfo_is_term_family(term, "iterm") || terminfo_is_term_family(term, "iTerm.app"); + bool gnome = terminfo_is_term_family(term, "gnome") + || terminfo_is_term_family(term, "vte"); + bool iterm = terminfo_is_term_family(term, "iterm") + || terminfo_is_term_family(term, "iTerm.app"); // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; - bool gnome_pretending_xterm = xterm && colorterm && strstr(colorterm, "gnome-terminal"); - bool mate_pretending_xterm = xterm && colorterm && strstr(colorterm, "mate-terminal"); + bool gnome_pretending_xterm = xterm && colorterm + && strstr(colorterm, "gnome-terminal"); + bool mate_pretending_xterm = xterm && colorterm + && strstr(colorterm, "mate-terminal"); bool true_xterm = xterm && !!xterm_version; char *fix_normal = (char *)unibi_get_str(ut, unibi_cursor_normal); @@ -1453,7 +1457,8 @@ static void augment_terminfo(TUIData *data, const char *term, bool putty = terminfo_is_term_family(term, "putty"); bool screen = terminfo_is_term_family(term, "screen"); bool st = terminfo_is_term_family(term, "st"); - bool iterm = terminfo_is_term_family(term, "iterm") || terminfo_is_term_family(term, "iTerm.app"); + bool iterm = terminfo_is_term_family(term, "iterm") + || terminfo_is_term_family(term, "iTerm.app"); // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; bool true_xterm = xterm && !!xterm_version; -- cgit From b604e3a086be8abff18c37203bfe6ac2f49d7e81 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 3 Jun 2017 14:08:31 +0100 Subject: tui: Add terminfo patches for linux on MacOS. Also enable italics on Konsole when it is falsely claiming to be xterm. Also note the reasons for some of the patcher terminfo patches. --- src/nvim/tui/tui.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index e68fb813ab..ca8270ac22 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1214,6 +1214,9 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, { unibi_term *ut = data->ut; const char * xterm_version = os_getenv("XTERM_VERSION"); +#if 0 // We don't need to identify this specifically, for now. + bool roxterm = !!os_getenv("ROXTERM_ID"); +#endif bool xterm = terminfo_is_term_family(term, "xterm"); bool linuxvt = terminfo_is_term_family(term, "linux"); bool rxvt = terminfo_is_term_family(term, "rxvt"); @@ -1227,6 +1230,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, || terminfo_is_term_family(term, "iTerm.app"); // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; + bool konsole_pretending_xterm = xterm && konsole; bool gnome_pretending_xterm = xterm && colorterm && strstr(colorterm, "gnome-terminal"); bool mate_pretending_xterm = xterm && colorterm @@ -1260,25 +1264,37 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // their own terminal types and terminfo entries, like PuTTY does, and not // claim to be xterm. Or they would mimic xterm properly enough to be // treatable as xterm. -#if 0 // We don't need to identify this specifically, for now. - bool roxterm = !!os_getenv("ROXTERM_ID"); -#endif + + // 2017-04 terminfo.src lacks these. genuine Xterm has them, as have + // the false claimants. unibi_set_if_empty(ut, unibi_to_status_line, "\x1b]0;"); unibi_set_if_empty(ut, unibi_from_status_line, "\x07"); unibi_set_if_empty(ut, unibi_set_tb_margin, "\x1b[%i%p1%d;%p2%dr"); + if (true_xterm) { + // 2017-04 terminfo.src lacks these. genuine Xterm has them. unibi_set_if_empty(ut, unibi_set_lr_margin, "\x1b[%i%p1%d;%p2%ds"); unibi_set_if_empty(ut, unibi_set_left_margin_parm, "\x1b[%i%p1%ds"); unibi_set_if_empty(ut, unibi_set_right_margin_parm, "\x1b[%i;%p2%ds"); } - if (iterm_pretending_xterm) { + if (true_xterm + || iterm_pretending_xterm + || gnome_pretending_xterm + || konsole_pretending_xterm) { + // Apple's outdated copy of terminfo.src for MacOS lacks these. + // genuine Xterm and three false claimants have them. unibi_set_if_empty(ut, unibi_enter_italics_mode, "\x1b[3m"); + unibi_set_if_empty(ut, unibi_exit_italics_mode, "\x1b[23m"); } } else if (rxvt) { + // 2017-04 terminfo.src lacks these. Unicode rxvt has them. unibi_set_if_empty(ut, unibi_enter_italics_mode, "\x1b[3m"); + unibi_set_if_empty(ut, unibi_exit_italics_mode, "\x1b[23m"); unibi_set_if_empty(ut, unibi_to_status_line, "\x1b]2"); unibi_set_if_empty(ut, unibi_from_status_line, "\x07"); - unibi_set_if_empty(ut, unibi_set_tb_margin, "\x1b[%i%p1%d;%p2%dr"); + // 2017-04 terminfo.src has older control sequences. + unibi_set_str(ut, unibi_enter_ca_mode, "\x1b[?1049h"); + unibi_set_str(ut, unibi_exit_ca_mode, "\x1b[?1049l"); } else if (screen) { // per the screen manual; 2017-04 terminfo.src lacks these. unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); @@ -1287,14 +1303,21 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); } else if (terminfo_is_term_family(term, "interix")) { + // 2017-04 terminfo.src lacks this. unibi_set_if_empty(ut, unibi_carriage_return, "\x0d"); } else if (linuxvt) { - // No bugs in the vanilla terminfo for our purposes. + // Apple's outdated copy of terminfo.src for MacOS lacks these. + unibi_set_if_empty(ut, unibi_parm_up_cursor, "\x1b[%p1%dA"); + unibi_set_if_empty(ut, unibi_parm_down_cursor, "\x1b[%p1%dB"); + unibi_set_if_empty(ut, unibi_parm_right_cursor, "\x1b[%p1%dC"); + unibi_set_if_empty(ut, unibi_parm_left_cursor, "\x1b[%p1%dD"); } else if (putty) { // No bugs in the vanilla terminfo for our purposes. } else if (iterm) { + // 2017-04 terminfo.src has older control sequences. unibi_set_str(ut, unibi_enter_ca_mode, "\x1b[?1049h"); unibi_set_str(ut, unibi_exit_ca_mode, "\x1b[?1049l"); + // 2017-04 terminfo.src lacks these. unibi_set_if_empty(ut, unibi_set_tb_margin, "\x1b[%i%p1%d;%p2%dr"); unibi_set_if_empty(ut, unibi_orig_pair, "\x1b[39;49m"); unibi_set_if_empty(ut, unibi_enter_dim_mode, "\x1b[2m"); -- cgit From f6116eeaa389e6c6af8091cfdf9cb1a5acfd7f00 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 3 Jun 2017 15:03:03 +0100 Subject: tui: Add tmux to the always 256-colour capable list. --- src/nvim/tui/tui.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index ca8270ac22..ba9356b7ca 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1223,6 +1223,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool teraterm = terminfo_is_term_family(term, "teraterm"); bool putty = terminfo_is_term_family(term, "putty"); bool screen = terminfo_is_term_family(term, "screen"); + bool tmux = terminfo_is_term_family(term, "tmux"); bool st = terminfo_is_term_family(term, "st"); bool gnome = terminfo_is_term_family(term, "gnome") || terminfo_is_term_family(term, "vte"); @@ -1236,6 +1237,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool mate_pretending_xterm = xterm && colorterm && strstr(colorterm, "mate-terminal"); bool true_xterm = xterm && !!xterm_version; + bool tmux_pretending_screen = screen && !!os_getenv("TMUX"); char *fix_normal = (char *)unibi_get_str(ut, unibi_cursor_normal); if (fix_normal) { @@ -1355,6 +1357,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } else if (konsole || xterm || gnome || rxvt || st || putty || linuxvt // Linux 4.8+ supports 256-colour SGR. || mate_pretending_xterm || gnome_pretending_xterm + || tmux || tmux_pretending_screen || (colorterm && strstr(colorterm, "256")) || (term && strstr(term, "256")) ) { -- cgit From 15500dbd8fa8365d36e5d1eed1d2b222c261dddd Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 3 Jun 2017 15:20:07 +0100 Subject: tui: Treat cygwin as an immediate-wrap terminal. Alongside interix. --- src/nvim/tui/tui.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index ba9356b7ca..54893014e9 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -206,7 +206,8 @@ static void terminfo_start(UI *ui) terminfo_is_term_family(term, "iterm") || (terminfo_is_term_family(term, "xterm") && iterm_env); data->immediate_wrap_after_last_column = - terminfo_is_term_family(term, "interix"); + terminfo_is_term_family(term, "cygwin") + || terminfo_is_term_family(term, "interix"); // Set 't_Co' from the result of unibilium & fix_terminfo. t_colors = unibi_get_num(data->ut, unibi_max_colors); // Enter alternate screen and clear -- cgit From 997411b6357b90d9c01935091713fdd7884e1395 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sun, 4 Jun 2017 21:18:44 +0100 Subject: tui: Do not optimize left motion at the right margin. From observation, there are several different possible behaviours: 1. Deferred wrap like a real DEC VT. The cursor stays visible in the last column, and CUB is calculated relative to that column. Examples: xterm, Unicode rxvt, PuTTY, nosh console-terminal-emulator, FreeBSD kernel's built-in emulator, Linux's built-in emulator 2. Deferred wrap like a real DEC VT. CUB is calculated relative to the last column. But the cursor is invisible. Examples: emulators using newer libvte 3. Non-deferred wrap. The cursor has already wrapped to the next line and CUB does not wrap back. Examples: cygwin, Interix 4. Non-deferred wrap that acts like deferred wrap. The cursor has already visibly wrapped to the next line, but CUB can wrap back around the left margin. Examples: Konsole 5. Deferred wrap with visibly out of bounds cursor. The cursor visibly moves outwith the screen boundaries. CUB is calculated relative to a cursor column that has overflowed the end of the screen grid array. Examples: iTerm2 6. Deferred wrap with invisibly out of bounds cursor. CUB is calculated relative to a cursor column that has overflowed the end of the screen grid array. And the cursor is invisible. Examples: emulators using older libvte In many cases, nvim does not have enough information to know which behaviour the terminal will exhibit, and thus the correct amount of CUB to issue. --- src/nvim/tui/tui.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 54893014e9..55ada08663 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -517,16 +517,19 @@ static void cursor_goto(UI *ui, int row, int col) } } if (row == grid->row) { - if (col < grid->col) { + if (col < grid->col + // Deferred right margin wrap terminals have inconsistent ideas about + // where the cursor actually is during a deferred wrap. Relative + // motion calculations have OBOEs that cannot be compensated for, + // because two terminals that claim to be the same will implement + // different cursor positioning rules. + && (data->immediate_wrap_after_last_column || grid->col < ui->width)) { int n = grid->col - col; if (n <= 4) { // This might be just BS, so it is considered really cheap. while (n--) { unibi_out(ui, unibi_cursor_left); } } else { - if (!data->immediate_wrap_after_last_column && grid->col >= ui->width) { - n--; // We have calculated one too many columns because of delayed wrap. - } data->params[0].i = n; unibi_out(ui, unibi_parm_left_cursor); } -- cgit From 239b0aaf2e59327454bc313da25dcfdfcee6a4cd Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sun, 4 Jun 2017 22:44:24 +0100 Subject: tui: Remove the iTerm2 corner case. --- src/nvim/screen.c | 3 ++- src/nvim/tui/tui.c | 11 ----------- 2 files changed, 2 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 61d0169226..e8cd6b4e9c 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5825,7 +5825,8 @@ static void screen_char(unsigned off, int row, int col) return; /* Outputting the last character on the screen may scrollup the screen. - * Don't to it! Mark the character invalid (update it when scrolled up) */ + * Don't to it! Mark the character invalid (update it when scrolled up) + * FIXME: The premise here is not actually true. c.f. deferred wrap */ if (row == screen_Rows - 1 && col == screen_Columns - 1 /* account for first command-line character in rightleft mode */ && !cmdmsg_rl diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 55ada08663..949a24db89 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -91,7 +91,6 @@ typedef struct { bool can_set_lr_margin; bool can_set_left_right_margin; bool immediate_wrap_after_last_column; - bool no_bottom_right_corner; bool mouse_enabled; bool busy; cursorentry_T cursor_shapes[SHAPE_IDX_COUNT]; @@ -202,9 +201,6 @@ static void terminfo_start(UI *ui) data->can_set_left_right_margin = !!unibi_get_str(data->ut, unibi_set_left_margin_parm) && !!unibi_get_str(data->ut, unibi_set_right_margin_parm); - data->no_bottom_right_corner = - terminfo_is_term_family(term, "iterm") - || (terminfo_is_term_family(term, "xterm") && iterm_env); data->immediate_wrap_after_last_column = terminfo_is_term_family(term, "cygwin") || terminfo_is_term_family(term, "interix"); @@ -436,13 +432,6 @@ static void print_cell(UI *ui, UCell *ptr) { TUIData *data = ui->data; UGrid *grid = &data->grid; - if (data->no_bottom_right_corner - && grid->row >= ui->height - 1 - && grid->col >= ui->width - 1) { - // This (rare) kind of terminal simply cannot print in this corner without - // scrolling the entire screen up a line, which we do not want to happen. - return; - } if (!data->immediate_wrap_after_last_column) { // Printing the next character finally advances the cursor. final_column_wrap(ui); -- cgit From 054b03e07ac8c27f49afba7225a20214697a3720 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Mon, 5 Jun 2017 22:12:53 +0100 Subject: tui: Combine multiple attribute changes. Use the terminfo set_attribute capability to set multiple attributes in one control sequence, if it is available. --- src/nvim/tui/tui.c | 55 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 949a24db89..387a340588 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -360,19 +360,43 @@ static void update_attrs(UI *ui, HlAttrs attrs) } data->print_attrs = attrs; - if (!data->default_attr) { - data->default_attr = true; - unibi_out(ui, unibi_exit_attribute_mode); - } UGrid *grid = &data->grid; int fg = attrs.foreground != -1 ? attrs.foreground : grid->fg; int bg = attrs.background != -1 ? attrs.background : grid->bg; - data->default_attr = fg == -1 && bg == -1 - && !attrs.bold && !attrs.italic && !attrs.underline && !attrs.undercurl - && !attrs.reverse; - + if (unibi_get_str(data->ut, unibi_set_attributes)) { + if (attrs.bold || attrs.reverse || attrs.underline || attrs.undercurl) { + data->params[0].i = 0; // standout + data->params[1].i = attrs.underline || attrs.undercurl; + data->params[2].i = attrs.reverse; + data->params[3].i = 0; // blink + data->params[4].i = 0; // dim + data->params[5].i = attrs.bold; + data->params[6].i = 0; // blank + data->params[7].i = 0; // protect + data->params[8].i = 0; // alternate character set + unibi_out(ui, unibi_set_attributes); + } else if (!data->default_attr) { + unibi_out(ui, unibi_exit_attribute_mode); + } + } else { + if (!data->default_attr) { + unibi_out(ui, unibi_exit_attribute_mode); + } + if (attrs.bold) { + unibi_out(ui, unibi_enter_bold_mode); + } + if (attrs.underline || attrs.undercurl) { + unibi_out(ui, unibi_enter_underline_mode); + } + if (attrs.reverse) { + unibi_out(ui, unibi_enter_reverse_mode); + } + } + if (attrs.italic) { + unibi_out(ui, unibi_enter_italics_mode); + } if (ui->rgb) { if (fg != -1) { data->params[0].i = (fg >> 16) & 0xff; // red @@ -399,18 +423,9 @@ static void update_attrs(UI *ui, HlAttrs attrs) } } - if (attrs.bold) { - unibi_out(ui, unibi_enter_bold_mode); - } - if (attrs.italic) { - unibi_out(ui, unibi_enter_italics_mode); - } - if (attrs.underline || attrs.undercurl) { - unibi_out(ui, unibi_enter_underline_mode); - } - if (attrs.reverse) { - unibi_out(ui, unibi_enter_reverse_mode); - } + data->default_attr = fg == -1 && bg == -1 + && !attrs.bold && !attrs.italic && !attrs.underline && !attrs.undercurl + && !attrs.reverse; } static void final_column_wrap(UI *ui) -- cgit From b22a61cdbba68ae88a58dd39f288a7bb13c5558d Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Mon, 5 Jun 2017 22:47:44 +0100 Subject: tui: Recognize "Tc" terminfo capability. This is a new convention pioneered by tmux. It does not do much for nvim; since nvim always looks to see whether it should be making up "setrgbf" and "setrgbb" capabilities. But it is a way for terminfo to force this, irrespective of the hardwired list in the code, for more terminal types. On the gripping hand, updating terminfo descriptions to actually have "setrgbf" and "setrgbb" capabilities so that nvim never has to try to invent them in the first place, is as good if not better an approach for overriding what is baked into the code. --- src/nvim/tui/tui.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 387a340588..2996d634a2 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1212,6 +1212,18 @@ static int unibi_find_ext_str(unibi_term *ut, const char *name) return -1; } +static int unibi_find_ext_bool(unibi_term *ut, const char *name) + { + size_t max = unibi_count_ext_bool(ut); + for (size_t i = 0; i < max; ++i) { + const char * n = unibi_get_ext_bool_name(ut, i); + if (n && 0 == strcmp(n, name)) { + return (int)i; + } + } + return -1; +} + /// Several entries in terminfo are known to be deficient or outright wrong, /// unfortunately; and several terminal emulators falsely announce incorrect /// terminal types. So patch the terminfo records after loading from an @@ -1497,7 +1509,7 @@ static void augment_terminfo(TUIData *data, const char *term, bool iterm_pretending_xterm = xterm && iterm_env; bool true_xterm = xterm && !!xterm_version; bool tmux_wrap = screen && !!os_getenv("TMUX"); - bool truecolor = colorterm + bool old_truecolor_env = colorterm && (0 == strcmp(colorterm, "truecolor") || 0 == strcmp(colorterm, "24bit")); // Only define this capability for terminal types that we know understand it. @@ -1519,17 +1531,20 @@ static void augment_terminfo(TUIData *data, const char *term, // them to terminal types, that do actually have such control sequences but // lack the correct definitions in terminfo, is an augmentation, not a // fixup. See https://gist.github.com/XVilka/8346728 for more about this. + int Tc = unibi_find_ext_bool(ut, "Tc"); + // "standard" means using colons like ISO 8613-6:1994/ITU T.416:1993 says. bool has_standard_rgb = vte_version >= 3600 // per GNOME bug #685759 || iterm || iterm_pretending_xterm // per analysis of VT100Terminal.m || true_xterm; - // "standard" means using colons like ISO 8613-6:1994/ITU T.416:1993 says. - bool has_non_standard_rgb = - linuxvt // Linux 4.8+ supports true-colour SGR. + bool has_non_standard_rgb = -1 != Tc + // terminfo is definitive if it says something. + ? unibi_get_ext_bool(ut, (size_t)Tc) + : linuxvt // Linux 4.8+ supports true-colour SGR. || konsole // per commentary in VT102Emulation.cpp // per http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html || rxvt || st // per experimentation - || truecolor; + || old_truecolor_env; data->unibi_ext.set_rgb_foreground = unibi_find_ext_str(ut, "setrgbf"); if (-1 == data->unibi_ext.set_rgb_foreground) { if (has_standard_rgb) { -- cgit From 6d35c5c7ec7ddd8ef0598565fbadb2d34551bd0d Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Fri, 9 Jun 2017 19:33:17 +0100 Subject: tui: Another linux terminfo capability fix For the linux terminal type apply the same fixup to the terminfo civis string that is applied to the cnorm string. --- src/nvim/tui/tui.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 2996d634a2..d017db3651 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -48,7 +48,8 @@ #define STARTS_WITH(str, prefix) (strlen(term) >= (sizeof(prefix) - 1) \ && 0 == memcmp((str), (prefix), sizeof(prefix) - 1)) #define TMUX_WRAP(is_tmux,seq) ((is_tmux) ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq) -#define LINUXRESETC "\x1b[?0c" +#define LINUXSET0C "\x1b[?0c" +#define LINUXSET1C "\x1b[?1c" // Per the commentary in terminfo, only a minus sign is a true suffix // separator. @@ -1270,12 +1271,23 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_str(ut, unibi_cursor_normal, fix_normal); } if (linuxvt - && strlen(fix_normal) >= (sizeof LINUXRESETC - 1) - && !memcmp(strchr(fix_normal,0) - (sizeof LINUXRESETC - 1), LINUXRESETC, sizeof LINUXRESETC - 1)) { + && strlen(fix_normal) >= (sizeof LINUXSET0C - 1) + && !memcmp(strchr(fix_normal,0) - (sizeof LINUXSET0C - 1), LINUXSET0C, sizeof LINUXSET0C - 1)) { // The Linux terminfo entry similarly includes a Linux-idiosyncractic // cursor shape reset in cnorm, which similarly interferes with // set_cursor_style. - fix_normal[strlen(fix_normal) - (sizeof LINUXRESETC - 1)] = 0; + fix_normal[strlen(fix_normal) - (sizeof LINUXSET0C - 1)] = 0; + } + } + char *fix_invisible = (char *)unibi_get_str(ut, unibi_cursor_invisible); + if (fix_invisible) { + if (linuxvt + && strlen(fix_invisible) >= (sizeof LINUXSET1C - 1) + && !memcmp(strchr(fix_invisible,0) - (sizeof LINUXSET1C - 1), LINUXSET1C, sizeof LINUXSET1C - 1)) { + // The Linux terminfo entry similarly includes a Linux-idiosyncractic + // cursor shape reset in cinvis, which similarly interferes with + // set_cursor_style. + fix_invisible[strlen(fix_invisible) - (sizeof LINUXSET1C - 1)] = 0; } } -- cgit From cdfaecb25f6a9a94f29a38d9f2d24a579b3dff5f Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Fri, 9 Jun 2017 19:50:13 +0100 Subject: tui: Eliminate more extraneous control sequences. When higher layers flush the TUI layer output buffer, but there is nothing in the buffer to flush, no longer does the TUI layer write out unnecessary cnorm/civis sequences surrounding that nothing. --- src/nvim/tui/tui.c | 60 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index d017db3651..931f2738ab 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -39,8 +39,8 @@ #include "nvim/syntax.h" #include "nvim/macros.h" -// Space reserved in the output buffer to restore the cursor to normal when -// flushing. No existing terminal will require 32 bytes to do that. +// Space reserved in two output buffers to make the cursor normal or invisible +// when flushing. No existing terminal will require 32 bytes to do that. #define CNORM_COMMAND_MAX_SIZE 32 #define OUTBUF_SIZE 0xffff @@ -73,7 +73,10 @@ typedef struct { bool stop; unibi_var_t params[9]; char buf[OUTBUF_SIZE]; - size_t bufpos, bufsize; + size_t bufpos; + char norm[CNORM_COMMAND_MAX_SIZE]; + char invis[CNORM_COMMAND_MAX_SIZE]; + size_t normlen, invislen; TermInput input; uv_loop_t write_loop; unibi_term *ut; @@ -155,12 +158,20 @@ UI *tui_start(void) return ui_bridge_attach(ui, tui_main, tui_scheduler); } +static size_t unibi_pre_fmt_str(TUIData *data, unsigned int unibi_index, char * buf, size_t len) +{ + const char *str = unibi_get_str(data->ut, unibi_index); + if (!str) { + return 0U; + } + return unibi_run(str, data->params, buf, len); +} + static void terminfo_start(UI *ui) { TUIData *data = ui->data; data->scroll_region_is_full_screen = true; data->bufpos = 0; - data->bufsize = sizeof(data->buf) - CNORM_COMMAND_MAX_SIZE; data->default_attr = false; data->showing_mode = SHAPE_IDX_N; data->unibi_ext.enable_mouse = -1; @@ -205,6 +216,8 @@ static void terminfo_start(UI *ui) data->immediate_wrap_after_last_column = terminfo_is_term_family(term, "cygwin") || terminfo_is_term_family(term, "interix"); + data->normlen = unibi_pre_fmt_str(data, unibi_cursor_normal, data->norm, sizeof data->norm); + data->invislen = unibi_pre_fmt_str(data, unibi_cursor_invisible, data->invis, sizeof data->invis); // Set 't_Co' from the result of unibilium & fix_terminfo. t_colors = unibi_get_num(data->ut, unibi_max_colors); // Enter alternate screen and clear @@ -1183,7 +1196,7 @@ static void out(void *ctx, const char *str, size_t len) { UI *ui = ctx; TUIData *data = ui->data; - size_t available = data->bufsize - data->bufpos; + size_t available = sizeof(data->buf) - data->bufpos; if (len > available) { flush_buf(ui, false); @@ -1613,28 +1626,37 @@ static void augment_terminfo(TUIData *data, const char *term, static void flush_buf(UI *ui, bool toggle_cursor) { uv_write_t req; - uv_buf_t buf; + uv_buf_t bufs[3]; + uv_buf_t *bufp = bufs; TUIData *data = ui->data; + if (data->bufpos <= 0) { + return; + } + if (toggle_cursor && !data->busy) { - // not busy and the cursor is invisible(see below). Append a "cursor - // normal" command to the end of the buffer. - data->bufsize += CNORM_COMMAND_MAX_SIZE; - unibi_out(ui, unibi_cursor_normal); - data->bufsize -= CNORM_COMMAND_MAX_SIZE; + // not busy and cursor is visible, write a "cursor invisible" command + // before writing the buffer. + bufp->base = data->invis; + bufp->len = data->invislen; + bufp++; } - buf.base = data->buf; - buf.len = data->bufpos; - uv_write(&req, STRUCT_CAST(uv_stream_t, &data->output_handle), &buf, 1, NULL); - uv_run(&data->write_loop, UV_RUN_DEFAULT); - data->bufpos = 0; + bufp->base = data->buf; + bufp->len = data->bufpos; + bufp++; if (toggle_cursor && !data->busy) { - // not busy and cursor is visible(see above), append a "cursor invisible" - // command to the beginning of the buffer for the next flush - unibi_out(ui, unibi_cursor_invisible); + // not busy and the cursor is invisible. Write a "cursor normal" command + // after writing the buffer. + bufp->base = data->norm; + bufp->len = data->normlen; + bufp++; } + + uv_write(&req, STRUCT_CAST(uv_stream_t, &data->output_handle), bufs, (unsigned)(bufp - bufs), NULL); + uv_run(&data->write_loop, UV_RUN_DEFAULT); + data->bufpos = 0; } #if TERMKEY_VERSION_MAJOR > 0 || TERMKEY_VERSION_MINOR > 18 -- cgit From 2c236fc67be22bceea87fd1ee1e2db5a9d3941c0 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sat, 10 Jun 2017 09:00:15 +0100 Subject: tui: Track cursor visibility. This fixes a test failure caused by dfaecb25f6a9a94f29a38d9f2d24a579b3dff5f not tracking what the current visibility is and whether it matches the current business state. --- src/nvim/tui/tui.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 931f2738ab..a85f119ef4 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -96,7 +96,7 @@ typedef struct { bool can_set_left_right_margin; bool immediate_wrap_after_last_column; bool mouse_enabled; - bool busy; + bool busy, is_invisible; cursorentry_T cursor_shapes[SHAPE_IDX_COUNT]; HlAttrs print_attrs; bool default_attr; @@ -173,6 +173,8 @@ static void terminfo_start(UI *ui) data->scroll_region_is_full_screen = true; data->bufpos = 0; data->default_attr = false; + data->is_invisible = true; + data->busy = false; data->showing_mode = SHAPE_IDX_N; data->unibi_ext.enable_mouse = -1; data->unibi_ext.disable_mouse = -1; @@ -1630,28 +1632,32 @@ static void flush_buf(UI *ui, bool toggle_cursor) uv_buf_t *bufp = bufs; TUIData *data = ui->data; - if (data->bufpos <= 0) { + if (data->bufpos <= 0 && data->busy == data->is_invisible) { return; } - if (toggle_cursor && !data->busy) { - // not busy and cursor is visible, write a "cursor invisible" command - // before writing the buffer. + if (toggle_cursor && !data->is_invisible) { + // cursor is visible. Write a "cursor invisible" command before writing the + // buffer. bufp->base = data->invis; bufp->len = data->invislen; bufp++; + data->is_invisible = true; } - bufp->base = data->buf; - bufp->len = data->bufpos; - bufp++; + if (data->bufpos > 0) { + bufp->base = data->buf; + bufp->len = data->bufpos; + bufp++; + } - if (toggle_cursor && !data->busy) { + if (toggle_cursor && !data->busy && data->is_invisible) { // not busy and the cursor is invisible. Write a "cursor normal" command // after writing the buffer. bufp->base = data->norm; bufp->len = data->normlen; bufp++; + data->is_invisible = data->busy; } uv_write(&req, STRUCT_CAST(uv_stream_t, &data->output_handle), bufs, (unsigned)(bufp - bufs), NULL); -- cgit From 90f62cc749da78afc9891bb03a195b79d0bedcff Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 26 Mar 2017 01:34:13 +0300 Subject: ex_getln: Clean up draw_cmdline a bit --- src/nvim/ex_getln.c | 70 +++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 858374c68e..013f936137 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2174,69 +2174,64 @@ void free_cmdline_buf(void) */ static void draw_cmdline(int start, int len) { - int i; - - if (cmdline_star > 0) - for (i = 0; i < len; ++i) { + if (cmdline_star > 0) { + for (int i = 0; i < len; i++) { msg_putchar('*'); - if (has_mbyte) + if (has_mbyte) { i += (*mb_ptr2len)(ccline.cmdbuff + start + i) - 1; + } } - else if (p_arshape && !p_tbidi && enc_utf8 && len > 0) { + } else if (p_arshape && !p_tbidi && enc_utf8 && len > 0) { static int buflen = 0; - char_u *p; - int j; - int newlen = 0; - int mb_l; - int pc, pc1 = 0; - int prev_c = 0; - int prev_c1 = 0; - int u8c; - int u8cc[MAX_MCO]; - int nc = 0; - /* - * Do arabic shaping into a temporary buffer. This is very - * inefficient! - */ + // Do arabic shaping into a temporary buffer. This is very + // inefficient! if (len * 2 + 2 > buflen) { - /* Re-allocate the buffer. We keep it around to avoid a lot of - * alloc()/free() calls. */ + // Re-allocate the buffer. We keep it around to avoid a lot of + // alloc()/free() calls. xfree(arshape_buf); buflen = len * 2 + 2; arshape_buf = xmalloc(buflen); } + int newlen = 0; if (utf_iscomposing(utf_ptr2char(ccline.cmdbuff + start))) { - /* Prepend a space to draw the leading composing char on. */ + // Prepend a space to draw the leading composing char on. arshape_buf[0] = ' '; newlen = 1; } - for (j = start; j < start + len; j += mb_l) { - p = ccline.cmdbuff + j; - u8c = utfc_ptr2char_len(p, u8cc, start + len - j); - mb_l = utfc_ptr2len_len(p, start + len - j); + int mb_l; + int prev_c = 0; + int prev_c1 = 0; + for (int i = start; i < start + len; i += mb_l) { + char_u *p = ccline.cmdbuff + i; + int u8cc[MAX_MCO]; + int u8c = utfc_ptr2char_len(p, u8cc, start + len - i); + mb_l = utfc_ptr2len_len(p, start + len - i); if (arabic_char(u8c)) { - /* Do Arabic shaping. */ + int pc; + int pc1 = 0; + int nc = 0; + // Do Arabic shaping. if (cmdmsg_rl) { - /* displaying from right to left */ + // Displaying from right to left. pc = prev_c; pc1 = prev_c1; prev_c1 = u8cc[0]; - if (j + mb_l >= start + len) + if (i + mb_l >= start + len) { nc = NUL; - else + } else { nc = utf_ptr2char(p + mb_l); + } } else { - /* displaying from left to right */ - if (j + mb_l >= start + len) + // Displaying from left to right. + if (i + mb_l >= start + len) { pc = NUL; - else { + } else { int pcc[MAX_MCO]; - pc = utfc_ptr2char_len(p + mb_l, pcc, - start + len - j - mb_l); + pc = utfc_ptr2char_len(p + mb_l, pcc, start + len - i - mb_l); pc1 = pcc[0]; } nc = prev_c; @@ -2260,8 +2255,9 @@ static void draw_cmdline(int start, int len) } msg_outtrans_len(arshape_buf, newlen); - } else + } else { msg_outtrans_len(ccline.cmdbuff + start, len); + } } /* -- cgit From 7db2f658e87278885a137ac2b0b88df6a1b546cb Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 26 Mar 2017 01:38:43 +0300 Subject: ex_getln: Do not do arabic shaping unless needed Should speed up execution without arabic characters a bit, slowing down with arabic characters. More necessary, this allows coloring prompt without caring about arabic shaping at the first iteration. --- src/nvim/ex_getln.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 013f936137..632f125b45 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2182,6 +2182,22 @@ static void draw_cmdline(int start, int len) } } } else if (p_arshape && !p_tbidi && enc_utf8 && len > 0) { + bool do_arabicshape = false; + int mb_l; + for (int i = start; i < start + len; i += mb_l) { + char_u *p = ccline.cmdbuff + i; + int u8cc[MAX_MCO]; + int u8c = utfc_ptr2char_len(p, u8cc, start + len - i); + mb_l = utfc_ptr2len_len(p, start + len - i); + if (arabic_char(u8c)) { + do_arabicshape = true; + break; + } + } + if (!do_arabicshape) { + goto draw_cmdline_no_arabicshape; + } + static int buflen = 0; // Do arabic shaping into a temporary buffer. This is very @@ -2201,7 +2217,6 @@ static void draw_cmdline(int start, int len) newlen = 1; } - int mb_l; int prev_c = 0; int prev_c1 = 0; for (int i = start; i < start + len; i += mb_l) { @@ -2256,6 +2271,7 @@ static void draw_cmdline(int start, int len) msg_outtrans_len(arshape_buf, newlen); } else { +draw_cmdline_no_arabicshape: msg_outtrans_len(ccline.cmdbuff + start, len); } } -- cgit From c1d21e9dd67cdea5e133bb1b79fc1765d20c191b Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 26 Mar 2017 03:40:59 +0300 Subject: ex_getln: Add basic support for coloring command-line prompt --- src/nvim/ex_getln.c | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 158 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 632f125b45..b08407233f 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -62,6 +62,7 @@ #include "nvim/os/os.h" #include "nvim/event/loop.h" #include "nvim/os/time.h" +#include "nvim/lib/kvec.h" /* * Variables shared between getcmdline(), redrawcmdline() and others. @@ -127,6 +128,15 @@ typedef struct command_line_state { struct cmdline_info save_ccline; } CommandLineState; +/// Command-line colors +typedef struct { + int start; ///< Colored chunk start. + int end; ///< Colored chunk end (exclusive, > start). + int attr; ///< Highlight attr. +} ColoredCmdlineChunk; + +kvec_t(ColoredCmdlineChunk) ccline_colors; + /* The current cmdline_info. It is initialized in getcmdline() and after that * used by other functions. When invoking getcmdline() recursively it needs * to be saved with save_cmdline() and restored with restore_cmdline(). @@ -2168,6 +2178,139 @@ void free_cmdline_buf(void) # endif +/// Color command-line +/// +/// Should use built-in command parser or user-specified one. Currently only the +/// latter is supported. +/// +/// Operates on ccline, saving results to ccline_colors. +/// +/// Always colors the whole cmdline. +static void color_cmdline(void) +{ + kv_size(ccline_colors) = 0; + if (ccline.cmdfirstc != ':') { + return; + } + static Callback prev_cb = { .type = kCallbackNone }; + static int prev_cb_errors = 0; + Callback color_cb; + if (!tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_cmdline"), + &color_cb)) { + return; + } + if (color_cb.type == kCallbackNone) { + return; + } + if (prev_cb_errors == 5 && tv_callback_equal(&prev_cb, &color_cb)) { + return; + } + callback_free(&prev_cb); + prev_cb = color_cb; + bool arg_allocated; + typval_T arg = { + .v_type = VAR_STRING, + }; + if (ccline.cmdbuff[ccline.cmdlen] == NUL) { + arg_allocated = false; + arg.vval.v_string = ccline.cmdbuff; + } else { + arg_allocated = true; + arg.vval.v_string = xmemdupz((const char *)ccline.cmdbuff, + (size_t)ccline.cmdlen); + } + typval_T tv; + msg_silent++; + if (!callback_call(&color_cb, 1, &arg, &tv)) { + msg_silent--; + goto color_cmdline_end; + } + msg_silent--; + if (tv.v_type != VAR_LIST || tv.vval.v_list == NULL) { + emsgf(_("E5400: Callback should return list")); + goto color_cmdline_error; + } + varnumber_T prev_end = 0; + int i = 0; + for (const listitem_T *li = tv.vval.v_list->lv_first; + li != NULL; li = li->li_next, i++) { + if (li->li_tv.v_type != VAR_LIST) { + emsgf(_("E5401: List item %i is not a List"), i); + goto color_cmdline_error; + } + const list_T *const l = li->li_tv.vval.v_list; + if (tv_list_len(l) != 3) { + emsgf(_("E5402: List item %i has incorrect length: %li /= 3"), + i, tv_list_len(l)); + goto color_cmdline_error; + } + bool error = false; + const varnumber_T start = tv_get_number_chk(&l->lv_first->li_tv, &error); + if (error) { + goto color_cmdline_error; + } else if (!(prev_end <= start && start <= ccline.cmdlen)) { + emsgf(_("E5403: Chunk %i start %" PRIdVARNUMBER " not in range " + "[%" PRIdVARNUMBER ", %i]"), + i, start, prev_end, ccline.cmdlen); + goto color_cmdline_error; + } + if (start != prev_end) { + kv_push(ccline_colors, ((ColoredCmdlineChunk) { + .start = prev_end, + .end = start, + .attr = 0, + })); + } + const varnumber_T end = tv_get_number_chk(&l->lv_first->li_next->li_tv, + &error); + if (error) { + goto color_cmdline_error; + } else if (!(start < end && end <= ccline.cmdlen)) { + emsgf(_("E5404: Chunk %i end %" PRIdVARNUMBER " not in range " + "(%" PRIdVARNUMBER ", %i]"), + i, end, start, ccline.cmdlen); + goto color_cmdline_error; + } + prev_end = end; + const char *const group = tv_get_string_chk(&l->lv_last->li_tv); + if (group == NULL) { + goto color_cmdline_error; + } + const int id = syn_name2id((char_u *)group); + const int attr = (id == 0 ? 0 : syn_id2attr(id)); + kv_push(ccline_colors, ((ColoredCmdlineChunk) { + .start = start, + .end = end, + .attr = attr, + })); + } + if (prev_end < ccline.cmdlen) { + kv_push(ccline_colors, ((ColoredCmdlineChunk) { + .start = prev_end, + .end = ccline.cmdlen, + .attr = 0, + })); + } + prev_cb_errors = 0; +color_cmdline_end: + if (arg_allocated) { + tv_clear(&arg); + } + tv_clear(&tv); + return; +color_cmdline_error: + prev_cb_errors++; + did_emsg = false; + if (did_throw) { + discard_current_exception(); + } + if (msg_list != NULL && *msg_list != NULL) { + free_global_msglist(); + } + kv_size(ccline_colors) = 0; + goto color_cmdline_end; +} + /* * Draw part of the cmdline at the current cursor position. But draw stars * when cmdline_star is TRUE. @@ -2272,7 +2415,21 @@ static void draw_cmdline(int start, int len) msg_outtrans_len(arshape_buf, newlen); } else { draw_cmdline_no_arabicshape: - msg_outtrans_len(ccline.cmdbuff + start, len); + color_cmdline(); + if (kv_size(ccline_colors)) { + for (size_t i = 0; i < kv_size(ccline_colors); i++) { + ColoredCmdlineChunk chunk = kv_A(ccline_colors, i); + if (chunk.end <= start) { + continue; + } + const int chunk_start = MAX(chunk.start, start); + msg_outtrans_len_attr(ccline.cmdbuff + chunk_start, + chunk.end - chunk_start, + chunk.attr); + } + } else { + msg_outtrans_len(ccline.cmdbuff + start, len); + } } } -- cgit From d82741f8c04d003bb9925d9c46d7e07179810ed4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 26 Mar 2017 17:25:03 +0300 Subject: ex_getln: Add some more tests, fix some found errors --- src/nvim/ex_getln.c | 92 +++++++++++++++++++++++++++++++++++++++++------------ src/nvim/mbyte.c | 2 +- src/nvim/mbyte.h | 3 ++ 3 files changed, 75 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index b08407233f..e4914d6ebc 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2178,6 +2178,8 @@ void free_cmdline_buf(void) # endif +enum { MAX_CB_ERRORS = 5 }; + /// Color command-line /// /// Should use built-in command parser or user-specified one. Currently only the @@ -2186,50 +2188,77 @@ void free_cmdline_buf(void) /// Operates on ccline, saving results to ccline_colors. /// /// Always colors the whole cmdline. -static void color_cmdline(void) +/// +/// @return true if draw_cmdline may proceed, false if it does not need anything +/// to do. +static bool color_cmdline(void) { + bool ret = true; kv_size(ccline_colors) = 0; if (ccline.cmdfirstc != ':') { - return; + return ret; } + + const int saved_force_abort = force_abort; + force_abort = true; + bool arg_allocated = false; + typval_T arg = { + .v_type = VAR_STRING, + .vval.v_string = ccline.cmdbuff, + }; + typval_T tv = { .v_type = VAR_UNKNOWN }; + static Callback prev_cb = { .type = kCallbackNone }; static int prev_cb_errors = 0; Callback color_cb; if (!tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_cmdline"), &color_cb)) { - return; + goto color_cmdline_error; } if (color_cb.type == kCallbackNone) { - return; + goto color_cmdline_end; } - if (prev_cb_errors == 5 && tv_callback_equal(&prev_cb, &color_cb)) { - return; + if (!tv_callback_equal(&prev_cb, &color_cb)) { + prev_cb_errors = 0; + } else if (prev_cb_errors >= MAX_CB_ERRORS) { + callback_free(&color_cb); + goto color_cmdline_end; } callback_free(&prev_cb); prev_cb = color_cb; - bool arg_allocated; - typval_T arg = { - .v_type = VAR_STRING, - }; - if (ccline.cmdbuff[ccline.cmdlen] == NUL) { - arg_allocated = false; - arg.vval.v_string = ccline.cmdbuff; - } else { + if (ccline.cmdbuff[ccline.cmdlen] != NUL) { arg_allocated = true; arg.vval.v_string = xmemdupz((const char *)ccline.cmdbuff, (size_t)ccline.cmdlen); } - typval_T tv; + // msg_start() called by e.g. :echo may shift command-line to the first column + // even though msg_silent is here. Two ways to workaround this problem without + // altering message.c: use full_screen or save and restore msg_col. + // + // Saving and restoring full_screen does not work well with :redraw!. Saving + // and restoring msg_col is neither ideal, but while with full_screen it + // appears shifted one character to the right and cursor position is no longer + // correct, with msg_col it just misses leading `:`. Since `redraw!` in + // callback lags this is least of the user problems. + const int saved_msg_col = msg_col; msg_silent++; if (!callback_call(&color_cb, 1, &arg, &tv)) { msg_silent--; - goto color_cmdline_end; + msg_col = saved_msg_col; + goto color_cmdline_error; } msg_silent--; - if (tv.v_type != VAR_LIST || tv.vval.v_list == NULL) { + msg_col = saved_msg_col; + if (got_int || did_emsg) { + goto color_cmdline_error; + } + if (tv.v_type != VAR_LIST) { emsgf(_("E5400: Callback should return list")); goto color_cmdline_error; } + if (tv.vval.v_list == NULL) { + goto color_cmdline_end; + } varnumber_T prev_end = 0; int i = 0; for (const listitem_T *li = tv.vval.v_list->lv_first; @@ -2248,11 +2277,15 @@ static void color_cmdline(void) const varnumber_T start = tv_get_number_chk(&l->lv_first->li_tv, &error); if (error) { goto color_cmdline_error; - } else if (!(prev_end <= start && start <= ccline.cmdlen)) { + } else if (!(prev_end <= start && start < ccline.cmdlen)) { emsgf(_("E5403: Chunk %i start %" PRIdVARNUMBER " not in range " - "[%" PRIdVARNUMBER ", %i]"), + "[%" PRIdVARNUMBER ", %i)"), i, start, prev_end, ccline.cmdlen); goto color_cmdline_error; + } else if (utf8len_tab_zero[(uint8_t)ccline.cmdbuff[start]] == 0) { + emsgf(_("E5405: Chunk %i start %" PRIdVARNUMBER " splits multibyte " + "character"), i, start); + goto color_cmdline_error; } if (start != prev_end) { kv_push(ccline_colors, ((ColoredCmdlineChunk) { @@ -2270,6 +2303,11 @@ static void color_cmdline(void) "(%" PRIdVARNUMBER ", %i]"), i, end, start, ccline.cmdlen); goto color_cmdline_error; + } else if (end < ccline.cmdlen + && utf8len_tab_zero[(uint8_t)ccline.cmdbuff[end]] == 0) { + emsgf(_("E5406: Chunk %i end %" PRIdVARNUMBER " splits multibyte " + "character"), i, end); + goto color_cmdline_error; } prev_end = end; const char *const group = tv_get_string_chk(&l->lv_last->li_tv); @@ -2293,13 +2331,16 @@ static void color_cmdline(void) } prev_cb_errors = 0; color_cmdline_end: + force_abort = saved_force_abort; if (arg_allocated) { tv_clear(&arg); } tv_clear(&tv); - return; + return ret; color_cmdline_error: prev_cb_errors++; + const bool do_redraw = (did_emsg || got_int); + got_int = false; did_emsg = false; if (did_throw) { discard_current_exception(); @@ -2308,6 +2349,12 @@ color_cmdline_error: free_global_msglist(); } kv_size(ccline_colors) = 0; + if (do_redraw) { + prev_cb_errors += MAX_CB_ERRORS; + redrawcmdline(); + prev_cb_errors -= MAX_CB_ERRORS; + ret = false; + } goto color_cmdline_end; } @@ -2317,6 +2364,10 @@ color_cmdline_error: */ static void draw_cmdline(int start, int len) { + if (!color_cmdline()) { + return; + } + if (cmdline_star > 0) { for (int i = 0; i < len; i++) { msg_putchar('*'); @@ -2415,7 +2466,6 @@ static void draw_cmdline(int start, int len) msg_outtrans_len(arshape_buf, newlen); } else { draw_cmdline_no_arabicshape: - color_cmdline(); if (kv_size(ccline_colors)) { for (size_t i = 0; i < kv_size(ccline_colors); i++) { ColoredCmdlineChunk chunk = kv_A(ccline_colors, i); diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index d5907da2ed..862ca7ea1a 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -75,7 +75,7 @@ struct interval { /* * Like utf8len_tab above, but using a zero for illegal lead bytes. */ -static uint8_t utf8len_tab_zero[256] = +const uint8_t utf8len_tab_zero[256] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h index ad9e38004c..02c6065672 100644 --- a/src/nvim/mbyte.h +++ b/src/nvim/mbyte.h @@ -1,6 +1,7 @@ #ifndef NVIM_MBYTE_H #define NVIM_MBYTE_H +#include #include #include @@ -67,6 +68,8 @@ typedef struct { ///< otherwise use '?'. } vimconv_T; +extern const uint8_t utf8len_tab_zero[256]; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "mbyte.h.generated.h" #endif -- cgit From 407abb3a6c5c1c706bf8797a1431e57e97a6b797 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Apr 2017 01:00:40 +0300 Subject: eval,ex_getln: Add support for coloring input() prompts --- src/nvim/eval.c | 12 ++++++-- src/nvim/ex_getln.c | 88 +++++++++++++++++++++++++++++++---------------------- src/nvim/ex_getln.h | 2 ++ 3 files changed, 64 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 18aa5bf763..1cc4a3eb15 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -11010,6 +11010,7 @@ void get_user_input(const typval_T *const argvars, const char *defstr = ""; const char *cancelreturn = NULL; const char *xp_name = NULL; + Callback input_callback = { .type = kCallbackNone }; char prompt_buf[NUMBUFLEN]; char defstr_buf[NUMBUFLEN]; char cancelreturn_buf[NUMBUFLEN]; @@ -11019,7 +11020,7 @@ void get_user_input(const typval_T *const argvars, emsgf(_("E5050: {opts} must be the only argument")); return; } - const dict_T *const dict = argvars[0].vval.v_dict; + dict_T *const dict = argvars[0].vval.v_dict; prompt = tv_dict_get_string_buf_chk(dict, S_LEN("prompt"), prompt_buf, ""); if (prompt == NULL) { return; @@ -11045,6 +11046,9 @@ void get_user_input(const typval_T *const argvars, if (xp_name == def) { // default to NULL xp_name = NULL; } + if (!tv_dict_get_callback(dict, S_LEN("highlight"), &input_callback)) { + return; + } } else { prompt = tv_get_string_buf_chk(&argvars[0], prompt_buf); if (prompt == NULL) { @@ -11103,12 +11107,16 @@ void get_user_input(const typval_T *const argvars, stuffReadbuffSpec(defstr); - int save_ex_normal_busy = ex_normal_busy; + const int save_ex_normal_busy = ex_normal_busy; + const Callback save_getln_input_callback = getln_input_callback; ex_normal_busy = 0; + getln_input_callback = input_callback; rettv->vval.v_string = getcmdline_prompt(inputsecret_flag ? NUL : '@', (char_u *)p, echo_attr, xp_type, (char_u *)xp_arg); + getln_input_callback = save_getln_input_callback; ex_normal_busy = save_ex_normal_busy; + callback_free(&input_callback); if (rettv->vval.v_string == NULL && cancelreturn != NULL) { rettv->vval.v_string = (char_u *)xstrdup(cancelreturn); diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e4914d6ebc..a2cc6d2b65 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -70,23 +70,26 @@ * structure. */ struct cmdline_info { - char_u *cmdbuff; /* pointer to command line buffer */ - int cmdbufflen; /* length of cmdbuff */ - int cmdlen; /* number of chars in command line */ - int cmdpos; /* current cursor position */ - int cmdspos; /* cursor column on screen */ - int cmdfirstc; /* ':', '/', '?', '=', '>' or NUL */ - int cmdindent; /* number of spaces before cmdline */ - char_u *cmdprompt; /* message in front of cmdline */ - int cmdattr; /* attributes for prompt */ - int overstrike; /* Typing mode on the command line. Shared by - getcmdline() and put_on_cmdline(). */ - expand_T *xpc; /* struct being used for expansion, xp_pattern - may point into cmdbuff */ - int xp_context; /* type of expansion */ - char_u *xp_arg; /* user-defined expansion arg */ - int input_fn; /* when TRUE Invoked for input() function */ + char_u *cmdbuff; // pointer to command line buffer + int cmdbufflen; // length of cmdbuff + int cmdlen; // number of chars in command line + int cmdpos; // current cursor position + int cmdspos; // cursor column on screen + int cmdfirstc; // ':', '/', '?', '=', '>' or NUL + int cmdindent; // number of spaces before cmdline + char_u *cmdprompt; // message in front of cmdline + int cmdattr; // attributes for prompt + int overstrike; // Typing mode on the command line. Shared by + // getcmdline() and put_on_cmdline(). + expand_T *xpc; // struct being used for expansion, xp_pattern + // may point into cmdbuff + int xp_context; // type of expansion + char_u *xp_arg; // user-defined expansion arg + int input_fn; // when TRUE Invoked for input() function + unsigned prompt_id; ///< Prompt number, used to disable coloring on errors. }; +/// Last value of prompt_id, incremented when doing new prompt +static unsigned last_prompt_id = 0; typedef struct command_line_state { VimState state; @@ -135,6 +138,9 @@ typedef struct { int attr; ///< Highlight attr. } ColoredCmdlineChunk; +/// Callback used for coloring input() prompts +Callback getln_input_callback = { .type = kCallbackNone }; + kvec_t(ColoredCmdlineChunk) ccline_colors; /* The current cmdline_info. It is initialized in getcmdline() and after that @@ -188,6 +194,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) cmd_hkmap = 0; } + ccline.prompt_id = last_prompt_id++; ccline.overstrike = false; // always start in insert mode s->old_cursor = curwin->w_cursor; // needs to be restored later s->old_curswant = curwin->w_curswant; @@ -1703,6 +1710,7 @@ getcmdline_prompt ( int msg_col_save = msg_col; save_cmdline(&save_ccline); + ccline.prompt_id = last_prompt_id++; ccline.cmdprompt = prompt; ccline.cmdattr = attr; ccline.xp_context = xp_context; @@ -2178,7 +2186,7 @@ void free_cmdline_buf(void) # endif -enum { MAX_CB_ERRORS = 5 }; +enum { MAX_CB_ERRORS = 1 }; /// Color command-line /// @@ -2195,9 +2203,6 @@ static bool color_cmdline(void) { bool ret = true; kv_size(ccline_colors) = 0; - if (ccline.cmdfirstc != ':') { - return ret; - } const int saved_force_abort = force_abort; force_abort = true; @@ -2208,24 +2213,32 @@ static bool color_cmdline(void) }; typval_T tv = { .v_type = VAR_UNKNOWN }; - static Callback prev_cb = { .type = kCallbackNone }; - static int prev_cb_errors = 0; - Callback color_cb; - if (!tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_cmdline"), - &color_cb)) { - goto color_cmdline_error; + static unsigned prev_prompt_id = UINT_MAX; + static int prev_prompt_errors = 0; + Callback color_cb = { .type = kCallbackNone }; + bool can_free_cb = false; + + if (ccline.input_fn) { + color_cb = getln_input_callback; + } else if (ccline.cmdfirstc == ':') { + if (!tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_cmdline"), + &color_cb)) { + goto color_cmdline_error; + } + can_free_cb = true; + } else { + goto color_cmdline_end; } + if (color_cb.type == kCallbackNone) { goto color_cmdline_end; } - if (!tv_callback_equal(&prev_cb, &color_cb)) { - prev_cb_errors = 0; - } else if (prev_cb_errors >= MAX_CB_ERRORS) { - callback_free(&color_cb); + if (ccline.prompt_id != prev_prompt_id) { + prev_prompt_errors = 0; + prev_prompt_id = ccline.prompt_id; + } else if (prev_prompt_errors >= MAX_CB_ERRORS) { goto color_cmdline_end; } - callback_free(&prev_cb); - prev_cb = color_cb; if (ccline.cmdbuff[ccline.cmdlen] != NUL) { arg_allocated = true; arg.vval.v_string = xmemdupz((const char *)ccline.cmdbuff, @@ -2329,8 +2342,11 @@ static bool color_cmdline(void) .attr = 0, })); } - prev_cb_errors = 0; + prev_prompt_errors = 0; color_cmdline_end: + if (can_free_cb) { + callback_free(&color_cb); + } force_abort = saved_force_abort; if (arg_allocated) { tv_clear(&arg); @@ -2338,7 +2354,7 @@ color_cmdline_end: tv_clear(&tv); return ret; color_cmdline_error: - prev_cb_errors++; + prev_prompt_errors++; const bool do_redraw = (did_emsg || got_int); got_int = false; did_emsg = false; @@ -2350,9 +2366,9 @@ color_cmdline_error: } kv_size(ccline_colors) = 0; if (do_redraw) { - prev_cb_errors += MAX_CB_ERRORS; + prev_prompt_errors += MAX_CB_ERRORS; redrawcmdline(); - prev_cb_errors -= MAX_CB_ERRORS; + prev_prompt_errors -= MAX_CB_ERRORS; ret = false; } goto color_cmdline_end; diff --git a/src/nvim/ex_getln.h b/src/nvim/ex_getln.h index 051564fbe1..92cb274010 100644 --- a/src/nvim/ex_getln.h +++ b/src/nvim/ex_getln.h @@ -52,6 +52,8 @@ typedef struct hist_entry { list_T *additional_elements; ///< Additional entries from ShaDa file. } histentry_T; +extern Callback getln_input_callback; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ex_getln.h.generated.h" #endif -- cgit From 072a853fa212bdce88f756ac170fb915a4972625 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 22 May 2017 22:44:08 +0300 Subject: ex_getln: Enable coloring for expression mode --- src/nvim/ex_getln.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index a2cc6d2b65..f9b2d6cda8 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2226,6 +2226,12 @@ static bool color_cmdline(void) goto color_cmdline_error; } can_free_cb = true; + } else if (ccline.cmdfirstc == '=') { + if (!tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_expr"), + &color_cb)) { + goto color_cmdline_error; + } + can_free_cb = true; } else { goto color_cmdline_end; } -- cgit From 0ed95423de714edac11ccff177b8aee6b7987bac Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 28 Jun 2017 14:26:23 +0300 Subject: ex_getln: Call highlight callback inside :try --- src/nvim/ex_getln.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index f9b2d6cda8..9c494a2640 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -63,6 +63,7 @@ #include "nvim/event/loop.h" #include "nvim/os/time.h" #include "nvim/lib/kvec.h" +#include "nvim/api/private/helpers.h" /* * Variables shared between getcmdline(), redrawcmdline() and others. @@ -2217,6 +2218,7 @@ static bool color_cmdline(void) static int prev_prompt_errors = 0; Callback color_cb = { .type = kCallbackNone }; bool can_free_cb = false; + Error err = ERROR_INIT; if (ccline.input_fn) { color_cb = getln_input_callback; @@ -2259,16 +2261,16 @@ static bool color_cmdline(void) // appears shifted one character to the right and cursor position is no longer // correct, with msg_col it just misses leading `:`. Since `redraw!` in // callback lags this is least of the user problems. + // + // Also using try_start() because error messages may overwrite typed + // command-line which is not expected. + try_start(); const int saved_msg_col = msg_col; msg_silent++; - if (!callback_call(&color_cb, 1, &arg, &tv)) { - msg_silent--; - msg_col = saved_msg_col; - goto color_cmdline_error; - } + const bool cbcall_ret = callback_call(&color_cb, 1, &arg, &tv); msg_silent--; msg_col = saved_msg_col; - if (got_int || did_emsg) { + if (try_end(&err) || !cbcall_ret) { goto color_cmdline_error; } if (tv.v_type != VAR_LIST) { @@ -2350,6 +2352,7 @@ static bool color_cmdline(void) } prev_prompt_errors = 0; color_cmdline_end: + assert(!ERROR_SET(&err)); if (can_free_cb) { callback_free(&color_cb); } @@ -2360,18 +2363,14 @@ color_cmdline_end: tv_clear(&tv); return ret; color_cmdline_error: - prev_prompt_errors++; - const bool do_redraw = (did_emsg || got_int); - got_int = false; - did_emsg = false; - if (did_throw) { - discard_current_exception(); - } - if (msg_list != NULL && *msg_list != NULL) { - free_global_msglist(); + if (ERROR_SET(&err)) { + emsgf(_("E5407: Callback has thrown an exception: %s"), err.msg); + api_clear_error(&err); } + prev_prompt_errors++; kv_size(ccline_colors) = 0; - if (do_redraw) { + if (did_emsg) { + did_emsg = false; prev_prompt_errors += MAX_CB_ERRORS; redrawcmdline(); prev_prompt_errors -= MAX_CB_ERRORS; -- cgit From 3da49cd68e7d5c968cc99a926819038ff57f488f Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 28 Jun 2017 22:09:10 +0300 Subject: ex_getln: Fix “echoerr msg not shown†problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also attempted to fix problem with cancelling input() on error by avoiding standard error printing facilities (assumed thrown error message is the problem), but with no luck so far. --- src/nvim/ex_getln.c | 52 ++++++++++++++++++++++++++++++---------------------- src/nvim/message.c | 21 +++++++++++++++++++++ 2 files changed, 51 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 9c494a2640..444a3e5b11 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -64,6 +64,7 @@ #include "nvim/os/time.h" #include "nvim/lib/kvec.h" #include "nvim/api/private/helpers.h" +#include "nvim/highlight_defs.h" /* * Variables shared between getcmdline(), redrawcmdline() and others. @@ -2202,6 +2203,13 @@ enum { MAX_CB_ERRORS = 1 }; /// to do. static bool color_cmdline(void) { + bool printed_errmsg = false; +#define PRINT_ERRMSG(...) \ + do { \ + msg_putchar('\n'); \ + msg_printf_attr(hl_attr(HLF_E)|MSG_HIST, __VA_ARGS__); \ + printed_errmsg = true; \ + } while (0) bool ret = true; kv_size(ccline_colors) = 0; @@ -2274,7 +2282,7 @@ static bool color_cmdline(void) goto color_cmdline_error; } if (tv.v_type != VAR_LIST) { - emsgf(_("E5400: Callback should return list")); + PRINT_ERRMSG(_("E5400: Callback should return list")); goto color_cmdline_error; } if (tv.vval.v_list == NULL) { @@ -2285,13 +2293,13 @@ static bool color_cmdline(void) for (const listitem_T *li = tv.vval.v_list->lv_first; li != NULL; li = li->li_next, i++) { if (li->li_tv.v_type != VAR_LIST) { - emsgf(_("E5401: List item %i is not a List"), i); + PRINT_ERRMSG(_("E5401: List item %i is not a List"), i); goto color_cmdline_error; } const list_T *const l = li->li_tv.vval.v_list; if (tv_list_len(l) != 3) { - emsgf(_("E5402: List item %i has incorrect length: %li /= 3"), - i, tv_list_len(l)); + PRINT_ERRMSG(_("E5402: List item %i has incorrect length: %li /= 3"), + i, tv_list_len(l)); goto color_cmdline_error; } bool error = false; @@ -2299,13 +2307,13 @@ static bool color_cmdline(void) if (error) { goto color_cmdline_error; } else if (!(prev_end <= start && start < ccline.cmdlen)) { - emsgf(_("E5403: Chunk %i start %" PRIdVARNUMBER " not in range " - "[%" PRIdVARNUMBER ", %i)"), - i, start, prev_end, ccline.cmdlen); + PRINT_ERRMSG(_("E5403: Chunk %i start %" PRIdVARNUMBER " not in range " + "[%" PRIdVARNUMBER ", %i)"), + i, start, prev_end, ccline.cmdlen); goto color_cmdline_error; } else if (utf8len_tab_zero[(uint8_t)ccline.cmdbuff[start]] == 0) { - emsgf(_("E5405: Chunk %i start %" PRIdVARNUMBER " splits multibyte " - "character"), i, start); + PRINT_ERRMSG(_("E5405: Chunk %i start %" PRIdVARNUMBER " splits " + "multibyte character"), i, start); goto color_cmdline_error; } if (start != prev_end) { @@ -2320,14 +2328,14 @@ static bool color_cmdline(void) if (error) { goto color_cmdline_error; } else if (!(start < end && end <= ccline.cmdlen)) { - emsgf(_("E5404: Chunk %i end %" PRIdVARNUMBER " not in range " - "(%" PRIdVARNUMBER ", %i]"), - i, end, start, ccline.cmdlen); + PRINT_ERRMSG(_("E5404: Chunk %i end %" PRIdVARNUMBER " not in range " + "(%" PRIdVARNUMBER ", %i]"), + i, end, start, ccline.cmdlen); goto color_cmdline_error; } else if (end < ccline.cmdlen && utf8len_tab_zero[(uint8_t)ccline.cmdbuff[end]] == 0) { - emsgf(_("E5406: Chunk %i end %" PRIdVARNUMBER " splits multibyte " - "character"), i, end); + PRINT_ERRMSG(_("E5406: Chunk %i end %" PRIdVARNUMBER " splits multibyte " + "character"), i, end); goto color_cmdline_error; } prev_end = end; @@ -2364,19 +2372,19 @@ color_cmdline_end: return ret; color_cmdline_error: if (ERROR_SET(&err)) { - emsgf(_("E5407: Callback has thrown an exception: %s"), err.msg); + PRINT_ERRMSG(_("E5407: Callback has thrown an exception: %s"), err.msg); api_clear_error(&err); } + assert(printed_errmsg); + prev_prompt_errors++; kv_size(ccline_colors) = 0; - if (did_emsg) { - did_emsg = false; - prev_prompt_errors += MAX_CB_ERRORS; - redrawcmdline(); - prev_prompt_errors -= MAX_CB_ERRORS; - ret = false; - } + prev_prompt_errors += MAX_CB_ERRORS; + redrawcmdline(); + prev_prompt_errors -= MAX_CB_ERRORS; + ret = false; goto color_cmdline_end; +#undef PRINT_ERRMSG } /* diff --git a/src/nvim/message.c b/src/nvim/message.c index 057ce75f79..ab918712e5 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1611,6 +1611,27 @@ void msg_puts_attr_len(const char *const str, const ptrdiff_t len, int attr) } } +/// Print a formatted message +/// +/// Message printed is limited by #IOSIZE. Must not be used from inside +/// msg_puts_attr(). +/// +/// @param[in] attr Highlight attributes. +/// @param[in] fmt Format string. +void msg_printf_attr(const int attr, const char *const fmt, ...) + FUNC_ATTR_NONNULL_ALL +{ + static char msgbuf[IOSIZE]; + + va_list ap; + va_start(ap, fmt); + const size_t len = vim_vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap, NULL); + va_end(ap); + + msg_scroll = true; + msg_puts_attr_len(msgbuf, (ptrdiff_t)len, attr); +} + /* * The display part of msg_puts_attr_len(). * May be called recursively to display scroll-back text. -- cgit From 99079a164db6ebea6d62f349e0c69894c6b9f799 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 28 Jun 2017 22:20:47 +0300 Subject: ex_getln: Make sure standard error reporting facility is not used --- src/nvim/ex_getln.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 444a3e5b11..7330bebe62 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2227,24 +2227,30 @@ static bool color_cmdline(void) Callback color_cb = { .type = kCallbackNone }; bool can_free_cb = false; Error err = ERROR_INIT; + const char *err_errmsg = (const char *)e_intern2; + bool dgc_ret = true; + try_start(); if (ccline.input_fn) { color_cb = getln_input_callback; } else if (ccline.cmdfirstc == ':') { - if (!tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_cmdline"), - &color_cb)) { - goto color_cmdline_error; - } + err_errmsg = N_( + "E5408: Unable to get Nvim_color_cmdline callback from g:: %s"); + dgc_ret = tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_cmdline"), + &color_cb); can_free_cb = true; } else if (ccline.cmdfirstc == '=') { - if (!tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_expr"), - &color_cb)) { - goto color_cmdline_error; - } + err_errmsg = N_( + "E5409: Unable to get Nvim_color_expr callback from g:: %s"); + dgc_ret = tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_expr"), + &color_cb); can_free_cb = true; } else { goto color_cmdline_end; } + if (try_end(&err) || !dgc_ret) { + goto color_cmdline_error; + } if (color_cb.type == kCallbackNone) { goto color_cmdline_end; @@ -2273,6 +2279,7 @@ static bool color_cmdline(void) // Also using try_start() because error messages may overwrite typed // command-line which is not expected. try_start(); + err_errmsg = N_("E5407: Callback has thrown an exception: %s"); const int saved_msg_col = msg_col; msg_silent++; const bool cbcall_ret = callback_call(&color_cb, 1, &arg, &tv); @@ -2372,7 +2379,7 @@ color_cmdline_end: return ret; color_cmdline_error: if (ERROR_SET(&err)) { - PRINT_ERRMSG(_("E5407: Callback has thrown an exception: %s"), err.msg); + PRINT_ERRMSG(_(err_errmsg), err.msg); api_clear_error(&err); } assert(printed_errmsg); -- cgit From 564d5f921c837e278f7e1aefeb7d832d08a63e97 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 28 Jun 2017 22:21:37 +0300 Subject: ex_getln: Fix indent --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 7330bebe62..e10a485f76 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2232,7 +2232,7 @@ static bool color_cmdline(void) try_start(); if (ccline.input_fn) { - color_cb = getln_input_callback; + color_cb = getln_input_callback; } else if (ccline.cmdfirstc == ':') { err_errmsg = N_( "E5408: Unable to get Nvim_color_cmdline callback from g:: %s"); -- cgit From ea75966e4232dc4a3693cbc4a572f2116c49b138 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 28 Jun 2017 22:54:13 +0300 Subject: ex_getln: Do not make interrupt input() after interrupting hl cb --- src/nvim/ex_getln.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e10a485f76..c23d6089a3 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -166,6 +166,12 @@ static int hisnum[HIST_COUNT] = {0, 0, 0, 0, 0}; /* identifying (unique) number of newest history entry */ static int hislen = 0; /* actual length of history tables */ +/// Flag for command_line_handle_key to ignore +/// +/// Used if it was received while processing highlight function in order for +/// user interrupting highlight function to not interrupt command-line. +static bool getln_interrupted_highlight = false; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ex_getln.c.generated.h" @@ -1026,8 +1032,11 @@ static int command_line_handle_key(CommandLineState *s) case ESC: // get here if p_wc != ESC or when ESC typed twice case Ctrl_C: // In exmode it doesn't make sense to return. Except when - // ":normal" runs out of characters. - if (exmode_active && (ex_normal_busy == 0 || typebuf.tb_len > 0)) { + // ":normal" runs out of characters. Also when highlight callback is active + // should interrupt only it. + if ((exmode_active && (ex_normal_busy == 0 || typebuf.tb_len > 0)) + || (getln_interrupted_highlight && s->c == Ctrl_C)) { + getln_interrupted_highlight = false; return command_line_not_changed(s); } @@ -2278,6 +2287,7 @@ static bool color_cmdline(void) // // Also using try_start() because error messages may overwrite typed // command-line which is not expected. + getln_interrupted_highlight = false; try_start(); err_errmsg = N_("E5407: Callback has thrown an exception: %s"); const int saved_msg_col = msg_col; @@ -2285,6 +2295,9 @@ static bool color_cmdline(void) const bool cbcall_ret = callback_call(&color_cb, 1, &arg, &tv); msg_silent--; msg_col = saved_msg_col; + if (got_int) { + getln_interrupted_highlight = true; + } if (try_end(&err) || !cbcall_ret) { goto color_cmdline_error; } -- cgit From 7ab152aaa58f493e54d03a15960b8a288196e588 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 1 Jul 2017 15:34:25 +0300 Subject: ex_getln: Save and restore try state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: when processing cycle such as :for pat in [' \ze*', ' \zs*'] : try : let l = matchlist('x x', pat) : $put ='E888 NOT detected for ' . pat : catch : $put ='E888 detected for ' . pat : endtry :endfor `:let l = …` throwing an error causes this error to be caught after color_cmdline attempts to get callback for highlighting next line (the one with `$put = 'E888 NOT…`). Saving/restoring state prevents this from happening. --- src/nvim/api/private/helpers.c | 46 ++++++++++++++++++++++++++++++++++++++++++ src/nvim/api/private/helpers.h | 12 +++++++++++ src/nvim/ex_getln.c | 16 ++++++++++----- 3 files changed, 69 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index d401ae52a0..883a5a2fd1 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -37,6 +37,52 @@ typedef struct { # include "api/private/ui_events_metadata.generated.h" #endif +/// Start block that may cause VimL exceptions while evaluating another code +/// +/// Used when caller is supposed to be operating when other VimL code is being +/// processed and that “other VimL code†must not be affected. +/// +/// @param[out] tstate Location where try state should be saved. +void try_enter(TryState *const tstate) +{ + *tstate = (TryState) { + .trylevel = trylevel, + .got_int = got_int, + .did_throw = did_throw, + .msg_list = (const struct msglist *const *)msg_list, + .private_msg_list = NULL, + }; + trylevel = 1; + got_int = false; + did_throw = false; + msg_list = &tstate->private_msg_list; +} + +/// End try block, set the error message if any and restore previous state +/// +/// @warning Return is consistent with most functions (false on error), not with +/// try_end (true on error). +/// +/// @param[in] tstate Previous state to restore. +/// @param[out] err Location where error should be saved. +/// +/// @return false if error occurred, true otherwise. +bool try_leave(const TryState *const tstate, Error *const err) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT +{ + const bool ret = !try_end(err); + assert(trylevel == 0); + assert(!got_int); + assert(!did_throw); + assert(msg_list == &tstate->private_msg_list); + assert(*msg_list == NULL); + trylevel = tstate->trylevel; + got_int = tstate->got_int; + did_throw = tstate->did_throw; + msg_list = (struct msglist **)tstate->msg_list; + return ret; +} + /// Start block that may cause vimscript exceptions void try_start(void) { diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h index 159b9d5c2a..112d785bfd 100644 --- a/src/nvim/api/private/helpers.h +++ b/src/nvim/api/private/helpers.h @@ -82,6 +82,18 @@ #define api_free_window(value) #define api_free_tabpage(value) +/// Structure used for saving state for :try +/// +/// Used when caller is supposed to be operating when other VimL code is being +/// processed and that “other VimL code†must not be affected. +typedef struct { + int trylevel; + int got_int; + int did_throw; + struct msglist *private_msg_list; + const struct msglist *const *msg_list; +} TryState; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "api/private/helpers.h.generated.h" #endif diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index c23d6089a3..e6cd7398ab 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2222,6 +2222,11 @@ static bool color_cmdline(void) bool ret = true; kv_size(ccline_colors) = 0; + if (ccline.cmdbuff == NULL || *ccline.cmdbuff == NUL) { + // Nothing to do, exiting. + return ret; + } + const int saved_force_abort = force_abort; force_abort = true; bool arg_allocated = false; @@ -2235,11 +2240,12 @@ static bool color_cmdline(void) static int prev_prompt_errors = 0; Callback color_cb = { .type = kCallbackNone }; bool can_free_cb = false; + TryState tstate; Error err = ERROR_INIT; const char *err_errmsg = (const char *)e_intern2; bool dgc_ret = true; - try_start(); + try_enter(&tstate); if (ccline.input_fn) { color_cb = getln_input_callback; } else if (ccline.cmdfirstc == ':') { @@ -2257,7 +2263,7 @@ static bool color_cmdline(void) } else { goto color_cmdline_end; } - if (try_end(&err) || !dgc_ret) { + if (!try_leave(&tstate, &err) || !dgc_ret) { goto color_cmdline_error; } @@ -2285,10 +2291,10 @@ static bool color_cmdline(void) // correct, with msg_col it just misses leading `:`. Since `redraw!` in // callback lags this is least of the user problems. // - // Also using try_start() because error messages may overwrite typed + // Also using try_enter() because error messages may overwrite typed // command-line which is not expected. getln_interrupted_highlight = false; - try_start(); + try_enter(&tstate); err_errmsg = N_("E5407: Callback has thrown an exception: %s"); const int saved_msg_col = msg_col; msg_silent++; @@ -2298,7 +2304,7 @@ static bool color_cmdline(void) if (got_int) { getln_interrupted_highlight = true; } - if (try_end(&err) || !cbcall_ret) { + if (!try_leave(&tstate, &err) || !cbcall_ret) { goto color_cmdline_error; } if (tv.v_type != VAR_LIST) { -- cgit From ac086d8ce2bf24ef643aeea428a81f5ec331bec0 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 18:05:54 +0300 Subject: mbyte: Refactor mb_unescape Does not alter its usages. --- src/nvim/mbyte.c | 85 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 44 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index d5907da2ed..5b00a4b9a8 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1739,52 +1739,55 @@ int mb_charlen_len(char_u *str, int len) return count; } -/* - * Try to un-escape a multi-byte character. - * Used for the "to" and "from" part of a mapping. - * Return the un-escaped string if it is a multi-byte character, and advance - * "pp" to just after the bytes that formed it. - * Return NULL if no multi-byte char was found. - */ -char_u * mb_unescape(char_u **pp) -{ - static char_u buf[6]; - int n; - int m = 0; - char_u *str = *pp; - - /* Must translate K_SPECIAL KS_SPECIAL KE_FILLER to K_SPECIAL and CSI - * KS_EXTRA KE_CSI to CSI. - * Maximum length of a utf-8 character is 4 bytes. */ - for (n = 0; str[n] != NUL && m < 4; ++n) { - if (str[n] == K_SPECIAL - && str[n + 1] == KS_SPECIAL - && str[n + 2] == KE_FILLER) { - buf[m++] = K_SPECIAL; - n += 2; - } else if ((str[n] == K_SPECIAL - ) - && str[n + 1] == KS_EXTRA - && str[n + 2] == (int)KE_CSI) { - buf[m++] = CSI; - n += 2; - } else if (str[n] == K_SPECIAL - ) - break; /* a special key can't be a multibyte char */ - else - buf[m++] = str[n]; - buf[m] = NUL; +/// Try to unescape a multibyte character +/// +/// Used for the rhs and lhs of the mappings. +/// +/// @param[in,out] pp String to unescape. Is advanced to just after the bytes +/// that form a multibyte character. +/// +/// @return Unescaped string if it is a multibyte character, NULL if no +/// multibyte character was found. Returns a static buffer, always one +/// and the same. +const char *mb_unescape(const char **const pp) + FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL +{ + static char buf[6]; + size_t buf_idx = 0; + uint8_t *str = (uint8_t *)(*pp); + + // Must translate K_SPECIAL KS_SPECIAL KE_FILLER to K_SPECIAL and CSI + // KS_EXTRA KE_CSI to CSI. + // Maximum length of a utf-8 character is 4 bytes. + for (size_t str_idx = 0; str[str_idx] != NUL && buf_idx < 4; str_idx++) { + if (str[str_idx] == K_SPECIAL + && str[str_idx + 1] == KS_SPECIAL + && str[str_idx + 2] == KE_FILLER) { + buf[buf_idx++] = (char)K_SPECIAL; + str_idx += 2; + } else if ((str[str_idx] == K_SPECIAL) + && str[str_idx + 1] == KS_EXTRA + && str[str_idx + 2] == KE_CSI) { + buf[buf_idx++] = (char)CSI; + str_idx += 2; + } else if (str[str_idx] == K_SPECIAL) { + break; // A special key can't be a multibyte char. + } else { + buf[buf_idx++] = (char)str[str_idx]; + } + buf[buf_idx] = NUL; - /* Return a multi-byte character if it's found. An illegal sequence - * will result in a 1 here. */ - if ((*mb_ptr2len)(buf) > 1) { - *pp = str + n + 1; + // Return a multi-byte character if it's found. An illegal sequence + // will result in a 1 here. + if (utf_ptr2len((const char_u *)buf) > 1) { + *pp = (const char *)str + buf_idx + 1; return buf; } - /* Bail out quickly for ASCII. */ - if (buf[0] < 128) + // Bail out quickly for ASCII. + if ((uint8_t)buf[0] < 128) { break; + } } return NULL; } -- cgit From e9e1668ca6520936eaa0958823325c11a72fa923 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 18:12:46 +0300 Subject: message: Refactor str2special_save and str2special Does not alter their usages as well. --- src/nvim/message.c | 120 +++++++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 58 deletions(-) (limited to 'src') diff --git a/src/nvim/message.c b/src/nvim/message.c index 057ce75f79..2263f9c00d 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1281,90 +1281,94 @@ msg_outtrans_special ( return retval; } -/* - * Return the lhs or rhs of a mapping, with the key codes turned into printable - * strings, in an allocated string. - */ -char_u * -str2special_save ( - char_u *str, - int is_lhs /* TRUE for lhs, FALSE for rhs */ -) +/// Convert string, replacing key codes with printables +/// +/// Used for lhs or rhs of mappings. +/// +/// @param[in] str String to convert. +/// @param[in] replace_spaces Convert spaces into , normally used for +/// lhs, but not rhs. +/// +/// @return [allocated] Converted string. +char *str2special_save(const char *const str, const bool replace_spaces) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC + FUNC_ATTR_NONNULL_RET { garray_T ga; - char_u *p = str; - ga_init(&ga, 1, 40); - while (*p != NUL) - ga_concat(&ga, str2special(&p, is_lhs)); + + const char *p = str; + while (*p != NUL) { + ga_concat(&ga, (const char_u *)str2special(&p, replace_spaces)); + } ga_append(&ga, NUL); - return (char_u *)ga.ga_data; + return (char *)ga.ga_data; } -/* - * Return the printable string for the key codes at "*sp". - * Used for translating the lhs or rhs of a mapping to printable chars. - * Advances "sp" to the next code. - */ -char_u * -str2special ( - char_u **sp, - int from /* TRUE for lhs of mapping */ -) +/// Convert character, replacing key one key code with printable representation +/// +/// @param[in,out] sp String to convert. Is advanced to the next key code. +/// @param[in] replace_spaces Convert spaces into , normally used for +/// lhs, but not rhs. +/// +/// @return Converted key code, in a static buffer. Buffer is always one and the +/// same, so save converted string somewhere before running str2special +/// for the second time. +const char *str2special(const char **const sp, const bool replace_spaces) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET { - int c; - static char_u buf[7]; - char_u *str = *sp; - int modifiers = 0; - int special = FALSE; + static char buf[7]; - if (has_mbyte) { - char_u *p; - - /* Try to un-escape a multi-byte character. Return the un-escaped - * string if it is a multi-byte character. */ - p = mb_unescape(sp); - if (p != NULL) - return p; + // Try to un-escape a multi-byte character. Return the un-escaped + // string if it is a multi-byte character. + const char *const p = mb_unescape(sp); + if (p != NULL) { + return p; } - c = *str; + const char *str = *sp; + int c = (uint8_t)(*str); + int modifiers = 0; + bool special = false; if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) { - if (str[1] == KS_MODIFIER) { - modifiers = str[2]; + if ((uint8_t)str[1] == KS_MODIFIER) { + modifiers = (uint8_t)str[2]; str += 3; - c = *str; + c = (uint8_t)(*str); } if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) { - c = TO_SPECIAL(str[1], str[2]); + c = TO_SPECIAL((uint8_t)str[1], (uint8_t)str[2]); str += 2; - if (c == KS_ZERO) /* display as ^@ or */ + if (c == KS_ZERO) { // display as ^@ or c = NUL; + } + } + if (IS_SPECIAL(c) || modifiers) { // Special key. + special = true; } - if (IS_SPECIAL(c) || modifiers) /* special key */ - special = TRUE; } - if (has_mbyte && !IS_SPECIAL(c)) { - int len = (*mb_ptr2len)(str); + if (!IS_SPECIAL(c)) { + const int len = utf_ptr2len((const char_u *)str); - /* For multi-byte characters check for an illegal byte. */ - if (has_mbyte && MB_BYTE2LEN(*str) > len) { - transchar_nonprint(buf, c); + // Check for an illegal byte. + if (MB_BYTE2LEN((uint8_t)(*str)) > len) { + transchar_nonprint((char_u *)buf, c); *sp = str + 1; return buf; } - /* Since 'special' is TRUE the multi-byte character 'c' will be - * processed by get_special_key_name() */ - c = (*mb_ptr2char)(str); + // Since 'special' is TRUE the multi-byte character 'c' will be + // processed by get_special_key_name(). + c = utf_ptr2char((const char_u *)str); *sp = str + len; - } else + } else { *sp = str + 1; + } - /* Make unprintable characters in <> form, also and . - * Use only for lhs of a mapping. */ - if (special || char2cells(c) > 1 || (from && c == ' ')) - return get_special_key_name(c, modifiers); + // Make unprintable characters in <> form, also and . + if (special || char2cells(c) > 1 || (replace_spaces && c == ' ')) { + return (const char *)get_special_key_name(c, modifiers); + } buf[0] = c; buf[1] = NUL; return buf; -- cgit From 832c158a663c7acb03a47fbd1e380ab7f835a9cd Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 18:24:16 +0300 Subject: message: Refactor str2specialbuf Does not alter its usages. --- src/nvim/message.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/message.c b/src/nvim/message.c index 2263f9c00d..656f1adaf8 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1374,19 +1374,25 @@ const char *str2special(const char **const sp, const bool replace_spaces) return buf; } -/* - * Translate a key sequence into special key names. - */ -void str2specialbuf(char_u *sp, char_u *buf, int len) +/// Convert string, replacing key codes with printables +/// +/// @param[in] str String to convert. +/// @param[out] buf Buffer to save results to. +/// @param[in] len Buffer length. +void str2specialbuf(const char *sp, char *buf, size_t len) + FUNC_ATTR_NONNULL_ALL { - char_u *s; - - *buf = NUL; while (*sp) { - s = str2special(&sp, FALSE); - if ((int)(STRLEN(s) + STRLEN(buf)) < len) - STRCAT(buf, s); + const char *s = str2special(&sp, false); + const size_t s_len = strlen(s); + if (s_len <= len) { + break; + } + memcpy(buf, s, s_len); + buf += s_len; + len -= s_len; } + *buf = NUL; } /* -- cgit From 6140396d97d700ab6390b4ecfc4fd7da0ebdfd9f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 18:29:42 +0300 Subject: *: Adjust usages of modified functions --- src/nvim/eval.c | 12 +++++++----- src/nvim/getchar.c | 10 ++++------ src/nvim/message.c | 2 +- src/nvim/option.c | 22 +++++++++++++--------- 4 files changed, 25 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 18aa5bf763..c4baf3f653 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12117,9 +12117,11 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) xfree(keys_buf); if (!get_dict) { - /* Return a string. */ - if (rhs != NULL) - rettv->vval.v_string = str2special_save(rhs, FALSE); + // Return a string. + if (rhs != NULL) { + rettv->vval.v_string = (char_u *)str2special_save( + (const char *)rhs, false); + } } else { tv_dict_alloc_ret(rettv); @@ -12154,7 +12156,7 @@ void mapblock_fill_dict(dict_T *const dict, bool compatible) FUNC_ATTR_NONNULL_ALL { - char_u *lhs = str2special_save(mp->m_keys, true); + char *const lhs = str2special_save((const char *)mp->m_keys, true); char *const mapmode = map_mode_to_chars(mp->m_mode); varnumber_T noremap_value; @@ -12168,7 +12170,7 @@ void mapblock_fill_dict(dict_T *const dict, noremap_value = mp->m_noremap == REMAP_SCRIPT ? 2 : !!mp->m_noremap; } - tv_dict_add_str(dict, S_LEN("lhs"), (const char *)lhs); + tv_dict_add_str(dict, S_LEN("lhs"), lhs); tv_dict_add_str(dict, S_LEN("rhs"), (const char *)mp->m_orig_str); tv_dict_add_nr(dict, S_LEN("noremap"), noremap_value); tv_dict_add_nr(dict, S_LEN("expr"), mp->m_expr ? 1 : 0); diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 4e42042959..1d1af69c94 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1806,7 +1806,7 @@ static int vgetorpeek(int advance) * and then changing 'encoding'. Beware * that 0x80 is escaped. */ char_u *p1 = mp->m_keys; - char_u *p2 = mb_unescape(&p1); + char_u *p2 = (char_u *)mb_unescape((const char **)&p1); if (has_mbyte && p2 != NULL && MB_BYTE2LEN(c1) > MB_PTR2LEN(p2)) mlen = 0; @@ -4000,11 +4000,9 @@ int put_escstr(FILE *fd, char_u *strstart, int what) } for (; *str != NUL; ++str) { - char_u *p; - - /* Check for a multi-byte character, which may contain escaped - * K_SPECIAL and CSI bytes */ - p = mb_unescape(&str); + // Check for a multi-byte character, which may contain escaped + // K_SPECIAL and CSI bytes. + const char *p = mb_unescape((const char **)&str); if (p != NULL) { while (*p != NUL) if (fputc(*p++, fd) < 0) diff --git a/src/nvim/message.c b/src/nvim/message.c index 656f1adaf8..feb2fb214e 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1269,7 +1269,7 @@ msg_outtrans_special ( string = ""; str++; } else { - string = (const char *)str2special((char_u **)&str, from); + string = str2special((const char **)&str, from); } const int len = vim_strsize((char_u *)string); // Highlight special keys diff --git a/src/nvim/option.c b/src/nvim/option.c index b48ffae85b..bc101ba703 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -5175,9 +5175,12 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int e * CTRL-V or backslash */ if (valuep == &p_pt) { s = *valuep; - while (*s != NUL) - if (put_escstr(fd, str2special(&s, FALSE), 2) == FAIL) + while (*s != NUL) { + if (put_escstr(fd, (char_u *)str2special((const char **)&s, false), 2) + == FAIL) { return FAIL; + } + } } else if (expand) { buf = xmalloc(MAXPATHL); home_replace(NULL, *valuep, buf, MAXPATHL, FALSE); @@ -6173,15 +6176,16 @@ option_value2string ( } } else { // P_STRING varp = *(char_u **)(varp); - if (varp == NULL) /* just in case */ + if (varp == NULL) { // Just in case. NameBuff[0] = NUL; - else if (opp->flags & P_EXPAND) - home_replace(NULL, varp, NameBuff, MAXPATHL, FALSE); - /* Translate 'pastetoggle' into special key names */ - else if ((char_u **)opp->var == &p_pt) - str2specialbuf(p_pt, NameBuff, MAXPATHL); - else + } else if (opp->flags & P_EXPAND) { + home_replace(NULL, varp, NameBuff, MAXPATHL, false); + // Translate 'pastetoggle' into special key names. + } else if ((char_u **)opp->var == &p_pt) { + str2specialbuf((const char *)p_pt, (char *)NameBuff, MAXPATHL); + } else { STRLCPY(NameBuff, varp, MAXPATHL); + } } } -- cgit From df040e55fbd3edc5a36462af927a7194d079d0b8 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 19:01:09 +0300 Subject: eval/typval: Add tv_dict_add_allocated_str() function --- src/nvim/eval/typval.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 4521085519..c339a5cdd2 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1386,12 +1386,33 @@ int tv_dict_add_str(dict_T *const d, const char *const key, const size_t key_len, const char *const val) FUNC_ATTR_NONNULL_ALL +{ + return tv_dict_add_allocated_str(d, key, key_len, xstrdup(val)); +} + +/// Add a string entry to dictionary +/// +/// Unlike tv_dict_add_str() saves val to the new dictionary item in place of +/// creating a new copy. +/// +/// @warning String will be freed even in case addition fails. +/// +/// @param[out] d Dictionary to add entry to. +/// @param[in] key Key to add. +/// @param[in] key_len Key length. +/// @param[in] val String to add. +/// +/// @return OK in case of success, FAIL when key already exists. +int tv_dict_add_allocated_str(dict_T *const d, + const char *const key, const size_t key_len, + char *const val) + FUNC_ATTR_NONNULL_ALL { dictitem_T *const item = tv_dict_item_alloc_len(key, key_len); item->di_tv.v_lock = VAR_UNLOCKED; item->di_tv.v_type = VAR_STRING; - item->di_tv.vval.v_string = (char_u *)xstrdup(val); + item->di_tv.vval.v_string = (char_u *)val; if (tv_dict_add(d, item) == FAIL) { tv_dict_item_free(item); return FAIL; -- cgit From 85a6329a2b73924006eaccf8fd9ab59ec5c3ec46 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 19:02:15 +0300 Subject: eval: Use tv_dict_add_allocated_str() for mapblock_fill_dict --- src/nvim/eval.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index c4baf3f653..32ba514d27 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12170,7 +12170,7 @@ void mapblock_fill_dict(dict_T *const dict, noremap_value = mp->m_noremap == REMAP_SCRIPT ? 2 : !!mp->m_noremap; } - tv_dict_add_str(dict, S_LEN("lhs"), lhs); + tv_dict_add_allocated_str(dict, S_LEN("lhs"), lhs); tv_dict_add_str(dict, S_LEN("rhs"), (const char *)mp->m_orig_str); tv_dict_add_nr(dict, S_LEN("noremap"), noremap_value); tv_dict_add_nr(dict, S_LEN("expr"), mp->m_expr ? 1 : 0); @@ -12178,10 +12178,7 @@ void mapblock_fill_dict(dict_T *const dict, tv_dict_add_nr(dict, S_LEN("sid"), (varnumber_T)mp->m_script_ID); tv_dict_add_nr(dict, S_LEN("buffer"), (varnumber_T)buffer_value); tv_dict_add_nr(dict, S_LEN("nowait"), mp->m_nowait ? 1 : 0); - tv_dict_add_str(dict, S_LEN("mode"), mapmode); - - xfree(lhs); - xfree(mapmode); + tv_dict_add_allocated_str(dict, S_LEN("mode"), mapmode); } /* -- cgit From 936c070059f8c60085fa83fa7ea2ee4797d69f7b Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 19:15:14 +0300 Subject: eval: Make nvim_get_keymap output more robust --- src/nvim/eval.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 32ba514d27..8ea0969dd5 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12156,7 +12156,8 @@ void mapblock_fill_dict(dict_T *const dict, bool compatible) FUNC_ATTR_NONNULL_ALL { - char *const lhs = str2special_save((const char *)mp->m_keys, true); + char *const lhs = str2special_save((const char *)mp->m_keys, + compatible ? true : false); char *const mapmode = map_mode_to_chars(mp->m_mode); varnumber_T noremap_value; @@ -12170,8 +12171,13 @@ void mapblock_fill_dict(dict_T *const dict, noremap_value = mp->m_noremap == REMAP_SCRIPT ? 2 : !!mp->m_noremap; } + if (compatible) { + tv_dict_add_str(dict, S_LEN("rhs"), (const char *)mp->m_orig_str); + } else { + tv_dict_add_allocated_str(dict, S_LEN("rhs"), + str2special_save((const char *)mp->m_str, false)); + } tv_dict_add_allocated_str(dict, S_LEN("lhs"), lhs); - tv_dict_add_str(dict, S_LEN("rhs"), (const char *)mp->m_orig_str); tv_dict_add_nr(dict, S_LEN("noremap"), noremap_value); tv_dict_add_nr(dict, S_LEN("expr"), mp->m_expr ? 1 : 0); tv_dict_add_nr(dict, S_LEN("silent"), mp->m_silent ? 1 : 0); -- cgit From 24f0056ca5cb392f1e1bf38d648a6037acf1f1ef Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 19:37:21 +0300 Subject: message: Add support for replacing `<` to str2special --- src/nvim/eval.c | 7 ++++--- src/nvim/message.c | 21 ++++++++++++++------- src/nvim/option.c | 3 ++- 3 files changed, 20 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 8ea0969dd5..662270e788 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12120,7 +12120,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) // Return a string. if (rhs != NULL) { rettv->vval.v_string = (char_u *)str2special_save( - (const char *)rhs, false); + (const char *)rhs, false, false); } } else { @@ -12157,7 +12157,7 @@ void mapblock_fill_dict(dict_T *const dict, FUNC_ATTR_NONNULL_ALL { char *const lhs = str2special_save((const char *)mp->m_keys, - compatible ? true : false); + compatible, !compatible); char *const mapmode = map_mode_to_chars(mp->m_mode); varnumber_T noremap_value; @@ -12175,7 +12175,8 @@ void mapblock_fill_dict(dict_T *const dict, tv_dict_add_str(dict, S_LEN("rhs"), (const char *)mp->m_orig_str); } else { tv_dict_add_allocated_str(dict, S_LEN("rhs"), - str2special_save((const char *)mp->m_str, false)); + str2special_save((const char *)mp->m_str, false, + true)); } tv_dict_add_allocated_str(dict, S_LEN("lhs"), lhs); tv_dict_add_nr(dict, S_LEN("noremap"), noremap_value); diff --git a/src/nvim/message.c b/src/nvim/message.c index feb2fb214e..8a9d8e1bc6 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1269,7 +1269,7 @@ msg_outtrans_special ( string = ""; str++; } else { - string = str2special((const char **)&str, from); + string = str2special((const char **)&str, from, false); } const int len = vim_strsize((char_u *)string); // Highlight special keys @@ -1286,11 +1286,13 @@ msg_outtrans_special ( /// Used for lhs or rhs of mappings. /// /// @param[in] str String to convert. -/// @param[in] replace_spaces Convert spaces into , normally used for +/// @param[in] replace_spaces Convert spaces into ``, normally used fo /// lhs, but not rhs. +/// @param[in] replace_lt Convert `<` into ``. /// /// @return [allocated] Converted string. -char *str2special_save(const char *const str, const bool replace_spaces) +char *str2special_save(const char *const str, const bool replace_spaces, + const bool replace_lt) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_RET { @@ -1299,7 +1301,7 @@ char *str2special_save(const char *const str, const bool replace_spaces) const char *p = str; while (*p != NUL) { - ga_concat(&ga, (const char_u *)str2special(&p, replace_spaces)); + ga_concat(&ga, (const char_u *)str2special(&p, replace_spaces, replace_lt)); } ga_append(&ga, NUL); return (char *)ga.ga_data; @@ -1310,11 +1312,13 @@ char *str2special_save(const char *const str, const bool replace_spaces) /// @param[in,out] sp String to convert. Is advanced to the next key code. /// @param[in] replace_spaces Convert spaces into , normally used for /// lhs, but not rhs. +/// @param[in] replace_lt Convert `<` into ``. /// /// @return Converted key code, in a static buffer. Buffer is always one and the /// same, so save converted string somewhere before running str2special /// for the second time. -const char *str2special(const char **const sp, const bool replace_spaces) +const char *str2special(const char **const sp, const bool replace_spaces, + const bool replace_lt) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET { static char buf[7]; @@ -1366,7 +1370,10 @@ const char *str2special(const char **const sp, const bool replace_spaces) } // Make unprintable characters in <> form, also and . - if (special || char2cells(c) > 1 || (replace_spaces && c == ' ')) { + if (special + || char2cells(c) > 1 + || (replace_spaces && c == ' ') + || (replace_lt && c == '<')) { return (const char *)get_special_key_name(c, modifiers); } buf[0] = c; @@ -1383,7 +1390,7 @@ void str2specialbuf(const char *sp, char *buf, size_t len) FUNC_ATTR_NONNULL_ALL { while (*sp) { - const char *s = str2special(&sp, false); + const char *s = str2special(&sp, false, false); const size_t s_len = strlen(s); if (s_len <= len) { break; diff --git a/src/nvim/option.c b/src/nvim/option.c index bc101ba703..7287db6eb8 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -5176,7 +5176,8 @@ static int put_setstring(FILE *fd, char *cmd, char *name, char_u **valuep, int e if (valuep == &p_pt) { s = *valuep; while (*s != NUL) { - if (put_escstr(fd, (char_u *)str2special((const char **)&s, false), 2) + if (put_escstr(fd, (char_u *)str2special((const char **)&s, false, + false), 2) == FAIL) { return FAIL; } -- cgit From b97df0bdad63ba5da87982ea74ca171854e65dee Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 2 Jul 2017 19:52:04 +0300 Subject: getchar: Fix linter error --- src/nvim/getchar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 1d1af69c94..fc1b8ccfcb 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -3999,7 +3999,7 @@ int put_escstr(FILE *fd, char_u *strstart, int what) return OK; } - for (; *str != NUL; ++str) { + for (; *str != NUL; str++) { // Check for a multi-byte character, which may contain escaped // K_SPECIAL and CSI bytes. const char *p = mb_unescape((const char **)&str); -- cgit From e333957a1a9ae64b7daa36e08fd1df583114d4ba Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Mon, 3 Jul 2017 23:03:30 +0200 Subject: dict_get_value(): name the missing key (#6952) --- src/nvim/api/private/helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index d401ae52a0..1ed2bc013e 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -95,7 +95,7 @@ Object dict_get_value(dict_T *dict, String key, Error *err) dictitem_T *const di = tv_dict_find(dict, key.data, (ptrdiff_t)key.size); if (di == NULL) { - api_set_error(err, kErrorTypeValidation, "Key not found"); + api_set_error(err, kErrorTypeValidation, "Key '%s' not found", key.data); return (Object)OBJECT_INIT; } -- cgit From e07e46f53921aa75bc826290098491e4b5622448 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 02:06:40 +0300 Subject: message: Fix `:echo "\x80"` printing `~@<80>` --- src/nvim/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/message.c b/src/nvim/message.c index 8a9d8e1bc6..36f9ca84ed 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1196,7 +1196,7 @@ int msg_outtrans_len_attr(char_u *msgstr, int len, int attr) len -= mb_l - 1; str += mb_l; } else { - s = transchar_byte(*str); + s = transchar_byte((uint8_t)(*str)); if (s[1] != NUL) { // Unprintable char: print the printable chars so far and the // translation of the unprintable char. -- cgit From 91b9ad7d8294532939db51db1045605abfff49c2 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 15:41:59 +0300 Subject: shada: Make sure that code does not attempt to read too long items Fixes #6957 --- src/nvim/shada.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 4788b1e7d0..728a3f65be 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -3413,7 +3413,15 @@ shada_read_next_item_start: return mru_ret; } - const size_t length = (size_t) length_u64; + if (length_u64 > PTRDIFF_MAX) { + emsgf(_(RCERR "Error while reading ShaDa file: " + "there is an item at position %" PRIu64 " " + "that is stated to be too long"), + initial_fpos); + return kSDReadStatusNotShaDa; + } + + const size_t length = (size_t)length_u64; entry->timestamp = (Timestamp) timestamp_u64; if (type_u64 == 0) { -- cgit From 2e89aaf3bdec8329537b290af1bd02de470929be Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 16:08:52 +0300 Subject: charset: Fix V728: excessive check --- src/nvim/charset.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 48db1030a6..403ef65c4f 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -981,10 +981,8 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he mb_ptr_adv(s); c = *s; - if (!((c != NUL) - && (vim_isbreak(c) - || (!vim_isbreak(c) - && ((col2 == col) || !vim_isbreak(*ps)))))) { + if (!(c != NUL + && (vim_isbreak(c) || col2 == col || !vim_isbreak(*ps)))) { break; } -- cgit From c930f32ab94c7d4e4a037ebb15006753dc3fa5e5 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 16:21:17 +0300 Subject: socket: Silence V641: buf size is not multiple of what it is cast to --- src/nvim/event/socket.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/event/socket.c b/src/nvim/event/socket.c index a796f303ab..6f45b09fce 100644 --- a/src/nvim/event/socket.c +++ b/src/nvim/event/socket.c @@ -105,9 +105,10 @@ int socket_watcher_start(SocketWatcher *watcher, int backlog, socket_cb cb) // contain 0 in this case, unless uv_tcp_getsockname() is used first. uv_tcp_getsockname(&watcher->uv.tcp.handle, (struct sockaddr *)&sas, &(int){ sizeof(sas) }); - uint16_t port = (uint16_t)((sas.ss_family == AF_INET) - ? ((struct sockaddr_in *)&sas)->sin_port - : ((struct sockaddr_in6 *)&sas)->sin6_port); + uint16_t port = (uint16_t)( + (sas.ss_family == AF_INET) + ? (STRUCT_CAST(struct sockaddr_in, &sas))->sin_port + : (STRUCT_CAST(struct sockaddr_in6, &sas))->sin6_port); // v:servername uses the string from watcher->addr size_t len = strlen(watcher->addr); snprintf(watcher->addr+len, sizeof(watcher->addr)-len, ":%" PRIu16, @@ -247,7 +248,7 @@ tcp_retry: uv_pipe_t *pipe = &stream->uv.pipe; uv_pipe_init(&loop->uv, pipe, 0); uv_pipe_connect(&req, pipe, address, connect_cb); - uv_stream = (uv_stream_t *)pipe; + uv_stream = STRUCT_CAST(uv_stream_t, pipe); } status = 1; LOOP_PROCESS_EVENTS_UNTIL(&main_loop, NULL, timeout, status != 1); -- cgit From 1f05ec95c04f7fd300ce3696b40f09e057d4fb06 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 16:24:48 +0300 Subject: ex_getln: Silent V519: value is assigned twice successively MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is usual “passing data via global†false positive. --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 7793081957..0ba6c79a71 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -306,7 +306,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) curwin->w_cursor = s->save_cursor; setpcmark(); } - curwin->w_cursor = s->search_start; + curwin->w_cursor = s->search_start; // -V519 } curwin->w_curswant = s->old_curswant; curwin->w_leftcol = s->old_leftcol; -- cgit From 63f72ac27c54d63fee049e45a5518d2d07fd379b Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 17:47:45 +0300 Subject: shada: Fix linter error --- src/nvim/shada.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 728a3f65be..736d6bf162 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -3422,7 +3422,7 @@ shada_read_next_item_start: } const size_t length = (size_t)length_u64; - entry->timestamp = (Timestamp) timestamp_u64; + entry->timestamp = (Timestamp)timestamp_u64; if (type_u64 == 0) { // kSDItemUnknown cannot possibly pass that far because it is -1 and that -- cgit From 94bd0f9915b0515fde449e3ee003ecbff3ad1b42 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 16:47:07 +0300 Subject: main: Fix V522: potential NULL dereference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is useless to use sbuffer here and print that to stdout, just using “fbuffer†instead. --- src/nvim/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index 19a661d7db..5c0cda978f 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -766,16 +766,18 @@ static void command_line_scan(mparm_T *parmp) version(); mch_exit(0); } else if (STRICMP(argv[0] + argv_idx, "api-info") == 0) { - msgpack_sbuffer* b = msgpack_sbuffer_new(); - msgpack_packer* p = msgpack_packer_new(b, msgpack_sbuffer_write); - Object md = DICTIONARY_OBJ(api_metadata()); - msgpack_rpc_from_object(md, p); + msgpack_packer *p = msgpack_packer_new(stdout, + msgpack_fbuffer_write); - for (size_t i = 0; i < b->size; i++) { - putchar(b->data[i]); + if (p == NULL) { + emsgf(_(e_outofmem)); } + Object md = DICTIONARY_OBJ(api_metadata()); + msgpack_rpc_from_object(md, p); + msgpack_packer_free(p); + file_close(&fp, false); mch_exit(0); } else if (STRICMP(argv[0] + argv_idx, "headless") == 0) { parmp->headless = true; -- cgit From 5ab9e9f617934fae8f85ceb6db398dbf1e93471d Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 17:03:07 +0300 Subject: os/fileio: Add msgpack_file_write function --- src/nvim/os/fileio.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src') diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index 4309ac723c..d16746b7bf 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -26,6 +26,7 @@ #include "nvim/globals.h" #include "nvim/rbuffer.h" #include "nvim/macros.h" +#include "nvim/message.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/fileio.c.generated.h" @@ -345,3 +346,23 @@ ptrdiff_t file_skip(FileDescriptor *const fp, const size_t size) return (ptrdiff_t)read_bytes; } + +/// Msgpack callback for writing to a file +/// +/// @param data File to write to. +/// @param[in] buf Data to write. +/// @param[in] len Length of the data to write. +/// +/// @return 0 in case of success, -1 in case of error. +int msgpack_file_write(void *data, const char *buf, size_t len) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT +{ + assert(len < PTRDIFF_MAX); + const ptrdiff_t written_bytes = file_write((FileDescriptor *)data, buf, len); + if (written_bytes < 0) { + emsgf(_("E5420: Failed to write to file: %s"), + os_strerror((int)written_bytes)); + return -1; + } + return 0; +} -- cgit From 72b3fd96642e7b2c268e17953de3b2ed995eb3b4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 17:08:43 +0300 Subject: os/fileio: Add ability to use os/fileio.c for file descriptors Code imported from #6299 --- src/nvim/os/fileio.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index d16746b7bf..0ed0ae87e3 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -49,7 +49,6 @@ int file_open(FileDescriptor *const ret_fp, const char *const fname, FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { int os_open_flags = 0; - int fd; TriState wr = kNone; // -V:FLAG:501 #define FLAG(flags, flag, fcntl_flags, wrval, cond) \ @@ -74,14 +73,35 @@ int file_open(FileDescriptor *const ret_fp, const char *const fname, FLAG(flags, kFileNoSymlink, O_NOFOLLOW, kNone, true); #endif #undef FLAG + // wr is used for kFileReadOnly flag, but on + // QB:neovim-qb-slave-ubuntu-12-04-64bit it still errors out with + // `error: variable ‘wr’ set but not used [-Werror=unused-but-set-variable]` + (void)wr; - fd = os_open(fname, os_open_flags, mode); + const int fd = os_open(fname, os_open_flags, mode); if (fd < 0) { return fd; } + return file_open_fd(ret_fp, fd, (wr == kTrue)); +} - ret_fp->wr = (wr == kTrue); +/// Wrap file descriptor with FileDescriptor structure +/// +/// @warning File descriptor wrapped like this must not be accessed by other +/// means. +/// +/// @param[out] ret_fp Address where information needed for reading from or +/// writing to a file is saved +/// @param[in] fd File descriptor to wrap. +/// @param[in] wr True if fd is opened for writing only, false if it is read +/// only. +/// +/// @return Error code (@see os_strerror()) or 0. Currently always returns 0. +int file_open_fd(FileDescriptor *const ret_fp, const int fd, const bool wr) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT +{ + ret_fp->wr = wr; ret_fp->fd = fd; ret_fp->eof = false; ret_fp->rv = rbuffer_new(kRWBufferSize); @@ -115,6 +135,26 @@ FileDescriptor *file_open_new(int *const error, const char *const fname, return fp; } +/// Like file_open_fd(), but allocate and return ret_fp +/// +/// @param[out] error Error code, @see os_strerror(). Is set to zero on +/// success. +/// @param[in] fd File descriptor to wrap. +/// @param[in] wr True if fd is opened for writing only, false if it is read +/// only. +/// +/// @return [allocated] Opened file or NULL in case of error. +FileDescriptor *file_open_fd_new(int *const error, const int fd, const bool wr) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESULT +{ + FileDescriptor *const fp = xmalloc(sizeof(*fp)); + if ((*error = file_open_fd(fp, fd, wr)) != 0) { + xfree(fp); + return NULL; + } + return fp; +} + /// Close file and free its buffer /// /// @param[in,out] fp File to close. -- cgit From f0b3029ad33cbba284c4e677a08b0e2488bf062b Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 17:12:00 +0300 Subject: os: Add OS_STD*_FILENO constants --- src/nvim/os/os_defs.h | 7 +++++++ src/nvim/os/win_defs.h | 10 ++++++++++ 2 files changed, 17 insertions(+) (limited to 'src') diff --git a/src/nvim/os/os_defs.h b/src/nvim/os/os_defs.h index f81785675e..923a362b41 100644 --- a/src/nvim/os/os_defs.h +++ b/src/nvim/os/os_defs.h @@ -13,6 +13,13 @@ # include "nvim/os/unix_defs.h" #endif +/// File descriptor number used for standard IO streams +enum { + OS_STDIN_FILENO = STDIN_FILENO, + OS_STDOUT_FILENO = STDOUT_FILENO, + OS_STDERR_FILENO = STDERR_FILENO, +}; + #define BASENAMELEN (NAME_MAX - 5) // Use the system path length if it makes sense. diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h index 7c980c3768..7ed70f6092 100644 --- a/src/nvim/os/win_defs.h +++ b/src/nvim/os/win_defs.h @@ -91,4 +91,14 @@ typedef SSIZE_T ssize_t; # define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) #endif +#ifndef STDIN_FILENO +# define STDIN_FILENO 0 +#endif +#ifndef STDOUT_FILENO +# define STDOUT_FILENO 1 +#endif +#ifndef STDERR_FILENO +# define STDERR_FILENO 2 +#endif + #endif // NVIM_OS_WIN_DEFS_H -- cgit From 605c8fb49cac3d9e8b3621fd4dfe55b882b85247 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 17:20:00 +0300 Subject: main: Use msgpack_file_write in place of “fbuffer†MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently the latter is not a part of the public C API. --- src/nvim/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index 5c0cda978f..f55f876608 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -57,6 +57,7 @@ #include "nvim/os/input.h" #include "nvim/os/os.h" #include "nvim/os/time.h" +#include "nvim/os/fileio.h" #include "nvim/event/loop.h" #include "nvim/os/signal.h" #include "nvim/event/process.h" @@ -766,8 +767,13 @@ static void command_line_scan(mparm_T *parmp) version(); mch_exit(0); } else if (STRICMP(argv[0] + argv_idx, "api-info") == 0) { - msgpack_packer *p = msgpack_packer_new(stdout, - msgpack_fbuffer_write); + FileDescriptor fp; + const int fof_ret = file_open_fd(&fp, OS_STDOUT_FILENO, true); + msgpack_packer *p = msgpack_packer_new(&fp, msgpack_file_write); + + if (fof_ret != 0) { + emsgf(_("E5421: Failed to open stdin: %s"), os_strerror(fof_ret)); + } if (p == NULL) { emsgf(_(e_outofmem)); -- cgit From 6552768c4faa1fcc81be49859815966123476e04 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 17:26:08 +0300 Subject: normal: Fix V728: excessive check --- src/nvim/normal.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 39cd2c6631..d891c74fd2 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1451,9 +1451,8 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) /* Never redo "zf" (define fold). */ if ((vim_strchr(p_cpo, CPO_YANK) != NULL || oap->op_type != OP_YANK) && ((!VIsual_active || oap->motion_force) - /* Also redo Operator-pending Visual mode mappings */ - || (VIsual_active && cap->cmdchar == ':' - && oap->op_type != OP_COLON)) + // Also redo Operator-pending Visual mode mappings. + || (cap->cmdchar == ':' && oap->op_type != OP_COLON)) && cap->cmdchar != 'D' && oap->op_type != OP_FOLD && oap->op_type != OP_FOLDOPEN -- cgit From f81d1ce003010892859898ec0436f81a883d4f3c Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 17:28:33 +0300 Subject: regexp: Silence V595: potential null dereference The code uses 2-iteration loop antipattern: retval is NULL on first iteration, not NULL on second, yet this is still a false positive. --- src/nvim/regexp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 5448cc7131..41070aebf4 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -6928,9 +6928,10 @@ char_u *reg_submatch(int no) STRNCPY(retval + len, reg_getline_submatch(lnum), submatch_mmatch->endpos[no].col); len += submatch_mmatch->endpos[no].col; - if (round == 2) - retval[len] = NUL; - ++len; + if (round == 2) { + retval[len] = NUL; // -V595 + } + len++; } if (retval == NULL) { -- cgit From 4cb63179008efbbef2f4134da448ae5bd7251281 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 17:29:57 +0300 Subject: spell: Fix V728: excessive check --- src/nvim/spell.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 25ae562e65..5785ee1a00 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1433,12 +1433,10 @@ spell_move_to ( // the cursor. if (dir == BACKWARD || lnum != wp->w_cursor.lnum - || (lnum == wp->w_cursor.lnum - && (wrapped - || ((colnr_T)(curline - ? p - buf + (ptrdiff_t)len - : p - buf) - > wp->w_cursor.col)))) { + || wrapped + || ((colnr_T)(curline + ? p - buf + (ptrdiff_t)len + : p - buf) > wp->w_cursor.col)) { if (has_syntax) { col = (int)(p - buf); (void)syn_get_id(wp, lnum, (colnr_T)col, -- cgit From aaab5e39005ab5a1273092ae4cef7f1a27a5097a Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 17:31:45 +0300 Subject: spell: Silence V512: buffer underflow --- src/nvim/spell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 5785ee1a00..715228cb4b 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -3633,7 +3633,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so // word). depth = 0; sp = &stack[0]; - memset(sp, 0, sizeof(trystate_T)); + memset(sp, 0, sizeof(trystate_T)); // -V512 sp->ts_curi = 1; if (soundfold) { -- cgit From af1f17f1dcd68ce75cfe06a0ebcb3b34d85f98bf Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 17:39:26 +0300 Subject: syntax: Fix V763: parameter always rewritten before being used This is the result of malloc error handling elimination: push_current_state() used to (not) return OK depending on whether growing garray failed or not and this return was checked, if errorred out push_next_match() will simply return its argument unchanged. Now when allocations are supposed to either always succeed or crash Neovim this check was returned, push_current_state() was stripped of its return value and moved out of if() condition, resulting in V763. --- src/nvim/syntax.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index a4bb260183..f0171fa525 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -1666,8 +1666,9 @@ syn_current_attr ( * If we found a match after the last column, use it. */ if (next_match_idx >= 0 && next_match_col >= (int)current_col - && next_match_col != MAXCOL) - (void)push_next_match(NULL); + && next_match_col != MAXCOL) { + (void)push_next_match(); + } current_finished = TRUE; current_state_stored = FALSE; @@ -1985,9 +1986,10 @@ syn_current_attr ( * endless loop). */ GA_APPEND(int, &zero_width_next_ga, next_match_idx); next_match_idx = -1; - } else - cur_si = push_next_match(cur_si); - found_match = TRUE; + } else { + cur_si = push_next_match(); + } + found_match = true; } } } @@ -2167,9 +2169,10 @@ static int did_match_already(int idx, garray_T *gap) /* * Push the next match onto the stack. */ -static stateitem_T *push_next_match(stateitem_T *cur_si) +static stateitem_T *push_next_match(void) { - synpat_T *spp; + stateitem_T *cur_si; + synpat_T *spp; int save_flags; spp = &(SYN_ITEMS(syn_block)[next_match_idx]); -- cgit From 28f6bd822b26ae92701ca553d29693d35864753f Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 17:42:10 +0300 Subject: terminal: Silence -V666 error: value not correspond with string length Looks like calling this function below with 4-character first strings made PVS think that OPT_LOCAL (it is equal to 4) is a string length. --- src/nvim/terminal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 1882f263db..099f49f09b 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -229,7 +229,7 @@ Terminal *terminal_open(TerminalOptions opts) rv->invalid_start = 0; rv->invalid_end = opts.height; refresh_screen(rv, curbuf); - set_option_value("buftype", 0, "terminal", OPT_LOCAL); + set_option_value("buftype", 0, "terminal", OPT_LOCAL); // -V666 // Default settings for terminal buffers curbuf->b_p_ma = false; // 'nomodifiable' -- cgit From 7109f63e3cf70ffc4581f3dfb6132632413e4817 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 19:48:26 +0300 Subject: main: Flush file in place of closing it, also do error reporting Apparently on travis OS X systems it crashes when cleaning up streams with stdout closed: (lldb) bt all * thread #1: tid = 0x0000, 0x00007fff8703df06 libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGSTOP * frame #0: 0x00007fff8703df06 libsystem_kernel.dylib`__pthread_kill + 10 frame #1: 0x00007fff93a764ec libsystem_pthread.dylib`pthread_kill + 90 frame #2: 0x00007fff97c056df libsystem_c.dylib`abort + 129 frame #3: 0x00007fff97bccdd8 libsystem_c.dylib`__assert_rtn + 321 frame #4: 0x0000000107a4e106 nvim`uv__close(fd=) + 102 at core.c:521 frame #5: 0x0000000107a5307d nvim`uv__loop_close(loop=0x00007fff5847c018) + 77 at loop.c:118 frame #6: 0x0000000107a4d149 nvim`uv_loop_close(loop=0x00007fff5847c018) + 57 at uv-common.c:626 frame #7: 0x000000010783e5bc nvim`stream_set_blocking(fd=0, blocking=true) + 204 at stream.c:34 frame #8: 0x000000010795d66b nvim`mch_exit(r=0) + 91 at os_unix.c:147 frame #9: 0x00000001078d5663 nvim`command_line_scan(parmp=0x00007fff5847c760) + 1779 at main.c:787 frame #10: 0x00000001078d4393 nvim`main(argc=2, argv=0x00007fff5847c898) + 163 at main.c:249 frame #11: 0x00007fff8cdd65ad libdyld.dylib`start + 1 frame #12: 0x00007fff8cdd65ad libdyld.dylib`start + 1 --- src/nvim/main.c | 5 ++++- src/nvim/os/fileio.c | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index f55f876608..7dcf00c26b 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -783,7 +783,10 @@ static void command_line_scan(mparm_T *parmp) msgpack_rpc_from_object(md, p); msgpack_packer_free(p); - file_close(&fp, false); + const int ff_ret = file_flush(&fp); + if (ff_ret < 0) { + msgpack_file_write_error(ff_ret); + } mch_exit(0); } else if (STRICMP(argv[0] + argv_idx, "headless") == 0) { parmp->headless = true; diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index 0ed0ae87e3..5d68473982 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -400,9 +400,18 @@ int msgpack_file_write(void *data, const char *buf, size_t len) assert(len < PTRDIFF_MAX); const ptrdiff_t written_bytes = file_write((FileDescriptor *)data, buf, len); if (written_bytes < 0) { - emsgf(_("E5420: Failed to write to file: %s"), - os_strerror((int)written_bytes)); - return -1; + return msgpack_file_write_error((int)written_bytes); } return 0; } + +/// Print error which occurs when failing to write msgpack data +/// +/// @param[in] error Error code of the error to print. +/// +/// @return -1 (error return for msgpack_packer callbacks). +int msgpack_file_write_error(const int error) +{ + emsgf(_("E5420: Failed to write to file: %s"), os_strerror(error)); + return -1; +} -- cgit From ce30998221a53e208a6a68b4b0a3f76db9a5eac3 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 4 Jul 2017 20:05:32 +0300 Subject: bufhl_defs: Silence V512: buffer underflow --- src/nvim/bufhl_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/bufhl_defs.h b/src/nvim/bufhl_defs.h index 24bd6b7f29..14b1afa7d9 100644 --- a/src/nvim/bufhl_defs.h +++ b/src/nvim/bufhl_defs.h @@ -29,6 +29,6 @@ typedef struct { } BufhlLineInfo; #define BUFHL_CMP(a, b) ((int)(((a)->line - (b)->line))) -KBTREE_INIT(bufhl, BufhlLine *, BUFHL_CMP, 10) +KBTREE_INIT(bufhl, BufhlLine *, BUFHL_CMP, 10) // -V512 typedef kbtree_t(bufhl) BufhlInfo; #endif // NVIM_BUFHL_DEFS_H -- cgit From e4dc878f8930e4c41f1ef4fc59fea567d98b76b1 Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Mon, 3 Apr 2017 17:00:47 +0100 Subject: options: Default to 'ttimeout' and 'ttimeoutlen=50' This gives libtermkey 50msec to reassemble split multibyte sequences like DCSes. --- src/nvim/options.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/options.lua b/src/nvim/options.lua index c2778a6329..103227f6b5 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -2513,14 +2513,14 @@ return { vi_def=true, vim=true, varname='p_ttimeout', - defaults={if_true={vi=false}} + defaults={if_true={vi=true}} }, { full_name='ttimeoutlen', abbreviation='ttm', type='number', scope={'global'}, vi_def=true, varname='p_ttm', - defaults={if_true={vi=-1}} + defaults={if_true={vi=50}} }, { full_name='ttyfast', abbreviation='tf', -- cgit From de8a9f6c338b5264d5204e7ce47eb6972eb1e783 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Thu, 15 Jun 2017 20:23:52 +0100 Subject: tui: Coding style changes only Per warnings about house style from automated tools. --- src/nvim/tui/tui.c | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index a85f119ef4..7616299a19 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -55,7 +55,9 @@ // separator. bool terminfo_is_term_family(const char *term, const char *family) { - if (!term) return false; + if (!term) { + return false; + } size_t tlen = strlen(term); size_t flen = strlen(family); return tlen >= flen @@ -158,7 +160,8 @@ UI *tui_start(void) return ui_bridge_attach(ui, tui_main, tui_scheduler); } -static size_t unibi_pre_fmt_str(TUIData *data, unsigned int unibi_index, char * buf, size_t len) +static size_t unibi_pre_fmt_str(TUIData *data, unsigned int unibi_index, + char * buf, size_t len) { const char *str = unibi_get_str(data->ut, unibi_index); if (!str) { @@ -218,8 +221,10 @@ static void terminfo_start(UI *ui) data->immediate_wrap_after_last_column = terminfo_is_term_family(term, "cygwin") || terminfo_is_term_family(term, "interix"); - data->normlen = unibi_pre_fmt_str(data, unibi_cursor_normal, data->norm, sizeof data->norm); - data->invislen = unibi_pre_fmt_str(data, unibi_cursor_invisible, data->invis, sizeof data->invis); + data->normlen = unibi_pre_fmt_str(data, unibi_cursor_normal, + data->norm, sizeof data->norm); + data->invislen = unibi_pre_fmt_str(data, unibi_cursor_invisible, + data->invis, sizeof data->invis); // Set 't_Co' from the result of unibilium & fix_terminfo. t_colors = unibi_get_num(data->ut, unibi_max_colors); // Enter alternate screen and clear @@ -630,7 +635,7 @@ static void clear_region(UI *ui, int top, int bot, int left, int right) if (!cleared) { // iterate through each line and clear with clr_eol - for (int row = top; row <= bot; ++row) { + for (int row = top; row <= bot; row++) { cursor_goto(ui, row, left); unibi_out(ui, unibi_clr_eol); } @@ -1219,7 +1224,7 @@ static void unibi_set_if_empty(unibi_term *ut, enum unibi_string str, static int unibi_find_ext_str(unibi_term *ut, const char *name) { size_t max = unibi_count_ext_str(ut); - for (size_t i = 0; i < max; ++i) { + for (size_t i = 0; i < max; i++) { const char * n = unibi_get_ext_str_name(ut, i); if (n && 0 == strcmp(n, name)) { return (int)i; @@ -1229,9 +1234,9 @@ static int unibi_find_ext_str(unibi_term *ut, const char *name) } static int unibi_find_ext_bool(unibi_term *ut, const char *name) - { +{ size_t max = unibi_count_ext_bool(ut); - for (size_t i = 0; i < max; ++i) { + for (size_t i = 0; i < max; i++) { const char * n = unibi_get_ext_bool_name(ut, i); if (n && 0 == strcmp(n, name)) { return (int)i; @@ -1287,7 +1292,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } if (linuxvt && strlen(fix_normal) >= (sizeof LINUXSET0C - 1) - && !memcmp(strchr(fix_normal,0) - (sizeof LINUXSET0C - 1), LINUXSET0C, sizeof LINUXSET0C - 1)) { + && !memcmp(strchr(fix_normal, 0) - (sizeof LINUXSET0C - 1), + LINUXSET0C, sizeof LINUXSET0C - 1)) { // The Linux terminfo entry similarly includes a Linux-idiosyncractic // cursor shape reset in cnorm, which similarly interferes with // set_cursor_style. @@ -1298,7 +1304,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, if (fix_invisible) { if (linuxvt && strlen(fix_invisible) >= (sizeof LINUXSET1C - 1) - && !memcmp(strchr(fix_invisible,0) - (sizeof LINUXSET1C - 1), LINUXSET1C, sizeof LINUXSET1C - 1)) { + && !memcmp(strchr(fix_invisible, 0) - (sizeof LINUXSET1C - 1), + LINUXSET1C, sizeof LINUXSET1C - 1)) { // The Linux terminfo entry similarly includes a Linux-idiosyncractic // cursor shape reset in cinvis, which similarly interferes with // set_cursor_style. @@ -1401,7 +1408,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_num(ut, unibi_max_colors, 256); unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); - } else if (konsole || xterm || gnome || rxvt || st || putty + } else + if (konsole || xterm || gnome || rxvt || st || putty || linuxvt // Linux 4.8+ supports 256-colour SGR. || mate_pretending_xterm || gnome_pretending_xterm || tmux || tmux_pretending_screen @@ -1450,8 +1458,10 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", ""); } - unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[ q"); - } else if (putty // per MinTTY 0.4.3-1 release notes from 2009 + unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, + "\x1b[ q"); + } else + if (putty // per MinTTY 0.4.3-1 release notes from 2009 // per https://bugzilla.gnome.org/show_bug.cgi?id=720821 || (vte_version >= 3900) // per tmux manual page and per @@ -1468,7 +1478,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", ""); } - unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[ q"); + unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, + "\x1b[ q"); } else if (linuxvt) { // Linux uses an idiosyncratic escape code to set the cursor shape and does // not support DECSCUSR. @@ -1490,7 +1501,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", ""); } - unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[?c"); + unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, + "\x1b[?c"); } else if (konsole) { // Konsole uses an idiosyncratic escape code to set the cursor shape and // does not support DECSCUSR. This makes Konsole set up and apply a @@ -1660,7 +1672,8 @@ static void flush_buf(UI *ui, bool toggle_cursor) data->is_invisible = data->busy; } - uv_write(&req, STRUCT_CAST(uv_stream_t, &data->output_handle), bufs, (unsigned)(bufp - bufs), NULL); + uv_write(&req, STRUCT_CAST(uv_stream_t, &data->output_handle), + bufs, (unsigned)(bufp - bufs), NULL); uv_run(&data->write_loop, UV_RUN_DEFAULT); data->bufpos = 0; } -- cgit From 5701165f06104c341dce9f19ba8437676139892b Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Fri, 16 Jun 2017 15:04:39 +0100 Subject: tui: Switch terminal keyboard mode properly. The terminfo doco explicitly states that it covers the case where the terminal is in application cursor/keypad (i.e. "keypad transmit") mode, and not where it is in normal cursor/keypad (i.e. "keypad local") mode. Full screen applications like nvim must switch to and from keypad transmit mode when expecting the control sequences given by terminfo. --- src/nvim/tui/tui.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 7616299a19..61fe1bb361 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -230,6 +230,7 @@ static void terminfo_start(UI *ui) // Enter alternate screen and clear // NOTE: Do this *before* changing terminal settings. #6433 unibi_out(ui, unibi_enter_ca_mode); + unibi_out(ui, unibi_keypad_xmit); unibi_out(ui, unibi_clear_screen); // Enable bracketed paste unibi_out(ui, data->unibi_ext.enable_bracketed_paste); @@ -258,6 +259,7 @@ static void terminfo_stop(UI *ui) unibi_out(ui, unibi_exit_attribute_mode); // cursor should be set to normal before exiting alternate screen unibi_out(ui, unibi_cursor_normal); + unibi_out(ui, unibi_keypad_local); unibi_out(ui, unibi_exit_ca_mode); // Disable bracketed paste unibi_out(ui, data->unibi_ext.disable_bracketed_paste); -- cgit From 852f21ed0587195fa1b1f2cf0b3b89e6cb03e676 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Fri, 16 Jun 2017 15:16:11 +0100 Subject: tui: Coding style changes only Per warnings about house style from automated tools. --- src/nvim/tui/terminfo.c | 40 ++++++++++++++++++++++++++-------------- src/nvim/tui/tui.c | 25 +++++++++++++------------ 2 files changed, 39 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c index 9492f3ddb1..ac1bdaa6bb 100644 --- a/src/nvim/tui/terminfo.c +++ b/src/nvim/tui/terminfo.c @@ -26,13 +26,13 @@ static const signed char xterm_256colour_terminfo[] = { // This is an 256-colour terminfo description that lacks // status line capabilities that tmux actually has. static const signed char tmux_256colour_terminfo[] = { - 26, 1, 56, 0, 15, 0, 15, 0, 105, 1, -48, 2, 116, 109, 117, 120, 124, 86, 84, 32, 49, 48, 48, 47, 65, 78, 83, 73, 32, 88, 51, 46, 54, 52, 32, 118, 105, 114, 116, 117, 97, 108, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, -1, -1, -1, -1, 45, 0, 62, 0, 64, 0, 68, 0, 75, 0, -1, -1, 77, 0, 89, 0, -1, -1, 93, 0, 96, 0, 102, 0, 106, 0, -1, -1, -1, -1, 110, 0, 112, 0, 117, 0, 122, 0, -1, -1, -1, -1, 123, 0, -1, -1, -1, -1, -128, 0, -123, 0, -118, 0, -1, -1, -113, 0, -111, 0, -106, 0, -1, -1, -105, 0, -100, 0, -94, 0, -88, 0, -1, -1, -1, -1, -1, -1, -85, 0, -1, -1, -1, -1, -1, -1, -81, 0, -1, -1, -77, 0, -1, -1, -1, -1, -1, -1, -75, 0, -1, -1, -70, 0, -1, -1, -1, -1, -1, -1, -1, -1, -66, 0, -62, 0, -56, 0, -52, 0, -48, 0, -44, 0, -38, 0, -32, 0, -26, 0, -20, 0, -14, 0, -9, 0, -1, -1, -4, 0, -1, -1, 0, 1, 5, 1, 10, 1, -1, -1, -1, -1, -1, -1, 14, 1, 18, 1, 26, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, 1, -1, -1, 37, 1, 46, 1, 55, 1, 64, 1, -1, -1, 73, 1, 82, 1, 91, 1, -1, -1, 100, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 109, 1, -1, -1, -1, -1, 126, 1, -1, -1, -127, 1, -124, 1, -122, 1, -119, 1, -46, 1, -1, -1, -43, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -41, 1, -1, -1, 24, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 35, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 40, 2, 46, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 52, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 57, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 66, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 71, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, 2, -1, -1, -1, -1, -1, -1, 81, 2, -112, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 51, 52, 104, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 51, 52, 108, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 15, 0, 27, 91, 109, 15, 0, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 103, 0, 27, 41, 48, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 69, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 43, 43, 44, 44, 45, 45, 46, 46, 48, 48, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, 41, 48, 0, 27, 91, 52, 126, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 109, 0, 27, 91, 50, 51, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 + 26, 1, 56, 0, 15, 0, 15, 0, 105, 1, -48, 2, 116, 109, 117, 120, 124, 86, 84, 32, 49, 48, 48, 47, 65, 78, 83, 73, 32, 88, 51, 46, 54, 52, 32, 118, 105, 114, 116, 117, 97, 108, 32, 116, 101, 114, 109, 105, 110, 97, 108, 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, -1, -1, -1, -1, 45, 0, 62, 0, 64, 0, 68, 0, 75, 0, -1, -1, 77, 0, 89, 0, -1, -1, 93, 0, 96, 0, 102, 0, 106, 0, -1, -1, -1, -1, 110, 0, 112, 0, 117, 0, 122, 0, -1, -1, -1, -1, 123, 0, -1, -1, -1, -1, -128, 0, -123, 0, -118, 0, -1, -1, -113, 0, -111, 0, -106, 0, -1, -1, -105, 0, -100, 0, -94, 0, -88, 0, -1, -1, -1, -1, -1, -1, -85, 0, -1, -1, -1, -1, -1, -1, -81, 0, -1, -1, -77, 0, -1, -1, -1, -1, -1, -1, -75, 0, -1, -1, -70, 0, -1, -1, -1, -1, -1, -1, -1, -1, -66, 0, -62, 0, -56, 0, -52, 0, -48, 0, -44, 0, -38, 0, -32, 0, -26, 0, -20, 0, -14, 0, -9, 0, -1, -1, -4, 0, -1, -1, 0, 1, 5, 1, 10, 1, -1, -1, -1, -1, -1, -1, 14, 1, 18, 1, 26, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, 1, -1, -1, 37, 1, 46, 1, 55, 1, 64, 1, -1, -1, 73, 1, 82, 1, 91, 1, -1, -1, 100, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 109, 1, -1, -1, -1, -1, 126, 1, -1, -1, -127, 1, -124, 1, -122, 1, -119, 1, -46, 1, -1, -1, -43, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -41, 1, -1, -1, 24, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 35, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 40, 2, 46, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 52, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 57, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 66, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 71, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 77, 2, -1, -1, -1, -1, -1, -1, 81, 2, -112, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 51, 52, 104, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 51, 52, 108, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 15, 0, 27, 91, 109, 15, 0, 0, 27, 91, 52, 108, 0, 27, 91, 50, 55, 109, 0, 27, 91, 50, 52, 109, 0, 27, 103, 0, 27, 41, 48, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 69, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 43, 43, 44, 44, 45, 45, 46, 46, 48, 48, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, 41, 48, 0, 27, 91, 52, 126, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 109, 0, 27, 91, 50, 51, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0 }; // Taken from unibilium/t/static_screen-256color.c as of 2015-08-14. // This is an 256-colour terminfo description that lacks // status line capabilities that screen actually has. static const signed char screen_256colour_terminfo[] = { - 26, 1, 43, 0, 43, 0, 15, 0, 105, 1, -43, 2, 115, 99, 114, 101, 101, 110, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 71, 78, 85, 32, 83, 99, 114, 101, 101, 110, 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, -1, -1, -1, -1, 45, 0, 62, 0, 64, 0, 68, 0, 75, 0, -1, -1, 77, 0, 89, 0, -1, -1, 93, 0, 96, 0, 102, 0, 106, 0, -1, -1, -1, -1, 110, 0, 112, 0, 117, 0, 122, 0, -1, -1, -1, -1, -125, 0, -1, -1, -1, -1, -120, 0, -115, 0, -110, 0, -1, -1, -105, 0, -103, 0, -98, 0, -1, -1, -89, 0, -84, 0, -78, 0, -72, 0, -1, -1, -1, -1, -1, -1, -69, 0, -1, -1, -1, -1, -1, -1, -65, 0, -1, -1, -61, 0, -1, -1, -1, -1, -1, -1, -59, 0, -1, -1, -54, 0, -1, -1, -1, -1, -1, -1, -1, -1, -50, 0, -46, 0, -40, 0, -36, 0, -32, 0, -28, 0, -22, 0, -16, 0, -10, 0, -4, 0, 2, 1, 7, 1, -1, -1, 12, 1, -1, -1, 16, 1, 21, 1, 26, 1, -1, -1, -1, -1, -1, -1, 30, 1, 34, 1, 42, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 1, -1, -1, 53, 1, 62, 1, 71, 1, 80, 1, -1, -1, 89, 1, 98, 1, 107, 1, -1, -1, 116, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 125, 1, -1, -1, -1, -1, -114, 1, -1, -1, -111, 1, -108, 1, -106, 1, -103, 1, -30, 1, -1, -1, -27, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -25, 1, -1, -1, 40, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 51, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 56, 2, 62, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 73, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 82, 2, -1, -1, -1, -1, -1, -1, 86, 2, -107, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 51, 52, 104, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 51, 52, 108, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, 48, 52, 57, 104, 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 51, 109, 0, 27, 91, 52, 109, 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 63, 49, 48, 52, 57, 108, 0, 27, 91, 52, 108, 0, 27, 91, 50, 51, 109, 0, 27, 91, 50, 52, 109, 0, 27, 103, 0, 27, 41, 48, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 69, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 49, 37, 116, 59, 51, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 43, 43, 44, 44, 45, 45, 46, 46, 48, 48, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, 41, 48, 0, 27, 91, 52, 126, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 0, 3, 0, 1, 0, 24, 0, 52, 0, -112, 0, 1, 1, 0, 0, 1, 0, 0, 0, 4, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 3, 0, 6, 0, 9, 0, 12, 0, 15, 0, 18, 0, 23, 0, 28, 0, 32, 0, 37, 0, 43, 0, 49, 0, 55, 0, 61, 0, 66, 0, 71, 0, 77, 0, 83, 0, 89, 0, 95, 0, 101, 0, 107, 0, 111, 0, 116, 0, 120, 0, 124, 0, -128, 0, 27, 40, 66, 0, 27, 40, 37, 112, 49, 37, 99, 0, 65, 88, 0, 71, 48, 0, 88, 84, 0, 85, 56, 0, 69, 48, 0, 83, 48, 0, 107, 68, 67, 53, 0, 107, 68, 67, 54, 0, 107, 68, 78, 0, 107, 68, 78, 53, 0, 107, 69, 78, 68, 53, 0, 107, 69, 78, 68, 54, 0, 107, 72, 79, 77, 53, 0, 107, 72, 79, 77, 54, 0, 107, 73, 67, 53, 0, 107, 73, 67, 54, 0, 107, 76, 70, 84, 53, 0, 107, 78, 88, 84, 53, 0, 107, 78, 88, 84, 54, 0, 107, 80, 82, 86, 53, 0, 107, 80, 82, 86, 54, 0, 107, 82, 73, 84, 53, 0, 107, 85, 80, 0, 107, 85, 80, 53, 0, 107, 97, 50, 0, 107, 98, 49, 0, 107, 98, 51, 0, 107, 99, 50, 0 + 26, 1, 43, 0, 43, 0, 15, 0, 105, 1, -43, 2, 115, 99, 114, 101, 101, 110, 45, 50, 53, 54, 99, 111, 108, 111, 114, 124, 71, 78, 85, 32, 83, 99, 114, 101, 101, 110, 32, 119, 105, 116, 104, 32, 50, 53, 54, 32, 99, 111, 108, 111, 114, 115, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, -1, 127, 0, 0, 4, 0, 6, 0, 8, 0, 25, 0, 30, 0, 37, 0, 41, 0, -1, -1, -1, -1, 45, 0, 62, 0, 64, 0, 68, 0, 75, 0, -1, -1, 77, 0, 89, 0, -1, -1, 93, 0, 96, 0, 102, 0, 106, 0, -1, -1, -1, -1, 110, 0, 112, 0, 117, 0, 122, 0, -1, -1, -1, -1, -125, 0, -1, -1, -1, -1, -120, 0, -115, 0, -110, 0, -1, -1, -105, 0, -103, 0, -98, 0, -1, -1, -89, 0, -84, 0, -78, 0, -72, 0, -1, -1, -1, -1, -1, -1, -69, 0, -1, -1, -1, -1, -1, -1, -65, 0, -1, -1, -61, 0, -1, -1, -1, -1, -1, -1, -59, 0, -1, -1, -54, 0, -1, -1, -1, -1, -1, -1, -1, -1, -50, 0, -46, 0, -40, 0, -36, 0, -32, 0, -28, 0, -22, 0, -16, 0, -10, 0, -4, 0, 2, 1, 7, 1, -1, -1, 12, 1, -1, -1, 16, 1, 21, 1, 26, 1, -1, -1, -1, -1, -1, -1, 30, 1, 34, 1, 42, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 1, -1, -1, 53, 1, 62, 1, 71, 1, 80, 1, -1, -1, 89, 1, 98, 1, 107, 1, -1, -1, 116, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 125, 1, -1, -1, -1, -1, -114, 1, -1, -1, -111, 1, -108, 1, -106, 1, -103, 1, -30, 1, -1, -1, -27, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -25, 1, -1, -1, 40, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 51, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 56, 2, 62, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 68, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 73, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 82, 2, -1, -1, -1, -1, -1, -1, 86, 2, -107, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 114, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 10, 0, 27, 91, 72, 0, 27, 91, 63, 50, 53, 108, 0, 8, 0, 27, 91, 51, 52, 104, 27, 91, 63, 50, 53, 104, 0, 27, 91, 67, 0, 27, 77, 0, 27, 91, 51, 52, 108, 0, 27, 91, 80, 0, 27, 91, 77, 0, 14, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 63, 49, 48, 52, 57, 104, 0, 27, 91, 52, 104, 0, 27, 91, 55, 109, 0, 27, 91, 51, 109, 0, 27, 91, 52, 109, 0, 15, 0, 27, 91, 109, 15, 0, 27, 91, 63, 49, 48, 52, 57, 108, 0, 27, 91, 52, 108, 0, 27, 91, 50, 51, 109, 0, 27, 91, 50, 52, 109, 0, 27, 103, 0, 27, 41, 48, 0, 27, 91, 76, 0, 8, 0, 27, 91, 51, 126, 0, 27, 79, 66, 0, 27, 79, 80, 0, 27, 91, 50, 49, 126, 0, 27, 79, 81, 0, 27, 79, 82, 0, 27, 79, 83, 0, 27, 91, 49, 53, 126, 0, 27, 91, 49, 55, 126, 0, 27, 91, 49, 56, 126, 0, 27, 91, 49, 57, 126, 0, 27, 91, 50, 48, 126, 0, 27, 91, 49, 126, 0, 27, 91, 50, 126, 0, 27, 79, 68, 0, 27, 91, 54, 126, 0, 27, 91, 53, 126, 0, 27, 79, 67, 0, 27, 79, 65, 0, 27, 91, 63, 49, 108, 27, 62, 0, 27, 91, 63, 49, 104, 27, 61, 0, 27, 69, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 99, 27, 91, 63, 49, 48, 48, 48, 108, 27, 91, 63, 50, 53, 104, 0, 27, 56, 0, 27, 55, 0, 10, 0, 27, 77, 0, 27, 91, 48, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 49, 37, 116, 59, 51, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 109, 37, 63, 37, 112, 57, 37, 116, 14, 37, 101, 15, 37, 59, 0, 27, 72, 0, 9, 0, 43, 43, 44, 44, 45, 45, 46, 46, 48, 48, 96, 96, 97, 97, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109, 110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116, 116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122, 123, 123, 124, 124, 125, 125, 126, 126, 0, 27, 91, 90, 0, 27, 40, 66, 27, 41, 48, 0, 27, 91, 52, 126, 0, 27, 91, 50, 51, 126, 0, 27, 91, 50, 52, 126, 0, 27, 91, 49, 75, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 77, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 51, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 57, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 51, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 27, 91, 37, 63, 37, 112, 49, 37, 123, 56, 125, 37, 60, 37, 116, 52, 37, 112, 49, 37, 100, 37, 101, 37, 112, 49, 37, 123, 49, 54, 125, 37, 60, 37, 116, 49, 48, 37, 112, 49, 37, 123, 56, 125, 37, 45, 37, 100, 37, 101, 52, 56, 59, 53, 59, 37, 112, 49, 37, 100, 37, 59, 109, 0, 0, 3, 0, 1, 0, 24, 0, 52, 0, -112, 0, 1, 1, 0, 0, 1, 0, 0, 0, 4, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 3, 0, 6, 0, 9, 0, 12, 0, 15, 0, 18, 0, 23, 0, 28, 0, 32, 0, 37, 0, 43, 0, 49, 0, 55, 0, 61, 0, 66, 0, 71, 0, 77, 0, 83, 0, 89, 0, 95, 0, 101, 0, 107, 0, 111, 0, 116, 0, 120, 0, 124, 0, -128, 0, 27, 40, 66, 0, 27, 40, 37, 112, 49, 37, 99, 0, 65, 88, 0, 71, 48, 0, 88, 84, 0, 85, 56, 0, 69, 48, 0, 83, 48, 0, 107, 68, 67, 53, 0, 107, 68, 67, 54, 0, 107, 68, 78, 0, 107, 68, 78, 53, 0, 107, 69, 78, 68, 53, 0, 107, 69, 78, 68, 54, 0, 107, 72, 79, 77, 53, 0, 107, 72, 79, 77, 54, 0, 107, 73, 67, 53, 0, 107, 73, 67, 54, 0, 107, 76, 70, 84, 53, 0, 107, 78, 88, 84, 53, 0, 107, 78, 88, 84, 54, 0, 107, 80, 82, 86, 53, 0, 107, 80, 82, 86, 54, 0, 107, 82, 73, 84, 53, 0, 107, 85, 80, 0, 107, 85, 80, 53, 0, 107, 97, 50, 0, 107, 98, 49, 0, 107, 98, 51, 0, 107, 99, 50, 0 }; // Taken from Dickey ncurses terminfo.src dated 2017-04-22. static const signed char iterm_256colour_terminfo[] = { @@ -83,25 +83,37 @@ static const signed char ansi_terminfo[] = { unibi_term *load_builtin_terminfo(const char * term) { if (terminfo_is_term_family(term, "xterm")) { - return unibi_from_mem((const char *)xterm_256colour_terminfo, sizeof xterm_256colour_terminfo); + return unibi_from_mem((const char *)xterm_256colour_terminfo, + sizeof xterm_256colour_terminfo); } else if (terminfo_is_term_family(term, "screen")) { - return unibi_from_mem((const char *)screen_256colour_terminfo, sizeof screen_256colour_terminfo); + return unibi_from_mem((const char *)screen_256colour_terminfo, + sizeof screen_256colour_terminfo); } else if (terminfo_is_term_family(term, "tmux")) { - return unibi_from_mem((const char *)tmux_256colour_terminfo, sizeof tmux_256colour_terminfo); + return unibi_from_mem((const char *)tmux_256colour_terminfo, + sizeof tmux_256colour_terminfo); } else if (terminfo_is_term_family(term, "rxvt")) { - return unibi_from_mem((const char *)rxvt_256colour_terminfo, sizeof rxvt_256colour_terminfo); + return unibi_from_mem((const char *)rxvt_256colour_terminfo, + sizeof rxvt_256colour_terminfo); } else if (terminfo_is_term_family(term, "putty")) { - return unibi_from_mem((const char *)putty_256colour_terminfo, sizeof putty_256colour_terminfo); + return unibi_from_mem((const char *)putty_256colour_terminfo, + sizeof putty_256colour_terminfo); } else if (terminfo_is_term_family(term, "linux")) { - return unibi_from_mem((const char *)linux_16colour_terminfo, sizeof linux_16colour_terminfo); + return unibi_from_mem((const char *)linux_16colour_terminfo, + sizeof linux_16colour_terminfo); } else if (terminfo_is_term_family(term, "interix")) { - return unibi_from_mem((const char *)interix_8colour_terminfo, sizeof interix_8colour_terminfo); - } else if (terminfo_is_term_family(term, "iterm") || terminfo_is_term_family(term, "iTerm.app")) { - return unibi_from_mem((const char *)iterm_256colour_terminfo, sizeof iterm_256colour_terminfo); + return unibi_from_mem((const char *)interix_8colour_terminfo, + sizeof interix_8colour_terminfo); + } else if (terminfo_is_term_family(term, "iterm") + || terminfo_is_term_family(term, "iTerm.app")) { + return unibi_from_mem((const char *)iterm_256colour_terminfo, + sizeof iterm_256colour_terminfo); } else if (terminfo_is_term_family(term, "st")) { - return unibi_from_mem((const char *)st_256colour_terminfo, sizeof st_256colour_terminfo); - } else if (terminfo_is_term_family(term, "gnome") || terminfo_is_term_family(term, "vte")) { - return unibi_from_mem((const char *)vte_256colour_terminfo, sizeof vte_256colour_terminfo); + return unibi_from_mem((const char *)st_256colour_terminfo, + sizeof st_256colour_terminfo); + } else if (terminfo_is_term_family(term, "gnome") + || terminfo_is_term_family(term, "vte")) { + return unibi_from_mem((const char *)vte_256colour_terminfo, + sizeof vte_256colour_terminfo); } else { return unibi_from_mem((const char *)ansi_terminfo, sizeof ansi_terminfo); } diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 61fe1bb361..b885861a23 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -47,7 +47,8 @@ #define TOO_MANY_EVENTS 1000000 #define STARTS_WITH(str, prefix) (strlen(term) >= (sizeof(prefix) - 1) \ && 0 == memcmp((str), (prefix), sizeof(prefix) - 1)) -#define TMUX_WRAP(is_tmux,seq) ((is_tmux) ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq) +#define TMUX_WRAP(is_tmux, seq) ((is_tmux) \ + ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq) #define LINUXSET0C "\x1b[?0c" #define LINUXSET1C "\x1b[?1c" @@ -552,7 +553,7 @@ static void cursor_goto(UI *ui, int row, int col) // different cursor positioning rules. && (data->immediate_wrap_after_last_column || grid->col < ui->width)) { int n = grid->col - col; - if (n <= 4) { // This might be just BS, so it is considered really cheap. + if (n <= 4) { // This might be just BS, so it is considered really cheap. while (n--) { unibi_out(ui, unibi_cursor_left); } @@ -579,7 +580,7 @@ static void cursor_goto(UI *ui, int row, int col) if (col == grid->col) { if (row > grid->row) { int n = row - grid->row; - if (n <= 4) { // This might be just LF, so it is considered really cheap. + if (n <= 4) { // This might be just LF, so it is considered really cheap. while (n--) { unibi_out(ui, unibi_cursor_down); } @@ -1483,21 +1484,21 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[ q"); } else if (linuxvt) { - // Linux uses an idiosyncratic escape code to set the cursor shape and does - // not support DECSCUSR. + // Linux uses an idiosyncratic escape code to set the cursor shape and + // does not support DECSCUSR. data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", "\x1b[?" "%?" // The parameter passed to Ss is the DECSCUSR parameter, so the // terminal capability has to translate into the Linux idiosyncratic // parameter. - "%p1%{2}%<" "%t%{8}" // blink block - "%p1%{2}%=" "%t%{24}" // steady block - "%p1%{3}%=" "%t%{1}" // blink underline - "%p1%{4}%=" "%t%{17}" // steady underline - "%p1%{5}%=" "%t%{1}" // blink bar - "%p1%{6}%=" "%t%{17}" // steady bar - "%e%{0}" // anything else + "%p1%{2}%<" "%t%{8}" // blink block + "%p1%{2}%=" "%t%{24}" // steady block + "%p1%{3}%=" "%t%{1}" // blink underline + "%p1%{4}%=" "%t%{17}" // steady underline + "%p1%{5}%=" "%t%{1}" // blink bar + "%p1%{6}%=" "%t%{17}" // steady bar + "%e%{0}" // anything else "%;" "%dc"); if (-1 == data->unibi_ext.reset_cursor_style) { data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", -- cgit From 1ae7744f42fe60ebc2caa383be4d17e714c71c5f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 7 Jul 2017 00:33:20 +0200 Subject: lint --- src/nvim/option.c | 3 ++- src/nvim/screen.c | 11 +++++------ src/nvim/tui/terminfo.c | 27 ++++++++++++++------------- src/nvim/tui/terminfo.h | 2 ++ src/nvim/tui/tui.c | 34 +++++++++++++++++----------------- 5 files changed, 40 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 0c423c900f..cc7f8333ff 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -969,7 +969,8 @@ void set_init_2(bool headless) p_window = Rows - 1; } set_number_default("window", Rows - 1); -#if 0 // This bodges around problems that should properly be fixed in the TUI layer. +#if 0 + // This bodges around problems that should be fixed in the TUI layer. if (!headless && !os_term_is_nice()) { set_string_option_direct((char_u *)"guicursor", -1, (char_u *)"", OPT_GLOBAL, SID_NONE); diff --git a/src/nvim/screen.c b/src/nvim/screen.c index e8cd6b4e9c..537b13f33d 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5824,13 +5824,12 @@ static void screen_char(unsigned off, int row, int col) if (row >= screen_Rows || col >= screen_Columns) return; - /* Outputting the last character on the screen may scrollup the screen. - * Don't to it! Mark the character invalid (update it when scrolled up) - * FIXME: The premise here is not actually true. c.f. deferred wrap */ + // Outputting the last character on the screen may scrollup the screen. + // Don't to it! Mark the character invalid (update it when scrolled up) + // FIXME: The premise here is not actually true (cf. deferred wrap). if (row == screen_Rows - 1 && col == screen_Columns - 1 - /* account for first command-line character in rightleft mode */ - && !cmdmsg_rl - ) { + // account for first command-line character in rightleft mode + && !cmdmsg_rl) { ScreenAttrs[off] = (sattr_T)-1; return; } diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c index ac1bdaa6bb..b8fffcb7d6 100644 --- a/src/nvim/tui/terminfo.c +++ b/src/nvim/tui/terminfo.c @@ -84,37 +84,38 @@ unibi_term *load_builtin_terminfo(const char * term) { if (terminfo_is_term_family(term, "xterm")) { return unibi_from_mem((const char *)xterm_256colour_terminfo, - sizeof xterm_256colour_terminfo); + sizeof xterm_256colour_terminfo); } else if (terminfo_is_term_family(term, "screen")) { return unibi_from_mem((const char *)screen_256colour_terminfo, - sizeof screen_256colour_terminfo); + sizeof screen_256colour_terminfo); } else if (terminfo_is_term_family(term, "tmux")) { return unibi_from_mem((const char *)tmux_256colour_terminfo, - sizeof tmux_256colour_terminfo); + sizeof tmux_256colour_terminfo); } else if (terminfo_is_term_family(term, "rxvt")) { return unibi_from_mem((const char *)rxvt_256colour_terminfo, - sizeof rxvt_256colour_terminfo); + sizeof rxvt_256colour_terminfo); } else if (terminfo_is_term_family(term, "putty")) { return unibi_from_mem((const char *)putty_256colour_terminfo, - sizeof putty_256colour_terminfo); + sizeof putty_256colour_terminfo); } else if (terminfo_is_term_family(term, "linux")) { return unibi_from_mem((const char *)linux_16colour_terminfo, - sizeof linux_16colour_terminfo); + sizeof linux_16colour_terminfo); } else if (terminfo_is_term_family(term, "interix")) { return unibi_from_mem((const char *)interix_8colour_terminfo, - sizeof interix_8colour_terminfo); + sizeof interix_8colour_terminfo); } else if (terminfo_is_term_family(term, "iterm") - || terminfo_is_term_family(term, "iTerm.app")) { + || terminfo_is_term_family(term, "iTerm.app")) { return unibi_from_mem((const char *)iterm_256colour_terminfo, - sizeof iterm_256colour_terminfo); + sizeof iterm_256colour_terminfo); } else if (terminfo_is_term_family(term, "st")) { return unibi_from_mem((const char *)st_256colour_terminfo, - sizeof st_256colour_terminfo); + sizeof st_256colour_terminfo); } else if (terminfo_is_term_family(term, "gnome") - || terminfo_is_term_family(term, "vte")) { + || terminfo_is_term_family(term, "vte")) { return unibi_from_mem((const char *)vte_256colour_terminfo, - sizeof vte_256colour_terminfo); + sizeof vte_256colour_terminfo); } else { - return unibi_from_mem((const char *)ansi_terminfo, sizeof ansi_terminfo); + return unibi_from_mem((const char *)ansi_terminfo, + sizeof ansi_terminfo); } } diff --git a/src/nvim/tui/terminfo.h b/src/nvim/tui/terminfo.h index 78f6b9c245..099df8967f 100644 --- a/src/nvim/tui/terminfo.h +++ b/src/nvim/tui/terminfo.h @@ -1,6 +1,8 @@ #ifndef NVIM_TUI_TERMINFO_H #define NVIM_TUI_TERMINFO_H +#include + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "tui/terminfo.h.generated.h" #endif diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index b885861a23..499dffa18a 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -162,7 +162,7 @@ UI *tui_start(void) } static size_t unibi_pre_fmt_str(TUIData *data, unsigned int unibi_index, - char * buf, size_t len) + char * buf, size_t len) { const char *str = unibi_get_str(data->ut, unibi_index); if (!str) { @@ -223,9 +223,9 @@ static void terminfo_start(UI *ui) terminfo_is_term_family(term, "cygwin") || terminfo_is_term_family(term, "interix"); data->normlen = unibi_pre_fmt_str(data, unibi_cursor_normal, - data->norm, sizeof data->norm); + data->norm, sizeof data->norm); data->invislen = unibi_pre_fmt_str(data, unibi_cursor_invisible, - data->invis, sizeof data->invis); + data->invis, sizeof data->invis); // Set 't_Co' from the result of unibilium & fix_terminfo. t_colors = unibi_get_num(data->ut, unibi_max_colors); // Enter alternate screen and clear @@ -539,7 +539,7 @@ static void cursor_goto(UI *ui, int row, int col) if (n <= (row == grid->row ? 4 : 2) && cheap_to_print(ui, grid->row, grid->col, n)) { UGRID_FOREACH_CELL(grid, grid->row, grid->row, - grid->col, col - 1, { + grid->col, col - 1, { print_cell(ui, cell); }); } @@ -1254,7 +1254,8 @@ static int unibi_find_ext_bool(unibi_term *ut, const char *name) /// external or a built-in database. In an ideal world, the real terminfo data /// would be correct and complete, and this function would be almost empty. static void patch_terminfo_bugs(TUIData *data, const char *term, - const char *colorterm, long vte_version, bool konsole, bool iterm_env) + const char *colorterm, long vte_version, + bool konsole, bool iterm_env) { unibi_term *ut = data->ut; const char * xterm_version = os_getenv("XTERM_VERSION"); @@ -1296,7 +1297,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, if (linuxvt && strlen(fix_normal) >= (sizeof LINUXSET0C - 1) && !memcmp(strchr(fix_normal, 0) - (sizeof LINUXSET0C - 1), - LINUXSET0C, sizeof LINUXSET0C - 1)) { + LINUXSET0C, sizeof LINUXSET0C - 1)) { // The Linux terminfo entry similarly includes a Linux-idiosyncractic // cursor shape reset in cnorm, which similarly interferes with // set_cursor_style. @@ -1308,7 +1309,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, if (linuxvt && strlen(fix_invisible) >= (sizeof LINUXSET1C - 1) && !memcmp(strchr(fix_invisible, 0) - (sizeof LINUXSET1C - 1), - LINUXSET1C, sizeof LINUXSET1C - 1)) { + LINUXSET1C, sizeof LINUXSET1C - 1)) { // The Linux terminfo entry similarly includes a Linux-idiosyncractic // cursor shape reset in cinvis, which similarly interferes with // set_cursor_style. @@ -1411,8 +1412,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_num(ut, unibi_max_colors, 256); unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); - } else - if (konsole || xterm || gnome || rxvt || st || putty + } else if (konsole || xterm || gnome || rxvt || st || putty || linuxvt // Linux 4.8+ supports 256-colour SGR. || mate_pretending_xterm || gnome_pretending_xterm || tmux || tmux_pretending_screen @@ -1455,23 +1455,23 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // console-terminal-emulator from the nosh toolset, which does indeed // implement the xterm extension: || (linuxvt && (xterm_version || (vte_version > 0) || colorterm))) { - data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", - "\x1b[%p1%d q"); + data->unibi_ext.set_cursor_style = + (int)unibi_add_ext_str(ut, "Ss", "\x1b[%p1%d q"); if (-1 == data->unibi_ext.reset_cursor_style) { data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", ""); } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, - "\x1b[ q"); - } else - if (putty // per MinTTY 0.4.3-1 release notes from 2009 + "\x1b[ q"); + } else if ( + // per MinTTY 0.4.3-1 release notes from 2009 + putty // per https://bugzilla.gnome.org/show_bug.cgi?id=720821 || (vte_version >= 3900) // per tmux manual page and per // https://lists.gnu.org/archive/html/screen-devel/2013-03/msg00000.html || screen) { - // Since we use the xterm extension, we have to map it to the unextended - // form. + // Since we use the xterm extension, we must map it to the unextended form data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", "\x1b[%?" "%p1%{4}%>" "%t%p1%{2}%-" // a bit of a bodge for extension values @@ -1676,7 +1676,7 @@ static void flush_buf(UI *ui, bool toggle_cursor) } uv_write(&req, STRUCT_CAST(uv_stream_t, &data->output_handle), - bufs, (unsigned)(bufp - bufs), NULL); + bufs, (unsigned)(bufp - bufs), NULL); uv_run(&data->write_loop, UV_RUN_DEFAULT); data->bufpos = 0; } -- cgit From f31c26f1afb5e4d17678927fa7cd3bb41197a298 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 29 May 2017 03:17:12 +0200 Subject: jobstop/process_stop: send SIGTERM directly This reverts the revert of #6644 (7c1a5d1d4), and handles it properly now (with tests). --- src/nvim/event/process.c | 35 ++++++++++++++++++----------------- src/nvim/event/process.h | 3 +-- 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index cad49e2007..c936583841 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -21,9 +21,9 @@ # include "event/process.c.generated.h" #endif -// Time (ns) for a process to exit cleanly before we send TERM/KILL. -#define TERM_TIMEOUT 1000000000 -#define KILL_TIMEOUT (TERM_TIMEOUT * 2) +// Time for a process to exit cleanly before we send KILL. +// For pty processes SIGTERM is sent first (in case SIGHUP was not enough). +#define KILL_TIMEOUT_MS 2000 #define CLOSE_PROC_STREAM(proc, stream) \ do { \ @@ -125,8 +125,6 @@ void process_teardown(Loop *loop) FUNC_ATTR_NONNULL_ALL // Close handles to process without killing it. CREATE_EVENT(loop->events, process_close_handles, 1, proc); } else { - uv_kill(proc->pid, SIGTERM); - proc->term_sent = true; process_stop(proc); } } @@ -238,6 +236,8 @@ void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL // stdout/stderr, they will be closed when it exits(possibly due to being // terminated after a timeout) process_close_in(proc); + ILOG("Sending SIGTERM to pid %d", proc->pid); + uv_kill(proc->pid, SIGTERM); break; case kProcessTypePty: // close all streams for pty processes to send SIGHUP to the process @@ -251,9 +251,10 @@ void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL Loop *loop = proc->loop; if (!loop->children_stop_requests++) { // When there's at least one stop request pending, start a timer that - // will periodically check if a signal should be send to a to the job - DLOG("Starting job kill timer"); - uv_timer_start(&loop->children_kill_timer, children_kill_cb, 100, 100); + // will periodically check if a signal should be send to the job. + ILOG("Starting job kill timer"); + uv_timer_start(&loop->children_kill_timer, children_kill_cb, + KILL_TIMEOUT_MS, KILL_TIMEOUT_MS); } } @@ -269,15 +270,15 @@ static void children_kill_cb(uv_timer_t *handle) if (!proc->stopped_time) { continue; } - uint64_t elapsed = now - proc->stopped_time; - - if (!proc->term_sent && elapsed >= TERM_TIMEOUT) { - ILOG("Sending SIGTERM to pid %d", proc->pid); - uv_kill(proc->pid, SIGTERM); - proc->term_sent = true; - } else if (elapsed >= KILL_TIMEOUT) { - ILOG("Sending SIGKILL to pid %d", proc->pid); - uv_kill(proc->pid, SIGKILL); + uint64_t elapsed = (now - proc->stopped_time) / 1000000 + 1; + + if (elapsed >= KILL_TIMEOUT_MS) { + int sig = proc->type == kProcessTypePty && elapsed < KILL_TIMEOUT_MS * 2 + ? SIGTERM + : SIGKILL; + ILOG("Sending %s to pid %d", sig == SIGTERM ? "SIGTERM" : "SIGKILL", + proc->pid); + uv_kill(proc->pid, sig); } } } diff --git a/src/nvim/event/process.h b/src/nvim/event/process.h index 26d70a5e6d..5c00e8e7ec 100644 --- a/src/nvim/event/process.h +++ b/src/nvim/event/process.h @@ -26,7 +26,7 @@ struct process { Stream *in, *out, *err; process_exit_cb cb; internal_process_cb internal_exit_cb, internal_close_cb; - bool closed, term_sent, detach; + bool closed, detach; MultiQueue *events; }; @@ -48,7 +48,6 @@ static inline Process process_init(Loop *loop, ProcessType type, void *data) .err = NULL, .cb = NULL, .closed = false, - .term_sent = false, .internal_close_cb = NULL, .internal_exit_cb = NULL, .detach = false -- cgit From 69e9cda5ace194a678c125256bc5558bc2bfcfce Mon Sep 17 00:00:00 2001 From: d10n Date: Sat, 8 Jul 2017 06:50:58 -0400 Subject: i_CTRL-O: fix :startinsert at end of line (#6963) The gchar_cursor() == NUL check is already done in ins_ctrl_o. ins_esc changes gchar_cursor() so this if block is probably never entered. Issue: Pressing CTRL-O in insert mode at the end of the line and typing :startinsert moves the cursor 1 column back, when I expect the cursor to remain at the end of the line This is a regression from Vim behavior. Since at least Vim version 7.0, Vim returns you to insert mode at the end of the line. 091e7d033cbf0f4da068292ce4ac934f1c3dd91e is the first bad neovim commit Steps to reproduce using `nvim -u NORC`: `aaaa:startinsert` Fixes #6962 --- src/nvim/edit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 08a2f42f74..ca62679fab 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -462,7 +462,7 @@ static void insert_enter(InsertState *s) // Always update o_lnum, so that a "CTRL-O ." that adds a line // still puts the cursor back after the inserted text. - if (ins_at_eol && gchar_cursor() == NUL) { + if (ins_at_eol) { o_lnum = curwin->w_cursor.lnum; } -- cgit From 78c5201234e478ff8f648adea95be18ca588a9cd Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 2 Jul 2017 04:54:24 +0200 Subject: 'cpoptions': remove "k" flag This was already removed in 3baba1e7bc66, except the documentation and CPO_VI entry. find_term_bykeys() is irrelevant to Nvim. --- src/nvim/api/vim.c | 1 - src/nvim/option_defs.h | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 80efe86ea3..ac7c9cbce6 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -153,7 +153,6 @@ String nvim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, char *ptr = NULL; // Set 'cpoptions' the way we want it. // FLAG_CPO_BSLASH set - backslashes are *not* treated specially - // FLAG_CPO_KEYCODE set - keycodes are *not* reverse-engineered // FLAG_CPO_SPECI unset - sequences *are* interpreted // The third from end parameter of replace_termcodes() is true so that the // sequence is recognised - needed for a real backslash. diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index e68dba734e..ff1d89e0a2 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -97,7 +97,6 @@ #define CPO_INTMOD 'i' /* interrupt a read makes buffer modified */ #define CPO_INDENT 'I' /* remove auto-indent more often */ #define CPO_ENDOFSENT 'J' /* need two spaces to detect end of sentence */ -#define CPO_KEYCODE 'k' /* don't recognize raw key code in mappings */ #define CPO_KOFFSET 'K' /* don't wait for key code in mappings */ #define CPO_LITERAL 'l' /* take char after backslash in [] literal */ #define CPO_LISTWM 'L' /* 'list' changes wrapmargin */ @@ -132,7 +131,7 @@ #define CPO_CHANGEW '_' // "cw" special-case // default values for Vim and Vi #define CPO_VIM "aABceFs_" -#define CPO_VI "aAbBcCdDeEfFiIJkKlLmMnoOpPqrRsStuvWxXyZ$!%+<>;_" +#define CPO_VI "aAbBcCdDeEfFiIJKlLmMnoOpPqrRsStuvWxXyZ$!%+<>;_" /* characters for p_ww option: */ #define WW_ALL "bshl<>[],~" -- cgit From 0ea7e45bc1d1881f505da2b77e0b3e4eb56f12fe Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 2 Jul 2017 13:21:38 +0200 Subject: 'cpoptions': remove "<" flag; ignore Closes #6937 "nvim_get_keymap output is unreliable" --- src/nvim/api/vim.c | 11 +++++------ src/nvim/eval.c | 2 +- src/nvim/ex_docmd.c | 2 +- src/nvim/getchar.c | 22 ++++++++-------------- src/nvim/keymap.c | 15 ++++++--------- src/nvim/keymap.h | 10 +++------- src/nvim/menu.c | 5 ++--- src/nvim/option.c | 2 +- src/nvim/option_defs.h | 11 +++++------ 9 files changed, 32 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index ac7c9cbce6..8ab0c0ebda 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -136,9 +136,13 @@ Integer nvim_input(String keys) return (Integer)input_enqueue(keys); } -/// Replaces terminal codes and key codes (, , ...) in a string with +/// Replaces terminal codes and |keycodes| (, , ...) in a string with /// the internal representation. /// +/// @param str String to be converted. +/// @param from_part Legacy Vim parameter. Usually true. +/// @param do_lt Also translate . Does nothing if `special` is false. +/// @param special Replace |keycodes|, e.g. becomes a "\n" char. /// @see replace_termcodes /// @see cpoptions String nvim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, @@ -151,11 +155,6 @@ String nvim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, } char *ptr = NULL; - // Set 'cpoptions' the way we want it. - // FLAG_CPO_BSLASH set - backslashes are *not* treated specially - // FLAG_CPO_SPECI unset - sequences *are* interpreted - // The third from end parameter of replace_termcodes() is true so that the - // sequence is recognised - needed for a real backslash. replace_termcodes((char_u *)str.data, str.size, (char_u **)&ptr, from_part, do_lt, special, CPO_TO_CPO_FLAGS); return cstr_as_string(ptr); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 662270e788..7e9c006f33 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12111,7 +12111,7 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) mode = get_map_mode((char_u **)&which, 0); - keys = replace_termcodes(keys, STRLEN(keys), &keys_buf, true, true, false, + keys = replace_termcodes(keys, STRLEN(keys), &keys_buf, true, true, true, CPO_TO_CPO_FLAGS); rhs = check_map(keys, mode, exact, false, abbr, &mp, &buffer_local); xfree(keys_buf); diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index af8845de87..5d7246581c 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4747,7 +4747,7 @@ static int uc_add_command(char_u *name, size_t name_len, char_u *rep, char_u *rep_buf = NULL; garray_T *gap; - replace_termcodes(rep, STRLEN(rep), &rep_buf, false, false, false, + replace_termcodes(rep, STRLEN(rep), &rep_buf, false, false, true, CPO_TO_CPO_FLAGS); if (rep_buf == NULL) { /* Can't replace termcodes - try using the string as is */ diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index fc1b8ccfcb..adf0ff1e53 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -2537,7 +2537,6 @@ do_map ( bool unique = false; bool nowait = false; bool silent = false; - bool special = false; bool expr = false; int noremap; char_u *orig_rhs; @@ -2583,12 +2582,9 @@ do_map ( continue; } - /* - * Check for "": accept special keys in <> - */ + // Ignore obsolete "" modifier. if (STRNCMP(keys, "", 9) == 0) { keys = skipwhite(keys + 9); - special = true; continue; } @@ -2657,7 +2653,7 @@ do_map ( // needs to be freed later (*keys_buf and *arg_buf). // replace_termcodes() also removes CTRL-Vs and sometimes backslashes. if (haskey) { - keys = replace_termcodes(keys, STRLEN(keys), &keys_buf, true, true, special, + keys = replace_termcodes(keys, STRLEN(keys), &keys_buf, true, true, true, CPO_TO_CPO_FLAGS); } orig_rhs = rhs; @@ -2665,7 +2661,7 @@ do_map ( if (STRICMP(rhs, "") == 0) { // "" means nothing rhs = (char_u *)""; } else { - rhs = replace_termcodes(rhs, STRLEN(rhs), &arg_buf, false, true, special, + rhs = replace_termcodes(rhs, STRLEN(rhs), &arg_buf, false, true, true, CPO_TO_CPO_FLAGS); } } @@ -3245,7 +3241,7 @@ bool map_to_exists(const char *const str, const char *const modechars, char_u *buf; char_u *const rhs = replace_termcodes((const char_u *)str, strlen(str), &buf, - false, true, false, + false, true, true, CPO_TO_CPO_FLAGS); #define MAPMODE(mode, modechars, chr, modeflags) \ @@ -4158,8 +4154,7 @@ void add_map(char_u *map, int mode) } // Translate an internal mapping/abbreviation representation into the -// corresponding external one recognized by :map/:abbrev commands; -// respects the current B/k/< settings of 'cpoption'. +// corresponding external one recognized by :map/:abbrev commands. // // This function is called when expanding mappings/abbreviations on the // command-line, and for building the "Ambiguous mapping..." error message. @@ -4179,7 +4174,6 @@ static char_u * translate_mapping ( ga_init(&ga, 1, 40); bool cpo_bslash = !(cpo_flags&FLAG_CPO_BSLASH); - bool cpo_special = !(cpo_flags&FLAG_CPO_SPECI); for (; *str; ++str) { int c = *str; @@ -4192,7 +4186,7 @@ static char_u * translate_mapping ( } if (c == K_SPECIAL && str[1] != NUL && str[2] != NUL) { - if (expmap && cpo_special) { + if (expmap) { ga_clear(&ga); return NULL; } @@ -4204,7 +4198,7 @@ static char_u * translate_mapping ( str += 2; } if (IS_SPECIAL(c) || modifiers) { /* special key */ - if (expmap && cpo_special) { + if (expmap) { ga_clear(&ga); return NULL; } @@ -4214,7 +4208,7 @@ static char_u * translate_mapping ( } if (c == ' ' || c == '\t' || c == Ctrl_J || c == Ctrl_V - || (c == '<' && !cpo_special) || (c == '\\' && !cpo_bslash)) { + || (c == '\\' && !cpo_bslash)) { ga_append(&ga, cpo_bslash ? Ctrl_V : '\\'); } diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index ee67b4c19d..295f246126 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -756,9 +756,9 @@ int get_mouse_button(int code, bool *is_click, bool *is_drag) /// Replace any terminal code strings with the equivalent internal /// representation /// -/// This is used for the "from" and "to" part of a mapping, and the "to" part of +/// Used for the "from" and "to" part of a mapping, and the "to" part of /// a menu command. Any strings like "" are also replaced, unless -/// 'cpoptions' contains '<'. K_SPECIAL by itself is replaced by K_SPECIAL +/// `special` is false. K_SPECIAL by itself is replaced by K_SPECIAL /// KS_SPECIAL KE_FILLER. /// /// @param[in] from What characters to replace. @@ -771,7 +771,7 @@ int get_mouse_button(int code, bool *is_click, bool *is_drag) /// When cpo_flags contains #FLAG_CPO_BSLASH, a backslash /// can be used in place of . All other /// characters are removed. -/// @param[in] special If true, always accept notation. +/// @param[in] special Replace keycodes, e.g. becomes a "\n" char. /// @param[in] cpo_flags Relevant flags derived from p_cpo, see /// #CPO_TO_CPO_FLAGS. /// @@ -790,11 +790,9 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len, const char_u *src; const char_u *const end = from + from_len - 1; int do_backslash; // backslash is a special character - int do_special; // recognize <> key codes char_u *result; // buffer for resulting string do_backslash = !(cpo_flags&FLAG_CPO_BSLASH); - do_special = !(cpo_flags&FLAG_CPO_SPECI) || special; // Allocate space for the translation. Worst case a single character is // replaced by 6 bytes (shifted special key), plus a NUL at the end. @@ -817,9 +815,8 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len, // Copy each byte from *from to result[dlen] while (src <= end) { - // If 'cpoptions' does not contain '<', check for special key codes, - // like "" - if (do_special && (do_lt || ((end - src) >= 3 + // Check for special <> keycodes, like "" + if (special && (do_lt || ((end - src) >= 3 && STRNCMP(src, "", 4) != 0))) { // Replace by K_SNR _. // (room: 5 * 6 = 30 bytes; needed: 3 + + 1 <= 14) @@ -846,7 +843,7 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len, } } - if (do_special) { + if (special) { char_u *p, *s, len; // Replace by the value of "mapleader". diff --git a/src/nvim/keymap.h b/src/nvim/keymap.h index bb8ba84a6a..b8fed77a90 100644 --- a/src/nvim/keymap.h +++ b/src/nvim/keymap.h @@ -464,13 +464,9 @@ enum key_extra { #define MAX_KEY_CODE_LEN 6 #define FLAG_CPO_BSLASH 0x01 -#define FLAG_CPO_SPECI 0x02 -#define CPO_TO_CPO_FLAGS (((vim_strchr(p_cpo, CPO_BSLASH) == NULL) \ - ? 0 \ - : FLAG_CPO_BSLASH)| \ - (vim_strchr(p_cpo, CPO_SPECI) == NULL \ - ? 0 \ - : FLAG_CPO_SPECI)) +#define CPO_TO_CPO_FLAGS ((vim_strchr(p_cpo, CPO_BSLASH) == NULL) \ + ? 0 \ + : FLAG_CPO_BSLASH) #ifdef INCLUDE_GENERATED_DECLARATIONS # include "keymap.h.generated.h" diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 7e9e9e9e5c..c8e6012e5c 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -60,7 +60,6 @@ ex_menu ( char_u *map_to; int noremap; bool silent = false; - bool special = false; int unmenu; char_u *map_buf; char_u *arg; @@ -86,7 +85,7 @@ ex_menu ( continue; } if (STRNCMP(arg, "", 9) == 0) { - special = true; + // Ignore obsolete "" modifier. arg = skipwhite(arg + 9); continue; } @@ -222,7 +221,7 @@ ex_menu ( map_buf = NULL; // Menu tips are plain text. } else { map_to = replace_termcodes(map_to, STRLEN(map_to), &map_buf, false, true, - special, CPO_TO_CPO_FLAGS); + true, CPO_TO_CPO_FLAGS); } menuarg.modes = modes; menuarg.noremap[0] = noremap; diff --git a/src/nvim/option.c b/src/nvim/option.c index ed058c420d..37b37e2859 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3034,7 +3034,7 @@ did_set_string_option ( /* 'pastetoggle': translate key codes like in a mapping */ else if (varp == &p_pt) { if (*p_pt) { - (void)replace_termcodes(p_pt, STRLEN(p_pt), &p, true, true, false, + (void)replace_termcodes(p_pt, STRLEN(p_pt), &p, true, true, true, CPO_TO_CPO_FLAGS); if (p != NULL) { if (new_value_alloced) diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index ff1d89e0a2..95cdc902f8 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -123,15 +123,14 @@ #define CPO_DOLLAR '$' #define CPO_FILTER '!' #define CPO_MATCH '%' -#define CPO_PLUS '+' /* ":write file" resets 'modified' */ -#define CPO_SPECI '<' /* don't recognize <> in mappings */ -#define CPO_REGAPPEND '>' /* insert NL when appending to a register */ -#define CPO_SCOLON ';' /* using "," and ";" will skip over char if - * cursor would not move */ +#define CPO_PLUS '+' // ":write file" resets 'modified' +#define CPO_REGAPPEND '>' // insert NL when appending to a register +#define CPO_SCOLON ';' // using "," and ";" will skip over char if + // cursor would not move #define CPO_CHANGEW '_' // "cw" special-case // default values for Vim and Vi #define CPO_VIM "aABceFs_" -#define CPO_VI "aAbBcCdDeEfFiIJKlLmMnoOpPqrRsStuvWxXyZ$!%+<>;_" +#define CPO_VI "aAbBcCdDeEfFiIJKlLmMnoOpPqrRsStuvWxXyZ$!%+>;_" /* characters for p_ww option: */ #define WW_ALL "bshl<>[],~" -- cgit From 0b88bf256d629cfe53c94896e140511e7f312b25 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 2 Jul 2017 13:46:41 +0200 Subject: doc: api.txt; deprecate --- src/nvim/api/vim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 8ab0c0ebda..2bc31b2812 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -141,7 +141,7 @@ Integer nvim_input(String keys) /// /// @param str String to be converted. /// @param from_part Legacy Vim parameter. Usually true. -/// @param do_lt Also translate . Does nothing if `special` is false. +/// @param do_lt Also translate . Ignored if `special` is false. /// @param special Replace |keycodes|, e.g. becomes a "\n" char. /// @see replace_termcodes /// @see cpoptions -- cgit From 829e1f2c43f84caa74c68e8a473d5faf8ec96c48 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 8 Jul 2017 16:17:21 +0200 Subject: lint --- src/nvim/getchar.c | 2 +- src/nvim/keymap.c | 2 +- src/nvim/option_defs.h | 58 +++++++++++++++++++++++++------------------------- 3 files changed, 31 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index adf0ff1e53..a22b716bb6 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -4197,7 +4197,7 @@ static char_u * translate_mapping ( } str += 2; } - if (IS_SPECIAL(c) || modifiers) { /* special key */ + if (IS_SPECIAL(c) || modifiers) { // special key if (expmap) { ga_clear(&ga); return NULL; diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index 295f246126..3d7ebb6382 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -817,7 +817,7 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len, while (src <= end) { // Check for special <> keycodes, like "" if (special && (do_lt || ((end - src) >= 3 - && STRNCMP(src, "", 4) != 0))) { + && STRNCMP(src, "", 4) != 0))) { // Replace by K_SNR _. // (room: 5 * 6 = 30 bytes; needed: 3 + + 1 <= 14) if (end - src >= 4 && STRNICMP(src, "", 5) == 0) { diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 95cdc902f8..a2fe90b3c2 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -81,45 +81,45 @@ #define DFLT_FO_VIM "tcqj" #define FO_ALL "tcroq2vlb1mMBn,awj" /* for do_set() */ -/* characters for the p_cpo option: */ -#define CPO_ALTREAD 'a' /* ":read" sets alternate file name */ -#define CPO_ALTWRITE 'A' /* ":write" sets alternate file name */ -#define CPO_BAR 'b' /* "\|" ends a mapping */ -#define CPO_BSLASH 'B' /* backslash in mapping is not special */ +// characters for the p_cpo option: +#define CPO_ALTREAD 'a' // ":read" sets alternate file name +#define CPO_ALTWRITE 'A' // ":write" sets alternate file name +#define CPO_BAR 'b' // "\|" ends a mapping +#define CPO_BSLASH 'B' // backslash in mapping is not special #define CPO_SEARCH 'c' -#define CPO_CONCAT 'C' /* Don't concatenate sourced lines */ -#define CPO_DOTTAG 'd' /* "./tags" in 'tags' is in current dir */ -#define CPO_DIGRAPH 'D' /* No digraph after "r", "f", etc. */ +#define CPO_CONCAT 'C' // Don't concatenate sourced lines +#define CPO_DOTTAG 'd' // "./tags" in 'tags' is in current dir +#define CPO_DIGRAPH 'D' // No digraph after "r", "f", etc. #define CPO_EXECBUF 'e' -#define CPO_EMPTYREGION 'E' /* operating on empty region is an error */ -#define CPO_FNAMER 'f' /* set file name for ":r file" */ -#define CPO_FNAMEW 'F' /* set file name for ":w file" */ -#define CPO_INTMOD 'i' /* interrupt a read makes buffer modified */ -#define CPO_INDENT 'I' /* remove auto-indent more often */ -#define CPO_ENDOFSENT 'J' /* need two spaces to detect end of sentence */ -#define CPO_KOFFSET 'K' /* don't wait for key code in mappings */ -#define CPO_LITERAL 'l' /* take char after backslash in [] literal */ -#define CPO_LISTWM 'L' /* 'list' changes wrapmargin */ +#define CPO_EMPTYREGION 'E' // operating on empty region is an error +#define CPO_FNAMER 'f' // set file name for ":r file" +#define CPO_FNAMEW 'F' // set file name for ":w file" +#define CPO_INTMOD 'i' // interrupt a read makes buffer modified +#define CPO_INDENT 'I' // remove auto-indent more often +#define CPO_ENDOFSENT 'J' // need two spaces to detect end of sentence +#define CPO_KOFFSET 'K' // don't wait for key code in mappings +#define CPO_LITERAL 'l' // take char after backslash in [] literal +#define CPO_LISTWM 'L' // 'list' changes wrapmargin #define CPO_SHOWMATCH 'm' -#define CPO_MATCHBSL 'M' /* "%" ignores use of backslashes */ -#define CPO_NUMCOL 'n' /* 'number' column also used for text */ +#define CPO_MATCHBSL 'M' // "%" ignores use of backslashes +#define CPO_NUMCOL 'n' // 'number' column also used for text #define CPO_LINEOFF 'o' -#define CPO_OVERNEW 'O' /* silently overwrite new file */ -#define CPO_LISP 'p' /* 'lisp' indenting */ -#define CPO_FNAMEAPP 'P' /* set file name for ":w >>file" */ -#define CPO_JOINCOL 'q' /* with "3J" use column after first join */ +#define CPO_OVERNEW 'O' // silently overwrite new file +#define CPO_LISP 'p' // 'lisp' indenting +#define CPO_FNAMEAPP 'P' // set file name for ":w >>file" +#define CPO_JOINCOL 'q' // with "3J" use column after first join #define CPO_REDO 'r' -#define CPO_REMMARK 'R' /* remove marks when filtering */ +#define CPO_REMMARK 'R' // remove marks when filtering #define CPO_BUFOPT 's' #define CPO_BUFOPTGLOB 'S' #define CPO_TAGPAT 't' -#define CPO_UNDO 'u' /* "u" undoes itself */ -#define CPO_BACKSPACE 'v' /* "v" keep deleted text */ -#define CPO_FWRITE 'W' /* "w!" doesn't overwrite readonly files */ +#define CPO_UNDO 'u' // "u" undoes itself +#define CPO_BACKSPACE 'v' // "v" keep deleted text +#define CPO_FWRITE 'W' // "w!" doesn't overwrite readonly files #define CPO_ESC 'x' -#define CPO_REPLCNT 'X' /* "R" with a count only deletes chars once */ +#define CPO_REPLCNT 'X' // "R" with a count only deletes chars once #define CPO_YANK 'y' -#define CPO_KEEPRO 'Z' /* don't reset 'readonly' on ":w!" */ +#define CPO_KEEPRO 'Z' // don't reset 'readonly' on ":w!" #define CPO_DOLLAR '$' #define CPO_FILTER '!' #define CPO_MATCH '%' -- cgit From 619838f85da24d692221ba7cc310d6839ebbe2a5 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Mon, 3 Jul 2017 09:36:43 +0200 Subject: inccommand: improve performance #6949 During a preview, we can stop looking for matches after we got enough lines for the preview buffer. Because of this perf improvement, the 'redrawtime' test needs to be slowed down in a different way: _long_ lines instead of just many lines. --- src/nvim/ex_cmds.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 8dcb3ac449..b550e9a9c6 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3332,7 +3332,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) // Check for a match on each line. linenr_T line2 = eap->line2; for (linenr_T lnum = eap->line1; - lnum <= line2 && !(got_quit || aborting()); + lnum <= line2 && !(got_quit || aborting()) + && (!preview || matched_lines.size <= (size_t)p_cwh); lnum++) { long nmatch = vim_regexec_multi(®match, curwin, curbuf, lnum, (colnr_T)0, NULL); -- cgit From 702c94aacfdca34b71eadf753c21b3d92d886cf0 Mon Sep 17 00:00:00 2001 From: Nikolai Aleksandrovich Pavlov Date: Sun, 9 Jul 2017 11:40:46 +0300 Subject: mbyte: Fix crash when using multibyte chars in maparg() return (#6986) This is a refactoring typo from #6947. Fixes #6985 Combined with #6947 where typo was made it also fixes vim/vim#1827 which was present in Neovim. --- src/nvim/mbyte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 5b00a4b9a8..2acfb896d8 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1780,7 +1780,7 @@ const char *mb_unescape(const char **const pp) // Return a multi-byte character if it's found. An illegal sequence // will result in a 1 here. if (utf_ptr2len((const char_u *)buf) > 1) { - *pp = (const char *)str + buf_idx + 1; + *pp = (const char *)str + str_idx + 1; return buf; } -- cgit From 68d2fb7570031cdd166722cbd7a50c41517004f2 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sun, 9 Jul 2017 18:48:32 +0100 Subject: tui: Improve the setrgbf/setrgbb fallback logic. The libvte test was too agressive, and is reduced to only triggering when it is libvte 0.36 AND a gnome or xterm terminal type is used. Contrastingly, tmux was not on the list at all and now is. --- src/nvim/tui/tui.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 499dffa18a..03dbb1a0e3 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1544,7 +1544,10 @@ static void augment_terminfo(TUIData *data, const char *term, bool teraterm = terminfo_is_term_family(term, "teraterm"); bool putty = terminfo_is_term_family(term, "putty"); bool screen = terminfo_is_term_family(term, "screen"); + bool tmux = terminfo_is_term_family(term, "tmux"); bool st = terminfo_is_term_family(term, "st"); + bool gnome = terminfo_is_term_family(term, "gnome") + || terminfo_is_term_family(term, "vte"); bool iterm = terminfo_is_term_family(term, "iterm") || terminfo_is_term_family(term, "iTerm.app"); // None of the following work over SSH; see :help TERM . @@ -1575,8 +1578,11 @@ static void augment_terminfo(TUIData *data, const char *term, // fixup. See https://gist.github.com/XVilka/8346728 for more about this. int Tc = unibi_find_ext_bool(ut, "Tc"); // "standard" means using colons like ISO 8613-6:1994/ITU T.416:1993 says. - bool has_standard_rgb = vte_version >= 3600 // per GNOME bug #685759 + bool has_standard_rgb = false + // per GNOME bug #685759 and bug #704449 + || ((gnome || xterm) && (vte_version >= 3600)) || iterm || iterm_pretending_xterm // per analysis of VT100Terminal.m + // per http://invisible-island.net/xterm/xterm.log.html#xterm_282 || true_xterm; bool has_non_standard_rgb = -1 != Tc // terminfo is definitive if it says something. @@ -1585,6 +1591,8 @@ static void augment_terminfo(TUIData *data, const char *term, || konsole // per commentary in VT102Emulation.cpp // per http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html || rxvt + || iterm // per https://gitlab.com/gnachman/iterm2/issues/218 + || tmux // per experimentation || st // per experimentation || old_truecolor_env; data->unibi_ext.set_rgb_foreground = unibi_find_ext_str(ut, "setrgbf"); -- cgit From 0a7e7e0ecfff2d9b261f964c0e79e6575d655218 Mon Sep 17 00:00:00 2001 From: Jonathan de Boyne Pollard Date: Sun, 9 Jul 2017 19:29:04 +0100 Subject: tui: Remove superflous iTerm2 test added in error. --- src/nvim/tui/tui.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 03dbb1a0e3..c6f4eff08f 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1591,7 +1591,6 @@ static void augment_terminfo(TUIData *data, const char *term, || konsole // per commentary in VT102Emulation.cpp // per http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html || rxvt - || iterm // per https://gitlab.com/gnachman/iterm2/issues/218 || tmux // per experimentation || st // per experimentation || old_truecolor_env; -- cgit From b4ccf5c20a41ea4d4bfeb636259553c8e55cb911 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Sun, 11 Jun 2017 18:35:16 +0900 Subject: vim-patch:7.4.2354 Problem: The example that explains nested backreferences does not work properly with the new regexp engine. (Harm te Hennepe) Solution: Also save the end position when adding a state. (closes vim/vim#990) https://github.com/vim/vim/commit/d563883a1fb5ec6cf4a2758c5e36ac1ff4e9bb3d --- src/nvim/regexp_nfa.c | 26 ++++++++++---------------- src/nvim/testdir/test_regexp_utf8.vim | 15 +++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 26 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 24c156d2ba..491693a371 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -3913,7 +3913,7 @@ addstate ( int k; int found = FALSE; nfa_thread_T *thread; - lpos_T save_lpos; + struct multipos save_multipos; int save_in_use; char_u *save_ptr; int i; @@ -4127,15 +4127,13 @@ skip_add: /* avoid compiler warnings */ save_ptr = NULL; - save_lpos.lnum = 0; - save_lpos.col = 0; + memset(&save_multipos, 0, sizeof(save_multipos)); /* Set the position (with "off" added) in the subexpression. Save * and restore it when it was in use. Otherwise fill any gap. */ if (REG_MULTI) { if (subidx < sub->in_use) { - save_lpos.lnum = sub->list.multi[subidx].start_lnum; - save_lpos.col = sub->list.multi[subidx].start_col; + save_multipos = sub->list.multi[subidx]; save_in_use = -1; } else { save_in_use = sub->in_use; @@ -4178,9 +4176,8 @@ skip_add: sub = &subs->norm; if (save_in_use == -1) { - if (REG_MULTI){ - sub->list.multi[subidx].start_lnum = save_lpos.lnum; - sub->list.multi[subidx].start_col = save_lpos.col; + if (REG_MULTI) { + sub->list.multi[subidx] = save_multipos; } else sub->list.line[subidx].start = save_ptr; @@ -4234,8 +4231,7 @@ skip_add: if (sub->in_use <= subidx) sub->in_use = subidx + 1; if (REG_MULTI) { - save_lpos.lnum = sub->list.multi[subidx].end_lnum; - save_lpos.col = sub->list.multi[subidx].end_col; + save_multipos = sub->list.multi[subidx]; if (off == -1) { sub->list.multi[subidx].end_lnum = reglnum + 1; sub->list.multi[subidx].end_col = 0; @@ -4249,9 +4245,8 @@ skip_add: } else { save_ptr = sub->list.line[subidx].end; sub->list.line[subidx].end = reginput + off; - /* avoid compiler warnings */ - save_lpos.lnum = 0; - save_lpos.col = 0; + // avoid compiler warnings + memset(&save_multipos, 0, sizeof(save_multipos)); } subs = addstate(l, state->out, subs, pim, off_arg); @@ -4261,9 +4256,8 @@ skip_add: else sub = &subs->norm; - if (REG_MULTI){ - sub->list.multi[subidx].end_lnum = save_lpos.lnum; - sub->list.multi[subidx].end_col = save_lpos.col; + if (REG_MULTI) { + sub->list.multi[subidx] = save_multipos; } else sub->list.line[subidx].end = save_ptr; diff --git a/src/nvim/testdir/test_regexp_utf8.vim b/src/nvim/testdir/test_regexp_utf8.vim index 7f3b31575d..a2f4286d4f 100644 --- a/src/nvim/testdir/test_regexp_utf8.vim +++ b/src/nvim/testdir/test_regexp_utf8.vim @@ -98,6 +98,21 @@ func Test_recursive_substitute() bwipe! endfunc +func Test_nested_backrefs() + " Check example in change.txt. + new + for re in range(0, 2) + exe 'set re=' . re + call setline(1, 'aa ab x') + 1s/\(\(a[a-d] \)*\)\(x\)/-\1- -\2- -\3-/ + call assert_equal('-aa ab - -ab - -x-', getline(1)) + + call assert_equal('-aa ab - -ab - -x-', substitute('aa ab x', '\(\(a[a-d] \)*\)\(x\)', '-\1- -\2- -\3-', '')) + endfor + bwipe! + set re=0 +endfunc + func Test_eow_with_optional() let expected = ['abc def', 'abc', 'def', '', '', '', '', '', '', ''] for re in range(0, 2) diff --git a/src/nvim/version.c b/src/nvim/version.c index 094ca29b01..0713684303 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -90,7 +90,7 @@ static const int included_patches[] = { 2357, 2356, 2355, - // 2354, + 2354, 2353, // 2352 NA // 2351 NA -- cgit From 04de6a64e2f7b3b235acd4ab779bfed30e59451f Mon Sep 17 00:00:00 2001 From: ckelsel Date: Fri, 7 Jul 2017 14:57:50 +0800 Subject: vim-patch:7.4.2189 https://github.com/vim/vim/commit/f71d7b9ee5ceba75f70c30845332ddd728fd16c6 Author: Bram Moolenaar Date: Tue Aug 9 22:14:05 2016 +0200 patch 7.4.2189 Problem: Cannot detect encoding in a fifo. Solution: Extend the stdin way of detecting encoding to fifo. Add a test for detecting encoding on stdin and fifo. (Ken Takata) --- src/nvim/buffer.c | 114 +++++++++++++++++++++++---------- src/nvim/fileio.c | 14 ++-- src/nvim/fileio.h | 3 +- src/nvim/testdir/Makefile | 2 + src/nvim/testdir/test_startup.vim | 2 +- src/nvim/testdir/test_startup_utf8.vim | 64 ++++++++++++++++++ src/nvim/version.c | 2 +- 7 files changed, 158 insertions(+), 43 deletions(-) create mode 100644 src/nvim/testdir/test_startup_utf8.vim (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index b5ca6543c5..504be8dde6 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -91,6 +91,54 @@ static char *e_auabort = N_("E855: Autocommands caused command to abort"); // Number of times free_buffer() was called. static int buf_free_count = 0; +/* Read data from buffer for retrying. */ +static int +read_buffer( + int read_stdin, /* read file from stdin, otherwise fifo */ + exarg_T *eap, /* for forced 'ff' and 'fenc' or NULL */ + int flags) /* extra flags for readfile() */ +{ + int retval = OK; + linenr_T line_count; + + /* + * Read from the buffer which the text is already filled in and append at + * the end. This makes it possible to retry when 'fileformat' or + * 'fileencoding' was guessed wrong. + */ + line_count = curbuf->b_ml.ml_line_count; + retval = readfile( + read_stdin ? NULL : curbuf->b_ffname, + read_stdin ? NULL : curbuf->b_fname, + (linenr_T)line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap, + flags | READ_BUFFER); + if (retval == OK) { + /* Delete the binary lines. */ + while (--line_count >= 0) + ml_delete((linenr_T)1, FALSE); + } else { + /* Delete the converted lines. */ + while (curbuf->b_ml.ml_line_count > line_count) + ml_delete(line_count, FALSE); + } + /* Put the cursor on the first line. */ + curwin->w_cursor.lnum = 1; + curwin->w_cursor.col = 0; + + if (read_stdin) { + /* Set or reset 'modified' before executing autocommands, so that + * it can be changed there. */ + if (!readonlymode && !bufempty()) + changed(); + else if (retval != FAIL) + unchanged(curbuf, FALSE); + + apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE, + curbuf, &retval); + } + return retval; +} + /* * Open current buffer, that is: open the memfile and read the file into * memory. @@ -106,6 +154,7 @@ open_buffer ( int retval = OK; bufref_T old_curbuf; long old_tw = curbuf->b_p_tw; + int read_fifo = FALSE; /* * The 'readonly' flag is only set when BF_NEVERLOADED is being reset. @@ -156,13 +205,37 @@ open_buffer ( if (curbuf->b_ffname != NULL) { int old_msg_silent = msg_silent; +#ifdef UNIX + int save_bin = curbuf->b_p_bin; + int perm; + + perm = os_getperm((const char *)curbuf->b_ffname); + if (perm >= 0 && (0 +# ifdef S_ISFIFO + || S_ISFIFO(perm) +# endif +# ifdef S_ISSOCK + || S_ISSOCK(perm) +# endif + )) + read_fifo = TRUE; + if (read_fifo) + curbuf->b_p_bin = TRUE; +#endif if (shortmess(SHM_FILEINFO)) { msg_silent = 1; } retval = readfile(curbuf->b_ffname, curbuf->b_fname, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, eap, - flags | READ_NEW); + flags | READ_NEW | (read_fifo ? READ_FIFO : 0)); +#ifdef UNIX + if (read_fifo) { + curbuf->b_p_bin = save_bin; + if (retval == OK) + retval = read_buffer(FALSE, eap, flags); + } +#endif msg_silent = old_msg_silent; // Help buffer is filtered. @@ -170,8 +243,7 @@ open_buffer ( fix_help_buffer(); } } else if (read_stdin) { - int save_bin = curbuf->b_p_bin; - linenr_T line_count; + int save_bin = curbuf->b_p_bin; /* * First read the text in binary mode into the buffer. @@ -184,37 +256,9 @@ open_buffer ( (linenr_T)0, (linenr_T)MAXLNUM, NULL, flags | (READ_NEW + READ_STDIN)); curbuf->b_p_bin = save_bin; - if (retval == OK) { - line_count = curbuf->b_ml.ml_line_count; - retval = readfile(NULL, NULL, (linenr_T)line_count, - (linenr_T)0, (linenr_T)MAXLNUM, eap, - flags | READ_BUFFER); - if (retval == OK) { - /* Delete the binary lines. */ - while (--line_count >= 0) - ml_delete((linenr_T)1, FALSE); - } else { - /* Delete the converted lines. */ - while (curbuf->b_ml.ml_line_count > line_count) - ml_delete(line_count, FALSE); - } - /* Put the cursor on the first line. */ - curwin->w_cursor.lnum = 1; - curwin->w_cursor.col = 0; - - // Set or reset 'modified' before executing autocommands, so that - // it can be changed there. - if (!readonlymode && !bufempty()) { - changed(); - } else if (retval == OK) { - unchanged(curbuf, false); - } - - if (retval == OK) { - apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, false, - curbuf, &retval); - } - } + if (retval == OK) + retval = read_buffer(TRUE, eap, flags); + } /* if first time loading this buffer, init b_chartab[] */ @@ -234,7 +278,7 @@ open_buffer ( || modified_was_set // ":set modified" used in autocmd || (aborting() && vim_strchr(p_cpo, CPO_INTMOD) != NULL)) { changed(); - } else if (retval == OK && !read_stdin) { + } else if (retval != FAIL && !read_stdin && !read_fifo) { unchanged(curbuf, false); } save_file_ff(curbuf); // keep this fileformat diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index be4188c4df..dcef09e21f 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -247,6 +247,7 @@ void filemess(buf_T *buf, char_u *name, char_u *s, int attr) * stdin) * READ_DUMMY read into a dummy buffer (to check if file contents changed) * READ_KEEP_UNDO don't clear undo info or read it from a file + * READ_FIFO read from fifo/socket instead of a file * * return FAIL for failure, NOTDONE for directory (failure), or OK */ @@ -267,6 +268,7 @@ readfile ( int filtering = (flags & READ_FILTER); int read_stdin = (flags & READ_STDIN); int read_buffer = (flags & READ_BUFFER); + int read_fifo = (flags & READ_FIFO); int set_options = newfile || read_buffer || (eap != NULL && eap->read_edit); linenr_T read_buf_lnum = 1; /* next line to read from curbuf */ @@ -426,7 +428,7 @@ readfile ( } } - if (!read_buffer && !read_stdin) { + if (!read_buffer && !read_stdin && !read_fifo) { perm = os_getperm((const char *)fname); #ifdef UNIX // On Unix it is possible to read a directory, so we have to @@ -468,7 +470,7 @@ readfile ( if (check_readonly && !readonlymode) curbuf->b_p_ro = FALSE; - if (newfile && !read_stdin && !read_buffer) { + if (newfile && !read_stdin && !read_buffer && !read_fifo) { /* Remember time of file. */ FileInfo file_info; if (os_fileinfo((char *)fname, &file_info)) { @@ -895,6 +897,7 @@ retry: * and we can't do it internally or with iconv(). */ if (fio_flags == 0 && !read_stdin && !read_buffer && *p_ccv != NUL + && !read_fifo # ifdef USE_ICONV && iconv_fd == (iconv_t)-1 # endif @@ -935,7 +938,7 @@ retry: /* Set "can_retry" when it's possible to rewind the file and try with * another "fenc" value. It's FALSE when no other "fenc" to try, reading * stdin or fixed at a specific encoding. */ - can_retry = (*fenc != NUL && !read_stdin && !keep_dest_enc); + can_retry = (*fenc != NUL && !read_stdin && !keep_dest_enc && !read_fifo); if (!skip_read) { linerest = 0; @@ -947,6 +950,7 @@ retry: && curbuf->b_ffname != NULL && curbuf->b_p_udf && !filtering + && !read_fifo && !read_stdin && !read_buffer); if (read_undo_file) @@ -1919,7 +1923,7 @@ failed: u_read_undo(NULL, hash, fname); } - if (!read_stdin && !read_buffer) { + if (!read_stdin && !read_fifo && (!read_buffer || sfname != NULL)) { int m = msg_scroll; int n = msg_scrolled; @@ -1937,7 +1941,7 @@ failed: if (filtering) { apply_autocmds_exarg(EVENT_FILTERREADPOST, NULL, sfname, false, curbuf, eap); - } else if (newfile) { + } else if (newfile || (read_buffer && sfname != NULL)) { apply_autocmds_exarg(EVENT_BUFREADPOST, NULL, sfname, false, curbuf, eap); if (!au_did_filetype && *curbuf->b_p_ft != NUL) { diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h index 426dc0fcb3..05dd0fa2c3 100644 --- a/src/nvim/fileio.h +++ b/src/nvim/fileio.h @@ -10,7 +10,8 @@ #define READ_STDIN 0x04 /* read from stdin */ #define READ_BUFFER 0x08 /* read from curbuf (converting stdin) */ #define READ_DUMMY 0x10 /* reading into a dummy buffer */ -#define READ_KEEP_UNDO 0x20 /* keep undo info*/ +#define READ_KEEP_UNDO 0x20 /* keep undo info */ +#define READ_FIFO 0x40 /* read from fifo or socket */ #define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y)) diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 7e55fffa06..510e8820f4 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -62,6 +62,8 @@ NEW_TESTS ?= \ test_signs.res \ test_smartindent.res \ test_stat.res \ + test_startup.res \ + test_startup_utf8.res \ test_substitute.res \ test_syntax.res \ test_tabpage.res \ diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 5996b2cd4a..64f7f31294 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -75,7 +75,7 @@ func Test_help_arg() " check if couple of lines are there let found = [] for line in lines - if line =~ '-R.*Readonly mode' + if line =~ '-R.*Read-only mode' call add(found, 'Readonly mode') endif " Watch out for a second --version line in the Gnome version. diff --git a/src/nvim/testdir/test_startup_utf8.vim b/src/nvim/testdir/test_startup_utf8.vim new file mode 100644 index 0000000000..d179a4cc79 --- /dev/null +++ b/src/nvim/testdir/test_startup_utf8.vim @@ -0,0 +1,64 @@ +" Tests for startup using utf-8. +if !has('multi_byte') + finish +endif + +source shared.vim + +func Test_read_stdin_utf8() + let linesin = ['テスト', '€ÀÈÌÒÙ'] + call writefile(linesin, 'Xtestin') + let before = [ + \ 'set enc=utf-8', + \ 'set fencs=cp932,utf-8', + \ ] + let after = [ + \ 'write ++enc=utf-8 Xtestout', + \ 'quit!', + \ ] + if has('win32') + let pipecmd = 'type Xtestin | ' + else + let pipecmd = 'cat Xtestin | ' + endif + if RunVimPiped(before, after, '-', pipecmd) + let lines = readfile('Xtestout') + call assert_equal(linesin, lines) + else + call assert_equal('', 'RunVimPiped failed.') + endif + call delete('Xtestout') + call delete('Xtestin') +endfunc + +func Test_read_fifo_utf8() + if !has('unix') + return + endif + " Using bash/zsh's process substitution. + if executable('bash') + set shell=bash + elseif executable('zsh') + set shell=zsh + else + return + endif + let linesin = ['テスト', '€ÀÈÌÒÙ'] + call writefile(linesin, 'Xtestin') + let before = [ + \ 'set enc=utf-8', + \ 'set fencs=cp932,utf-8', + \ ] + let after = [ + \ 'write ++enc=utf-8 Xtestout', + \ 'quit!', + \ ] + if RunVim(before, after, '<(cat Xtestin)') + let lines = readfile('Xtestout') + call assert_equal(linesin, lines) + else + call assert_equal('', 'RunVim failed.') + endif + call delete('Xtestout') + call delete('Xtestin') +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 0713684303..ec4a804f2e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -255,7 +255,7 @@ static const int included_patches[] = { // 2192 NA // 2191 NA 2190, - // 2189, + 2189, 2188, 2187, // 2186 NA -- cgit From 2999d7c0e89087f76711e914eb65af55578a6691 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Mon, 10 Jul 2017 07:58:40 +0800 Subject: vim-patch:7.4.2229 https://github.com/vim/vim/commit/f04507d132fbcb63999167ec006fc6e700b5af4f Author: Bram Moolenaar Date: Sat Aug 20 15:05:39 2016 +0200 patch 7.4.2229 Problem: Startup test fails on Solaris. Solution: Recognize a character device. (Danek Duvall) --- src/nvim/buffer.c | 3 +++ src/nvim/fileio.c | 2 +- src/nvim/version.c | 2 +- src/nvim/vim.h | 4 ++++ 4 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 504be8dde6..1534af478f 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -216,6 +216,9 @@ open_buffer ( # endif # ifdef S_ISSOCK || S_ISSOCK(perm) +# endif +# ifdef OPEN_CHR_FILES + || (S_ISCHR(perm) && is_dev_fd_file(curbuf->b_ffname)) # endif )) read_fifo = TRUE; diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index dcef09e21f..41117fdd3d 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -1974,7 +1974,7 @@ failed: /// Do not accept "/dev/fd/[012]", opening these may hang Vim. /// /// @param fname file name to check -static bool is_dev_fd_file(char_u *fname) +bool is_dev_fd_file(char_u *fname) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { return STRNCMP(fname, "/dev/fd/", 8) == 0 diff --git a/src/nvim/version.c b/src/nvim/version.c index ec4a804f2e..09ee23e58f 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -215,7 +215,7 @@ static const int included_patches[] = { // 2232 NA 2231, 2230, - // 2229, + 2229, 2228, 2227, 2226, diff --git a/src/nvim/vim.h b/src/nvim/vim.h index f29ccdd296..5d2c27a2f4 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -319,4 +319,8 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() // Lowest number used for window ID. Cannot have this many windows per tab. #define LOWEST_WIN_ID 1000 +#if defined(__FreeBSD__) && defined(S_ISCHR) +# define OPEN_CHR_FILES +#endif + #endif /* NVIM_VIM_H */ -- cgit From 462a6148a64f2c2faabdee1eacac273ddbbd095a Mon Sep 17 00:00:00 2001 From: ckelsel Date: Tue, 11 Jul 2017 09:07:18 +0800 Subject: lint --- src/nvim/buffer.c | 86 ++++++++++++++++++++++++++++++------------------------- src/nvim/fileio.c | 4 +-- src/nvim/fileio.h | 16 +++++------ 3 files changed, 57 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 1534af478f..90a564bb6a 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -91,21 +91,21 @@ static char *e_auabort = N_("E855: Autocommands caused command to abort"); // Number of times free_buffer() was called. static int buf_free_count = 0; -/* Read data from buffer for retrying. */ +// Read data from buffer for retrying. static int read_buffer( - int read_stdin, /* read file from stdin, otherwise fifo */ - exarg_T *eap, /* for forced 'ff' and 'fenc' or NULL */ - int flags) /* extra flags for readfile() */ + int read_stdin, // read file from stdin, otherwise fifo + exarg_T *eap, // for forced 'ff' and 'fenc' or NULL + int flags) // extra flags for readfile() { int retval = OK; linenr_T line_count; - /* - * Read from the buffer which the text is already filled in and append at - * the end. This makes it possible to retry when 'fileformat' or - * 'fileencoding' was guessed wrong. - */ + // + // Read from the buffer which the text is already filled in and append at + // the end. This makes it possible to retry when 'fileformat' or + // 'fileencoding' was guessed wrong. + // line_count = curbuf->b_ml.ml_line_count; retval = readfile( read_stdin ? NULL : curbuf->b_ffname, @@ -113,27 +113,30 @@ read_buffer( (linenr_T)line_count, (linenr_T)0, (linenr_T)MAXLNUM, eap, flags | READ_BUFFER); if (retval == OK) { - /* Delete the binary lines. */ - while (--line_count >= 0) - ml_delete((linenr_T)1, FALSE); + // Delete the binary lines. + while (--line_count >= 0) { + ml_delete((linenr_T)1, false); + } } else { - /* Delete the converted lines. */ - while (curbuf->b_ml.ml_line_count > line_count) - ml_delete(line_count, FALSE); + // Delete the converted lines. + while (curbuf->b_ml.ml_line_count > line_count) { + ml_delete(line_count, false); + } } - /* Put the cursor on the first line. */ + // Put the cursor on the first line. curwin->w_cursor.lnum = 1; curwin->w_cursor.col = 0; if (read_stdin) { - /* Set or reset 'modified' before executing autocommands, so that - * it can be changed there. */ - if (!readonlymode && !bufempty()) + // Set or reset 'modified' before executing autocommands, so that + // it can be changed there. + if (!readonlymode && !bufempty()) { changed(); - else if (retval != FAIL) - unchanged(curbuf, FALSE); + } else if (retval != FAIL) { + unchanged(curbuf, false); + } - apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, FALSE, + apply_autocmds_retval(EVENT_STDINREADPOST, NULL, NULL, false, curbuf, &retval); } return retval; @@ -154,7 +157,7 @@ open_buffer ( int retval = OK; bufref_T old_curbuf; long old_tw = curbuf->b_p_tw; - int read_fifo = FALSE; + int read_fifo = false; /* * The 'readonly' flag is only set when BF_NEVERLOADED is being reset. @@ -212,18 +215,22 @@ open_buffer ( perm = os_getperm((const char *)curbuf->b_ffname); if (perm >= 0 && (0 # ifdef S_ISFIFO - || S_ISFIFO(perm) + || S_ISFIFO(perm) # endif # ifdef S_ISSOCK - || S_ISSOCK(perm) + || S_ISSOCK(perm) # endif # ifdef OPEN_CHR_FILES - || (S_ISCHR(perm) && is_dev_fd_file(curbuf->b_ffname)) + || (S_ISCHR(perm) + && is_dev_fd_file(curbuf->b_ffname)) # endif - )) - read_fifo = TRUE; - if (read_fifo) - curbuf->b_p_bin = TRUE; + ) + ) { + read_fifo = true; + } + if (read_fifo) { + curbuf->b_p_bin = true; + } #endif if (shortmess(SHM_FILEINFO)) { msg_silent = 1; @@ -235,8 +242,9 @@ open_buffer ( #ifdef UNIX if (read_fifo) { curbuf->b_p_bin = save_bin; - if (retval == OK) - retval = read_buffer(FALSE, eap, flags); + if (retval == OK) { + retval = read_buffer(false, eap, flags); + } } #endif msg_silent = old_msg_silent; @@ -246,7 +254,7 @@ open_buffer ( fix_help_buffer(); } } else if (read_stdin) { - int save_bin = curbuf->b_p_bin; + int save_bin = curbuf->b_p_bin; /* * First read the text in binary mode into the buffer. @@ -259,14 +267,14 @@ open_buffer ( (linenr_T)0, (linenr_T)MAXLNUM, NULL, flags | (READ_NEW + READ_STDIN)); curbuf->b_p_bin = save_bin; - if (retval == OK) - retval = read_buffer(TRUE, eap, flags); - + if (retval == OK) { + retval = read_buffer(true, eap, flags); + } } /* if first time loading this buffer, init b_chartab[] */ if (curbuf->b_flags & BF_NEVERLOADED) { - (void)buf_init_chartab(curbuf, FALSE); + (void)buf_init_chartab(curbuf, false); parse_cino(curbuf); } @@ -463,8 +471,8 @@ void close_buffer(win_T *win, buf_T *buf, int action, int abort_if_last) return; } - /* When the buffer becomes hidden, but is not unloaded, trigger - * BufHidden */ + // When the buffer becomes hidden, but is not unloaded, trigger + // BufHidden if (!unload_buf) { buf->b_locked++; if (apply_autocmds(EVENT_BUFHIDDEN, buf->b_fname, buf->b_fname, false, diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 41117fdd3d..a0536d456d 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -268,7 +268,7 @@ readfile ( int filtering = (flags & READ_FILTER); int read_stdin = (flags & READ_STDIN); int read_buffer = (flags & READ_BUFFER); - int read_fifo = (flags & READ_FIFO); + int read_fifo = (flags & READ_FIFO); int set_options = newfile || read_buffer || (eap != NULL && eap->read_edit); linenr_T read_buf_lnum = 1; /* next line to read from curbuf */ @@ -471,7 +471,7 @@ readfile ( curbuf->b_p_ro = FALSE; if (newfile && !read_stdin && !read_buffer && !read_fifo) { - /* Remember time of file. */ + // Remember time of file. FileInfo file_info; if (os_fileinfo((char *)fname, &file_info)) { buf_store_file_info(curbuf, &file_info); diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h index 05dd0fa2c3..8db4b89806 100644 --- a/src/nvim/fileio.h +++ b/src/nvim/fileio.h @@ -4,14 +4,14 @@ #include "nvim/buffer_defs.h" #include "nvim/os/os.h" -/* Values for readfile() flags */ -#define READ_NEW 0x01 /* read a file into a new buffer */ -#define READ_FILTER 0x02 /* read filter output */ -#define READ_STDIN 0x04 /* read from stdin */ -#define READ_BUFFER 0x08 /* read from curbuf (converting stdin) */ -#define READ_DUMMY 0x10 /* reading into a dummy buffer */ -#define READ_KEEP_UNDO 0x20 /* keep undo info */ -#define READ_FIFO 0x40 /* read from fifo or socket */ +// Values for readfile() flags +#define READ_NEW 0x01 // read a file into a new buffer +#define READ_FILTER 0x02 // read filter output +#define READ_STDIN 0x04 // read from stdin +#define READ_BUFFER 0x08 // read from curbuf (converting stdin) +#define READ_DUMMY 0x10 // reading into a dummy buffer +#define READ_KEEP_UNDO 0x20 // keep undo info +#define READ_FIFO 0x40 // read from fifo or socket #define READ_STRING(x, y) (char_u *)read_string((x), (size_t)(y)) -- cgit From c805f2cf54aa4ab066bb9e7f3d5b7cc40d04004e Mon Sep 17 00:00:00 2001 From: ckelsel Date: Mon, 10 Jul 2017 08:55:54 +0800 Subject: vim-patch:7.4.2250 Problem: Some error message cannot be translated. Solution: Enclose them in _() and N_(). (Dominique Pelle) https://github.com/vim/vim/commit/5b30291785e6b9be1a607504c14bd03c601b59a6 --- src/nvim/eval.c | 4 ++-- src/nvim/ex_cmds.c | 4 ++-- src/nvim/spell.c | 2 +- src/nvim/version.c | 2 +- src/nvim/window.c | 12 ++++++------ 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 7e9c006f33..e5bb7f1b38 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12451,7 +12451,7 @@ static void f_matchadd(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } if (id >= 1 && id <= 3) { - EMSGN("E798: ID is reserved for \":match\": %" PRId64, id); + EMSGN(_("E798: ID is reserved for \":match\": %" PRId64), id); return; } @@ -12508,7 +12508,7 @@ static void f_matchaddpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) // id == 3 is ok because matchaddpos() is supposed to substitute :3match if (id == 1 || id == 2) { - EMSGN("E798: ID is reserved for \"match\": %" PRId64, id); + EMSGN(_("E798: ID is reserved for \"match\": %" PRId64), id); return; } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index b550e9a9c6..a534a476df 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -5024,7 +5024,7 @@ static void helptags_one(char_u *dir, char_u *ext, char_u *tagfname, EW_FILE|EW_SILENT) == FAIL || filecount == 0) { if (!got_int) - EMSG2("E151: No match: %s", NameBuff); + EMSG2(_("E151: No match: %s"), NameBuff); return; } @@ -5223,7 +5223,7 @@ static void do_helptags(char_u *dirname, bool add_help_tags) if (gen_expand_wildcards(1, buff_list, &filecount, &files, EW_FILE|EW_SILENT) == FAIL || filecount == 0) { - EMSG2("E151: No match: %s", NameBuff); + EMSG2(_("E151: No match: %s"), NameBuff); xfree(dirname); return; } diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 715228cb4b..42c9bcc0ee 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2068,7 +2068,7 @@ char_u *did_set_spelllang(win_T *wp) // destroying the buffer we are using... if (!bufref_valid(&bufref)) { ret_msg = - (char_u *)"E797: SpellFileMissing autocommand deleted buffer"; + (char_u *)N_("E797: SpellFileMissing autocommand deleted buffer"); goto theend; } } diff --git a/src/nvim/version.c b/src/nvim/version.c index 0713684303..a1a06f0e7c 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -194,7 +194,7 @@ static const int included_patches[] = { // 2253 NA // 2252 NA 2251, - // 2250, + 2250, 2249, 2248, // 2247 NA diff --git a/src/nvim/window.c b/src/nvim/window.c index 43af2e5e4f..079e0647e1 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5532,8 +5532,8 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, return -1; } if (id < -1 || id == 0) { - EMSGN("E799: Invalid ID: %" PRId64 - " (must be greater than or equal to 1)", + EMSGN(_("E799: Invalid ID: %" PRId64 + " (must be greater than or equal to 1)"), id); return -1; } @@ -5541,7 +5541,7 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, cur = wp->w_match_head; while (cur != NULL) { if (cur->id == id) { - EMSGN("E801: ID already taken: %" PRId64, id); + EMSGN(_("E801: ID already taken: %" PRId64), id); return -1; } cur = cur->next; @@ -5706,8 +5706,8 @@ int match_delete(win_T *wp, int id, int perr) if (id < 1) { if (perr == TRUE) - EMSGN("E802: Invalid ID: %" PRId64 - " (must be greater than or equal to 1)", + EMSGN(_("E802: Invalid ID: %" PRId64 + " (must be greater than or equal to 1)"), id); return -1; } @@ -5717,7 +5717,7 @@ int match_delete(win_T *wp, int id, int perr) } if (cur == NULL) { if (perr == TRUE) - EMSGN("E803: ID not found: %" PRId64, id); + EMSGN(_("E803: ID not found: %" PRId64), id); return -1; } if (cur == prev) -- cgit From 06f4b963222efd2a986e79b7390b50d6e42941be Mon Sep 17 00:00:00 2001 From: ckelsel Date: Tue, 11 Jul 2017 08:27:05 +0800 Subject: lint --- src/nvim/ex_cmds.c | 3 ++- src/nvim/window.c | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index a534a476df..0987cb3915 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -5023,8 +5023,9 @@ static void helptags_one(char_u *dir, char_u *ext, char_u *tagfname, if (gen_expand_wildcards(1, buff_list, &filecount, &files, EW_FILE|EW_SILENT) == FAIL || filecount == 0) { - if (!got_int) + if (!got_int) { EMSG2(_("E151: No match: %s"), NameBuff); + } return; } diff --git a/src/nvim/window.c b/src/nvim/window.c index 079e0647e1..29f5412ba0 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5533,7 +5533,7 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, } if (id < -1 || id == 0) { EMSGN(_("E799: Invalid ID: %" PRId64 - " (must be greater than or equal to 1)"), + " (must be greater than or equal to 1)"), id); return -1; } @@ -5705,10 +5705,11 @@ int match_delete(win_T *wp, int id, int perr) int rtype = SOME_VALID; if (id < 1) { - if (perr == TRUE) + if (perr) { EMSGN(_("E802: Invalid ID: %" PRId64 - " (must be greater than or equal to 1)"), + " (must be greater than or equal to 1)"), id); + } return -1; } while (cur != NULL && cur->id != id) { @@ -5716,8 +5717,9 @@ int match_delete(win_T *wp, int id, int perr) cur = cur->next; } if (cur == NULL) { - if (perr == TRUE) + if (perr) { EMSGN(_("E803: ID not found: %" PRId64), id); + } return -1; } if (cur == prev) -- cgit From 06ec15121a4da439684cfa1909d920c3f22f2894 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 8 Apr 2017 22:50:50 -0400 Subject: Bump Vim version to 8.0 and applied patches --- src/nvim/version.c | 2860 +++++++++++----------------------------------------- src/nvim/version.h | 8 +- 2 files changed, 576 insertions(+), 2292 deletions(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 5f83dd1fd0..75b09bcee7 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -77,2372 +77,656 @@ static char *features[] = { // clang-format off static const int included_patches[] = { - // 2367,NA - // 2366 NA - // 2365 NA - // 2364,NA - // 2363 NA - 2362, - // 2361 NA - 2360, - 2359, - // 2358 NA - 2357, - 2356, - 2355, - 2354, - 2353, - // 2352 NA - // 2351 NA - // 2350, - 2349, - 2348, - 2347, - 2346, - // 2345 NA - // 2344 NA - 2343, - // 2342 NA - 2341, - // 2340 NA - 2339, - // 2338 NA - 2337, - 2336, - 2335, - 2334, - 2333, - 2332, - 2331, - 2330, - 2329, - 2328, - // 2327 NA - 2326, - // 2325 NA - 2324, - 2323, - 2322, - 2321, - 2320, - // 2319 NA - 2318, - 2317, - // 2316 NA - 2315, - 2314, - 2313, - 2312, - // 2311 NA - // 2310 NA - 2309, - // 2308 NA - 2307, - 2306, - 2305, - 2304, - 2303, - // 2302 NA - // 2301 NA - 2300, - 2299, - // 2298 NA - // 2297 NA - 2296, - 2295, - 2294, - 2293, - 2292, - 2291, - // 2290 NA - // 2289 NA - // 2288 NA - // 2287 NA - // 2286 NA - // 2285 NA - 2284, - 2283, - // 2282 NA - 2281, - 2280, - 2279, - // 2278 NA - 2277, - 2276, - 2275, - 2274, - 2273, - 2272, - // 2271 NA - // 2270 NA - 2269, - 2268, - // 2267 NA - 2266, - 2265, - 2264, - 2263, - // 2262 NA - // 2261 NA - // 2260 NA - 2259, - // 2258 NA - // 2257 NA - 2256, - 2255, - // 2254 NA - // 2253 NA - // 2252 NA - 2251, - 2250, - 2249, - 2248, - // 2247 NA - 2246, - 2245, - 2244, - // 2243 NA - 2242, - 2241, - 2240, - 2239, - // 2238 NA - 2237, - 2236, - 2235, - // 2234 NA - 2233, - // 2232 NA - 2231, - 2230, - 2229, - 2228, - 2227, - 2226, - 2225, - 2224, - 2223, - 2222, - 2221, - 2220, - 2219, - // 2218 NA - 2217, - // 2216 NA - 2215, - // 2214 NA - 2213, - 2212, - // 2211 NA - // 2210 NA - 2209, - 2208, - // 2207 NA - // 2206 NA - 2205, - 2204, - // 2203 NA - // 2202 NA - 2201, - 2200, - // 2199 NA - // 2198 NA - 2197, - 2196, - // 2195 NA - 2194, - // 2193 NA - // 2192 NA - // 2191 NA - 2190, - 2189, - 2188, - 2187, - // 2186 NA - 2185, - 2184, - 2183, - // 2182 NA - // 2181 NA - 2180, - 2179, - 2178, - 2177, - // 2176 NA - 2175, - 2174, - 2173, - 2172, - // 2171 NA - 2170, - 2169, - // 2168 NA - // 2167 NA - // 2166 NA - 2165, - 2164, - 2163, - 2162, - 2161, - 2160, - 2159, - 2158, - // 2157 NA - // 2156 NA - // 2155 NA - // 2154 NA - // 2153 NA - 2152, - 2151, - // 2150 NA - 2149, - 2148, - 2147, - 2146, - // 2145 NA - 2144, - 2143, - 2142, - 2141, - // 2140 NA - 2139, - // 2138 NA - 2137, - 2136, - 2135, - 2134, - // 2133 NA - // 2132 NA - // 2131 NA - // 2130 NA - // 2129 NA - 2128, - 2127, - 2126, - // 2125 NA - 2124, - 2123, - // 2122 NA - 2121, - 2120, - 2119, - // 2118 NA - 2117, - // 2116 NA - // 2115 NA - // 2114 NA - 2113, - 2112, - // 2111 NA - 2110, - 2109, - // 2108 NA - 2107, - 2106, - // 2105 NA - 2104, - 2103, - // 2102 NA - 2101, - 2100, - 2099, - 2098, - 2097, - 2096, - 2095, - // 2094 NA - // 2093 NA - // 2092 NA - // 2091 NA - 2090, - // 2089 NA - 2088, - 2087, - 2086, - 2085, - 2084, - // 2083 NA - 2082, - 2081, - // 2080 NA - // 2079 NA - // 2078 NA - 2077, - 2076, - 2075, - 2074, - // 2073 NA - 2072, - 2071, - // 2070 NA - 2069, - 2068, - 2067, - 2066, - 2065, - 2064, - // 2063 NA - 2062, - 2061, - // 2060 NA - // 2059 NA - // 2058 NA - // 2057 NA - // 2056 NA - // 2055 NA - // 2054 NA - // 2053 NA - // 2052 NA - 2051, - 2050, - 2049, - // 2048 NA - 2047, - 2046, - // 2045 NA - 2044, - 2043, - // 2042 NA - // 2041 NA - // 2040 NA - // 2039 NA - // 2038 NA - // 2037 NA - 2036, - // 2035 NA - // 2034 NA - 2033, - // 2032 NA - 2031, - // 2030 NA - 2029, - 2028, - // 2027 NA - // 2026 NA - // 2025 NA - 2024, - 2023, - 2022, - 2021, - // 2020 NA - 2019, - 2018, - 2017, - // 2016 NA - 2015, - 2014, - 2013, - 2012, - 2011, - 2010, - 2009, - 2008, - 2007, - 2006, - 2005, - // 2004 NA - // 2003 NA - 2002, - // 2001 NA - 2000, - 1999, - // 1998 NA - 1997, - 1996, - // 1995 NA - 1994, - 1993, - 1992, - 1991, - 1990, - 1989, - // 1988 NA - // 1987 NA - 1986, - // 1985 NA - 1984, - // 1983 NA - // 1982 NA - 1981, - 1980, - 1979, - 1978, - 1977, - 1976, - 1975, - // 1974 NA - 1973, - // 1972 NA - 1971, - 1970, - // 1969 NA - 1968, - 1967, - 1966, - // 1965 NA - 1964, - // 1963 NA - 1962, - 1961, - 1960, - // 1959 NA - // 1958 NA - // 1957 NA - 1956, - // 1955 NA - 1954, - 1953, - 1952, - // 1951 NA - 1950, - 1949, - 1948, - // 1947 NA - // 1946 NA - // 1945 NA - // 1944 NA - // 1943 NA - // 1942 NA - 1941, - 1940, - // 1939 NA - // 1938 NA - 1937, - // 1936 NA - // 1935 NA - // 1934 NA - // 1933 NA - // 1932 NA - // 1931 NA - // 1930 NA - // 1929 NA - 1928, - // 1927 NA - // 1926 NA - 1925, - // 1924 NA - 1923, - // 1922 NA - // 1921 NA - // 1920 NA - // 1919 NA - // 1918 NA - // 1917 NA - // 1916 NA - // 1915 NA - // 1914 NA - 1913, - 1912, - // 1911 NA - 1910, - 1909, - // 1908 NA - // 1907 NA - // 1906 NA - // 1905 NA - // 1904 NA - // 1903 NA - // 1902 NA - // 1901 NA - 1900, - // 1899 NA - 1898, - 1897, - 1896, - 1895, - 1894, - 1893, - 1892, - // 1891 NA - // 1890 NA - 1889, - // 1888 NA - // 1887 NA - // 1886 NA - // 1885 NA - 1884, - // 1883 NA - 1882, - 1881, - // 1880 NA - // 1879 NA - // 1878 NA - // 1877 NA - 1876, - 1875, - // 1874 NA - // 1873 NA - // 1872 NA - 1871, - // 1870 NA - // 1869 NA - 1868, - 1867, - 1866, - // 1865 NA - // 1864 NA - // 1863 NA - // 1862 NA - 1861, - 1860, - // 1859 NA - // 1858 NA - // 1857 NA - // 1856 NA - // 1855 NA - // 1854 NA - // 1853 NA - // 1852 NA - 1851, - // 1850 NA - // 1849 NA - // 1848 NA - 1847, - // 1846 NA - // 1845 NA - // 1844 NA - // 1843 NA - 1842, - 1841, - 1840, - 1839, - 1838, - 1837, - 1836, - 1835, - 1834, - 1833, - 1832, - 1831, - // 1830 NA - // 1829 NA - // 1828 NA - // 1827 NA - // 1826 NA - // 1825 NA - // 1824 NA - 1823, - // 1822 NA - 1821, - 1820, - // 1819 NA - 1818, - // 1817 NA - 1816, - 1815, - // 1814 NA - 1813, - // 1812 NA - // 1811 NA - // 1810 NA - 1809, - 1808, - // 1807 NA - 1806, - // 1805 NA - // 1804 NA - // 1803 NA - 1802, - // 1801 NA - // 1800 NA - 1799, - // 1798 NA - // 1797 NA - // 1796 NA - // 1795 NA - // 1794 NA - 1793, - // 1792 NA - // 1791 NA - // 1790 NA - // 1789 NA - // 1789 NA - // 1788 NA - // 1787 NA - // 1786 NA - 1785, - // 1784 NA - 1783, - 1782, - 1781, - 1780, - 1779, - // 1778 NA - // 1777 NA - // 1776 NA - // 1775 NA - // 1774 NA - // 1773 NA - // 1772 NA - // 1771 NA - // 1770 NA - // 1769 NA - 1768, - // 1767 NA - // 1766 NA - 1765, - // 1764 NA - 1763, - // 1762 NA - // 1761 NA - // 1760 NA - 1759, - 1758, - 1757, - // 1756 NA - 1755, - 1754, - 1753, - 1752, - 1751, - // 1750 NA - // 1749 NA - 1748, - // 1747 NA - // 1746 NA - // 1745 NA - // 1744 NA - // 1743 NA - 1742, - 1741, - 1740, - 1739, - 1738, - // 1737 NA - // 1736 NA - 1735, - 1734, - // 1733 NA - 1732, - // 1731 NA - 1730, - // 1729 NA - 1728, - 1727, - // 1726 NA - // 1725 NA - // 1724 NA - 1723, - // 1722 NA - // 1721 NA - // 1720 NA - 1719, - 1718, - // 1717 NA - 1716, - 1715, - 1714, - // 1713 NA - 1712, - 1711, - // 1710 NA - // 1709 NA - 1708, - 1707, - // 1706 NA - // 1705 NA - 1704, - 1703, - 1702, - 1701, - 1700, - 1699, - // 1698 NA - 1697, - 1696, - 1695, - // 1694 NA - // 1693 NA - 1692, - 1691, - // 1690 NA - // 1689 NA - // 1688 NA - // 1687 NA - 1686, - 1685, - // 1684 NA - // 1683 NA - 1682, - 1681, - // 1680 NA - 1679, - // 1678 NA - // 1677 NA - 1676, - 1675, - // 1674 NA - 1673, - // 1672 NA - 1671, - 1670, - // 1669 NA - // 1668 NA - // 1667 NA - // 1666 NA - // 1665 NA - 1664, - 1663, - // 1662 NA - // 1661 NA - 1660, - // 1659 NA - 1658, - // 1657 NA - 1656, - // 1655 NA - 1654, - // 1653 NA - 1652, - // 1651 NA - 1650, - 1649, - 1648, - 1647, - // 1646 NA - 1645, - // 1644 NA - 1643, - 1642, - 1641, - 1640, - 1639, - 1638, - // 1637 NA - // 1636 NA - // 1635 NA - 1634, - // 1633 NA - // 1632 NA - // 1631 NA - 1630, - 1629, - // 1628 NA - // 1627 NA - // 1626 NA - // 1625 NA - // 1624 NA - // 1623 NA - // 1622 NA - // 1621 NA - 1620, - 1619, - // 1618 NA - // 1617 NA - // 1616 NA - // 1615 NA - 1614, - // 1613 NA - // 1612 NA - // 1611 NA - // 1610 NA - // 1609 NA - 1608, - 1607, - 1606, - 1605, - 1604, - 1603, - // 1602 NA - // 1601 NA - // 1600 NA - // 1599 NA - // 1598 NA - // 1597 NA - 1596, - // 1595 NA - // 1594 NA - // 1593 NA - 1592, - 1591, - 1590, - 1589, - 1588, - // 1587 NA - 1586, - 1585, - // 1584 NA - // 1583 NA - 1582, - 1581, - 1580, - // 1579 NA - 1578, - 1577, - 1576, - // 1575 NA - 1574, - // 1573 NA - // 1572 NA - 1571, - 1570, - 1569, - 1568, - 1567, - // 1566 NA - 1565, - 1564, - 1563, - // 1562 NA - // 1561 NA - // 1560 NA - 1559, - 1558, - 1557, - // 1556 NA - // 1555 NA - 1554, - 1553, - 1552, - 1551, - 1550, - 1549, - 1548, - 1547, - 1546, - // 1545 NA - // 1544 NA - // 1543 NA - // 1542 NA - // 1541 NA - // 1540 NA - // 1539 NA - // 1538 NA - // 1537 NA - // 1536 NA - 1535, - // 1534 NA - 1533, - // 1532 NA - // 1531 NA - // 1530 NA - // 1529 NA - 1528, - // 1527 NA - // 1526 NA - // 1525 NA - // 1524 NA - // 1523 NA - // 1522 NA - 1521, - // 1520 NA - // 1519 NA - // 1518 NA - // 1517 NA - 1516, - // 1515 NA - // 1514 NA - 1513, - // 1512 NA - 1511, - // 1510 NA - // 1509 NA - // 1508 NA - // 1507 NA - // 1506 NA - // 1505 NA - // 1504 NA - // 1503 NA - // 1502 NA - // 1501 NA - 1500, - 1499, - // 1498 NA - // 1497 NA - // 1496 NA - // 1495 NA - 1494, - // 1493 NA - 1492, - 1491, - // 1490 NA - // 1489 NA - // 1488 NA - // 1487 NA - 1486, - // 1485 NA - // 1484 NA - // 1483 NA - // 1482 NA - // 1481 NA - 1480, - 1479, - 1478, - 1477, - // 1476 NA - // 1475 NA - // 1474 NA - // 1473 NA - // 1472 NA - // 1471 NA - // 1470 NA - // 1469 NA - 1468, - // 1467 NA - // 1466 NA - // 1465 NA - 1464, - // 1463 NA - // 1462 NA - // 1461 NA - // 1460 NA - // 1459 NA - // 1458 NA - // 1457 NA - // 1456 NA - // 1455 NA - // 1454 NA - // 1453 NA - // 1452 NA - // 1451 NA - // 1450 NA - // 1449 NA - // 1448 NA - // 1447 NA - // 1446 NA - // 1445 NA - // 1444 NA - // 1443 NA - // 1442 NA - // 1441 NA - // 1440 NA - // 1439 NA - // 1438 NA - // 1437 NA - // 1436 NA - // 1435 NA - // 1434 NA - // 1433 NA - // 1432 NA - // 1431 NA - // 1430 NA - // 1429 NA - // 1428 NA - // 1427 NA - // 1426 NA - 1425, - // 1424 NA - // 1423 NA - // 1422 NA - // 1421 NA - // 1420 NA - // 1419 NA - // 1418 NA - // 1417 NA - // 1416 NA - // 1415 NA - // 1414 NA - // 1413 NA - // 1412 NA - // 1411 NA - 1410, - // 1409 NA - // 1408 NA - // 1407 NA - 1406, - 1405, - // 1404 NA - // 1403 NA - // 1402 NA - 1401, - // 1400 NA - // 1399 NA - // 1398 NA - 1397, - 1396, - // 1395 NA - 1394, - // 1393 NA - // 1392 NA - // 1391 NA - // 1390 NA - // 1389 NA - 1388, - // 1387 NA - // 1386 NA - // 1385 NA - 1384, - // 1383 NA - // 1382 NA - // 1381 NA - // 1380 NA - // 1379 NA - // 1378 NA - // 1377 NA - // 1376 NA - // 1375 NA - // 1374 NA - // 1373 NA - // 1372 NA - // 1371 NA - // 1370 NA - // 1369 NA - // 1368 NA - // 1367 NA - 1366, - 1365, - // 1364 NA - // 1363 NA - // 1362 NA - // 1361 NA - // 1360 NA - // 1359 NA - // 1358 NA - // 1357 NA - // 1356 NA - // 1355 NA - // 1354 NA - // 1353 NA - 1352, - // 1351 NA - // 1350 NA - // 1349 NA - // 1348 NA - 1347, - 1346, - // 1345 NA - // 1344 NA - // 1343 NA - // 1342 NA - // 1341 NA - // 1340 NA - // 1339 NA - // 1338 NA - // 1337 NA - // 1336 NA - // 1335 NA - // 1334 NA - // 1333 NA - // 1332 NA - // 1331 NA - // 1330 NA - // 1329 NA - // 1328 NA - // 1327 NA - // 1326 NA - // 1325 NA - // 1324 NA - // 1323 NA - // 1322 NA - // 1321 NA - // 1320 NA - // 1319 NA - // 1318 NA - // 1317 NA - // 1316 NA - // 1315 NA - // 1314 NA - // 1313 NA - // 1312 NA - // 1311 NA - // 1310 NA - 1309, - // 1308 NA - // 1307 NA - // 1306 NA - 1305, - 1304, - // 1303 NA - // 1302 NA - // 1301 NA - // 1300 NA - // 1299 NA - // 1298 NA - // 1297 NA - 1296, - // 1295 NA - // 1294 NA - // 1293 NA - 1292, - // 1291 NA - // 1290 NA - // 1289 NA - // 1288 NA - // 1287 NA - // 1286 NA - 1285, - 1284, - // 1283 NA - 1282, - 1281, - // 1280 NA - // 1279 NA - // 1278 NA - // 1277 NA - 1276, - // 1275 NA - // 1274 NA - // 1273 NA - // 1272 NA - 1271, - // 1270 NA - 1269, - // 1268 NA - 1267, - 1266, - // 1265 NA - // 1264 NA - // 1263 NA - // 1262 NA - // 1261 NA - // 1260 NA - 1259, - // 1258 NA - // 1257 NA - // 1256 NA - // 1255 NA - // 1254 NA - // 1253 NA - // 1252 NA - // 1251 NA - // 1250 NA - // 1249 NA - // 1248 NA - // 1247 NA - // 1246 NA - // 1245 NA - // 1244 NA - // 1243 NA - // 1242 NA - // 1241 NA - // 1240 NA - // 1239 NA - // 1238 NA - 1237, - 1236, - // 1235 NA - // 1234 NA - // 1233 NA - // 1232 NA - // 1231 NA - // 1230 NA - // 1229 NA - 1228, - // 1227 NA - // 1226 NA - // 1225 NA - // 1224 NA - 1223, - // 1222 NA - // 1221 NA - // 1220 NA - // 1219 NA - // 1218 NA - // 1217 NA - // 1216 NA - // 1215 NA - // 1214 NA - // 1213 NA - // 1212 NA - // 1211 NA - // 1210 NA - // 1209 NA - // 1208 NA - // 1207 NA - // 1206 NA - // 1205 NA - // 1204 NA - // 1203 NA - // 1202 NA - // 1201 NA - // 1200 NA - // 1199 NA - // 1198 NA - // 1197 NA - // 1196 NA - // 1195 NA - // 1194 NA - // 1193 NA - // 1192 NA - // 1191 NA - // 1190 NA - // 1189 NA - // 1188 NA - // 1187 NA - // 1186 NA - // 1185 NA - // 1184 NA - // 1183 NA - // 1182 NA - 1181, - 1180, - 1179, - 1178, - // 1177 NA - // 1176 NA - // 1175 NA - // 1174 NA - 1173, - // 1172 NA - // 1171 NA - // 1170 NA - // 1169 NA - 1168, - 1167, - 1166, - // 1165 NA - 1164, - 1163, - // 1162 NA - 1161, - 1160, - // 1159 NA - // 1158 NA - 1157, - // 1156 NA - // 1155 NA - // 1154 NA - 1153, - // 1152 NA - 1151, - 1150, - 1149, - // 1148 NA - 1147, - // 1146 NA - // 1145 NA - 1144, - 1143, - 1142, - 1141, - 1140, - // 1139 NA - // 1138 NA - 1137, - 1136, - // 1135 NA - // 1134 NA - // 1133 NA - 1132, - // 1131 NA - // 1130 NA - // 1129 NA - // 1128 NA - // 1127 NA - 1126, - // 1125 NA - // 1124 NA - 1123, - // 1122 NA - 1121, - 1120, - 1119, - 1118, - 1117, - 1116, - // 1115 NA - 1114, - 1113, - 1112, - 1111, - 1110, - // 1109 NA - 1108, - 1107, - // 1106 NA - 1105, - // 1104 NA - // 1103 NA - 1102, - 1101, - // 1100 NA - // 1099 NA - // 1098 NA - // 1097 NA - 1096, - // 1095 NA - 1094, - 1093, - 1092, - 1091, - 1090, - 1089, - 1088, - 1087, - 1086, - 1085, - 1084, - // 1083 NA - // 1082 NA - 1081, - // 1080 NA - // 1079 NA - // 1078 NA - // 1077 NA - 1076, - 1075, - // 1074 NA - // 1073 NA - 1072, - 1071, - // 1070 NA - // 1069 NA - 1068, - // 1067 NA - // 1066 NA - 1065, - 1064, - // 1063 NA - // 1062 NA - 1061, - // 1060 NA - 1059, - // 1058 NA - 1057, - 1056, - 1055, - 1054, - 1053, - 1052, - 1051, - 1050, - 1049, - 1048, - 1047, - 1046, - // 1045 NA - // 1044 NA - // 1043 NA - 1042, - 1041, - // 1040 NA - // 1039 NA - // 1038 NA - 1037, - 1036, - 1035, - 1034, - // 1033 NA - 1032, - // 1031 NA - 1030, - 1029, - // 1028 NA - 1027, - // 1026 NA - // 1025 NA - // 1024 NA - // 1023 NA - // 1022 NA - // 1021 NA - // 1020 NA - // 1019 NA - 1018, - 1017, - // 1016 NA - 1015, - // 1014 NA - 1013, - // 1012 NA - // 1011 NA - // 1010 NA - // 1009 NA - // 1008 NA - 1007, - 1006, - // 1005 NA - // 1004 NA - // 1003 NA - // 1002 NA - 1001, - 1000, - // 999 NA - 998, - // 997 NA - // 996 NA - // 995 NA - // 994 NA - // 993 NA - // 992 NA - 991, - // 990 NA - 989, - // 988 NA - // 987 NA - // 986 NA - // 985 NA - 984, - // 983 NA - // 982 NA - 981, - 980, - // 979 NA - 978, - 977, - // 976 NA - 975, - 974, - 973, - 972, - // 971 NA - // 970 NA - // 969 NA - // 968 NA - // 967 NA - // 966 NA - // 965 NA - // 964 NA - 963, - // 962 NA - 961, - // 960 NA - // 959 NA - 958, - 957, - // 956 NA - 955, - // 954 NA - 953, - 952, - 951, - 950, - 949, - // 948 NA - // 947 NA - 946, - 945, - 944, - // 943 NA - 942, - 941, - // 940 NA - 939, - // 938 NA - 937, - 936, - // 935 NA - // 934 NA - 933, - 932, - // 931 NA - // 930 NA - 929, - // 928 NA - // 927 NA - 926, - 925, - // 924 NA - // 923 NA - 922, - // 921 NA - // 920 NA - // 919 NA - // 918 NA - // 917 NA - 916, - 915, - // 914 NA - // 913 NA - 912, - // 911 NA - // 910 NA - // 909 NA - // 908 NA - // 907 NA - // 906 NA - // 905 NA - 904, - 903, - // 902 NA - 901, - // 900 NA - // 899 NA - 898, - // 897 NA - 896, - 895, - // 894 NA - 893, - // 892 NA - 891, - // 890 NA - 889, - 888, - 887, - // 886 NA - 885, - // 884 NA - 883, - 882, - 881, - // 880 NA - 879, - 878, - 877, - // 876 NA - // 875 NA - // 874 NA - // 873 NA - // 872 NA - 871, - 870, - // 869 NA - 868, - // 867 NA - // 866 NA - // 865 NA - // 864 NA - // 863 NA - // 862 NA - // 861 NA - // 860 NA - 859, - 858, - 857, - 856, - // 855 NA - // 854 NA - 853, - // 852 NA - // 851 NA - // 850 NA - 849, - 848, - 847, - // 846 NA - 845, - 844, - 843, - // 842 NA - // 841 NA - // 840 NA - // 839 NA - // 838 NA - // 837 NA - 836, - 835, - 834, - 833, - 832, - 831, - 830, - // 829 NA - 828, - // 827 NA - 826, - 825, - // 824 NA - 823, - 822, - // 821 NA - 820, - 819, - 818, - 817, - 816, - 815, - 814, - 813, - // 812 NA - 811, - 810, - 809, - // 808 NA - 807, - 806, - 805, - // 804 NA - 803, - 802, - 801, - 800, - 799, - 798, - // 797 NA - // 796 NA - 795, - // 794 NA - 793, - 792, - 791, - 790, - 789, - // 788 NA - 787, - 786, - 785, - 784, - // 783 NA - 782, - 781, - 780, - 779, - 778, - // 777 NA - 776, - 775, - 774, - 773, - // 772 NA - 771, - // 770 NA - 769, - 768, - // 767 NA - // 766 NA - 765, - 764, - // 763 NA - // 762 NA - // 761 NA - 760, - // 759 NA - 758, - // 757 NA - // 756 NA - 755, - 754, - 753, - // 752 NA - // 751 NA - // 750 NA - 749, - 748, - 747, - 746, - 745, - // 744 NA - 743, - 742, - 741, - 740, - 739, - // 738 NA - 737, - 736, - // 735 NA - 734, - // 733 NA - 732, - // 731 NA - // 730 NA - 729, - // 728 NA - // 727 NA - // 726 NA - // 725 NA - // 724 NA - 723, - 722, - 721, - // 720 NA - 719, - 718, - 717, - 716, - 715, - 714, - 713, - 712, - 711, - 710, - 709, - 708, - 707, - 706, - // 705 NA - 704, - // 703 NA - 702, - // 701 NA - 700, - 699, - 698, - 697, - 696, - 695, - 694, - 693, - // 692 NA - // 691 NA - 690, - 689, - 688, - // 687 NA - 686, - 685, - // 684 NA - // 683 NA - 682, - // 681 NA - 680, - // 679 NA - // 678 NA - // 677 NA - // 676 NA - 675, - // 674 NA - 673, - 672, - 671, - 670, - // 669 NA - 668, - 667, - // 666 NA - 665, - // 664 NA - // 663 NA - 662, - // 661 NA - 660, - 659, - 658, - // 657 NA - 656, - 655, - 654, - 653, - // 652 NA - 651, - // 650 NA - 649, - // 648 NA - // 647 NA - 646, - 645, - // 644 NA - 643, - 642, - // 641 NA - 640, - 639, - // 638 NA - 637, - 636, - 635, - 634, - 633, - // 632 NA - 631, - 630, - 629, - // 628 NA - // 627 NA - // 626 NA - // 625 NA - // 624 NA - 623, - // 622 NA - // 621 NA - // 620 NA - // 619 NA - // 618 NA - 617, - 616, - 615, + 652, + // 651, + // 650, + // 649, + // 648, + // 647, + // 646, + // 645, + // 644, + // 643, + // 642, + // 641, + // 640, + // 639, + // 638, + // 637, + // 636, + // 635, + // 634, + // 633, + // 632, + // 631, + // 630, + // 629, + // 628, + // 627, + // 626, + // 625, + // 624, + // 623, + // 622, + // 621, + // 620, + // 619, + 618, + // 617, + // 616, + // 615, 614, - 613, - 612, - // 611 NA - // 610 NA - 609, - 608, - // 607 NA - 606, + // 613, + // 612, + // 611, + // 610, + // 609, + // 608, + 607, + // 606, 605, - 604, - 603, - 602, - 601, - 600, - 599, - 598, - 597, - // 596 NA - 595, - 594, - 593, - // 592 NA - // 591 NA - 590, - // 589 NA - 588, - 587, - // 586 NA - 585, - // 584 NA - // 583 NA - 582, - // 581 NA - 580, - 579, - 578, - 577, - 576, - 575, - 574, - 573, - 572, - // 571 NA - // 570 NA - 569, - 568, - 567, - 566, - 565, - // 564 NA - 563, - 562, + // 604, + // 603, + // 602, + // 601, + // 600, + // 599, + // 598, + // 597, + // 596, + // 595, + // 594, + // 593, + // 592, + // 591, + // 590, + // 589, + // 588, + // 587, + // 586, + // 585, + // 584, + // 583, + // 582, + // 581, + // 580, + // 579, + // 578, + // 577, + // 576, + // 575, + // 574, + // 573, + // 572, + 571, + // 570, + // 569, + // 568, + // 567, + // 566, + // 565, + // 564, + // 563, + // 562, 561, - // 560 NA - 559, - // 558 NA - // 557 NA - // 556 NA - // 555 NA + // 560, + // 559, + // 558, + // 557, + // 556, + 555, 554, 553, 552, - 551, + // 551, 550, - 549, - // 548 NA - 547, - 546, - 545, - // 544 NA - 543, - 542, - 541, - // 540 NA - 539, - 538, - 537, - 536, - 535, - // 534 NA - 533, - 532, - 531, - 530, - 529, - 528, - 527, - 526, - 525, - 524, - // 523 NA - // 522 NA - 521, - 520, - 519, - 518, - 517, - 516, - 515, - 514, - 513, - // 512 NA - // 511 NA - // 510 NA - // 509 NA - 508, - // 507 NA - // 506 NA - // 505 NA - // 504 NA - 503, + // 549, + // 548, + // 547, + // 546, + // 545, + // 544, + // 543, + // 542, + // 541, + // 540, + // 539, + // 538, + // 537, + // 536, + // 535, + // 534, + // 533, + // 532, + // 531, + // 530, + // 529, + // 528, + // 527, + // 526, + // 525, + // 524, + // 523, + // 522, + // 521, + // 520, + // 519, + // 518, + // 517, + // 516, + // 515, + // 514, + // 513, + // 512, + // 511, + // 510, + // 509, + // 508, + // 507, + // 506, + // 505, + // 504, + // 503, 502, - // 501 NA - 500, + // 501, + // 500, 499, - // 498 NA - 497, - // 496 NA - // 495 NA - 494, - 493, - 492, - 491, - 490, - 489, - 488, + // 498, + // 497, + // 496, + // 495, + // 494, + // 493, + // 492, + // 491, + // 490, + // 489, + // 488, 487, 486, 485, - // 484 NA + // 484, 483, - // 482 NA - // 481 NA - // 480 NA - // 479 NA + 482, + // 481, + // 480, + // 479, 478, 477, - // 476 NA - // 475 NA - 474, - 473, - 472, - // 471 NA - 470, - // 469 NA - 468, - 467, - 466, - // 465 NA - // 464 NA - 463, - 462, - // 461 NA - // 460 NA - // 459 NA - 458, + // 476, + // 475, + // 474, + // 473, + // 472, + // 471, + // 470, + // 469, + // 468, + // 467, + // 466, + 465, + // 464, + // 463, + // 462, + 461, + // 460, + 459, + // 458, 457, - 456, - 455, - 454, - // 453 NA - 452, - // 451 NA - 450, - 449, - // 448 NA - 447, - 446, - 445, - 444, - // 443 NA - 442, - 441, - 440, - 439, - 438, - 437, - 436, - 435, - 434, - 433, - // 432 NA - // 431 NA - // 430 NA - // 429 NA - // 428 NA - 427, - // 426 NA - 425, - // 424 NA - 423, - 422, - 421, - // 420 NA - 419, - 418, - 417, - 416, - 415, - 414, - // 413 NA - // 412 NA - 411, - 410, - // 409 NA + // 456, + // 455, + // 454, + 453, + // 452, + // 451, + // 450, + // 449, + // 448, + // 447, + // 446, + // 445, + // 444, + // 443, + // 442, + // 441, + // 440, + // 439, + // 438, + // 437, + // 436, + // 435, + // 434, + // 433, + // 432, + // 431, + // 430, + // 429, + // 428, + // 427, + // 426, + // 425, + // 424, + // 423, + // 422, + // 421, + // 420, + // 419, + // 418, + // 417, + // 416, + // 415, + // 414, + // 413, + // 412, + // 411, + // 410, + // 409, 408, 407, - 406, + // 406, 405, - // 404 NA - // 403 NA - // 402 NA - // 401 NA - // 400 NA - // 399 NA - // 398 NA - 397, - 396, - 395, - // 394 NA - // 393 NA - 392, - 391, + // 404, + // 403, + // 402, + // 401, + 400, + // 399, + // 398, + // 397, + // 396, + // 395, + // 394, + 393, + // 392, + // 391, 390, - 389, + // 389, 388, - 387, - 386, - // 385 NA - // 384 NA - 383, - 382, - 381, - // 380 NA - 379, + // 387, + // 386, + // 385, + // 384, + // 383, + // 382, + // 381, + // 380, + // 379, 378, 377, 376, - 375, - 374, - 373, - 372, - 371, - 370, - 369, - 368, - 367, - // 366 NA - 365, - 364, - // 363 NA - 362, - 361, + // 375, + // 374, + // 373, + // 372, + // 371, + // 370, + // 369, + // 368, + // 367, + // 366, + // 365, + // 364, + // 363, + // 362, + // 361, 360, - 359, - 358, - 357, - // 356 NA - 355, - // 354 NA + // 359, + // 358, + // 357, + // 356, + // 355, + // 354, 353, - 352, - 351, - 350, - 349, - 348, + // 352, + // 351, + // 350, + // 349, + // 348, 347, - 346, + // 346, 345, - 344, + // 344, 343, - // 342 NA + // 342, 341, - // 340 NA - 339, - 338, - 337, - 336, - 335, - 334, - // 333 NA - // 332 NA + // 340, + // 339, + // 338, + // 337, + // 336, + // 335, + // 334, + // 333, + // 332, 331, - 330, - 329, - 328, - 327, - // 326 NA - 325, - 324, - 323, - // 322 NA - // 321 NA - 320, - // 319 NA - 318, - 317, - // 316 NA - 315, - 314, - 313, - 312, - 311, - 310, - 309, - 308, - // 307 NA - 306, - 305, - // 304 NA - 303, - 302, - 301, - // 300 NA - // 299 NA - 298, + // 330, + // 329, + // 328, + // 327, + // 326, + // 325, + // 324, + // 323, + 322, + // 321, + // 320, + 319, + // 318, + // 317, + // 316, + // 315, + // 314, + // 313, + // 312, + // 311, + // 310, + // 309, + // 308, + 307, + // 306, + // 305, + // 304, + // 303, + // 302, + // 301, + // 300, + // 299, + // 298, 297, - 296, - 295, - 294, - 293, - 292, - 291, - 290, - 289, - 288, - // 287 NA - 286, - 285, - 284, - // 283 NA - 282, - 281, + // 296, + // 295, + // 294, + // 293, + // 292, + // 291, + // 290, + // 289, + // 288, + // 287, + // 286, + // 285, + // 284, + // 283, + // 282, + // 281, 280, - 279, - 278, - 277, - 276, + // 279, + // 278, + // 277, + // 276, 275, 274, - // 273 NA - 272, - // 271 NA - // 270 NA - 269, - 268, - 267, + // 273, + // 272, + // 271, + // 270, + // 269, + // 268, + // 267, 266, - 265, - 264, - // 263 NA - 262, - 261, - 260, - // 259 NA - // 258 NA - // 257 NA - 256, - // 255 NA - // 254 NA - 253, - // 252 NA - 251, - // 250 NA - 249, - 248, - 247, - // 246 NA - 245, - // 244 NA + // 265, + // 264, + // 263, + // 262, + // 261, + // 260, + 259, + // 258, + // 257, + // 256, + // 255, + // 254, + // 253, + // 252, + // 251, + 250, + // 249, + // 248, + // 247, + // 246, + // 245, + // 244, 243, - 242, - 241, - 240, - 239, - // 238 NA - 237, - 236, - 235, - 234, - 233, - 232, - 231, - 230, + // 242, + // 241, + // 240, + // 239, + // 238, + // 237, + // 236, + // 235, + // 234, + // 233, + // 232, + // 231, + // 230, 229, - // 228 NA - // 227 NA - 226, - // 225 NA - // 224 NA - // 223 NA - // 222 NA - 221, - 220, + // 228, + // 227, + // 226, + // 225, + // 224, + 223, + // 222, + // 221, + // 220, 219, - 218, - // 217 NA - // 216 NA - 215, - // 214 NA - 213, - // 212 NA - 211, - 210, - 209, - // 208 NA - 207, - // 206 NA + // 218, + // 217, + // 216, + // 215, + // 214, + // 213, + // 212, + // 211, + // 210, + // 209, + 208, + // 207, + // 206, 205, - 204, - 203, - // 202 NA - 201, - // 200 NA - 199, - // 198 NA - // 197 NA - // 196 NA - // 195 NA - // 194 NA - 193, - 192, - 191, - // 190 NA - // 189 NA - // 188 NA - 187, - 186, - // 185 NA - 184, - // 183 NA - // 182 NA - 181, - // 180 NA - // 179 NA + // 204, + // 203, + // 202, + // 201, + // 200, + // 199, + // 198, + // 197, + // 196, + 195, + // 194, + // 193, + // 192, + // 191, + 190, + // 189, + // 188, + // 187, + // 186, + // 185, + // 184, + // 183, + // 182, + // 181, + // 180, + 179, 178, - // 177 NA - // 176 NA - // 175 NA - // 174 NA - 173, + 177, + 176, + // 175, + // 174, + // 173, 172, - 171, - 170, - 169, - // 168 NA + // 171, + // 170, + // 169, + 168, 167, - 166, - 165, - // 164 NA - // 163 NA - // 162 NA - // 161 NA - 160, + // 166, + // 165, + // 164, + // 163, + // 162, + // 161, + // 160, 159, 158, - 157, + // 157, 156, - 155, - 154, - 153, - 152, - 151, + // 155, + // 154, + // 153, + // 152, + // 151, 150, - 149, - 148, - 147, - 146, - 145, - 144, - 143, - 142, - 141, - 140, - 139, - 138, - 137, + // 149, + // 148, + // 147, + // 146, + // 145, + // 144, + // 143, + // 142, + // 141, + // 140, + // 139, + // 138, + // 137, 136, 135, - 134, - 133, - 132, - 131, - 130, - 129, - 128, + // 134, + // 133, + // 132, + // 131, + // 130, + // 129, + // 128, 127, - 126, - 125, - 124, - 123, - 122, + // 126, + // 125, + // 124, + // 123, + // 122, 121, - 120, - 119, - 118, - 117, + // 120, + // 119, + // 118, + // 117, 116, - 115, - 114, - 113, - 112, - 111, + // 115, + // 114, + // 113, + // 112, + // 111, 110, - 109, - 108, - 107, - 106, + // 109, + // 108, + // 107, + // 106, 105, - 104, - 103, - 102, - 101, - 100, + // 104, + // 103, + // 102, + // 101, + // 100, 99, - 98, - 97, - 96, - 95, - 94, - 93, - 92, - 91, - 90, - 89, - 88, - 87, - 86, - 85, - 84, + // 98, + // 97, + // 96, + // 95, + // 94, + // 93, + // 92, + // 91, + // 90, + // 89, + // 88, + // 87, + // 86, + // 85, + // 84, 83, - 82, - 81, - 80, - 79, - 78, - 77, - 76, - 75, - 74, - 73, - 72, - 71, - 70, - 69, + // 82, + // 81, + // 80, + // 79, + // 78, + // 77, + // 76, + // 75, + // 74, + // 73, + // 72, + // 71, + // 70, + // 69, 68, - 67, + // 67, 66, - 65, + // 65, 64, - 63, - 62, - 61, + // 63, + // 62, + // 61, 60, - 59, + // 59, 58, 57, 56, - 55, - 54, + // 55, + // 54, 53, - 52, - 51, + // 52, + // 51, 50, 49, - 48, + // 48, 47, - 46, - 45, - 44, + // 46, + // 45, + // 44, 43, 42, 41, 40, - 39, - 38, + // 39, + // 38, 37, - 36, + // 36, 35, - 34, + // 34, 33, 32, - 31, - 30, - 29, - 28, - 27, - 26, - 25, - 24, - 23, - 22, - 21, - 20, + // 31, + // 30, + // 29, + // 28, + // 27, + // 26, + // 25, + // 24, + // 23, + // 22, + // 21, + // 20, 19, - 18, - 17, - 16, - 15, - 14, - 13, - 12, - 11, - 10, - 9, + // 18, + // 17, + // 16, + // 15, + // 14, + // 13, + // 12, + // 11, + // 10, + // 9, 8, - 7, + // 7, 6, - 5, - 4, - 3, + // 5, + // 4, + // 3, 2, 1, 0 diff --git a/src/nvim/version.h b/src/nvim/version.h index a0babfb156..c10f6fa534 100644 --- a/src/nvim/version.h +++ b/src/nvim/version.h @@ -10,14 +10,14 @@ extern char* longVersion; // // Vim version number, name, etc. Patchlevel is defined in version.c. // -#define VIM_VERSION_MAJOR 7 -#define VIM_VERSION_MINOR 4 +#define VIM_VERSION_MAJOR 8 +#define VIM_VERSION_MINOR 0 #define VIM_VERSION_100 (VIM_VERSION_MAJOR * 100 + VIM_VERSION_MINOR) // used for the runtime directory name -#define VIM_VERSION_NODOT "vim74" +#define VIM_VERSION_NODOT "vim80" // swap file compatibility (max. length is 6 chars) -#define VIM_VERSION_SHORT "7.4" +#define VIM_VERSION_SHORT "8.0" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "version.h.generated.h" -- cgit From 08e4b6b4f377aa3cc9f9fd10c0049783dc1f4a94 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 22 Apr 2017 21:38:58 -0400 Subject: version.c: Mark NA patches - Netbeans: 0005, 0024, 0213 - Vim-specific documentation: 0007 - Vim CI/buildsystem: 0009, 0077, 0080, 0082, 0093, 0115, 0117, 0129, 0130, 0144, 0145, 0203, 0239, 0240, 0249, 0257, 0272, 0279 - +cryptv: 0010, 0014 - Channel support: 0011, 0013, 0015, 0016, 0022, 0027, 0036, 0076, 0097, 0103, 0105, 0107, 0108, 0120, 0122, 0152, 0267, 0284 - Timer implementation: 0028, 0098 - Removing legacy support: 0029, 0070, 0109, 0241, 0246 - TUI tweaks: 0030 - viminfo: 0039 - Jobs: 0045, 0048, 0050, 0051, 0054, 0071, 0087 - Style: 0055, 0114 - VMS/Sun support: 0059, 0067, 0123, 0173 - FEAT_* ifdefs: 0061, 0065, 0138, 0139, 0161, 0192, 0193, 0199, 0211, 0217, 0221, 0260, 0276, 0281 - GUI support: 0072, 0089, 0095, 0113, 0162, 0273, 0277, 0278 - win32 fixes: 0094 - Test infrastructure: 0285, 0288, 0400 - Language bindings: 0163, 0187, 0191, 0268-0271 - Unsupported options: 0232 vim-patch:20eeb612 vim-patch:17777875 vim-patch:99c5eb4f vim-patch:294740d2 vim-patch:a4ce25bd vim-patch:7034a837 vim-patch:14a612fa vim-patch:aaeabfbc --- src/nvim/version.c | 198 ++++++++++++++++++++++++++--------------------------- 1 file changed, 99 insertions(+), 99 deletions(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 75b09bcee7..44e9d5e26c 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -324,12 +324,12 @@ static const int included_patches[] = { 408, 407, // 406, - 405, + // 405 NA // 404, // 403, // 402, // 401, - 400, + // 400 NA // 399, // 398, // 397, @@ -441,38 +441,38 @@ static const int included_patches[] = { // 291, // 290, // 289, - // 288, + // 288 NA // 287, // 286, - // 285, - // 284, + // 285 NA + // 284 NA // 283, // 282, - // 281, + // 281 NA 280, - // 279, - // 278, - // 277, - // 276, + // 279 NA + // 278 NA + // 277 NA + // 276 NA 275, 274, - // 273, - // 272, - // 271, - // 270, - // 269, - // 268, - // 267, + // 273 NA + // 272 NA + // 271 NA + // 270 NA + // 269 NA + // 268 NA + // 267 NA 266, // 265, // 264, // 263, // 262, // 261, - // 260, + // 260 NA 259, // 258, - // 257, + // 257 NA // 256, // 255, // 254, @@ -480,24 +480,24 @@ static const int included_patches[] = { // 252, // 251, 250, - // 249, + // 249 NA // 248, // 247, - // 246, + // 246 NA // 245, // 244, 243, // 242, - // 241, - // 240, - // 239, + // 241 NA + // 240 NA + // 239 NA // 238, // 237, // 236, // 235, // 234, // 233, - // 232, + // 232 NA // 231, // 230, 229, @@ -508,17 +508,17 @@ static const int included_patches[] = { // 224, 223, // 222, - // 221, + // 221 NA // 220, 219, // 218, - // 217, + // 217 NA // 216, // 215, // 214, - // 213, + // 213 NA // 212, - // 211, + // 211 NA // 210, // 209, 208, @@ -526,23 +526,23 @@ static const int included_patches[] = { // 206, 205, // 204, - // 203, + // 203 NA // 202, // 201, // 200, - // 199, + // 199 NA // 198, // 197, // 196, 195, // 194, - // 193, - // 192, - // 191, + // 193 NA + // 192 NA + // 191 NA 190, // 189, // 188, - // 187, + // 187 NA // 186, // 185, // 184, @@ -556,7 +556,7 @@ static const int included_patches[] = { 176, // 175, // 174, - // 173, + // 173 NA 172, // 171, // 170, @@ -566,9 +566,9 @@ static const int included_patches[] = { // 166, // 165, // 164, - // 163, - // 162, - // 161, + // 163 NA + // 162 NA + // 161 NA // 160, 159, 158, @@ -577,21 +577,21 @@ static const int included_patches[] = { // 155, // 154, // 153, - // 152, + // 152 NA // 151, 150, // 149, // 148, // 147, // 146, - // 145, - // 144, + // 145 NA + // 144 NA // 143, // 142, // 141, // 140, - // 139, - // 138, + // 139 NA + // 138 NA // 137, 136, 135, @@ -599,132 +599,132 @@ static const int included_patches[] = { // 133, // 132, // 131, - // 130, - // 129, + // 130 NA + // 129 NA // 128, 127, // 126, // 125, // 124, - // 123, - // 122, + // 123 NA + // 122 NA 121, - // 120, + // 120 NA // 119, // 118, - // 117, + // 117 NA 116, - // 115, - // 114, - // 113, + // 115 NA + // 114 NA + // 113 NA // 112, // 111, 110, - // 109, - // 108, - // 107, + // 109 NA + // 108 NA + // 107 NA // 106, - 105, + // 105 NA // 104, - // 103, + // 103 NA // 102, // 101, // 100, 99, - // 98, - // 97, + // 98 NA + // 97 NA // 96, - // 95, - // 94, - // 93, + // 95 NA + // 94 NA + // 93 NA // 92, // 91, // 90, - // 89, + // 89 NA // 88, - // 87, + // 87 NA // 86, // 85, // 84, 83, - // 82, + // 82 NA // 81, - // 80, + // 80 NA // 79, // 78, - // 77, - // 76, + // 77 NA + // 76 NA // 75, // 74, // 73, - // 72, - // 71, - // 70, + // 72 NA + // 71 NA + // 70 NA // 69, 68, - // 67, + // 67 NA 66, - // 65, + // 65 NA 64, // 63, // 62, - // 61, + // 61 NA 60, - // 59, + // 59 NA 58, 57, 56, - // 55, - // 54, + // 55 NA + // 54 NA 53, // 52, - // 51, - 50, + // 51 NA + // 50 NA 49, - // 48, + // 48 NA 47, // 46, - // 45, + // 45 NA // 44, 43, 42, 41, 40, - // 39, + // 39 NA // 38, 37, - // 36, + // 36 NA 35, // 34, 33, 32, // 31, - // 30, - // 29, - // 28, - // 27, + // 30 NA + // 29 NA + // 28 NA + // 27 NA // 26, // 25, - // 24, + // 24 NA // 23, - // 22, + // 22 NA // 21, // 20, 19, // 18, // 17, - // 16, - // 15, - // 14, - // 13, + // 16 NA + // 15 NA + // 14 NA + // 13 NA // 12, - // 11, - // 10, - // 9, + // 11 NA + // 10 NA + // 9 NA 8, - // 7, + // 7 NA 6, - // 5, + // 5 NA // 4, // 3, 2, -- cgit From 8898793adeb3a82fe50da4258c30940e10ebcc9d Mon Sep 17 00:00:00 2001 From: DarkDefender Date: Sat, 15 Jul 2017 16:36:45 +0200 Subject: tui: Do not override 'termguicolors' choice (#7004) * Do not guard true color support with white list * Remove ext_bool (it is unused) Closes #7003 --- src/nvim/tui/tui.c | 86 +++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index c6f4eff08f..ab78a72909 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1236,18 +1236,6 @@ static int unibi_find_ext_str(unibi_term *ut, const char *name) return -1; } -static int unibi_find_ext_bool(unibi_term *ut, const char *name) -{ - size_t max = unibi_count_ext_bool(ut); - for (size_t i = 0; i < max; i++) { - const char * n = unibi_get_ext_bool_name(ut, i); - if (n && 0 == strcmp(n, name)) { - return (int)i; - } - } - return -1; -} - /// Several entries in terminfo are known to be deficient or outright wrong, /// unfortunately; and several terminal emulators falsely announce incorrect /// terminal types. So patch the terminfo records after loading from an @@ -1389,14 +1377,21 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // No bugs in the vanilla terminfo for our purposes. } -#define XTERM_SETAF_256 \ +// At this time (2017-07-12) it seems like all terminals that support 256 +// color codes can use semicolons in the terminal code and be fine. +// However, this is not correct according to the spec. So to reward those +// terminals that also support colons, we output the code that way on these +// specific ones. + +// using colons like ISO 8613-6:1994/ITU T.416:1993 says. +#define XTERM_SETAF_256_COLON \ "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38:5:%p1%d%;m" -#define XTERM_SETAB_256 \ +#define XTERM_SETAB_256_COLON \ "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48:5:%p1%d%;m" - // "standard" means using colons like ISO 8613-6:1994/ITU T.416:1993 says. -#define XTERM_SETAF_256_NONSTANDARD \ + +#define XTERM_SETAF_256 \ "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m" -#define XTERM_SETAB_256_NONSTANDARD \ +#define XTERM_SETAB_256 \ "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m" #define XTERM_SETAF_16 \ "\x1b[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e39%;m" @@ -1410,8 +1405,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // more on this. if (true_xterm || iterm || iterm_pretending_xterm) { unibi_set_num(ut, unibi_max_colors, 256); - unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); - unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); + unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256_COLON); + unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256_COLON); } else if (konsole || xterm || gnome || rxvt || st || putty || linuxvt // Linux 4.8+ supports 256-colour SGR. || mate_pretending_xterm || gnome_pretending_xterm @@ -1420,8 +1415,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, || (term && strstr(term, "256")) ) { unibi_set_num(ut, unibi_max_colors, 256); - unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256_NONSTANDARD); - unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256_NONSTANDARD); + unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); + unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); } } // Terminals where there is actually 16-colour SGR support despite what @@ -1536,26 +1531,20 @@ static void augment_terminfo(TUIData *data, const char *term, const char *colorterm, long vte_version, bool konsole, bool iterm_env) { unibi_term *ut = data->ut; - const char * xterm_version = os_getenv("XTERM_VERSION"); bool xterm = terminfo_is_term_family(term, "xterm"); bool dtterm = terminfo_is_term_family(term, "dtterm"); - bool linuxvt = terminfo_is_term_family(term, "linux"); bool rxvt = terminfo_is_term_family(term, "rxvt"); bool teraterm = terminfo_is_term_family(term, "teraterm"); bool putty = terminfo_is_term_family(term, "putty"); bool screen = terminfo_is_term_family(term, "screen"); - bool tmux = terminfo_is_term_family(term, "tmux"); - bool st = terminfo_is_term_family(term, "st"); - bool gnome = terminfo_is_term_family(term, "gnome") - || terminfo_is_term_family(term, "vte"); bool iterm = terminfo_is_term_family(term, "iterm") || terminfo_is_term_family(term, "iTerm.app"); // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; - bool true_xterm = xterm && !!xterm_version; bool tmux_wrap = screen && !!os_getenv("TMUX"); - bool old_truecolor_env = colorterm - && (0 == strcmp(colorterm, "truecolor") || 0 == strcmp(colorterm, "24bit")); + + const char * xterm_version = os_getenv("XTERM_VERSION"); + bool true_xterm = xterm && !!xterm_version; // Only define this capability for terminal types that we know understand it. if (dtterm // originated this extension @@ -1576,40 +1565,37 @@ static void augment_terminfo(TUIData *data, const char *term, // them to terminal types, that do actually have such control sequences but // lack the correct definitions in terminfo, is an augmentation, not a // fixup. See https://gist.github.com/XVilka/8346728 for more about this. - int Tc = unibi_find_ext_bool(ut, "Tc"); - // "standard" means using colons like ISO 8613-6:1994/ITU T.416:1993 says. - bool has_standard_rgb = false + + // At this time (2017-07-12) it seems like all terminals that support rgb + // color codes can use semicolons in the terminal code and be fine. + // However, this is not correct according to the spec. So to reward those + // terminals that also support colons, we output the code that way on these + // specific ones. + + // can use colons like ISO 8613-6:1994/ITU T.416:1993 says. + bool has_colon_rgb = false // per GNOME bug #685759 and bug #704449 - || ((gnome || xterm) && (vte_version >= 3600)) + || (vte_version >= 3600) || iterm || iterm_pretending_xterm // per analysis of VT100Terminal.m // per http://invisible-island.net/xterm/xterm.log.html#xterm_282 || true_xterm; - bool has_non_standard_rgb = -1 != Tc - // terminfo is definitive if it says something. - ? unibi_get_ext_bool(ut, (size_t)Tc) - : linuxvt // Linux 4.8+ supports true-colour SGR. - || konsole // per commentary in VT102Emulation.cpp - // per http://lists.schmorp.de/pipermail/rxvt-unicode/2016q2/002261.html - || rxvt - || tmux // per experimentation - || st // per experimentation - || old_truecolor_env; + data->unibi_ext.set_rgb_foreground = unibi_find_ext_str(ut, "setrgbf"); if (-1 == data->unibi_ext.set_rgb_foreground) { - if (has_standard_rgb) { + if (has_colon_rgb) { data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, "setrgbf", "\x1b[38:2:%p1%d:%p2%d:%p3%dm"); - } else if (has_non_standard_rgb) { + } else { data->unibi_ext.set_rgb_foreground = (int)unibi_add_ext_str(ut, "setrgbf", "\x1b[38;2;%p1%d;%p2%d;%p3%dm"); } } data->unibi_ext.set_rgb_background = unibi_find_ext_str(ut, "setrgbb"); if (-1 == data->unibi_ext.set_rgb_background) { - if (has_standard_rgb) { + if (has_colon_rgb) { data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, "setrgbb", "\x1b[48:2:%p1%d:%p2%d:%p3%dm"); - } else if (has_non_standard_rgb) { + } else { data->unibi_ext.set_rgb_background = (int)unibi_add_ext_str(ut, "setrgbb", "\x1b[48;2;%p1%d;%p2%d;%p3%dm"); } @@ -1621,7 +1607,9 @@ static void augment_terminfo(TUIData *data, const char *term, // would use a tmux control sequence and an extra if(screen) test. data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( ut, NULL, TMUX_WRAP(tmux_wrap, "\033]Pl%p1%06x\033\\")); - } else if (xterm) { + } else if (xterm || (vte_version != 0) || rxvt) { + // This seems to be supported for a long time in VTE + // urxvt also supports this data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( ut, NULL, "\033]12;#%p1%06x\007"); } -- cgit From d8fe63199f10c944312e802010bec13b5950120a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 15 Jul 2017 18:13:49 +0200 Subject: intro: change byline to "by al." (#6984) Several people have suggested that the "by Bram" byline is misleading, it implies that Bram is actively involved with the project. Up to now we left it as an homage. Bram agreed that it is misleading, and suggested a mention somewhere other than the intro. --- src/nvim/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 44e9d5e26c..c7b8220776 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -993,7 +993,7 @@ void intro_message(int colon) static char *(lines[]) = { N_(NVIM_VERSION_LONG), "", - N_("by Bram Moolenaar et al."), + N_("by al."), N_("Nvim is open source and freely distributable"), N_("https://neovim.io/community"), "", -- cgit From 33efad7dbc26750486d1910157345c508684125e Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sun, 16 Jul 2017 14:23:56 +0200 Subject: vim-patch:8.0.0017 Problem: Cannot get the number of the current quickfix or location list. Solution: Use the current list if "nr" in "what" is zero. (Yegappan Lakshmanan) Remove debug command from test. https://github.com/vim/vim/commit/890680ca6364386fabb271c85e0755bcaa6a33c1 --- src/nvim/quickfix.c | 9 ++++++--- src/nvim/testdir/test_quickfix.vim | 9 ++++++--- src/nvim/version.c | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index bd5dfa92cc..6797632008 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4025,9 +4025,12 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) if ((di = tv_dict_find(what, S_LEN("nr"))) != NULL) { // Use the specified quickfix/location list if (di->di_tv.v_type == VAR_NUMBER) { - qf_idx = (int)di->di_tv.vval.v_number - 1; - if (qf_idx < 0 || qf_idx >= qi->qf_listcount) { - return FAIL; + // for zero use the current list + if (di->di_tv.vval.v_number != 0) { + qf_idx = (int)di->di_tv.vval.v_number - 1; + if (qf_idx < 0 || qf_idx >= qi->qf_listcount) { + return FAIL; + } } flags |= QF_GETLIST_NR; } else { diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 75ab01f013..64d0173965 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -1427,12 +1427,10 @@ function! Test_two_windows() laddexpr 'one.txt:3:one one one' let loc_one = getloclist(one_id) -echo string(loc_one) call assert_equal('Xone/a/one.txt', bufname(loc_one[1].bufnr)) call assert_equal(3, loc_one[1].lnum) let loc_two = getloclist(two_id) -echo string(loc_two) call assert_equal('Xtwo/a/two.txt', bufname(loc_two[1].bufnr)) call assert_equal(5, loc_two[1].lnum) @@ -1532,6 +1530,11 @@ function Xproperty_tests(cchar) call assert_equal('N1', g:Xgetlist({'all':1}).title) call g:Xsetlist([], ' ', {'title' : 'N2'}) call assert_equal(qfnr + 1, g:Xgetlist({'all':1}).nr) + + let res = g:Xgetlist({'nr': 0}) + call assert_equal(qfnr + 1, res.nr) + call assert_equal(['nr'], keys(res)) + call g:Xsetlist([], ' ', {'title' : 'N3'}) call assert_equal('N2', g:Xgetlist({'nr':2, 'title':1}).title) @@ -1544,7 +1547,7 @@ function Xproperty_tests(cchar) call assert_equal({}, g:Xgetlist({'abc':1})) if a:cchar == 'l' - call assert_equal({}, getloclist(99, ['title'])) + call assert_equal({}, getloclist(99, {'title': 1})) endif endfunction diff --git a/src/nvim/version.c b/src/nvim/version.c index c7b8220776..a8b1e4d22d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -712,7 +712,7 @@ static const int included_patches[] = { // 20, 19, // 18, - // 17, + 17, // 16 NA // 15 NA // 14 NA -- cgit From c00300ecdd694cad53da74256e52675f79a3fd78 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sun, 16 Jul 2017 16:58:25 +0200 Subject: vim-patch:8.0.0026 Problem: Error format with %W, %C and %Z does not work. (Gerd Wachsmuth) Solution: Skip code when qf_multiignore is set. (Lcd) https://github.com/vim/vim/commit/9b4579481892a62e7e002498b9eddaaf75bbda49 --- src/nvim/quickfix.c | 62 ++++++++++++++++++++------------------ src/nvim/testdir/test_quickfix.vim | 23 ++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 56 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 6797632008..29beb35495 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -875,36 +875,38 @@ restofline: qi->qf_multiignore = false; // reset continuation } else if (vim_strchr((char_u *)"CZ", idx) != NULL) { // continuation of multi-line msg - qfline_T *qfprev = qi->qf_lists[qi->qf_curlist].qf_last; - if (qfprev == NULL) { - return QF_FAIL; - } - if (*fields->errmsg && !qi->qf_multiignore) { - size_t len = STRLEN(qfprev->qf_text); - qfprev->qf_text = xrealloc(qfprev->qf_text, - len + STRLEN(fields->errmsg) + 2); - qfprev->qf_text[len] = '\n'; - STRCPY(qfprev->qf_text + len + 1, fields->errmsg); - } - if (qfprev->qf_nr == -1) { - qfprev->qf_nr = fields->enr; - } - if (vim_isprintc(fields->type) && !qfprev->qf_type) { - qfprev->qf_type = fields->type; // only printable chars allowed - } - if (!qfprev->qf_lnum) { - qfprev->qf_lnum = fields->lnum; - } - if (!qfprev->qf_col) { - qfprev->qf_col = fields->col; - } - qfprev->qf_viscol = fields->use_viscol; - if (!qfprev->qf_fnum) { - qfprev->qf_fnum = qf_get_fnum(qi, qi->qf_directory, - *fields->namebuf || qi->qf_directory - ? fields->namebuf - : qi->qf_currfile && fields->valid - ? qi->qf_currfile : 0); + if (!qi->qf_multiignore) { + qfline_T *qfprev = qi->qf_lists[qi->qf_curlist].qf_last; + if (qfprev == NULL) { + return QF_FAIL; + } + if (*fields->errmsg && !qi->qf_multiignore) { + size_t len = STRLEN(qfprev->qf_text); + qfprev->qf_text = xrealloc(qfprev->qf_text, + len + STRLEN(fields->errmsg) + 2); + qfprev->qf_text[len] = '\n'; + STRCPY(qfprev->qf_text + len + 1, fields->errmsg); + } + if (qfprev->qf_nr == -1) { + qfprev->qf_nr = fields->enr; + } + if (vim_isprintc(fields->type) && !qfprev->qf_type) { + qfprev->qf_type = fields->type; // only printable chars allowed + } + if (!qfprev->qf_lnum) { + qfprev->qf_lnum = fields->lnum; + } + if (!qfprev->qf_col) { + qfprev->qf_col = fields->col; + } + qfprev->qf_viscol = fields->use_viscol; + if (!qfprev->qf_fnum) { + qfprev->qf_fnum = qf_get_fnum(qi, qi->qf_directory, + *fields->namebuf || qi->qf_directory + ? fields->namebuf + : qi->qf_currfile && fields->valid + ? qi->qf_currfile : 0); + } } if (idx == 'Z') { qi->qf_multiline = qi->qf_multiignore = false; diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 64d0173965..e2966ec5c4 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -816,6 +816,29 @@ function! Test_efm_dirstack() call delete('habits1.txt') endfunction +" Test for resync after continuing an ignored message +function! Xefm_ignore_continuations(cchar) + call s:setup_commands(a:cchar) + + let save_efm = &efm + + let &efm = + \ '%Eerror %m %l,' . + \ '%-Wignored %m %l,' . + \ '%+Cmore ignored %m %l,' . + \ '%Zignored end' + Xgetexpr ['ignored warning 1', 'more ignored continuation 2', 'ignored end', 'error resync 4'] + let l = map(g:Xgetlist(), '[v:val.text, v:val.valid, v:val.lnum, v:val.type]') + call assert_equal([['resync', 1, 4, 'E']], l) + + let &efm = save_efm +endfunction + +function! Test_efm_ignore_continuations() + call Xefm_ignore_continuations('c') + call Xefm_ignore_continuations('l') +endfunction + " Tests for invalid error format specifies function Xinvalid_efm_Tests(cchar) call s:setup_commands(a:cchar) diff --git a/src/nvim/version.c b/src/nvim/version.c index a8b1e4d22d..efda51547e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -703,7 +703,7 @@ static const int included_patches[] = { // 29 NA // 28 NA // 27 NA - // 26, + 26, // 25, // 24 NA // 23, -- cgit From ffa2e4354986cc12b8d44781708f0b9d51b84f31 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sun, 16 Jul 2017 17:28:14 +0200 Subject: vim-patch:8.0.0078 Problem: Accessing freed memory in quickfix. Solution: Reset pointer when freeing 'errorformat'. (Domenique Pelle) https://github.com/vim/vim/commit/63bed3d319b5d90765dbdae93a3579b6322d79fb --- src/nvim/quickfix.c | 5 ++++- src/nvim/testdir/test_quickfix.vim | 10 ++++++++++ src/nvim/version.c | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 29beb35495..6814ca855b 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -383,6 +383,8 @@ static int efm_to_regpat(char_u *efm, int len, efm_T *fmt_ptr, return 0; } +static efm_T *fmt_start = NULL; // cached across qf_parse_line() calls + static void free_efm_list(efm_T **efm_first) { for (efm_T *efm_ptr = *efm_first; efm_ptr != NULL; efm_ptr = *efm_first) { @@ -390,6 +392,8 @@ static void free_efm_list(efm_T **efm_first) vim_regfree(efm_ptr->prog); xfree(efm_ptr); } + + fmt_start = NULL; } // Parse 'errorformat' option @@ -671,7 +675,6 @@ static int qf_parse_line(qf_info_T *qi, char_u *linebuf, size_t linelen, efm_T *fmt_first, qffields_T *fields) { efm_T *fmt_ptr; - static efm_T *fmt_start = NULL; // cached across calls size_t len; int i; int idx = 0; diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index e2966ec5c4..316ef6f221 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -1630,3 +1630,13 @@ function! Test_Autocmd_Exception() set efm&vim endfunction + +function Test_caddbuffer() + " This used to cause a memory access in freed memory + let save_efm = &efm + set efm=%EEEE%m,%WWWW,%+CCCC%>%#,%GGGG%.# + cgetexpr ['WWWW', 'EEEE', 'CCCC'] + let &efm = save_efm + cad + bwipe! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index efda51547e..d10d78d695 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -651,7 +651,7 @@ static const int included_patches[] = { // 81, // 80 NA // 79, - // 78, + 78, // 77 NA // 76 NA // 75, -- cgit From 875c356a83b07573b87b2995478fc3b0703bc023 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sun, 16 Jul 2017 17:32:32 +0200 Subject: vim-patch:8.0.0079 Problem: Accessing freed memory in quickfix. (Domenique Pelle) Solution: Do not free the current list when adding to it. https://github.com/vim/vim/commit/2b946c9f9b0e0fd805fb8f3e4c16e0a68ae13129 --- src/nvim/quickfix.c | 12 +- src/nvim/testdir/test_quickfix.vim | 249 +++++++++++++++++++------------------ src/nvim/version.c | 2 +- 3 files changed, 139 insertions(+), 124 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 6814ca855b..44469a77df 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -972,6 +972,7 @@ qf_init_ext( NULL, 0, 0 }; qffields_T fields = { NULL, NULL, 0, 0L, 0, false, NULL, 0, 0, 0 }; qfline_T *old_last = NULL; + bool adding = false; static efm_T *fmt_first = NULL; char_u *efm; static char_u *last_efm = NULL; @@ -997,6 +998,7 @@ qf_init_ext( qf_new_list(qi, qf_title); } else if (qi->qf_lists[qi->qf_curlist].qf_count > 0) { // Adding to existing list, use last entry. + adding = true; old_last = qi->qf_lists[qi->qf_curlist].qf_last; } @@ -1113,10 +1115,12 @@ qf_init_ext( } EMSG(_(e_readerrf)); error2: - qf_free(qi, qi->qf_curlist); - qi->qf_listcount--; - if (qi->qf_curlist > 0) { - qi->qf_curlist--; + if (!adding) { + qf_free(qi, qi->qf_curlist); + qi->qf_listcount--; + if (qi->qf_curlist > 0) { + qi->qf_curlist--; + } } qf_init_end: if (state.fd != NULL) { diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 316ef6f221..08a749f65e 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -6,7 +6,7 @@ endif set encoding=utf-8 -function! s:setup_commands(cchar) +func s:setup_commands(cchar) if a:cchar == 'c' command! -nargs=* -bang Xlist clist command! -nargs=* Xgetexpr cgetexpr @@ -68,10 +68,10 @@ function! s:setup_commands(cchar) let g:Xgetlist = function('getloclist', [0]) let g:Xsetlist = function('setloclist', [0]) endif -endfunction +endfunc " Tests for the :clist and :llist commands -function XlistTests(cchar) +func XlistTests(cchar) call s:setup_commands(a:cchar) " With an empty list, command should return error @@ -128,17 +128,17 @@ function XlistTests(cchar) let l = split(result, "\n") call assert_equal([' 2 Xtestfile1:1 col 3: Line1', \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) -endfunction +endfunc -function Test_clist() +func Test_clist() call XlistTests('c') call XlistTests('l') -endfunction +endfunc " Tests for the :colder, :cnewer, :lolder and :lnewer commands " Note that this test assumes that a quickfix/location list is " already set by the caller. -function XageTests(cchar) +func XageTests(cchar) call s:setup_commands(a:cchar) " Jumping to a non existent list should return error @@ -171,20 +171,20 @@ function XageTests(cchar) Xnewer 2 let l = g:Xgetlist() call assert_equal('Line3', l[0].text) -endfunction +endfunc -function Test_cage() +func Test_cage() let list = [{'bufnr': 1, 'lnum': 1}] call setqflist(list) call XageTests('c') call setloclist(0, list) call XageTests('l') -endfunction +endfunc " Tests for the :cwindow, :lwindow :cclose, :lclose, :copen and :lopen " commands -function XwindowTests(cchar) +func XwindowTests(cchar) call s:setup_commands(a:cchar) " Create a list with no valid entries @@ -227,16 +227,16 @@ function XwindowTests(cchar) " Calling cwindow should close the quickfix window with no valid errors Xwindow call assert_true(winnr('$') == 1) -endfunction +endfunc -function Test_cwindow() +func Test_cwindow() call XwindowTests('c') call XwindowTests('l') -endfunction +endfunc " Tests for the :cfile, :lfile, :caddfile, :laddfile, :cgetfile and :lgetfile " commands. -function XfileTests(cchar) +func XfileTests(cchar) call s:setup_commands(a:cchar) call writefile(['Xtestfile1:700:10:Line 700', @@ -275,16 +275,16 @@ function XfileTests(cchar) \ l[1].lnum == 333 && l[1].col == 88 && l[1].text ==# 'Line 333') call delete('Xqftestfile1') -endfunction +endfunc -function Test_cfile() +func Test_cfile() call XfileTests('c') call XfileTests('l') -endfunction +endfunc " Tests for the :cbuffer, :lbuffer, :caddbuffer, :laddbuffer, :cgetbuffer and " :lgetbuffer commands. -function XbufferTests(cchar) +func XbufferTests(cchar) call s:setup_commands(a:cchar) enew! @@ -316,26 +316,26 @@ function XbufferTests(cchar) \ l[3].lnum == 750 && l[3].col == 25 && l[3].text ==# 'Line 750') enew! -endfunction +endfunc -function Test_cbuffer() +func Test_cbuffer() call XbufferTests('c') call XbufferTests('l') -endfunction +endfunc -function XexprTests(cchar) +func XexprTests(cchar) call s:setup_commands(a:cchar) call assert_fails('Xexpr 10', 'E777:') -endfunction +endfunc -function Test_cexpr() +func Test_cexpr() call XexprTests('c') call XexprTests('l') -endfunction +endfunc " Tests for :cnext, :cprev, :cfirst, :clast commands -function Xtest_browse(cchar) +func Xtest_browse(cchar) call s:setup_commands(a:cchar) call s:create_test_file('Xqftestfile1') @@ -366,14 +366,14 @@ function Xtest_browse(cchar) call delete('Xqftestfile1') call delete('Xqftestfile2') -endfunction +endfunc -function Test_browse() +func Test_browse() call Xtest_browse('c') call Xtest_browse('l') -endfunction +endfunc -function! s:test_xhelpgrep(cchar) +func s:test_xhelpgrep(cchar) call s:setup_commands(a:cchar) Xhelpgrep quickfix Xopen @@ -385,9 +385,9 @@ function! s:test_xhelpgrep(cchar) call assert_true(w:quickfix_title =~ title_text, w:quickfix_title) " This wipes out the buffer, make sure that doesn't cause trouble. Xclose -endfunction +endfunc -function Test_helpgrep() +func Test_helpgrep() call s:test_xhelpgrep('c') helpclose call s:test_xhelpgrep('l') @@ -425,7 +425,7 @@ func Test_vimgreptitle() augroup! QfBufWinEnter endfunc -function XqfTitleTests(cchar) +func XqfTitleTests(cchar) call s:setup_commands(a:cchar) Xgetexpr ['file:1:1:message'] @@ -444,16 +444,16 @@ function XqfTitleTests(cchar) endif call assert_equal(title, w:quickfix_title) Xclose -endfunction +endfunc " Tests for quickfix window's title -function Test_qf_title() +func Test_qf_title() call XqfTitleTests('c') call XqfTitleTests('l') -endfunction +endfunc " Tests for 'errorformat' -function Test_efm() +func Test_efm() let save_efm = &efm set efm=%EEEE%m,%WWWW%m,%+CCCC%.%#,%-GGGG%.%# cgetexpr ['WWWW', 'EEEE', 'CCCC'] @@ -466,7 +466,7 @@ function Test_efm() let l = strtrans(string(map(getqflist(), '[v:val.text, v:val.valid]'))) call assert_equal("[['W', 1], ['ZZZZ', 0], ['E^@CCCC', 1], ['YYYY', 0]]", l) let &efm = save_efm -endfunction +endfunc " This will test for problems in quickfix: " A. incorrectly copying location lists which caused the location list to show @@ -477,7 +477,7 @@ endfunction " window it belongs to. " " Set up the test environment: -function! ReadTestProtocol(name) +func ReadTestProtocol(name) let base = substitute(a:name, '\v^test://(.*)%(\.[^.]+)?', '\1', '') let word = substitute(base, '\v(.*)\..*', '\1', '') @@ -496,9 +496,9 @@ function! ReadTestProtocol(name) setl nomodifiable setl readonly exe 'doautocmd BufRead ' . substitute(a:name, '\v^test://(.*)', '\1', '') -endfunction +endfunc -function Test_locationlist() +func Test_locationlist() enew augroup testgroup @@ -578,15 +578,15 @@ function Test_locationlist() wincmd n | only augroup! testgroup -endfunction + endfunc -function Test_locationlist_curwin_was_closed() +func Test_locationlist_curwin_was_closed() augroup testgroup au! autocmd BufReadCmd test_curwin.txt call R(expand("")) augroup END - function! R(n) + func! R(n) quit endfunc @@ -597,9 +597,9 @@ function Test_locationlist_curwin_was_closed() call assert_fails('lrewind', 'E924:') augroup! testgroup -endfunction + endfunc -function Test_locationlist_cross_tab_jump() +func Test_locationlist_cross_tab_jump() call writefile(['loclistfoo'], 'loclistfoo') call writefile(['loclistbar'], 'loclistbar') set switchbuf=usetab @@ -613,10 +613,10 @@ function Test_locationlist_cross_tab_jump() set switchbuf&vim call delete('loclistfoo') call delete('loclistbar') -endfunction +endfunc " More tests for 'errorformat' -function! Test_efm1() +func Test_efm1() if !has('unix') " The 'errorformat' setting is different on non-Unix systems. " This test works only on Unix-like systems. @@ -734,10 +734,10 @@ function! Test_efm1() call delete('Xerrorfile1') call delete('Xerrorfile2') call delete('Xtestfile') -endfunction + endfunc " Test for quickfix directory stack support -function! s:dir_stack_tests(cchar) +func s:dir_stack_tests(cchar) call s:setup_commands(a:cchar) let save_efm=&efm @@ -779,10 +779,10 @@ function! s:dir_stack_tests(cchar) call assert_equal(5, qf[11].lnum) let &efm=save_efm -endfunction +endfunc " Tests for %D and %X errorformat options -function! Test_efm_dirstack() +func Test_efm_dirstack() " Create the directory stack and files call mkdir('dir1') call mkdir('dir1/a') @@ -814,10 +814,10 @@ function! Test_efm_dirstack() call delete('dir1', 'rf') call delete('dir2', 'rf') call delete('habits1.txt') -endfunction +endfunc " Test for resync after continuing an ignored message -function! Xefm_ignore_continuations(cchar) +func Xefm_ignore_continuations(cchar) call s:setup_commands(a:cchar) let save_efm = &efm @@ -832,15 +832,15 @@ function! Xefm_ignore_continuations(cchar) call assert_equal([['resync', 1, 4, 'E']], l) let &efm = save_efm -endfunction +endfunc -function! Test_efm_ignore_continuations() +func Test_efm_ignore_continuations() call Xefm_ignore_continuations('c') call Xefm_ignore_continuations('l') -endfunction +endfunc " Tests for invalid error format specifies -function Xinvalid_efm_Tests(cchar) +func Xinvalid_efm_Tests(cchar) call s:setup_commands(a:cchar) let save_efm = &efm @@ -873,17 +873,17 @@ function Xinvalid_efm_Tests(cchar) call assert_fails('Xexpr ["Entering dir abc", "abc.txt:1:Hello world"]', 'E379:') let &efm = save_efm -endfunction +endfunc -function Test_invalid_efm() +func Test_invalid_efm() call Xinvalid_efm_Tests('c') call Xinvalid_efm_Tests('l') -endfunction +endfunc " TODO: " Add tests for the following formats in 'errorformat' " %r %O -function! Test_efm2() +func Test_efm2() let save_efm = &efm " Test for %s format in efm @@ -969,19 +969,19 @@ function! Test_efm2() call assert_equal('unittests/dbfacadeTest.py', bufname(l[4].bufnr)) let &efm = save_efm -endfunction +endfunc -function XquickfixChangedByAutocmd(cchar) +func XquickfixChangedByAutocmd(cchar) call s:setup_commands(a:cchar) if a:cchar == 'c' let ErrorNr = 'E925' - function! ReadFunc() + func! ReadFunc() colder cgetexpr [] endfunc else let ErrorNr = 'E926' - function! ReadFunc() + func! ReadFunc() lolder lgetexpr [] endfunc @@ -1004,10 +1004,10 @@ function XquickfixChangedByAutocmd(cchar) augroup! testgroup endfunc -function Test_quickfix_was_changed_by_autocmd() +func Test_quickfix_was_changed_by_autocmd() call XquickfixChangedByAutocmd('c') call XquickfixChangedByAutocmd('l') -endfunction +endfunc func Test_caddbuffer_to_empty() helpgr quickfix @@ -1029,7 +1029,7 @@ func Test_cgetexpr_works() endfunc " Tests for the setqflist() and setloclist() functions -function SetXlistTests(cchar, bnum) +func SetXlistTests(cchar, bnum) call s:setup_commands(a:cchar) call g:Xsetlist([{'bufnr': a:bnum, 'lnum': 1}, @@ -1064,9 +1064,9 @@ function SetXlistTests(cchar, bnum) call g:Xsetlist([]) let l = g:Xgetlist() call assert_equal(0, len(l)) -endfunction +endfunc -function Test_setqflist() +func Test_setqflist() new Xtestfile | only let bnum = bufnr('%') call setline(1, range(1,5)) @@ -1076,9 +1076,9 @@ function Test_setqflist() enew! call delete('Xtestfile') -endfunction +endfunc -function Xlist_empty_middle(cchar) +func Xlist_empty_middle(cchar) call s:setup_commands(a:cchar) " create three quickfix lists @@ -1101,12 +1101,12 @@ function Xlist_empty_middle(cchar) call assert_equal(matchlen, len(g:Xgetlist())) endfunc -function Test_setqflist_empty_middle() +func Test_setqflist_empty_middle() call Xlist_empty_middle('c') call Xlist_empty_middle('l') -endfunction +endfunc -function Xlist_empty_older(cchar) +func Xlist_empty_older(cchar) call s:setup_commands(a:cchar) " create three quickfix lists @@ -1127,14 +1127,14 @@ function Xlist_empty_older(cchar) call assert_equal(twolen, len(g:Xgetlist())) Xnewer call assert_equal(threelen, len(g:Xgetlist())) -endfunction +endfunc -function Test_setqflist_empty_older() +func Test_setqflist_empty_older() call Xlist_empty_older('c') call Xlist_empty_older('l') -endfunction +endfunc -function! XquickfixSetListWithAct(cchar) +func XquickfixSetListWithAct(cchar) call s:setup_commands(a:cchar) let list1 = [{'filename': 'fnameA', 'text': 'A'}, @@ -1208,12 +1208,12 @@ function! XquickfixSetListWithAct(cchar) call assert_fails("call g:Xsetlist(list1, 0)", 'E928:') endfunc -function Test_quickfix_set_list_with_act() +func Test_quickfix_set_list_with_act() call XquickfixSetListWithAct('c') call XquickfixSetListWithAct('l') -endfunction +endfunc -function XLongLinesTests(cchar) +func XLongLinesTests(cchar) let l = g:Xgetlist() call assert_equal(4, len(l)) @@ -1231,9 +1231,9 @@ function XLongLinesTests(cchar) call assert_equal(10, len(l[3].text)) call g:Xsetlist([], 'r') -endfunction +endfunc -function s:long_lines_tests(cchar) +func s:long_lines_tests(cchar) call s:setup_commands(a:cchar) let testfile = 'samples/quickfix.txt' @@ -1254,22 +1254,22 @@ function s:long_lines_tests(cchar) exe 'edit' testfile exe 'Xbuffer' bufnr('%') call XLongLinesTests(a:cchar) -endfunction +endfunc -function Test_long_lines() +func Test_long_lines() call s:long_lines_tests('c') call s:long_lines_tests('l') -endfunction +endfunc -function! s:create_test_file(filename) +func s:create_test_file(filename) let l = [] for i in range(1, 20) call add(l, 'Line' . i) endfor call writefile(l, a:filename) -endfunction +endfunc -function! Test_switchbuf() +func Test_switchbuf() call s:create_test_file('Xqftestfile1') call s:create_test_file('Xqftestfile2') call s:create_test_file('Xqftestfile3') @@ -1356,9 +1356,9 @@ function! Test_switchbuf() call delete('Xqftestfile1') call delete('Xqftestfile2') call delete('Xqftestfile3') -endfunction +endfunc -function! Xadjust_qflnum(cchar) +func Xadjust_qflnum(cchar) call s:setup_commands(a:cchar) enew | only @@ -1383,17 +1383,17 @@ function! Xadjust_qflnum(cchar) enew! call delete(fname) -endfunction +endfunc -function! Test_adjust_lnum() +func Test_adjust_lnum() call setloclist(0, []) call Xadjust_qflnum('c') call setqflist([]) call Xadjust_qflnum('l') -endfunction +endfunc " Tests for the :grep/:lgrep and :grepadd/:lgrepadd commands -function! s:test_xgrep(cchar) +func s:test_xgrep(cchar) call s:setup_commands(a:cchar) " The following lines are used for the grep test. Don't remove. @@ -1412,9 +1412,9 @@ function! s:test_xgrep(cchar) set makeef=Temp_File_## silent Xgrepadd GrepAdd_Test_Text: test_quickfix.vim call assert_true(len(g:Xgetlist()) == 6) -endfunction +endfunc -function! Test_grep() +func Test_grep() if !has('unix') " The grepprg may not be set on non-Unix systems return @@ -1422,9 +1422,9 @@ function! Test_grep() call s:test_xgrep('c') call s:test_xgrep('l') -endfunction +endfunc -function! Test_two_windows() +func Test_two_windows() " Use one 'errorformat' for two windows. Add an expression to each of them, " make sure they each keep their own state. set efm=%DEntering\ dir\ '%f',%f:%l:%m,%XLeaving\ dir\ '%f' @@ -1465,7 +1465,7 @@ function! Test_two_windows() call delete('Xtwo', 'rf') endfunc -function XbottomTests(cchar) +func XbottomTests(cchar) call s:setup_commands(a:cchar) call g:Xsetlist([{'filename': 'foo', 'lnum': 42}]) @@ -1481,12 +1481,12 @@ function XbottomTests(cchar) endfunc " Tests for the :cbottom and :lbottom commands -function Test_cbottom() +func Test_cbottom() call XbottomTests('c') call XbottomTests('l') -endfunction +endfunc -function HistoryTest(cchar) +func HistoryTest(cchar) call s:setup_commands(a:cchar) call assert_fails(a:cchar . 'older 99', 'E380:') @@ -1526,7 +1526,7 @@ func Test_duplicate_buf() endfunc " Quickfix/Location list set/get properties tests -function Xproperty_tests(cchar) +func Xproperty_tests(cchar) call s:setup_commands(a:cchar) " Error cases @@ -1572,19 +1572,19 @@ function Xproperty_tests(cchar) if a:cchar == 'l' call assert_equal({}, getloclist(99, {'title': 1})) endif -endfunction + endfunc -function Test_qf_property() +func Test_qf_property() call Xproperty_tests('c') call Xproperty_tests('l') -endfunction + endfunc " Tests for the QuickFixCmdPre/QuickFixCmdPost autocommands -function QfAutoCmdHandler(loc, cmd) +func QfAutoCmdHandler(loc, cmd) call add(g:acmds, a:loc . a:cmd) -endfunction +endfunc -function Test_Autocmd() +func Test_Autocmd() autocmd QuickFixCmdPre * call QfAutoCmdHandler('pre', expand('')) autocmd QuickFixCmdPost * call QfAutoCmdHandler('post', expand('')) @@ -1612,9 +1612,9 @@ function Test_Autocmd() \ 'precaddbuffer', \ 'postcaddbuffer'] call assert_equal(l, g:acmds) -endfunction +endfunc -function! Test_Autocmd_Exception() +func Test_Autocmd_Exception() set efm=%m lgetexpr '?' @@ -1629,14 +1629,25 @@ function! Test_Autocmd_Exception() call assert_equal('1', getloclist(0)[0].text) set efm&vim -endfunction +endfunc -function Test_caddbuffer() - " This used to cause a memory access in freed memory +func Test_caddbuffer_wrong() + " This used to cause a memory access in freed memory. let save_efm = &efm set efm=%EEEE%m,%WWWW,%+CCCC%>%#,%GGGG%.# cgetexpr ['WWWW', 'EEEE', 'CCCC'] let &efm = save_efm - cad + caddbuffer bwipe! endfunc + +func Test_caddexpr_wrong() + " This used to cause a memory access in freed memory. + cbuffer + cbuffer + copen + let save_efm = &efm + set efm=% + call assert_fails('caddexpr ""', 'E376:') + let &efm = save_efm +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index d10d78d695..62af3ab34d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -650,7 +650,7 @@ static const int included_patches[] = { // 82 NA // 81, // 80 NA - // 79, + 79, 78, // 77 NA // 76 NA -- cgit From e29ec131d67f3410dba85ab13ba4c617e5768269 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sun, 16 Jul 2017 17:39:53 +0200 Subject: vim-patch:8.0.0084 Problem: Using freed memory when adding to a quickfix list. (Domenique Pelle) Solution: Clear the directory name. https://github.com/vim/vim/commit/7618e00d3b8bfe064cfc524640d754607361f9df --- src/nvim/quickfix.c | 4 +++- src/nvim/testdir/test_quickfix.vim | 22 ++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 44469a77df..f17075f0c4 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1417,7 +1417,7 @@ void copy_loclist(win_T *from, win_T *to) to->w_llist->qf_curlist = qi->qf_curlist; /* current list */ } -// Get buffer number for file "directory.fname". +// Get buffer number for file "directory/fname". // Also sets the b_has_qf_entry flag. static int qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname) { @@ -2371,7 +2371,9 @@ static void qf_free(qf_info_T *qi, int idx) qi->qf_lists[idx].qf_index = 0; qf_clean_dir_stack(&qi->qf_dir_stack); + qi->qf_directory = NULL; qf_clean_dir_stack(&qi->qf_file_stack); + qi->qf_currfile = NULL; } /* diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 08a749f65e..aff5fc2eed 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -1651,3 +1651,25 @@ func Test_caddexpr_wrong() call assert_fails('caddexpr ""', 'E376:') let &efm = save_efm endfunc + +func Test_dirstack_cleanup() + " This used to cause a memory access in freed memory. + let save_efm = &efm + lexpr '0' + lopen + fun X(c) + let save_efm=&efm + set efm=%D%f + if a:c == 'c' + caddexpr '::' + else + laddexpr ':0:0' + endif + let &efm=save_efm + endfun + call X('c') + call X('l') + call setqflist([], 'r') + caddbuffer + let &efm = save_efm +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 62af3ab34d..2beb13edf8 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -645,7 +645,7 @@ static const int included_patches[] = { // 87 NA // 86, // 85, - // 84, + 84, 83, // 82 NA // 81, -- cgit From 3660535f0229afc4ce3391d94794253f685ec400 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 16 Jul 2017 21:17:24 +0300 Subject: oldtests: Use $(TOOL) in place of $(VALGRIND) --- src/nvim/testdir/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 510e8820f4..9ba4e4b3c1 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -201,7 +201,7 @@ nolog: # New style of tests uses Vim script with assert calls. These are easier # to write and a lot easier to read and debug. # Limitation: Only works with the +eval feature. -RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(NVIM_PRG) -u unix.vim -U NONE --noplugin +RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(TOOL) $(NVIM_PRG) -u unix.vim -U NONE --noplugin newtests: newtestssilent @/bin/sh -c "if test -f messages && grep -q 'FAILED' messages; then \ -- cgit From 2a6423eba732b005e277bac393f2246308dcc378 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 16 Jul 2017 22:03:31 +0300 Subject: api helpers: Save/restore more values in try_enter/try_leave This fixes memory leak reported by ASAN. This also somehow fixes test40, though I have no idea why except that that test yields memory leak report. --- src/nvim/api/private/helpers.c | 9 +++++++++ src/nvim/api/private/helpers.h | 3 +++ src/nvim/ex_eval.c | 2 ++ src/nvim/ex_getln.c | 3 --- 4 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index a04cc9a312..6ff56709cd 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -49,13 +49,17 @@ void try_enter(TryState *const tstate) .trylevel = trylevel, .got_int = got_int, .did_throw = did_throw, + .need_rethrow = need_rethrow, + .current_exception = current_exception, .msg_list = (const struct msglist *const *)msg_list, .private_msg_list = NULL, }; trylevel = 1; got_int = false; did_throw = false; + need_rethrow = false; msg_list = &tstate->private_msg_list; + current_exception = NULL; } /// End try block, set the error message if any and restore previous state @@ -72,14 +76,17 @@ bool try_leave(const TryState *const tstate, Error *const err) { const bool ret = !try_end(err); assert(trylevel == 0); + assert(!need_rethrow); assert(!got_int); assert(!did_throw); assert(msg_list == &tstate->private_msg_list); assert(*msg_list == NULL); + assert(current_exception == NULL); trylevel = tstate->trylevel; got_int = tstate->got_int; did_throw = tstate->did_throw; msg_list = (struct msglist **)tstate->msg_list; + current_exception = tstate->current_exception; return ret; } @@ -96,6 +103,8 @@ void try_start(void) /// @return true if an error occurred bool try_end(Error *err) { + // Note: all globals manipulated here should be saved/restored in + // try_enter/try_leave. --trylevel; // Without this it stops processing all subsequent VimL commands and diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h index 112d785bfd..0b2cf883a6 100644 --- a/src/nvim/api/private/helpers.h +++ b/src/nvim/api/private/helpers.h @@ -6,6 +6,7 @@ #include "nvim/api/private/defs.h" #include "nvim/vim.h" #include "nvim/memory.h" +#include "nvim/ex_eval.h" #include "nvim/lib/kvec.h" #define OBJECT_OBJ(o) o @@ -90,6 +91,8 @@ typedef struct { int trylevel; int got_int; int did_throw; + int need_rethrow; + except_T *current_exception; struct msglist *private_msg_list; const struct msglist *const *msg_list; } TryState; diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 5d664b94a8..139305998d 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -565,6 +565,8 @@ static void discard_exception(except_T *excp, int was_finished) void discard_current_exception(void) { discard_exception(current_exception, FALSE); + // Note: all globals manipulated here should be saved/restored in + // try_enter/try_leave. current_exception = NULL; did_throw = FALSE; need_rethrow = FALSE; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 6c61e30f3d..275e1b7fdd 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2341,8 +2341,6 @@ static bool color_cmdline(void) return ret; } - const int saved_force_abort = force_abort; - force_abort = true; bool arg_allocated = false; typval_T arg = { .v_type = VAR_STRING, @@ -2504,7 +2502,6 @@ color_cmdline_end: if (can_free_cb) { callback_free(&color_cb); } - force_abort = saved_force_abort; if (arg_allocated) { tv_clear(&arg); } -- cgit From 9ffa22b7efefebf49a42364de21bb895adabd2de Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sun, 16 Jul 2017 20:49:07 +0200 Subject: vim-patch:8.0.0023 Problem: "gd" and "gD" may find a match in a comment or string. Solution: Ignore matches in comments and strings. (Anton Lindqvist) https://github.com/vim/vim/commit/226630a030c0d41145e1109f09633360fc9c999d --- src/nvim/normal.c | 68 ++++++++-- src/nvim/testdir/test_goto.vim | 281 +++++++++++++++++++++++++++++++++++++++-- src/nvim/version.c | 2 +- 3 files changed, 328 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index d891c74fd2..c1676780d8 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -3657,6 +3657,39 @@ nv_gd ( } } +// Return true if line[offset] is not inside a C-style comment or string, false +// otherwise. +static bool is_ident(char_u *line, int offset) +{ + bool incomment = false; + int instring = 0; + int prev = 0; + + for (int i = 0; i < offset && line[i] != NUL; i++) { + if (instring != 0) { + if (prev != '\\' && line[i] == instring) { + instring = 0; + } + } else if ((line[i] == '"' || line[i] == '\'') && !incomment) { + instring = line[i]; + } else { + if (incomment) { + if (prev == '*' && line[i] == '/') { + incomment = false; + } + } else if (prev == '/' && line[i] == '*') { + incomment = true; + } else if (prev == '/' && line[i] == '/') { + return false; + } + } + + prev = line[i]; + } + + return incomment == false && instring == 0; +} + /* * Search for variable declaration of "ptr[len]". * When "locally" is true in the current function ("gd"), otherwise in the @@ -3683,6 +3716,7 @@ find_decl ( bool retval = true; bool incll; int searchflags = flags_arg; + bool valid; pat = xmalloc(len + 7); @@ -3717,6 +3751,7 @@ find_decl ( /* Search forward for the identifier, ignore comment lines. */ clearpos(&found_pos); for (;; ) { + valid = false; t = searchit(curwin, curbuf, &curwin->w_cursor, FORWARD, pat, 1L, searchflags, RE_LAST, (linenr_T)0, NULL); if (curwin->w_cursor.lnum >= old_pos.lnum) @@ -3747,20 +3782,35 @@ find_decl ( curwin->w_cursor.col = 0; continue; } - if (!locally) /* global search: use first match found */ + valid = is_ident(get_cursor_line_ptr(), curwin->w_cursor.col); + + // If the current position is not a valid identifier and a previous match is + // present, favor that one instead. + if (!valid && found_pos.lnum != 0) { + curwin->w_cursor = found_pos; break; - if (curwin->w_cursor.lnum >= par_pos.lnum) { - /* If we previously found a valid position, use it. */ - if (found_pos.lnum != 0) + } + // global search: use first match found + if (valid && !locally) { + break; + } + if (valid && curwin->w_cursor.lnum >= par_pos.lnum) { + // If we previously found a valid position, use it. + if (found_pos.lnum != 0) { curwin->w_cursor = found_pos; + } break; } - // For finding a local variable and the match is before the "{" search - // to find a later match. For K&R style function declarations this - // skips the function header without types. Remove SEARCH_START from - // flags to avoid getting stuck at one position. - found_pos = curwin->w_cursor; + // For finding a local variable and the match is before the "{" or + // inside a comment, continue searching. For K&R style function + // declarations this skips the function header without types. + if (!valid) { + clearpos(&found_pos); + } else { + found_pos = curwin->w_cursor; + } + // Remove SEARCH_START from flags to avoid getting stuck at one position. searchflags &= ~SEARCH_START; } diff --git a/src/nvim/testdir/test_goto.vim b/src/nvim/testdir/test_goto.vim index b6ac5720c3..909e29e27e 100644 --- a/src/nvim/testdir/test_goto.vim +++ b/src/nvim/testdir/test_goto.vim @@ -1,22 +1,277 @@ " Test commands that jump somewhere. -func Test_geeDEE() +" Create a new buffer using "lines" and place the cursor on the word after the +" first occurrence of return and invoke "cmd". The cursor should now be +" positioned at the given line and col. +func XTest_goto_decl(cmd, lines, line, col) new - call setline(1, ["Filename x;", "", "int Filename", "int func() {", "Filename y;"]) - /y;/ - normal gD - call assert_equal(1, line('.')) + call setline(1, a:lines) + /return/ + normal! W + execute 'norm! ' . a:cmd + call assert_equal(a:line, line('.')) + call assert_equal(a:col, col('.')) quit! endfunc -func Test_gee_dee() - new - call setline(1, ["int x;", "", "int func(int x)", "{", " return x;", "}"]) - /return/ - normal $hgd - call assert_equal(3, line('.')) - call assert_equal(14, col('.')) - quit! +func Test_gD() + let lines = [ + \ 'int x;', + \ '', + \ 'int func(void)', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gD', lines, 1, 5) +endfunc + +func Test_gD_too() + let lines = [ + \ 'Filename x;', + \ '', + \ 'int Filename', + \ 'int func() {', + \ ' Filename x;', + \ ' return x;', + \ ] + call XTest_goto_decl('gD', lines, 1, 10) +endfunc + +func Test_gD_comment() + let lines = [ + \ '/* int x; */', + \ 'int x;', + \ '', + \ 'int func(void)', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gD', lines, 2, 5) +endfunc + +func Test_gD_inline_comment() + let lines = [ + \ 'int y /* , x */;', + \ 'int x;', + \ '', + \ 'int func(void)', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gD', lines, 2, 5) +endfunc + +func Test_gD_string() + let lines = [ + \ 'char *s[] = "x";', + \ 'int x = 1;', + \ '', + \ 'int func(void)', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gD', lines, 2, 5) +endfunc + +func Test_gD_string_same_line() + let lines = [ + \ 'char *s[] = "x", int x = 1;', + \ '', + \ 'int func(void)', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gD', lines, 1, 22) +endfunc + +func Test_gD_char() + let lines = [ + \ "char c = 'x';", + \ 'int x = 1;', + \ '', + \ 'int func(void)', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gD', lines, 2, 5) +endfunc + +func Test_gd() + let lines = [ + \ 'int x;', + \ '', + \ 'int func(int x)', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gd', lines, 3, 14) +endfunc + +func Test_gd_not_local() + let lines = [ + \ 'int func1(void)', + \ '{', + \ ' return x;', + \ '}', + \ '', + \ 'int func2(int x)', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gd', lines, 3, 10) +endfunc + +func Test_gd_kr_style() + let lines = [ + \ 'int func(x)', + \ ' int x;', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gd', lines, 2, 7) +endfunc + +func Test_gd_missing_braces() + let lines = [ + \ 'def func1(a)', + \ ' a + 1', + \ 'end', + \ '', + \ 'a = 1', + \ '', + \ 'def func2()', + \ ' return a', + \ 'end', + \ ] + call XTest_goto_decl('gd', lines, 1, 11) +endfunc + +func Test_gd_comment() + let lines = [ + \ 'int func(void)', + \ '{', + \ ' /* int x; */', + \ ' int x;', + \ ' return x;', + \ '}', + \] + call XTest_goto_decl('gd', lines, 4, 7) +endfunc + +func Test_gd_comment_in_string() + let lines = [ + \ 'int func(void)', + \ '{', + \ ' char *s ="//"; int x;', + \ ' int x;', + \ ' return x;', + \ '}', + \] + call XTest_goto_decl('gd', lines, 3, 22) +endfunc + +func Test_gd_string_in_comment() + set comments= + let lines = [ + \ 'int func(void)', + \ '{', + \ ' /* " */ int x;', + \ ' int x;', + \ ' return x;', + \ '}', + \] + call XTest_goto_decl('gd', lines, 3, 15) + set comments& +endfunc + +func Test_gd_inline_comment() + let lines = [ + \ 'int func(/* x is an int */ int x)', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gd', lines, 1, 32) +endfunc + +func Test_gd_inline_comment_only() + let lines = [ + \ 'int func(void) /* one lonely x */', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gd', lines, 3, 10) +endfunc + +func Test_gd_inline_comment_body() + let lines = [ + \ 'int func(void)', + \ '{', + \ ' int y /* , x */;', + \ '', + \ ' for (/* int x = 0 */; y < 2; y++);', + \ '', + \ ' int x = 0;', + \ '', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gd', lines, 7, 7) +endfunc + +func Test_gd_trailing_multiline_comment() + let lines = [ + \ 'int func(int x) /* x is an int */', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gd', lines, 1, 14) +endfunc + +func Test_gd_trailing_comment() + let lines = [ + \ 'int func(int x) // x is an int', + \ '{', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gd', lines, 1, 14) +endfunc + +func Test_gd_string() + let lines = [ + \ 'int func(void)', + \ '{', + \ ' char *s = "x";', + \ ' int x = 1;', + \ '', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gd', lines, 4, 7) +endfunc + +func Test_gd_string_only() + let lines = [ + \ 'int func(void)', + \ '{', + \ ' char *s = "x";', + \ '', + \ ' return x;', + \ '}', + \ ] + call XTest_goto_decl('gd', lines, 5, 10) endfunc " Check that setting 'cursorline' does not change curswant diff --git a/src/nvim/version.c b/src/nvim/version.c index c7b8220776..0bc1655a74 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -706,7 +706,7 @@ static const int included_patches[] = { // 26, // 25, // 24 NA - // 23, + 23, // 22 NA // 21, // 20, -- cgit From 9cf0415761bab62e8dad95b965fb6a14d00a4f4b Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Sun, 16 Jul 2017 21:43:17 +0200 Subject: vim-patch:8.0.0025 Problem: Inconsistent use of spaces vs tabs in gd test. Solution: Use tabs. (Anton Lindqvist) https://github.com/vim/vim/commit/936c48f8ca82a0257640c8c9d0792538f5a7e813 --- src/nvim/testdir/test_goto.vim | 292 ++++++++++++++++++++--------------------- src/nvim/version.c | 2 +- 2 files changed, 147 insertions(+), 147 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_goto.vim b/src/nvim/testdir/test_goto.vim index 909e29e27e..2573401707 100644 --- a/src/nvim/testdir/test_goto.vim +++ b/src/nvim/testdir/test_goto.vim @@ -16,13 +16,13 @@ endfunc func Test_gD() let lines = [ - \ 'int x;', - \ '', - \ 'int func(void)', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ 'int x;', + \ '', + \ 'int func(void)', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gD', lines, 1, 5) endfunc @@ -40,237 +40,237 @@ endfunc func Test_gD_comment() let lines = [ - \ '/* int x; */', - \ 'int x;', - \ '', - \ 'int func(void)', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ '/* int x; */', + \ 'int x;', + \ '', + \ 'int func(void)', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gD', lines, 2, 5) endfunc func Test_gD_inline_comment() let lines = [ - \ 'int y /* , x */;', - \ 'int x;', - \ '', - \ 'int func(void)', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ 'int y /* , x */;', + \ 'int x;', + \ '', + \ 'int func(void)', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gD', lines, 2, 5) endfunc func Test_gD_string() let lines = [ - \ 'char *s[] = "x";', - \ 'int x = 1;', - \ '', - \ 'int func(void)', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ 'char *s[] = "x";', + \ 'int x = 1;', + \ '', + \ 'int func(void)', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gD', lines, 2, 5) endfunc func Test_gD_string_same_line() let lines = [ - \ 'char *s[] = "x", int x = 1;', - \ '', - \ 'int func(void)', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ 'char *s[] = "x", int x = 1;', + \ '', + \ 'int func(void)', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gD', lines, 1, 22) endfunc func Test_gD_char() let lines = [ - \ "char c = 'x';", - \ 'int x = 1;', - \ '', - \ 'int func(void)', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ "char c = 'x';", + \ 'int x = 1;', + \ '', + \ 'int func(void)', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gD', lines, 2, 5) endfunc func Test_gd() let lines = [ - \ 'int x;', - \ '', - \ 'int func(int x)', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ 'int x;', + \ '', + \ 'int func(int x)', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gd', lines, 3, 14) endfunc func Test_gd_not_local() let lines = [ - \ 'int func1(void)', - \ '{', - \ ' return x;', - \ '}', - \ '', - \ 'int func2(int x)', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ 'int func1(void)', + \ '{', + \ ' return x;', + \ '}', + \ '', + \ 'int func2(int x)', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gd', lines, 3, 10) endfunc func Test_gd_kr_style() let lines = [ - \ 'int func(x)', - \ ' int x;', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ 'int func(x)', + \ ' int x;', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gd', lines, 2, 7) endfunc func Test_gd_missing_braces() let lines = [ - \ 'def func1(a)', - \ ' a + 1', - \ 'end', - \ '', - \ 'a = 1', - \ '', - \ 'def func2()', - \ ' return a', - \ 'end', - \ ] + \ 'def func1(a)', + \ ' a + 1', + \ 'end', + \ '', + \ 'a = 1', + \ '', + \ 'def func2()', + \ ' return a', + \ 'end', + \ ] call XTest_goto_decl('gd', lines, 1, 11) endfunc func Test_gd_comment() let lines = [ - \ 'int func(void)', - \ '{', - \ ' /* int x; */', - \ ' int x;', - \ ' return x;', - \ '}', - \] + \ 'int func(void)', + \ '{', + \ ' /* int x; */', + \ ' int x;', + \ ' return x;', + \ '}', + \] call XTest_goto_decl('gd', lines, 4, 7) endfunc func Test_gd_comment_in_string() let lines = [ - \ 'int func(void)', - \ '{', - \ ' char *s ="//"; int x;', - \ ' int x;', - \ ' return x;', - \ '}', - \] + \ 'int func(void)', + \ '{', + \ ' char *s ="//"; int x;', + \ ' int x;', + \ ' return x;', + \ '}', + \] call XTest_goto_decl('gd', lines, 3, 22) endfunc func Test_gd_string_in_comment() set comments= let lines = [ - \ 'int func(void)', - \ '{', - \ ' /* " */ int x;', - \ ' int x;', - \ ' return x;', - \ '}', - \] + \ 'int func(void)', + \ '{', + \ ' /* " */ int x;', + \ ' int x;', + \ ' return x;', + \ '}', + \] call XTest_goto_decl('gd', lines, 3, 15) set comments& endfunc func Test_gd_inline_comment() let lines = [ - \ 'int func(/* x is an int */ int x)', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ 'int func(/* x is an int */ int x)', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gd', lines, 1, 32) endfunc func Test_gd_inline_comment_only() let lines = [ - \ 'int func(void) /* one lonely x */', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ 'int func(void) /* one lonely x */', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gd', lines, 3, 10) endfunc func Test_gd_inline_comment_body() let lines = [ - \ 'int func(void)', - \ '{', - \ ' int y /* , x */;', - \ '', - \ ' for (/* int x = 0 */; y < 2; y++);', - \ '', - \ ' int x = 0;', - \ '', - \ ' return x;', - \ '}', - \ ] + \ 'int func(void)', + \ '{', + \ ' int y /* , x */;', + \ '', + \ ' for (/* int x = 0 */; y < 2; y++);', + \ '', + \ ' int x = 0;', + \ '', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gd', lines, 7, 7) endfunc func Test_gd_trailing_multiline_comment() let lines = [ - \ 'int func(int x) /* x is an int */', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ 'int func(int x) /* x is an int */', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gd', lines, 1, 14) endfunc func Test_gd_trailing_comment() let lines = [ - \ 'int func(int x) // x is an int', - \ '{', - \ ' return x;', - \ '}', - \ ] + \ 'int func(int x) // x is an int', + \ '{', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gd', lines, 1, 14) endfunc func Test_gd_string() let lines = [ - \ 'int func(void)', - \ '{', - \ ' char *s = "x";', - \ ' int x = 1;', - \ '', - \ ' return x;', - \ '}', - \ ] + \ 'int func(void)', + \ '{', + \ ' char *s = "x";', + \ ' int x = 1;', + \ '', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gd', lines, 4, 7) endfunc func Test_gd_string_only() let lines = [ - \ 'int func(void)', - \ '{', - \ ' char *s = "x";', - \ '', - \ ' return x;', - \ '}', - \ ] + \ 'int func(void)', + \ '{', + \ ' char *s = "x";', + \ '', + \ ' return x;', + \ '}', + \ ] call XTest_goto_decl('gd', lines, 5, 10) endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 0bc1655a74..b6a0ca3e1b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -704,7 +704,7 @@ static const int included_patches[] = { // 28 NA // 27 NA // 26, - // 25, + 25, // 24 NA 23, // 22 NA -- cgit From f4744e18219726d2eaa57b26198166ea255c62a4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 17 Jul 2017 01:55:10 +0300 Subject: ex_getln: Do not goto color_cmdline_end without first cleaning up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The issue with debug mode was actually not cleaning up after `try_enter`: location `&tstate` was pointing to got invalidated and received some “garbage†(actually, values that got stored on the stack afterwards). But pointer to that garbage was still stored in `msg_list`, so next attempt to check it resulted in a crash. --- src/nvim/ex_getln.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 275e1b7fdd..1052053ddf 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2372,8 +2372,6 @@ static bool color_cmdline(void) dgc_ret = tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_expr"), &color_cb); can_free_cb = true; - } else { - goto color_cmdline_end; } if (!try_leave(&tstate, &err) || !dgc_ret) { goto color_cmdline_error; -- cgit From dc0a496d41ed23106632d12bbc33679997281c73 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 17 Jul 2017 01:57:27 +0300 Subject: ex_getln: Do not do useless try_enter/try_leave calls These are actually needed for two modes only. And even for these modes they should eventually go away. --- src/nvim/ex_getln.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 1052053ddf..9bcabeee72 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2356,24 +2356,28 @@ static bool color_cmdline(void) Error err = ERROR_INIT; const char *err_errmsg = (const char *)e_intern2; bool dgc_ret = true; + bool tl_ret = true; - try_enter(&tstate); if (ccline.input_fn) { color_cb = getln_input_callback; } else if (ccline.cmdfirstc == ':') { + try_enter(&tstate); err_errmsg = N_( "E5408: Unable to get Nvim_color_cmdline callback from g:: %s"); dgc_ret = tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_cmdline"), &color_cb); + tl_ret = try_leave(&tstate, &err); can_free_cb = true; } else if (ccline.cmdfirstc == '=') { + try_enter(&tstate); err_errmsg = N_( "E5409: Unable to get Nvim_color_expr callback from g:: %s"); dgc_ret = tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_expr"), &color_cb); + tl_ret = try_leave(&tstate, &err); can_free_cb = true; } - if (!try_leave(&tstate, &err) || !dgc_ret) { + if (!tl_ret || !dgc_ret) { goto color_cmdline_error; } -- cgit From 3a923ad2db87b2bece89616b28a14ab9826d569a Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 17 Jul 2017 02:33:18 +0300 Subject: ex_getln: Replace global with entry in save_ccline --- src/nvim/eval.c | 7 ++--- src/nvim/eval/typval.h | 2 +- src/nvim/ex_cmds2.c | 3 ++- src/nvim/ex_getln.c | 70 ++++++++++++++++++++++++++++---------------------- src/nvim/ex_getln.h | 2 -- 5 files changed, 44 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 694c34731d..afa6711645 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -11108,13 +11108,10 @@ void get_user_input(const typval_T *const argvars, stuffReadbuffSpec(defstr); const int save_ex_normal_busy = ex_normal_busy; - const Callback save_getln_input_callback = getln_input_callback; ex_normal_busy = 0; - getln_input_callback = input_callback; rettv->vval.v_string = - getcmdline_prompt(inputsecret_flag ? NUL : '@', (char_u *)p, echo_attr, - xp_type, (char_u *)xp_arg); - getln_input_callback = save_getln_input_callback; + (char_u *)getcmdline_prompt(inputsecret_flag ? NUL : '@', p, echo_attr, + xp_type, xp_arg, input_callback); ex_normal_busy = save_ex_normal_busy; callback_free(&input_callback); diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 3f8ed3b3f9..c44b85644d 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -43,7 +43,7 @@ typedef struct partial_S partial_T; typedef struct ufunc ufunc_T; typedef enum { - kCallbackNone, + kCallbackNone = 0, kCallbackFuncref, kCallbackPartial, } CallbackType; diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 1a728647ca..79882973b1 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -189,7 +189,8 @@ void do_debug(char_u *cmd) } xfree(cmdline); - cmdline = getcmdline_prompt('>', NULL, 0, EXPAND_NOTHING, NULL); + cmdline = (char_u *)getcmdline_prompt('>', NULL, 0, EXPAND_NOTHING, NULL, + CALLBACK_NONE); if (typeahead_saved) { restore_typeahead(&typeaheadbuf); diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 9bcabeee72..13bae4dadc 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -89,6 +89,7 @@ struct cmdline_info { char_u *xp_arg; // user-defined expansion arg int input_fn; // when TRUE Invoked for input() function unsigned prompt_id; ///< Prompt number, used to disable coloring on errors. + Callback highlight_callback; ///< Callback used for coloring user input. }; /// Last value of prompt_id, incremented when doing new prompt static unsigned last_prompt_id = 0; @@ -148,9 +149,6 @@ typedef struct { int attr; ///< Highlight attr. } ColoredCmdlineChunk; -/// Callback used for coloring input() prompts -Callback getln_input_callback = { .type = kCallbackNone }; - kvec_t(ColoredCmdlineChunk) ccline_colors; /* The current cmdline_info. It is initialized in getcmdline() and after that @@ -1815,42 +1813,50 @@ getcmdline ( return command_line_enter(firstc, count, indent); } -/* - * Get a command line with a prompt. - * This is prepared to be called recursively from getcmdline() (e.g. by - * f_input() when evaluating an expression from CTRL-R =). - * Returns the command line in allocated memory, or NULL. - */ -char_u * -getcmdline_prompt ( - int firstc, - char_u *prompt, /* command line prompt */ - int attr, /* attributes for prompt */ - int xp_context, /* type of expansion */ - char_u *xp_arg /* user-defined expansion argument */ -) +/// Get a command line with a prompt +/// +/// This is prepared to be called recursively from getcmdline() (e.g. by +/// f_input() when evaluating an expression from `=`). +/// +/// @param[in] firstc Prompt type: e.g. '@' for input(), '>' for debug. +/// @param[in] prompt Prompt string: what is displayed before the user text. +/// @param[in] attr Prompt highlighting. +/// @param[in] xp_context Type of expansion. +/// @param[in] xp_arg User-defined expansion argument. +/// @param[in] highlight_callback Callback used for highlighting user input. +/// +/// @return [allocated] Command line or NULL. +char *getcmdline_prompt(const char firstc, const char *const prompt, + const int attr, const int xp_context, + const char *const xp_arg, + const Callback highlight_callback) + FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC { - char_u *s; - struct cmdline_info save_ccline; - int msg_col_save = msg_col; + const int msg_col_save = msg_col; + struct cmdline_info save_ccline; save_cmdline(&save_ccline); + ccline.prompt_id = last_prompt_id++; - ccline.cmdprompt = prompt; + ccline.cmdprompt = (char_u *)prompt; ccline.cmdattr = attr; ccline.xp_context = xp_context; - ccline.xp_arg = xp_arg; + ccline.xp_arg = (char_u *)xp_arg; ccline.input_fn = (firstc == '@'); - s = getcmdline(firstc, 1L, 0); + ccline.highlight_callback = highlight_callback; + + char *const ret = (char *)getcmdline(firstc, 1L, 0); + restore_cmdline(&save_ccline); - /* Restore msg_col, the prompt from input() may have changed it. - * But only if called recursively and the commandline is therefore being - * restored to an old one; if not, the input() prompt stays on the screen, - * so we need its modified msg_col left intact. */ - if (ccline.cmdbuff != NULL) + // Restore msg_col, the prompt from input() may have changed it. + // But only if called recursively and the commandline is therefore being + // restored to an old one; if not, the input() prompt stays on the screen, + // so we need its modified msg_col left intact. + if (ccline.cmdbuff != NULL) { msg_col = msg_col_save; + } - return s; + return ret; } /* @@ -2358,8 +2364,10 @@ static bool color_cmdline(void) bool dgc_ret = true; bool tl_ret = true; - if (ccline.input_fn) { - color_cb = getln_input_callback; + if (ccline.highlight_callback.type != kCallbackNone) { + // Currently this should only happen while processing input() prompts. + assert(ccline.input_fn); + color_cb = ccline.highlight_callback; } else if (ccline.cmdfirstc == ':') { try_enter(&tstate); err_errmsg = N_( diff --git a/src/nvim/ex_getln.h b/src/nvim/ex_getln.h index 92cb274010..051564fbe1 100644 --- a/src/nvim/ex_getln.h +++ b/src/nvim/ex_getln.h @@ -52,8 +52,6 @@ typedef struct hist_entry { list_T *additional_elements; ///< Additional entries from ShaDa file. } histentry_T; -extern Callback getln_input_callback; - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ex_getln.h.generated.h" #endif -- cgit From 24a0d4e122024071195ac8a2828fba3184c8e12e Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 17 Jul 2017 22:38:03 +0800 Subject: vim-patch:8.0.0004 (#7044) Problem: A string argument for function() that is not a function name results in an error message with NULL. (Christian Brabandt) Solution: Use the argument for the error message. https://github.com/vim/vim/commit/5582ef14384525e8cec86016876d97a6b32dd548 --- src/nvim/testdir/test_expr.vim | 3 +++ src/nvim/version.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim index 82c5d21bd0..710eae9b8b 100644 --- a/src/nvim/testdir/test_expr.vim +++ b/src/nvim/testdir/test_expr.vim @@ -418,6 +418,9 @@ func Test_function_with_funcref() let s:fref = function(s:f) call assert_equal(v:t_string, s:fref('x')) call assert_fails("call function('s:f')", 'E700:') + + call assert_fails("call function('foo()')", 'E475:') + call assert_fails("call function('foo()')", 'foo()') endfunc func Test_funcref() diff --git a/src/nvim/version.c b/src/nvim/version.c index c7b8220776..06efcc5bfc 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -725,7 +725,7 @@ static const int included_patches[] = { // 7 NA 6, // 5 NA - // 4, + 4, // 3, 2, 1, -- cgit From cfb1d937a64fcec836fdf26d6ea67024aeafabeb Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 18 Jul 2017 00:08:57 +0300 Subject: api helpers: Also save and restore did_emsg --- src/nvim/api/private/helpers.c | 19 ++++++++++++------- src/nvim/api/private/helpers.h | 7 ++++--- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 6ff56709cd..b6ecc319c1 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -46,20 +46,22 @@ typedef struct { void try_enter(TryState *const tstate) { *tstate = (TryState) { + .current_exception = current_exception, + .msg_list = (const struct msglist *const *)msg_list, + .private_msg_list = NULL, .trylevel = trylevel, .got_int = got_int, .did_throw = did_throw, .need_rethrow = need_rethrow, - .current_exception = current_exception, - .msg_list = (const struct msglist *const *)msg_list, - .private_msg_list = NULL, + .did_emsg = did_emsg, }; + msg_list = &tstate->private_msg_list; + current_exception = NULL; trylevel = 1; got_int = false; did_throw = false; need_rethrow = false; - msg_list = &tstate->private_msg_list; - current_exception = NULL; + did_emsg = false; } /// End try block, set the error message if any and restore previous state @@ -79,14 +81,17 @@ bool try_leave(const TryState *const tstate, Error *const err) assert(!need_rethrow); assert(!got_int); assert(!did_throw); + assert(!did_emsg); assert(msg_list == &tstate->private_msg_list); assert(*msg_list == NULL); assert(current_exception == NULL); + msg_list = (struct msglist **)tstate->msg_list; + current_exception = tstate->current_exception; trylevel = tstate->trylevel; got_int = tstate->got_int; did_throw = tstate->did_throw; - msg_list = (struct msglist **)tstate->msg_list; - current_exception = tstate->current_exception; + need_rethrow = tstate->need_rethrow; + did_emsg = tstate->did_emsg; return ret; } diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h index 0b2cf883a6..87f334ac30 100644 --- a/src/nvim/api/private/helpers.h +++ b/src/nvim/api/private/helpers.h @@ -88,13 +88,14 @@ /// Used when caller is supposed to be operating when other VimL code is being /// processed and that “other VimL code†must not be affected. typedef struct { + except_T *current_exception; + struct msglist *private_msg_list; + const struct msglist *const *msg_list; int trylevel; int got_int; int did_throw; int need_rethrow; - except_T *current_exception; - struct msglist *private_msg_list; - const struct msglist *const *msg_list; + int did_emsg; } TryState; #ifdef INCLUDE_GENERATED_DECLARATIONS -- cgit From 8a581b918b339b84b5abd80919416a84932eb13f Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 18 Jul 2017 00:20:21 +0300 Subject: ex_getln: Check prev_prompt_errors before running redrawcmdline Otherwise there will be infinite recursion and shortly a crash. Running redrawcmdline recursively occurs under color_cmdline_error label. --- src/nvim/ex_getln.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 13bae4dadc..4be0dd0e0d 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2364,6 +2364,12 @@ static bool color_cmdline(void) bool dgc_ret = true; bool tl_ret = true; + if (ccline.prompt_id != prev_prompt_id) { + prev_prompt_errors = 0; + prev_prompt_id = ccline.prompt_id; + } else if (prev_prompt_errors >= MAX_CB_ERRORS) { + goto color_cmdline_end; + } if (ccline.highlight_callback.type != kCallbackNone) { // Currently this should only happen while processing input() prompts. assert(ccline.input_fn); @@ -2392,12 +2398,6 @@ static bool color_cmdline(void) if (color_cb.type == kCallbackNone) { goto color_cmdline_end; } - if (ccline.prompt_id != prev_prompt_id) { - prev_prompt_errors = 0; - prev_prompt_id = ccline.prompt_id; - } else if (prev_prompt_errors >= MAX_CB_ERRORS) { - goto color_cmdline_end; - } if (ccline.cmdbuff[ccline.cmdlen] != NUL) { arg_allocated = true; arg.vval.v_string = xmemdupz((const char *)ccline.cmdbuff, -- cgit From 25c6ac1af63c0d68b7993910e94d3b0f1b8bbfd7 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 18 Jul 2017 01:21:23 +0300 Subject: *: Fix clint errors --- src/nvim/api/private/helpers.c | 2 +- src/nvim/ex_eval.c | 2 +- src/nvim/ex_getln.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index b6ecc319c1..cdaceddc11 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -110,7 +110,7 @@ bool try_end(Error *err) { // Note: all globals manipulated here should be saved/restored in // try_enter/try_leave. - --trylevel; + trylevel--; // Without this it stops processing all subsequent VimL commands and // generates strange error messages if I e.g. try calling Test() in a diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 139305998d..4434dbe1a5 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -564,7 +564,7 @@ static void discard_exception(except_T *excp, int was_finished) */ void discard_current_exception(void) { - discard_exception(current_exception, FALSE); + discard_exception(current_exception, false); // Note: all globals manipulated here should be saved/restored in // try_enter/try_leave. current_exception = NULL; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 4be0dd0e0d..6ac0d062ac 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2321,7 +2321,7 @@ enum { MAX_CB_ERRORS = 1 }; /// Color command-line /// -/// Should use built-in command parser or user-specified one. Currently only the +/// Should use built-in command parser or user-specified one. Currently only the /// latter is supported. /// /// Operates on ccline, saving results to ccline_colors. -- cgit From 740dcaef0d6a7dda08e025fba678b763994128af Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 18 Jul 2017 01:25:55 +0300 Subject: ex_getln: Avoid GCC “unused variable†warning from QB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 17:25:45,363 WARN - /home/quickbuild/buildagent/workspace/root/neovim/pull-requests-automated/src/nvim/ex_getln.c: In function ‘color_cmdline’: 17:25:45,363 WARN - /home/quickbuild/buildagent/workspace/root/neovim/pull-requests-automated/src/nvim/ex_getln.c:2335:8: error: variable ‘printed_errmsg’ set but not used [-Werror=unused-but-set-variable] 17:25:45,363 WARN - bool printed_errmsg = false; 17:25:45,363 WARN - ^ 17:25:45,399 WARN - cc1: all warnings being treated as errors --- src/nvim/ex_getln.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 6ac0d062ac..6115ebf2cb 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2523,6 +2523,7 @@ color_cmdline_error: api_clear_error(&err); } assert(printed_errmsg); + (void)printed_errmsg; prev_prompt_errors++; kv_size(ccline_colors) = 0; -- cgit From b98ea04226d5ae7f2d8f9650101f87a848145ca4 Mon Sep 17 00:00:00 2001 From: lonerover Date: Sat, 15 Jul 2017 21:02:15 +0800 Subject: vim-patch:8.0.0003 Problem: getwinvar() returns wrong Value of boolean and number options, especially non big endian systems. (James McCoy) Solution: Cast the pointer to long or int. (closes vim/vim#1060) https://github.com/vim/vim/commit/789a5c0e3d27f09456678f0cfb6c1bd2d8ab4a35 --- src/nvim/option.c | 5 ++++- src/nvim/testdir/test_bufwintabinfo.vim | 13 +++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 37b37e2859..40fae18aaf 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -7039,8 +7039,11 @@ dict_T *get_winbuf_options(const int bufopt) if (opt->flags & P_STRING) { tv_dict_add_str(d, opt->fullname, strlen(opt->fullname), *(const char **)varp); + } else if (opt->flags & P_NUM) { + tv_dict_add_nr(d, opt->fullname, strlen(opt->fullname), + *(long *)varp); } else { - tv_dict_add_nr(d, opt->fullname, strlen(opt->fullname), *varp); + tv_dict_add_nr(d, opt->fullname, strlen(opt->fullname), *(int *)varp); } } } diff --git a/src/nvim/testdir/test_bufwintabinfo.vim b/src/nvim/testdir/test_bufwintabinfo.vim index 5c916e2dd7..1c9350c416 100644 --- a/src/nvim/testdir/test_bufwintabinfo.vim +++ b/src/nvim/testdir/test_bufwintabinfo.vim @@ -87,9 +87,17 @@ function Test_get_buf_options() endfunc function Test_get_win_options() + if has('folding') + set foldlevel=999 + endif + set list let opts = getwinvar(1, '&') call assert_equal(v:t_dict, type(opts)) call assert_equal(0, opts.linebreak) + call assert_equal(1, opts.list) + if has('folding') + call assert_equal(999, opts.foldlevel) + endif if has('signs') call assert_equal('auto', opts.signcolumn) endif @@ -97,7 +105,12 @@ function Test_get_win_options() let opts = gettabwinvar(1, 1, '&') call assert_equal(v:t_dict, type(opts)) call assert_equal(0, opts.linebreak) + call assert_equal(1, opts.list) if has('signs') call assert_equal('auto', opts.signcolumn) endif + set list& + if has('folding') + set foldlevel=0 + endif endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 2200c5e04a..a7d6885b4c 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -726,7 +726,7 @@ static const int included_patches[] = { 6, // 5 NA 4, - // 3, + 3, 2, 1, 0 -- cgit From 710546c5e93cd433bd2eb566df52b58e3583c386 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Mon, 17 Jul 2017 15:53:23 +0200 Subject: vim-patch:8.0.0085 Problem: Using freed memory with recursive function call. (Dominique Pelle) Solution: Make a copy of the function name. https://github.com/vim/vim/commit/8a01f969c198eeb655ad2f96f2796a6f6f4a1924 --- src/nvim/eval.c | 6 ++++++ src/nvim/testdir/test_nested_function.vim | 36 ++++++++++++++++++++----------- src/nvim/version.c | 2 +- 3 files changed, 30 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index e5bb7f1b38..08b3d1dbd7 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -4239,11 +4239,17 @@ static int eval7( // use its contents. s = deref_func_name((const char *)s, &len, &partial, !evaluate); + // Need to make a copy, in case evaluating the arguments makes + // the name invalid. + s = xmemdupz(s, len); + // Invoke the function. ret = get_func_tv(s, len, rettv, arg, curwin->w_cursor.lnum, curwin->w_cursor.lnum, &len, evaluate, partial, NULL); + xfree(s); + // If evaluate is false rettv->v_type was not set in // get_func_tv, but it's needed in handle_subscript() to parse // what follows. So set it here. diff --git a/src/nvim/testdir/test_nested_function.vim b/src/nvim/testdir/test_nested_function.vim index f881730529..7e301ed33e 100644 --- a/src/nvim/testdir/test_nested_function.vim +++ b/src/nvim/testdir/test_nested_function.vim @@ -1,32 +1,42 @@ "Tests for nested functions " -function! NestedFunc() - fu! Func1() +func NestedFunc() + func! Func1() let g:text .= 'Func1 ' - endfunction + endfunc call Func1() - fu! s:func2() + func! s:func2() let g:text .= 's:func2 ' - endfunction + endfunc call s:func2() - fu! s:_func3() + func! s:_func3() let g:text .= 's:_func3 ' - endfunction + endfunc call s:_func3() let fn = 'Func4' - fu! {fn}() + func! {fn}() let g:text .= 'Func4 ' - endfunction + endfunc call {fn}() let fn = 'func5' - fu! s:{fn}() + func! s:{fn}() let g:text .= 's:func5' - endfunction + endfunc call s:{fn}() -endfunction +endfunc -function! Test_nested_functions() +func Test_nested_functions() let g:text = '' call NestedFunc() call assert_equal('Func1 s:func2 s:_func3 Func4 s:func5', g:text) endfunction + +func Test_nested_argument() + func g:X() + let g:Y = function('sort') + endfunc + let g:Y = function('sort') + echo g:Y([], g:X()) + delfunc g:X + unlet g:Y +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index a7d6885b4c..9b5c5eefb8 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -644,7 +644,7 @@ static const int included_patches[] = { // 88, // 87 NA // 86, - // 85, + 85, 84, 83, // 82 NA -- cgit From 962e8cc1dd4d1b901b249e8434ac4db6554d3e05 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 23 Jul 2017 00:59:14 +0800 Subject: vim-patch:8.0.0052 (#7057) Problem: Conceal test passes even without the bug fix. Solution: Add a redraw command. (Christian Brabandt) https://github.com/vim/vim/commit/35a1f59d635d9a655e1267c18f7cc757afd0d5b0 --- src/nvim/testdir/test_matchadd_conceal.vim | 1 + src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_matchadd_conceal.vim b/src/nvim/testdir/test_matchadd_conceal.vim index c788689e33..c11f1a84a9 100644 --- a/src/nvim/testdir/test_matchadd_conceal.vim +++ b/src/nvim/testdir/test_matchadd_conceal.vim @@ -277,6 +277,7 @@ function! Test_matchadd_and_syn_conceal() call assert_notequal(screenattr(1, 11) , screenattr(1, 12)) call assert_equal(screenattr(1, 11) , screenattr(1, 32)) call matchadd('CheckedByCoq', '\%<2l\%>9c\%<16c') + redraw! call assert_equal(expect, s:screenline(1)) call assert_notequal(screenattr(1, 10) , screenattr(1, 11)) call assert_notequal(screenattr(1, 11) , screenattr(1, 12)) diff --git a/src/nvim/version.c b/src/nvim/version.c index 9b5c5eefb8..b325052cd2 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -677,7 +677,7 @@ static const int included_patches[] = { // 55 NA // 54 NA 53, - // 52, + 52, // 51 NA // 50 NA 49, -- cgit From 8fb599029f41b74e6c34b680a0817ff19f544cf3 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 23 Jul 2017 01:03:15 +0800 Subject: vim-patch:8.0.0031 (#7050) Problem: After ":bwipeout" 'fileformat' is not set to the right default. Solution: Get the default from 'fileformats'. (Mike Williams) https://github.com/vim/vim/commit/e8ef3a093453b73594e15462d4de50b011c8ba66 --- src/nvim/option.c | 17 ++++++++++++++++- src/nvim/testdir/test_alot.vim | 1 + src/nvim/testdir/test_fileformat.vim | 17 +++++++++++++++++ src/nvim/version.c | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 src/nvim/testdir/test_fileformat.vim (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 40fae18aaf..75b56b4eb4 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -5718,7 +5718,22 @@ void buf_copy_options(buf_T *buf, int flags) free_buf_options(buf, TRUE); buf->b_p_ro = FALSE; /* don't copy readonly */ buf->b_p_fenc = vim_strsave(p_fenc); - buf->b_p_ff = vim_strsave(p_ff); + switch (*p_ffs) { + case 'm': + buf->b_p_ff = vim_strsave((char_u *)FF_MAC); + break; + case 'd': + buf->b_p_ff = vim_strsave((char_u *)FF_DOS); + break; + case 'u': + buf->b_p_ff = vim_strsave((char_u *)FF_UNIX); + break; + default: + buf->b_p_ff = vim_strsave(p_ff); + } + if (buf->b_p_ff != NULL) { + buf->b_start_ffc = *buf->b_p_ff; + } buf->b_p_bh = empty_option; buf->b_p_bt = empty_option; } else diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index 1103778107..d55170c27c 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -14,6 +14,7 @@ source test_float_func.vim source test_functions.vim source test_goto.vim source test_jumps.vim +source test_fileformat.vim source test_lambda.vim source test_menu.vim source test_mapping.vim diff --git a/src/nvim/testdir/test_fileformat.vim b/src/nvim/testdir/test_fileformat.vim new file mode 100644 index 0000000000..584f20cdfc --- /dev/null +++ b/src/nvim/testdir/test_fileformat.vim @@ -0,0 +1,17 @@ +" Test behavior of fileformat after bwipeout of last buffer + +func Test_fileformat_after_bw() + bwipeout + set fileformat& + if &fileformat == 'dos' + let test_fileformats = 'unix' + elseif &fileformat == 'unix' + let test_fileformats = 'mac' + else " must be mac + let test_fileformats = 'dos' + endif + exec 'set fileformats='.test_fileformats + bwipeout! + call assert_equal(test_fileformats, &fileformat) + set fileformats& +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index b325052cd2..61d947017e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -698,7 +698,7 @@ static const int included_patches[] = { // 34, 33, 32, - // 31, + 31, // 30 NA // 29 NA // 28 NA -- cgit From 253f6f3bbfd16b7aeb2f72714c1d5d1c88a3478a Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 23 Jul 2017 01:04:45 +0800 Subject: vim-patch:8.0.0038 (#7051) Problem: OPEN_CHR_FILES not defined for FreeBSD using Debian userland files. Solution: Check for __FreeBSD_kernel__. (James McCoy, closes vim/vim#1166) https://github.com/vim/vim/commit/ca291aec99b60fe81eaab36aa718e51421bb88d5 --- src/nvim/version.c | 2 +- src/nvim/vim.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 61d947017e..d372779c75 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -691,7 +691,7 @@ static const int included_patches[] = { 41, 40, // 39 NA - // 38, + 38, 37, // 36 NA 35, diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 5d2c27a2f4..c71ca411ea 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -319,7 +319,7 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() // Lowest number used for window ID. Cannot have this many windows per tab. #define LOWEST_WIN_ID 1000 -#if defined(__FreeBSD__) && defined(S_ISCHR) +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && defined(S_ISCHR) # define OPEN_CHR_FILES #endif -- cgit From 13f5bc9586cd84eac758a7e109fc88587f858cf0 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 16 Jul 2017 18:09:48 +0200 Subject: log: all UI events, not just UI-bridge Rename ui_bridge.c:UI_CALL to UI_BRIDGE_CALL. --- src/nvim/README.md | 32 +++++++++++++++++++------------ src/nvim/generators/gen_api_ui_events.lua | 3 ++- src/nvim/ui.c | 25 ++++++++++++++++++++++++ src/nvim/ui_bridge.c | 28 ++++----------------------- 4 files changed, 51 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/nvim/README.md b/src/nvim/README.md index 3032913500..660e3d1010 100644 --- a/src/nvim/README.md +++ b/src/nvim/README.md @@ -1,14 +1,19 @@ -## Source code overview -This document is an overview of how Nvim works internally, focusing on parts -that are different from Vim. Since Nvim inherited from Vim, some information in -[its README](https://raw.githubusercontent.com/vim/vim/master/src/README.txt) -still applies. +Module-specific details are documented at the top of each module (e.g. +terminal.c, screen.c). -For module-specific details, read the source code. Some files are extensively -commented at the top (e.g. terminal.c, screen.c). +See also `:help development`. -### Source file name conventions +UI Debugging +------------ + +At `DEBUG_LOG_LEVEL`, all UI events are logged. + + rm -rf build/ + make CMAKE_EXTRA_FLAGS="-DMIN_LOG_LEVEL=0" + +Filename conventions +-------------------- The source files use extensions to hint about their purpose. @@ -19,10 +24,12 @@ The source files use extensions to hint about their purpose. - `*.h.generated.h` - exported functions’ declarations. - `*.c.generated.h` - static functions’ declarations. -### Top-level program loops +Nvim lifecycle +-------------- + +Following describes how Nvim processes input. -Let's understand what a Vim-like program does by analyzing the workflow of -a typical editing session: +Consider a typical Vim-like editing session: 01. Vim dispays the welcome screen 02. User types: `:` @@ -154,7 +161,8 @@ modes managed by the `state_enter` loop: - insert mode: `insert_{enter,check,execute}()`(`edit.c`) - terminal mode: `terminal_{enter,execute}()`(`terminal.c`) -### Async event support +Async event support +------------------- One of the features Nvim added is the support for handling arbitrary asynchronous events, which can include: diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua index acdb25ca67..d2b90db707 100644 --- a/src/nvim/generators/gen_api_ui_events.lua +++ b/src/nvim/generators/gen_api_ui_events.lua @@ -119,7 +119,7 @@ for i = 1, #events do write_signature(bridge_output, ev, 'UI *ui') bridge_output:write('\n{\n') bridge_output:write(send) - bridge_output:write(' UI_CALL(ui, '..ev.name..', '..argc..', ui'..argv..');\n}\n') + bridge_output:write(' UI_BRIDGE_CALL(ui, '..ev.name..', '..argc..', ui'..argv..');\n}\n') end end @@ -128,6 +128,7 @@ for i = 1, #events do call_output:write('\n{\n') if ev.remote_only then write_arglist(call_output, ev, false) + call_output:write(' UI_LOG('..ev.name..', 0);\n') call_output:write(' ui_event("'..ev.name..'", args);\n') else call_output:write(' UI_CALL') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 0a2154438f..a60c061949 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -8,6 +8,7 @@ #include #include "nvim/vim.h" +#include "nvim/log.h" #include "nvim/ui.h" #include "nvim/charset.h" #include "nvim/cursor.h" @@ -59,6 +60,27 @@ static int busy = 0; static int height, width; static int old_mode_idx = -1; +#if MIN_LOG_LEVEL > DEBUG_LOG_LEVEL +# define UI_LOG(funname, ...) +#else +static size_t uilog_seen = 0; +static char uilog_last_event[1024] = { 0 }; +# define UI_LOG(funname, ...) \ + do { \ + if (strequal(uilog_last_event, STR(funname))) { \ + uilog_seen++; \ + } else { \ + if (uilog_seen > 0) { \ + do_log(DEBUG_LOG_LEVEL, "ui", 0, true, \ + "%s (+%zu times...)", uilog_last_event, uilog_seen); \ + } \ + DLOG("ui: " STR(funname)); \ + uilog_seen = 0; \ + xstrlcpy(uilog_last_event, STR(funname), sizeof(uilog_last_event)); \ + } \ + } while (0) +#endif + // UI_CALL invokes a function on all registered UI instances. The functions can // have 0-5 arguments (configurable by SELECT_NTH). // @@ -67,6 +89,7 @@ static int old_mode_idx = -1; # define UI_CALL(funname, ...) \ do { \ flush_cursor_update(); \ + UI_LOG(funname, 0); \ for (size_t i = 0; i < ui_count; i++) { \ UI *ui = uis[i]; \ UI_CALL_MORE(funname, __VA_ARGS__); \ @@ -76,6 +99,7 @@ static int old_mode_idx = -1; # define UI_CALL(...) \ do { \ flush_cursor_update(); \ + UI_LOG(__VA_ARGS__, 0); \ for (size_t i = 0; i < ui_count; i++) { \ UI *ui = uis[i]; \ UI_CALL_HELPER(CNT(__VA_ARGS__), __VA_ARGS__); \ @@ -85,6 +109,7 @@ static int old_mode_idx = -1; #define CNT(...) SELECT_NTH(__VA_ARGS__, MORE, MORE, MORE, MORE, ZERO, ignore) #define SELECT_NTH(a1, a2, a3, a4, a5, a6, ...) a6 #define UI_CALL_HELPER(c, ...) UI_CALL_HELPER2(c, __VA_ARGS__) +// Resolves to UI_CALL_MORE or UI_CALL_ZERO. #define UI_CALL_HELPER2(c, ...) UI_CALL_##c(__VA_ARGS__) #define UI_CALL_MORE(method, ...) if (ui->method) ui->method(ui, __VA_ARGS__) #define UI_CALL_ZERO(method) if (ui->method) ui->method(ui) diff --git a/src/nvim/ui_bridge.c b/src/nvim/ui_bridge.c index 0165db7c0c..5585886612 100644 --- a/src/nvim/ui_bridge.c +++ b/src/nvim/ui_bridge.c @@ -24,30 +24,10 @@ #define UI(b) (((UIBridgeData *)b)->ui) -#if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL -static size_t uilog_seen = 0; -static argv_callback uilog_event = NULL; -#define UI_CALL(ui, name, argc, ...) \ - do { \ - if (uilog_event == ui_bridge_##name##_event) { \ - uilog_seen++; \ - } else { \ - if (uilog_seen > 0) { \ - DLOG("UI bridge: ...%zu times", uilog_seen); \ - } \ - DLOG("UI bridge: " STR(name)); \ - uilog_seen = 0; \ - uilog_event = ui_bridge_##name##_event; \ - } \ - ((UIBridgeData *)ui)->scheduler( \ - event_create(ui_bridge_##name##_event, argc, __VA_ARGS__), UI(ui)); \ - } while (0) -#else // Schedule a function call on the UI bridge thread. -#define UI_CALL(ui, name, argc, ...) \ +#define UI_BRIDGE_CALL(ui, name, argc, ...) \ ((UIBridgeData *)ui)->scheduler( \ event_create(ui_bridge_##name##_event, argc, __VA_ARGS__), UI(ui)) -#endif #define INT2PTR(i) ((void *)(intptr_t)i) #define PTR2INT(p) ((Integer)(intptr_t)p) @@ -128,7 +108,7 @@ static void ui_bridge_stop(UI *b) { UIBridgeData *bridge = (UIBridgeData *)b; bool stopped = bridge->stopped = false; - UI_CALL(b, stop, 1, b); + UI_BRIDGE_CALL(b, stop, 1, b); for (;;) { uv_mutex_lock(&bridge->mutex); stopped = bridge->stopped; @@ -154,7 +134,7 @@ static void ui_bridge_highlight_set(UI *b, HlAttrs attrs) { HlAttrs *a = xmalloc(sizeof(HlAttrs)); *a = attrs; - UI_CALL(b, highlight_set, 2, b, a); + UI_BRIDGE_CALL(b, highlight_set, 2, b, a); } static void ui_bridge_highlight_set_event(void **argv) { @@ -167,7 +147,7 @@ static void ui_bridge_suspend(UI *b) { UIBridgeData *data = (UIBridgeData *)b; uv_mutex_lock(&data->mutex); - UI_CALL(b, suspend, 1, b); + UI_BRIDGE_CALL(b, suspend, 1, b); data->ready = false; // suspend the main thread until CONTINUE is called by the UI thread while (!data->ready) { -- cgit From 502af39f6261e1d1b71df7fa3169e943707ee7f2 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 19 Jul 2017 02:24:12 +0200 Subject: log: channel registration --- src/nvim/msgpack_rpc/channel.c | 44 +++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 68ac35bc4e..d7748925aa 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -117,12 +117,11 @@ void channel_teardown(void) /// Creates an API channel by starting a process and connecting to its /// stdin/stdout. stderr is handled by the job infrastructure. /// -/// @param argv The argument vector for the process. [consumed] -/// @return The channel id (> 0), on success. -/// 0, on error. +/// @return Channel id (> 0), on success. 0, on error. uint64_t channel_from_process(Process *proc, uint64_t id) { - Channel *channel = register_channel(kChannelTypeProc, id, proc->events); + Channel *channel = register_channel(kChannelTypeProc, id, proc->events, + proc->argv); incref(channel); // process channels are only closed by the exit_cb channel->data.proc = proc; @@ -138,7 +137,7 @@ uint64_t channel_from_process(Process *proc, uint64_t id) /// @param watcher The SocketWatcher ready to accept the connection void channel_from_connection(SocketWatcher *watcher) { - Channel *channel = register_channel(kChannelTypeSocket, 0, NULL); + Channel *channel = register_channel(kChannelTypeSocket, 0, NULL, NULL); socket_watcher_accept(watcher, &channel->data.stream); incref(channel); // close channel only after the stream is closed channel->data.stream.internal_close_cb = close_cb; @@ -161,7 +160,7 @@ uint64_t channel_connect(bool tcp, const char *address, xfree(path); } - Channel *channel = register_channel(kChannelTypeSocket, 0, NULL); + Channel *channel = register_channel(kChannelTypeSocket, 0, NULL, NULL); if (!socket_connect(&main_loop, &channel->data.stream, tcp, address, timeout, error)) { decref(channel); @@ -333,7 +332,7 @@ bool channel_close(uint64_t id) /// Neovim void channel_from_stdio(void) { - Channel *channel = register_channel(kChannelTypeStdio, 0, NULL); + Channel *channel = register_channel(kChannelTypeStdio, 0, NULL, NULL); incref(channel); // stdio channels are only closed on exit // read stream rstream_init_fd(&main_loop, &channel->data.std.in, 0, CHANNEL_BUFFER_SIZE); @@ -346,7 +345,7 @@ void channel_from_stdio(void) /// when an instance connects to its own named pipe. uint64_t channel_create_internal(void) { - Channel *channel = register_channel(kChannelTypeInternal, 0, NULL); + Channel *channel = register_channel(kChannelTypeInternal, 0, NULL, NULL); incref(channel); // internal channel lives until process exit return channel->id; } @@ -746,7 +745,7 @@ static void close_cb(Stream *stream, void *data) } static Channel *register_channel(ChannelType type, uint64_t id, - MultiQueue *events) + MultiQueue *events, char **argv) { Channel *rv = xmalloc(sizeof(Channel)); rv->events = events ? events : multiqueue_new_child(main_loop.events); @@ -761,6 +760,33 @@ static Channel *register_channel(ChannelType type, uint64_t id, kv_init(rv->call_stack); kv_init(rv->delayed_notifications); pmap_put(uint64_t)(channels, rv->id, rv); + +#if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL + switch(type) { + case kChannelTypeSocket: + DLOG("register ch %" PRIu64 " type=socket", rv->id); + break; + case kChannelTypeProc: { + char buf[IOSIZE]; + buf[0] = '\0'; + char **p = argv; + while (p != NULL && *p != NULL) { + xstrlcat(buf, *p, sizeof(buf)); + xstrlcat(buf, " ", sizeof(buf)); + p++; + } + DLOG("register ch %" PRIu64 " type=proc argv=%s", rv->id, buf); + } + break; + case kChannelTypeStdio: + DLOG("register ch %" PRIu64 " type=stdio", rv->id); + break; + case kChannelTypeInternal: + DLOG("register ch %" PRIu64 " type=internal", rv->id); + break; + } +#endif + return rv; } -- cgit From ad07e9c7fcabeb991f0849c9e11b5b225cf470fd Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 23 Jul 2017 10:12:05 +0800 Subject: vim-patch:8.0.0069 Problem: Compiler warning for self-comparison. Solution: Define ONE_WINDOW and add vim/vim#ifdef. https://github.com/vim/vim/commit/a1f4cb93ba50ea9e40cd4b1f5592b8a6d1398660 --- src/nvim/buffer.c | 2 +- src/nvim/ex_cmds.c | 2 +- src/nvim/ex_docmd.c | 2 +- src/nvim/globals.h | 1 + src/nvim/move.c | 4 ++-- src/nvim/quickfix.c | 2 +- src/nvim/screen.c | 4 ++-- src/nvim/version.c | 2 +- src/nvim/window.c | 8 ++++---- 9 files changed, 14 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 90a564bb6a..efb8af50a4 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -4429,7 +4429,7 @@ do_arg_all ( } } /* don't close last window */ - if (firstwin == lastwin + if (ONE_WINDOW && (first_tabpage->tp_next == NULL || !had_tab)) use_firstwin = TRUE; else { diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 0987cb3915..81cee5d535 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2806,7 +2806,7 @@ void ex_z(exarg_T *eap) * 'scroll' */ if (eap->forceit) bigness = curwin->w_height; - else if (firstwin == lastwin) + else if (ONE_WINDOW) bigness = curwin->w_p_scr * 2; else bigness = curwin->w_height - 3; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 5d7246581c..0a44392080 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5976,7 +5976,7 @@ static void ex_quit(exarg_T *eap) // specified. Example: // :h|wincmd w|1q - don't quit // :h|wincmd w|q - quit - if (only_one_window() && (firstwin == lastwin || eap->addr_count == 0)) { + if (only_one_window() && (ONE_WINDOW || eap->addr_count == 0)) { getout(0); } /* close window; may free buffer */ diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 6d1bd1de12..f08812600f 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -494,6 +494,7 @@ EXTERN int updating_screen INIT(= FALSE); EXTERN win_T *firstwin; /* first window */ EXTERN win_T *lastwin; /* last window */ EXTERN win_T *prevwin INIT(= NULL); /* previous window */ +# define ONE_WINDOW (firstwin == lastwin) /* * When using this macro "break" only breaks out of the inner loop. Use "goto" * to break out of the tabpage loop. diff --git a/src/nvim/move.c b/src/nvim/move.c index d5be4cb8c3..81d46a7f17 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1763,7 +1763,7 @@ int onepage(int dir, long count) loff.fill = 0; if (dir == FORWARD) { - if (firstwin == lastwin && p_window > 0 && p_window < Rows - 1) { + if (ONE_WINDOW && p_window > 0 && p_window < Rows - 1) { /* Vi compatible scrolling */ if (p_window <= 2) ++curwin->w_topline; @@ -1797,7 +1797,7 @@ int onepage(int dir, long count) max_topfill(); continue; } - if (firstwin == lastwin && p_window > 0 && p_window < Rows - 1) { + if (ONE_WINDOW && p_window > 0 && p_window < Rows - 1) { /* Vi compatible scrolling (sort of) */ if (p_window <= 2) --curwin->w_topline; diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index f17075f0c4..4997209556 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1878,7 +1878,7 @@ win_found: * If there is only one window and it is the quickfix window, create a * new one above the quickfix window. */ - if (((firstwin == lastwin) && bt_quickfix(curbuf)) || !usable_win) { + if ((ONE_WINDOW && bt_quickfix(curbuf)) || !usable_win) { flags = WSP_ABOVE; if (ll_ref != NULL) flags |= WSP_NEWLOC; diff --git a/src/nvim/screen.c b/src/nvim/screen.c index a8353153fd..bcc996679b 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -991,7 +991,7 @@ static void win_update(win_T *wp) * first. */ if (mid_start == 0) { mid_end = wp->w_height; - if (lastwin == firstwin) { + if (ONE_WINDOW) { /* Clear the screen when it was not done by win_del_lines() or * win_ins_lines() above, "screen_cleared" is FALSE or MAYBE * then. */ @@ -7160,7 +7160,7 @@ static int fillchar_status(int *attr, win_T *wp) * window differs, or the fillchars differ, or this is not the * current window */ if (*attr != 0 && ((win_hl_attr(wp, HLF_S) != win_hl_attr(wp, HLF_SNC) - || !is_curwin || firstwin == lastwin) + || !is_curwin || ONE_WINDOW) || (fill_stl != fill_stlnc))) { return fill; } diff --git a/src/nvim/version.c b/src/nvim/version.c index d372779c75..4e780f31ad 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -660,7 +660,7 @@ static const int included_patches[] = { // 72 NA // 71 NA // 70 NA - // 69, + 69, 68, // 67 NA 66, diff --git a/src/nvim/window.c b/src/nvim/window.c index 29f5412ba0..7517d4e120 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -193,7 +193,7 @@ newwindow: /* cursor to previous window with wrap around */ case 'W': CHECK_CMDWIN - if (firstwin == lastwin && Prenum != 1) /* just one window */ + if (ONE_WINDOW && Prenum != 1) /* just one window */ beep_flush(); else { if (Prenum) { /* go to specified window */ @@ -1271,7 +1271,7 @@ static void win_rotate(int upwards, int count) frame_T *frp; int n; - if (firstwin == lastwin) { /* nothing to do */ + if (ONE_WINDOW) { /* nothing to do */ beep_flush(); return; } @@ -2194,7 +2194,7 @@ winframe_remove ( /* * If there is only one window there is nothing to remove. */ - if (tp == NULL ? firstwin == lastwin : tp->tp_firstwin == tp->tp_lastwin) + if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) return NULL; /* @@ -2331,7 +2331,7 @@ win_altframe ( frame_T *frp; int b; - if (tp == NULL ? firstwin == lastwin : tp->tp_firstwin == tp->tp_lastwin) + if (tp == NULL ? ONE_WINDOW : tp->tp_firstwin == tp->tp_lastwin) /* Last window in this tab page, will go to next tab page. */ return alt_tabpage()->tp_curwin->w_frame; -- cgit From b656159fcfded40839c222ae1c4e86873c82f295 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 23 Jul 2017 11:11:56 +0800 Subject: vim-patch:8.0.0073 Problem: More comparisons between firstwin and lastwin. Solution: Use ONE_WINDOW for consistency. (Hirohito Higashi) https://github.com/vim/vim/commit/459ca563128f2edb7e3bb190090bbb755a56dd55 --- src/nvim/buffer.c | 4 ++-- src/nvim/ex_docmd.c | 4 ++-- src/nvim/memory.c | 2 +- src/nvim/option.c | 6 +++--- src/nvim/version.c | 2 +- src/nvim/window.c | 14 +++++++------- 6 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index efb8af50a4..f5d8b6ad30 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1203,7 +1203,7 @@ do_buffer ( */ while (buf == curbuf && !(curwin->w_closing || curwin->w_buffer->b_locked > 0) - && (firstwin != lastwin || first_tabpage->tp_next != NULL)) { + && (!ONE_WINDOW || first_tabpage->tp_next != NULL)) { if (win_close(curwin, FALSE) == FAIL) break; } @@ -4593,7 +4593,7 @@ void ex_buffer_all(exarg_T *eap) - tabline_height() : wp->w_width != Columns) || (had_tab > 0 && wp != firstwin)) - && firstwin != lastwin + && !ONE_WINDOW && !(wp->w_closing || wp->w_buffer->b_locked > 0) ) { win_close(wp, FALSE); diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 0a44392080..62fa26be3c 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6176,9 +6176,9 @@ void tabpage_close(int forceit) { /* First close all the windows but the current one. If that worked then * close the last window in this tab, that will close it. */ - if (lastwin != firstwin) + if (!ONE_WINDOW) close_others(TRUE, forceit); - if (lastwin == firstwin) + if (ONE_WINDOW) ex_win_close(forceit, curwin, NULL); } diff --git a/src/nvim/memory.c b/src/nvim/memory.c index 74c58fb203..328b96fd5c 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -585,7 +585,7 @@ void free_all_mem(void) p_ea = false; if (first_tabpage->tp_next != NULL) do_cmdline_cmd("tabonly!"); - if (firstwin != lastwin) + if (!ONE_WINDOW) do_cmdline_cmd("only!"); /* Free all spell info. */ diff --git a/src/nvim/option.c b/src/nvim/option.c index 75b56b4eb4..a6ae022e79 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -4078,7 +4078,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, } /* Change window height NOW */ - if (lastwin != firstwin) { + if (!ONE_WINDOW) { if (pp == &p_wh && curwin->w_height < p_wh) win_setheight((int)p_wh); if (pp == &p_hh && curbuf->b_help && curwin->w_height < p_hh) @@ -4107,7 +4107,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, } /* Change window width NOW */ - if (lastwin != firstwin && curwin->w_width < p_wiw) + if (!ONE_WINDOW && curwin->w_width < p_wiw) win_setwidth((int)p_wiw); } /* 'winminwidth' */ @@ -5239,7 +5239,7 @@ static int put_setbool(FILE *fd, char *cmd, char *name, int value) void comp_col(void) { - int last_has_status = (p_ls == 2 || (p_ls == 1 && firstwin != lastwin)); + int last_has_status = (p_ls == 2 || (p_ls == 1 && !ONE_WINDOW)); sc_col = 0; ru_col = 0; diff --git a/src/nvim/version.c b/src/nvim/version.c index 4e780f31ad..d27b2b2012 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -656,7 +656,7 @@ static const int included_patches[] = { // 76 NA // 75, // 74, - // 73, + 73, // 72 NA // 71 NA // 70 NA diff --git a/src/nvim/window.c b/src/nvim/window.c index 7517d4e120..faf5bceb56 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -574,7 +574,7 @@ int win_split_ins(int size, int flags, win_T *new_wp, int dir) oldwin = curwin; /* add a status line when p_ls == 1 and splitting the first window */ - if (lastwin == firstwin && p_ls == 1 && oldwin->w_status_height == 0) { + if (ONE_WINDOW && p_ls == 1 && oldwin->w_status_height == 0) { if (oldwin->w_height <= p_wmh && new_wp == NULL) { EMSG(_(e_noroom)); return FAIL; @@ -1182,7 +1182,7 @@ static void win_exchange(long Prenum) win_T *wp2; int temp; - if (lastwin == firstwin) { /* just one window */ + if (ONE_WINDOW) { /* just one window */ beep_flush(); return; } @@ -1343,7 +1343,7 @@ static void win_totop(int size, int flags) int dir; int height = curwin->w_height; - if (lastwin == firstwin) { + if (ONE_WINDOW) { beep_flush(); return; } @@ -1728,7 +1728,7 @@ void close_windows(buf_T *buf, int keep_curwin) ++RedrawingDisabled; - for (win_T *wp = firstwin; wp != NULL && lastwin != firstwin; ) { + for (win_T *wp = firstwin; wp != NULL && !ONE_WINDOW; ) { if (wp->w_buffer == buf && (!keep_curwin || wp != curwin) && !(wp->w_closing || wp->w_buffer->b_locked > 0)) { if (win_close(wp, false) == FAIL) { @@ -1810,7 +1810,7 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, tabpage_T *prev_curtab) FUNC_ATTR_NONNULL_ARG(1) { - if (firstwin != lastwin) { + if (!ONE_WINDOW) { return false; } buf_T *old_curbuf = curbuf; @@ -2851,7 +2851,7 @@ close_others ( win_close(wp, !P_HID(wp->w_buffer) && !bufIsChanged(wp->w_buffer)); } - if (message && lastwin != firstwin) + if (message && !ONE_WINDOW) EMSG(_("E445: Other window contains changes")); } @@ -5173,7 +5173,7 @@ last_status ( { /* Don't make a difference between horizontal or vertical split. */ last_status_rec(topframe, (p_ls == 2 - || (p_ls == 1 && (morewin || lastwin != firstwin)))); + || (p_ls == 1 && (morewin || !ONE_WINDOW)))); } static void last_status_rec(frame_T *fr, int statusline) -- cgit From bc6a3fe78445f41851f30c6f55e11b6b1ed5feaf Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 19 Jul 2017 10:27:34 +0200 Subject: log: caller provides the source details --- src/nvim/eval.c | 16 +++++++++--- src/nvim/msgpack_rpc/channel.c | 57 +++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 08b3d1dbd7..3ec8deb666 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -15141,7 +15141,8 @@ static void f_sockconnect(typval_T *argvars, typval_T *rettv, FunPtr fptr) } const char *error = NULL; - uint64_t id = channel_connect(tcp, address, 50, &error); + eval_format_source_name_line((char *)IObuff, sizeof(IObuff)); + uint64_t id = channel_connect(tcp, address, 50, (char *)IObuff, &error); if (error) { EMSG2(_("connection failed: %s"), error); @@ -22449,8 +22450,9 @@ static inline bool common_job_start(TerminalJobData *data, typval_T *rettv) if (data->rpc) { - // the rpc channel takes over the in and out streams - channel_from_process(proc, data->id); + eval_format_source_name_line((char *)IObuff, sizeof(IObuff)); + // RPC channel takes over the in/out streams. + channel_from_process(proc, data->id, (char *)IObuff); } else { wstream_init(proc->in, 0); if (proc->out) { @@ -22775,3 +22777,11 @@ bool eval_has_provider(const char *name) return false; } + +/// Writes ":" to `buf[bufsize]`. +void eval_format_source_name_line(char *buf, size_t bufsize) +{ + snprintf(buf, bufsize, "%s:%" PRIdLINENR, + (sourcing_name ? sourcing_name : (char_u *)"?"), + (sourcing_name ? sourcing_lnum : 0)); +} diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index d7748925aa..6fd1af1ba6 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -117,11 +117,15 @@ void channel_teardown(void) /// Creates an API channel by starting a process and connecting to its /// stdin/stdout. stderr is handled by the job infrastructure. /// +/// @param proc process object +/// @param id (optional) channel id +/// @param source description of source function, rplugin name, TCP addr, etc +/// /// @return Channel id (> 0), on success. 0, on error. -uint64_t channel_from_process(Process *proc, uint64_t id) +uint64_t channel_from_process(Process *proc, uint64_t id, char *source) { Channel *channel = register_channel(kChannelTypeProc, id, proc->events, - proc->argv); + source); incref(channel); // process channels are only closed by the exit_cb channel->data.proc = proc; @@ -137,7 +141,8 @@ uint64_t channel_from_process(Process *proc, uint64_t id) /// @param watcher The SocketWatcher ready to accept the connection void channel_from_connection(SocketWatcher *watcher) { - Channel *channel = register_channel(kChannelTypeSocket, 0, NULL, NULL); + Channel *channel = register_channel(kChannelTypeSocket, 0, NULL, + watcher->addr); socket_watcher_accept(watcher, &channel->data.stream); incref(channel); // close channel only after the stream is closed channel->data.stream.internal_close_cb = close_cb; @@ -147,8 +152,9 @@ void channel_from_connection(SocketWatcher *watcher) rstream_start(&channel->data.stream, receive_msgpack, channel); } -uint64_t channel_connect(bool tcp, const char *address, - int timeout, const char **error) +/// @param source description of source function, rplugin name, TCP addr, etc +uint64_t channel_connect(bool tcp, const char *address, int timeout, + char *source, const char **error) { if (!tcp) { char *path = fix_fname(address); @@ -160,7 +166,7 @@ uint64_t channel_connect(bool tcp, const char *address, xfree(path); } - Channel *channel = register_channel(kChannelTypeSocket, 0, NULL, NULL); + Channel *channel = register_channel(kChannelTypeSocket, 0, NULL, source); if (!socket_connect(&main_loop, &channel->data.stream, tcp, address, timeout, error)) { decref(channel); @@ -328,8 +334,7 @@ bool channel_close(uint64_t id) return true; } -/// Creates an API channel from stdin/stdout. This is used when embedding -/// Neovim +/// Creates an API channel from stdin/stdout. Used to embed Nvim. void channel_from_stdio(void) { Channel *channel = register_channel(kChannelTypeStdio, 0, NULL, NULL); @@ -744,9 +749,12 @@ static void close_cb(Stream *stream, void *data) decref(data); } +/// @param source description of source function, rplugin name, TCP addr, etc static Channel *register_channel(ChannelType type, uint64_t id, - MultiQueue *events, char **argv) + MultiQueue *events, char *source) { + // Jobs and channels share the same id namespace. + assert(id == 0 || !pmap_get(uint64_t)(channels, id)); Channel *rv = xmalloc(sizeof(Channel)); rv->events = events ? events : multiqueue_new_child(main_loop.events); rv->type = type; @@ -761,31 +769,12 @@ static Channel *register_channel(ChannelType type, uint64_t id, kv_init(rv->delayed_notifications); pmap_put(uint64_t)(channels, rv->id, rv); -#if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL - switch(type) { - case kChannelTypeSocket: - DLOG("register ch %" PRIu64 " type=socket", rv->id); - break; - case kChannelTypeProc: { - char buf[IOSIZE]; - buf[0] = '\0'; - char **p = argv; - while (p != NULL && *p != NULL) { - xstrlcat(buf, *p, sizeof(buf)); - xstrlcat(buf, " ", sizeof(buf)); - p++; - } - DLOG("register ch %" PRIu64 " type=proc argv=%s", rv->id, buf); - } - break; - case kChannelTypeStdio: - DLOG("register ch %" PRIu64 " type=stdio", rv->id); - break; - case kChannelTypeInternal: - DLOG("register ch %" PRIu64 " type=internal", rv->id); - break; - } -#endif + ILOG("new channel %" PRIu64 " (%s): %s", rv->id, + (type == kChannelTypeProc ? "proc" + : (type == kChannelTypeSocket ? "socket" + : (type == kChannelTypeStdio ? "stdio" + : (type == kChannelTypeInternal ? "internal" : "?")))), + (source ? source : "?")); return rv; } -- cgit From 4b390fafc910eb3e0acf17d5eb8a702b5fdd12ce Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 22 Jul 2017 21:24:26 +0200 Subject: log: termios info to DEBUG instead of INFO --- src/nvim/tui/tui.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index ab78a72909..0975b87ea3 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1007,7 +1007,7 @@ static void tui_flush(UI *ui) size_t nrevents = loop_size(data->loop); if (nrevents > TOO_MANY_EVENTS) { - ILOG("TUI event-queue flooded (thread_events=%zu); purging", nrevents); + WLOG("TUI event-queue flooded (thread_events=%zu); purging", nrevents); // Back-pressure: UI events may accumulate much faster than the terminal // device can serve them. Even if SIGINT/CTRL-C is received, user must still // wait for the TUI event-queue to drain, and if there are ~millions of @@ -1690,7 +1690,7 @@ static const char *tui_get_stty_erase(void) if (tcgetattr(input_global_fd(), &t) != -1) { stty_erase[0] = (char)t.c_cc[VERASE]; stty_erase[1] = '\0'; - ILOG("stty/termios:erase=%s", stty_erase); + DLOG("stty/termios:erase=%s", stty_erase); } #endif return stty_erase; @@ -1707,12 +1707,12 @@ static const char *tui_tk_ti_getstr(const char *name, const char *value, } if (strequal(name, "key_backspace")) { - ILOG("libtermkey:kbs=%s", value); + DLOG("libtermkey:kbs=%s", value); if (stty_erase[0] != 0) { return stty_erase; } } else if (strequal(name, "key_dc")) { - ILOG("libtermkey:kdch1=%s", value); + DLOG("libtermkey:kdch1=%s", value); // Vim: "If and are now the same, redefine ." if (value != NULL && strequal(stty_erase, value)) { return stty_erase[0] == DEL ? CTRL_H_STR : DEL_STR; -- cgit From 5fc775e2efd1adf4985d9abcb1d970dcaa944555 Mon Sep 17 00:00:00 2001 From: Yichao Zhou Date: Thu, 13 Apr 2017 22:06:19 +0200 Subject: log.h: LOG_CALLSTACK --- src/nvim/log.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/nvim/log.h b/src/nvim/log.h index 221f0bbaf6..48be7606e7 100644 --- a/src/nvim/log.h +++ b/src/nvim/log.h @@ -61,6 +61,30 @@ __VA_ARGS__) #endif +#if defined(__linux__) +# include +# define LOG_CALLSTACK(prefix) \ + do { \ + void *trace[100]; \ + int trace_size = backtrace(trace, 100); \ + \ + char exe[1024]; \ + ssize_t elen = readlink("/proc/self/exe", exe, sizeof(exe) - 1); \ + exe[elen] = 0; \ + \ + for (int i = 1; i < trace_size; i++) { \ + char buf[256]; \ + snprintf(buf, sizeof(buf), "addr2line -e %s -f -p %p", exe, trace[i]); \ + FILE *fp = popen(buf, "r"); \ + while (fgets(buf, sizeof(buf) - 1, fp) != NULL) { \ + buf[strlen(buf)-1] = 0; \ + do_log(DEBUG_LOG_LEVEL, __func__, __LINE__, true, prefix "%s", buf); \ + } \ + fclose(fp); \ + } \ + } while (0) +#endif + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "log.h.generated.h" #endif -- cgit From eb2473e9ea0a875b79612f84d1fae32b670d9b88 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 23 Jul 2017 17:00:30 +0200 Subject: log: log_callstack() --- src/nvim/README.md | 19 +++++++++++++------ src/nvim/log.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/nvim/log.h | 22 +--------------------- 3 files changed, 61 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/nvim/README.md b/src/nvim/README.md index 660e3d1010..1c1c3c364e 100644 --- a/src/nvim/README.md +++ b/src/nvim/README.md @@ -1,13 +1,20 @@ +Nvim core source +================ -Module-specific details are documented at the top of each module (e.g. -terminal.c, screen.c). +Module-specific details are documented at the top of each module (`terminal.c`, +`screen.c`, ...). -See also `:help development`. +See `:help development` for more guidelines. -UI Debugging ------------- +Logs +---- -At `DEBUG_LOG_LEVEL`, all UI events are logged. +Low-level log messages sink to `$NVIM_LOG_FILE`. + +You can use `LOG_CALLSTACK()` anywhere in the source to log the current +stacktrace. (Currently Linux-only.) + +UI events are logged at level 0 (`DEBUG_LOG_LEVEL`). rm -rf build/ make CMAKE_EXTRA_FLAGS="-DMIN_LOG_LEVEL=0" diff --git a/src/nvim/log.c b/src/nvim/log.c index f1dbe61dda..252fe5438d 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -173,6 +173,53 @@ FILE *open_log_file(void) return stderr; } +#if defined(__linux__) +# include +void log_callstack(const char *const func_name, const int line_num) +{ + void *trace[100]; + int trace_size = backtrace(trace, ARRAY_SIZE(trace)); + + char exepath[MAXPATHL] = { 0 }; + size_t exepathlen = MAXPATHL; + if (os_exepath(exepath, &exepathlen) != 0) { + abort(); + } + assert(24 + exepathlen < IOSIZE); // Must fit in `cmdbuf` below. + + do_log(DEBUG_LOG_LEVEL, func_name, line_num, true, "trace:"); + + char cmdbuf[IOSIZE + (20 * ARRAY_SIZE(trace))]; + snprintf(cmdbuf, sizeof(cmdbuf), "addr2line -e %s -f -p", exepath); + for (int i = 1; i < trace_size; i++) { + char buf[20]; // 64-bit pointer 0xNNNNNNNNNNNNNNNN with leading space. + snprintf(buf, sizeof(buf), " %p", trace[i]); + xstrlcat(cmdbuf, buf, sizeof(cmdbuf)); + } + // Now we have a command string like: + // addr2line -e /path/to/exe -f -p 0x123 0x456 ... + + log_lock(); + FILE *log_file = open_log_file(); + if (log_file == NULL) { + goto end; + } + + FILE *fp = popen(cmdbuf, "r"); + char linebuf[IOSIZE]; + while (fgets(linebuf, sizeof(linebuf) - 1, fp) != NULL) { + fprintf(log_file, " %s", linebuf); + } + pclose(fp); + + if (log_file != stderr && log_file != stdout) { + fclose(log_file); + } +end: + log_unlock(); +} +#endif + static bool do_log_to_file(FILE *log_file, int log_level, const char *func_name, int line_num, bool eol, const char* fmt, ...) diff --git a/src/nvim/log.h b/src/nvim/log.h index 48be7606e7..2bd18f5776 100644 --- a/src/nvim/log.h +++ b/src/nvim/log.h @@ -62,27 +62,7 @@ #endif #if defined(__linux__) -# include -# define LOG_CALLSTACK(prefix) \ - do { \ - void *trace[100]; \ - int trace_size = backtrace(trace, 100); \ - \ - char exe[1024]; \ - ssize_t elen = readlink("/proc/self/exe", exe, sizeof(exe) - 1); \ - exe[elen] = 0; \ - \ - for (int i = 1; i < trace_size; i++) { \ - char buf[256]; \ - snprintf(buf, sizeof(buf), "addr2line -e %s -f -p %p", exe, trace[i]); \ - FILE *fp = popen(buf, "r"); \ - while (fgets(buf, sizeof(buf) - 1, fp) != NULL) { \ - buf[strlen(buf)-1] = 0; \ - do_log(DEBUG_LOG_LEVEL, __func__, __LINE__, true, prefix "%s", buf); \ - } \ - fclose(fp); \ - } \ - } while (0) +# define LOG_CALLSTACK() log_callstack(__func__, __LINE__) #endif #ifdef INCLUDE_GENERATED_DECLARATIONS -- cgit From 86f2c473dc0e5b3c886d71b2fee99e1f3c9849b6 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Mon, 24 Jul 2017 07:41:01 +0800 Subject: fix lint --- src/nvim/buffer.c | 18 ++++++++++-------- src/nvim/ex_cmds.c | 14 ++++++++------ src/nvim/ex_docmd.c | 12 +++++++----- 3 files changed, 25 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index f5d8b6ad30..724a8578ac 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1204,7 +1204,7 @@ do_buffer ( while (buf == curbuf && !(curwin->w_closing || curwin->w_buffer->b_locked > 0) && (!ONE_WINDOW || first_tabpage->tp_next != NULL)) { - if (win_close(curwin, FALSE) == FAIL) + if (win_close(curwin, false) == FAIL) break; } @@ -4428,15 +4428,17 @@ do_arg_all ( continue; } } - /* don't close last window */ + // don't close last window if (ONE_WINDOW - && (first_tabpage->tp_next == NULL || !had_tab)) - use_firstwin = TRUE; - else { + && (first_tabpage->tp_next == NULL || !had_tab)) { + use_firstwin = true; + } else { win_close(wp, !P_HID(buf) && !bufIsChanged(buf)); - /* check if autocommands removed the next window */ - if (!win_valid(wpnext)) - wpnext = firstwin; /* start all over... */ + // check if autocommands removed the next window + if (!win_valid(wpnext)) { + // start all over... + wpnext = firstwin; + } } } } diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 81cee5d535..a555fb77e8 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -2802,16 +2802,18 @@ void ex_z(exarg_T *eap) int j; linenr_T lnum = eap->line2; - /* Vi compatible: ":z!" uses display height, without a count uses - * 'scroll' */ - if (eap->forceit) + // Vi compatible: ":z!" uses display height, without a count uses + // 'scroll' + if (eap->forceit) { bigness = curwin->w_height; - else if (ONE_WINDOW) + } else if (ONE_WINDOW) { bigness = curwin->w_p_scr * 2; - else + } else { bigness = curwin->w_height - 3; - if (bigness < 1) + } + if (bigness < 1) { bigness = 1; + } x = eap->arg; kind = x; diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 62fa26be3c..d2eb881bc6 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6174,12 +6174,14 @@ static void ex_tabonly(exarg_T *eap) */ void tabpage_close(int forceit) { - /* First close all the windows but the current one. If that worked then - * close the last window in this tab, that will close it. */ - if (!ONE_WINDOW) - close_others(TRUE, forceit); - if (ONE_WINDOW) + // First close all the windows but the current one. If that worked then + // close the last window in this tab, that will close it. + if (!ONE_WINDOW) { + close_others(true, forceit); + } + if (ONE_WINDOW) { ex_win_close(forceit, curwin, NULL); + } } /* -- cgit From 811c45163c5613981c8e5abdca40e28c1b61d076 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Tue, 25 Jul 2017 18:30:28 +0200 Subject: vim-patch:8.0.0034 Problem: No completion for ":messages". Solution: Complete "clear" argument. (Hirohito Higashi) https://github.com/vim/vim/commit/9e507ca8a3e1535e62de4bd86374b0fcd18ef5b8 --- src/nvim/ex_docmd.c | 16 ++++++++++++++++ src/nvim/ex_getln.c | 1 + src/nvim/testdir/test_cmdline.vim | 5 +++++ src/nvim/version.c | 2 +- src/nvim/vim.h | 1 + 5 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index d2eb881bc6..99a0b86d2b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3440,6 +3440,11 @@ const char * set_one_cmd_context( xp->xp_pattern = (char_u *)arg; break; + case CMD_messages: + xp->xp_context = EXPAND_MESSAGES; + xp->xp_pattern = (char_u *)arg; + break; + case CMD_history: xp->xp_context = EXPAND_HISTORY; xp->xp_pattern = (char_u *)arg; @@ -4874,6 +4879,7 @@ static struct { #endif { EXPAND_MAPPINGS, "mapping" }, { EXPAND_MENUS, "menu" }, + { EXPAND_MESSAGES, "messages" }, { EXPAND_OWNSYNTAX, "syntax" }, { EXPAND_SYNTIME, "syntime" }, { EXPAND_SETTINGS, "option" }, @@ -9595,6 +9601,16 @@ char_u *get_behave_arg(expand_T *xp, int idx) return NULL; } +// Function given to ExpandGeneric() to obtain the possible arguments of the +// ":messages {clear}" command. +char_u *get_messages_arg(expand_T *xp FUNC_ATTR_UNUSED, int idx) +{ + if (idx == 0) { + return (char_u *)"clear"; + } + return NULL; +} + static TriState filetype_detect = kNone; static TriState filetype_plugin = kNone; static TriState filetype_indent = kNone; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 0ba6c79a71..1d81a39dfe 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4050,6 +4050,7 @@ ExpandFromContext ( } tab[] = { { EXPAND_COMMANDS, get_command_name, false, true }, { EXPAND_BEHAVE, get_behave_arg, true, true }, + { EXPAND_MESSAGES, get_messages_arg, true, true }, { EXPAND_HISTORY, get_history_arg, true, true }, { EXPAND_USER_COMMANDS, get_user_commands, false, true }, { EXPAND_USER_ADDR_TYPE, get_user_cmd_addr_type, false, true }, diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 0c9d1297d6..f7a6aba6e7 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -130,6 +130,11 @@ func Test_getcompletion() let l = getcompletion('dark', 'highlight') call assert_equal([], l) + let l = getcompletion('', 'messages') + call assert_true(index(l, 'clear') >= 0) + let l = getcompletion('not', 'messages') + call assert_equal([], l) + if has('cscope') let l = getcompletion('', 'cscope') let cmds = ['add', 'find', 'help', 'kill', 'reset', 'show'] diff --git a/src/nvim/version.c b/src/nvim/version.c index 62e8919913..44348c4d98 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -695,7 +695,7 @@ static const int included_patches[] = { 37, // 36 NA 35, - // 34, + 34, 33, 32, 31, diff --git a/src/nvim/vim.h b/src/nvim/vim.h index c71ca411ea..62ffc7433e 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -163,6 +163,7 @@ enum { EXPAND_SYNTIME, EXPAND_USER_ADDR_TYPE, EXPAND_PACKADD, + EXPAND_MESSAGES, }; -- cgit From 09470eb673e7582e6103173754fff85ee0e1d232 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Tue, 25 Jul 2017 18:53:47 +0200 Subject: vim-patch:8.0.0075 Problem: Using number for exception type lacks type checking. Solution: Use an enum. https://github.com/vim/vim/commit/8a5883b7488e492419dde7e1637cc72f2d566ba4 --- src/nvim/ex_docmd.c | 2 -- src/nvim/ex_eval.c | 19 ++++++++----------- src/nvim/ex_eval.h | 27 ++++++++++++++------------- src/nvim/version.c | 2 +- 4 files changed, 23 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index d2eb881bc6..61c35a494b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -844,8 +844,6 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, break; case ET_INTERRUPT: break; - default: - p = vim_strsave((char_u *)_(e_internal)); } saved_sourcing_name = sourcing_name; diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 5d664b94a8..c029df2f13 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -374,10 +374,9 @@ int do_intthrow(struct condstack *cstack) return TRUE; } -/* - * Get an exception message that is to be stored in current_exception->value. - */ -char_u *get_exception_string(void *value, int type, char_u *cmdname, int *should_free) +// Get an exception message that is to be stored in current_exception->value. +char_u *get_exception_string(void *value, except_type_T type, char_u *cmdname, + int *should_free) { char_u *ret, *mesg; char_u *p, *val; @@ -435,13 +434,11 @@ char_u *get_exception_string(void *value, int type, char_u *cmdname, int *should } -/* - * Throw a new exception. Return FAIL when out of memory or it was tried to - * throw an illegal user exception. "value" is the exception string for a - * user or interrupt exception, or points to a message list in case of an - * error exception. - */ -static int throw_exception(void *value, int type, char_u *cmdname) +// Throw a new exception. Return FAIL when out of memory or it was tried to +// throw an illegal user exception. "value" is the exception string for a +// user or interrupt exception, or points to a message list in case of an +// error exception. +static int throw_exception(void *value, except_type_T type, char_u *cmdname) { except_T *excp; int should_free; diff --git a/src/nvim/ex_eval.h b/src/nvim/ex_eval.h index f61e01d25b..d5f8737bf3 100644 --- a/src/nvim/ex_eval.h +++ b/src/nvim/ex_eval.h @@ -89,27 +89,28 @@ struct msglist { struct msglist *next; /* next of several messages in a row */ }; +// The exception types. +typedef enum +{ + ET_USER, // exception caused by ":throw" command + ET_ERROR, // error exception + ET_INTERRUPT // interrupt exception triggered by Ctrl-C +} except_type_T; + /* * Structure describing an exception. * (don't use "struct exception", it's used by the math library). */ typedef struct vim_exception except_T; struct vim_exception { - int type; /* exception type */ - char_u *value; /* exception value */ - struct msglist *messages; /* message(s) causing error exception */ - char_u *throw_name; /* name of the throw point */ - linenr_T throw_lnum; /* line number of the throw point */ - except_T *caught; /* next exception on the caught stack */ + except_type_T type; // exception type + char_u *value; // exception value + struct msglist *messages; // message(s) causing error exception + char_u *throw_name; // name of the throw point + linenr_T throw_lnum; // line number of the throw point + except_T *caught; // next exception on the caught stack }; -/* - * The exception types. - */ -#define ET_USER 0 /* exception caused by ":throw" command */ -#define ET_ERROR 1 /* error exception */ -#define ET_INTERRUPT 2 /* interrupt exception triggered by Ctrl-C */ - /* * Structure to save the error/interrupt/exception state between calls to * enter_cleanup() and leave_cleanup(). Must be allocated as an automatic diff --git a/src/nvim/version.c b/src/nvim/version.c index 62e8919913..be3ee12262 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -654,7 +654,7 @@ static const int included_patches[] = { 78, // 77 NA // 76 NA - // 75, + 75, // 74, 73, // 72 NA -- cgit From d94e39a517d5ccf895c6f1b95bfb621954f3bbec Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Tue, 25 Jul 2017 18:47:10 +0200 Subject: vim-patch:8.0.0062 Problem: No digraph for HORIZONTAL ELLIPSIS. Solution: Use ",.". (Hans Ginzel, closes vim/vim#1226) https://github.com/vim/vim/commit/81615517249bb78cba9c37c9834b787c1b265521 --- src/nvim/digraph.c | 1 + src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 32e71f61f7..bfb1b94738 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -793,6 +793,7 @@ static digr_T digraphdefault[] = { '/', '-', 0x2020 }, { '/', '=', 0x2021 }, { '.', '.', 0x2025 }, + { ',', '.', 0x2026 }, { '%', '0', 0x2030 }, { '1', '\'', 0x2032 }, { '2', '\'', 0x2033 }, diff --git a/src/nvim/version.c b/src/nvim/version.c index 62e8919913..bc478c4123 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -667,7 +667,7 @@ static const int included_patches[] = { // 65 NA 64, // 63, - // 62, + 62, // 61 NA 60, // 59 NA -- cgit From 2952a00d2e2bf0cc6988c9b865497b1f567190c1 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 26 Jul 2017 22:01:48 +0300 Subject: message: Only require second (format) argument to be not NULL --- src/nvim/message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/message.c b/src/nvim/message.c index 92dd5a4695..fd7043cea8 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1636,7 +1636,7 @@ void msg_puts_attr_len(const char *const str, const ptrdiff_t len, int attr) /// @param[in] attr Highlight attributes. /// @param[in] fmt Format string. void msg_printf_attr(const int attr, const char *const fmt, ...) - FUNC_ATTR_NONNULL_ALL + FUNC_ATTR_NONNULL_ARG(2) { static char msgbuf[IOSIZE]; -- cgit From c5857e3f3807d305598d7639949793d44b380e23 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 26 Jul 2017 22:56:48 +0300 Subject: ex_getln: Cache highlight callback calling results --- src/nvim/ex_getln.c | 121 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 83 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 6115ebf2cb..6eb975fea3 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -142,14 +142,37 @@ typedef struct command_line_state { struct cmdline_info save_ccline; } CommandLineState; -/// Command-line colors +/// Command-line colors: one chunk +/// +/// Defines a region which has the same highlighting. typedef struct { int start; ///< Colored chunk start. int end; ///< Colored chunk end (exclusive, > start). int attr; ///< Highlight attr. -} ColoredCmdlineChunk; +} CmdlineColorChunk; + +/// Command-line colors +/// +/// Holds data about all colors. +typedef kvec_t(CmdlineColorChunk) CmdlineColors; + +/// Command-line coloring +/// +/// Holds both what are the colors and what have been colored. Latter is used to +/// suppress unnecessary calls to coloring callbacks. +typedef struct { + unsigned prompt_id; ///< ID of the prompt which was colored last. + char *cmdbuff; ///< What exactly was colored last time or NULL. + CmdlineColors colors; ///< Last colors. +} ColoredCmdline; + +/// Last command-line colors. +ColoredCmdline last_ccline_colors = { + .cmdbuff = NULL, + .colors = KV_INITIAL_VALUE +}; -kvec_t(ColoredCmdlineChunk) ccline_colors; +typedef struct cmdline_info CmdlineInfo; /* The current cmdline_info. It is initialized in getcmdline() and after that * used by other functions. When invoking getcmdline() recursively it needs @@ -2324,13 +2347,20 @@ enum { MAX_CB_ERRORS = 1 }; /// Should use built-in command parser or user-specified one. Currently only the /// latter is supported. /// -/// Operates on ccline, saving results to ccline_colors. +/// @param[in] colored_ccline Command-line to color. +/// @param[out] ret_ccline_colors What should be colored. Also holds a cache: +/// if ->prompt_id and ->cmdbuff values happen +/// to be equal to those from colored_cmdline it +/// will just do nothing, assuming that ->colors +/// already contains needed data. /// /// Always colors the whole cmdline. /// /// @return true if draw_cmdline may proceed, false if it does not need anything /// to do. -static bool color_cmdline(void) +static bool color_cmdline(const CmdlineInfo *const colored_ccline, + ColoredCmdline *const ret_ccline_colors) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { bool printed_errmsg = false; #define PRINT_ERRMSG(...) \ @@ -2340,17 +2370,27 @@ static bool color_cmdline(void) printed_errmsg = true; \ } while (0) bool ret = true; - kv_size(ccline_colors) = 0; - if (ccline.cmdbuff == NULL || *ccline.cmdbuff == NUL) { + // Check whether result of the previous call is still valid. + if (ret_ccline_colors->prompt_id == colored_ccline->prompt_id + && ret_ccline_colors->cmdbuff != NULL + && STRCMP(ret_ccline_colors->cmdbuff, colored_ccline->cmdbuff) == 0) { + return ret; + } + + kv_size(ret_ccline_colors->colors) = 0; + + if (colored_ccline->cmdbuff == NULL || *colored_ccline->cmdbuff == NUL) { // Nothing to do, exiting. + xfree(ret_ccline_colors->cmdbuff); + ret_ccline_colors->cmdbuff = NULL; return ret; } bool arg_allocated = false; typval_T arg = { .v_type = VAR_STRING, - .vval.v_string = ccline.cmdbuff, + .vval.v_string = colored_ccline->cmdbuff, }; typval_T tv = { .v_type = VAR_UNKNOWN }; @@ -2364,17 +2404,17 @@ static bool color_cmdline(void) bool dgc_ret = true; bool tl_ret = true; - if (ccline.prompt_id != prev_prompt_id) { + if (colored_ccline->prompt_id != prev_prompt_id) { prev_prompt_errors = 0; - prev_prompt_id = ccline.prompt_id; + prev_prompt_id = colored_ccline->prompt_id; } else if (prev_prompt_errors >= MAX_CB_ERRORS) { goto color_cmdline_end; } - if (ccline.highlight_callback.type != kCallbackNone) { + if (colored_ccline->highlight_callback.type != kCallbackNone) { // Currently this should only happen while processing input() prompts. - assert(ccline.input_fn); - color_cb = ccline.highlight_callback; - } else if (ccline.cmdfirstc == ':') { + assert(colored_ccline->input_fn); + color_cb = colored_ccline->highlight_callback; + } else if (colored_ccline->cmdfirstc == ':') { try_enter(&tstate); err_errmsg = N_( "E5408: Unable to get Nvim_color_cmdline callback from g:: %s"); @@ -2382,7 +2422,7 @@ static bool color_cmdline(void) &color_cb); tl_ret = try_leave(&tstate, &err); can_free_cb = true; - } else if (ccline.cmdfirstc == '=') { + } else if (colored_ccline->cmdfirstc == '=') { try_enter(&tstate); err_errmsg = N_( "E5409: Unable to get Nvim_color_expr callback from g:: %s"); @@ -2398,10 +2438,10 @@ static bool color_cmdline(void) if (color_cb.type == kCallbackNone) { goto color_cmdline_end; } - if (ccline.cmdbuff[ccline.cmdlen] != NUL) { + if (colored_ccline->cmdbuff[colored_ccline->cmdlen] != NUL) { arg_allocated = true; - arg.vval.v_string = xmemdupz((const char *)ccline.cmdbuff, - (size_t)ccline.cmdlen); + arg.vval.v_string = xmemdupz((const char *)colored_ccline->cmdbuff, + (size_t)colored_ccline->cmdlen); } // msg_start() called by e.g. :echo may shift command-line to the first column // even though msg_silent is here. Two ways to workaround this problem without @@ -2454,18 +2494,18 @@ static bool color_cmdline(void) const varnumber_T start = tv_get_number_chk(&l->lv_first->li_tv, &error); if (error) { goto color_cmdline_error; - } else if (!(prev_end <= start && start < ccline.cmdlen)) { + } else if (!(prev_end <= start && start < colored_ccline->cmdlen)) { PRINT_ERRMSG(_("E5403: Chunk %i start %" PRIdVARNUMBER " not in range " "[%" PRIdVARNUMBER ", %i)"), - i, start, prev_end, ccline.cmdlen); + i, start, prev_end, colored_ccline->cmdlen); goto color_cmdline_error; - } else if (utf8len_tab_zero[(uint8_t)ccline.cmdbuff[start]] == 0) { + } else if (utf8len_tab_zero[(uint8_t)colored_ccline->cmdbuff[start]] == 0) { PRINT_ERRMSG(_("E5405: Chunk %i start %" PRIdVARNUMBER " splits " "multibyte character"), i, start); goto color_cmdline_error; } if (start != prev_end) { - kv_push(ccline_colors, ((ColoredCmdlineChunk) { + kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) { .start = prev_end, .end = start, .attr = 0, @@ -2475,13 +2515,14 @@ static bool color_cmdline(void) &error); if (error) { goto color_cmdline_error; - } else if (!(start < end && end <= ccline.cmdlen)) { + } else if (!(start < end && end <= colored_ccline->cmdlen)) { PRINT_ERRMSG(_("E5404: Chunk %i end %" PRIdVARNUMBER " not in range " "(%" PRIdVARNUMBER ", %i]"), - i, end, start, ccline.cmdlen); + i, end, start, colored_ccline->cmdlen); goto color_cmdline_error; - } else if (end < ccline.cmdlen - && utf8len_tab_zero[(uint8_t)ccline.cmdbuff[end]] == 0) { + } else if (end < colored_ccline->cmdlen + && (utf8len_tab_zero[(uint8_t)colored_ccline->cmdbuff[end]] + == 0)) { PRINT_ERRMSG(_("E5406: Chunk %i end %" PRIdVARNUMBER " splits multibyte " "character"), i, end); goto color_cmdline_error; @@ -2493,16 +2534,16 @@ static bool color_cmdline(void) } const int id = syn_name2id((char_u *)group); const int attr = (id == 0 ? 0 : syn_id2attr(id)); - kv_push(ccline_colors, ((ColoredCmdlineChunk) { + kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) { .start = start, .end = end, .attr = attr, })); } - if (prev_end < ccline.cmdlen) { - kv_push(ccline_colors, ((ColoredCmdlineChunk) { + if (prev_end < colored_ccline->cmdlen) { + kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) { .start = prev_end, - .end = ccline.cmdlen, + .end = colored_ccline->cmdlen, .attr = 0, })); } @@ -2512,8 +2553,14 @@ color_cmdline_end: if (can_free_cb) { callback_free(&color_cb); } + xfree(ret_ccline_colors->cmdbuff); + // Note: errors “output†is cached just as well as regular results. + ret_ccline_colors->prompt_id = colored_ccline->prompt_id; if (arg_allocated) { - tv_clear(&arg); + ret_ccline_colors->cmdbuff = (char *)arg.vval.v_string; + } else { + ret_ccline_colors->cmdbuff = xmemdupz((const char *)colored_ccline->cmdbuff, + (size_t)colored_ccline->cmdlen); } tv_clear(&tv); return ret; @@ -2526,10 +2573,8 @@ color_cmdline_error: (void)printed_errmsg; prev_prompt_errors++; - kv_size(ccline_colors) = 0; - prev_prompt_errors += MAX_CB_ERRORS; + kv_size(ret_ccline_colors->colors) = 0; redrawcmdline(); - prev_prompt_errors -= MAX_CB_ERRORS; ret = false; goto color_cmdline_end; #undef PRINT_ERRMSG @@ -2541,7 +2586,7 @@ color_cmdline_error: */ static void draw_cmdline(int start, int len) { - if (!color_cmdline()) { + if (!color_cmdline(&ccline, &last_ccline_colors)) { return; } @@ -2643,9 +2688,9 @@ static void draw_cmdline(int start, int len) msg_outtrans_len(arshape_buf, newlen); } else { draw_cmdline_no_arabicshape: - if (kv_size(ccline_colors)) { - for (size_t i = 0; i < kv_size(ccline_colors); i++) { - ColoredCmdlineChunk chunk = kv_A(ccline_colors, i); + if (kv_size(last_ccline_colors.colors)) { + for (size_t i = 0; i < kv_size(last_ccline_colors.colors); i++) { + CmdlineColorChunk chunk = kv_A(last_ccline_colors.colors, i); if (chunk.end <= start) { continue; } -- cgit From 8eb54c5deca228fa5a34d22cb9f91d956eed773c Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Thu, 27 Jul 2017 09:56:25 +0800 Subject: vim-patch:8.0.0088 (#7080) Problem: When a test fails in Setup or Teardown the problem is not reported. Solution: Add a try/catch. (Hirohito Higashi) https://github.com/vim/vim/commit/cc28e2d05d05552d8b72a520be8a193f3d9822d4 --- src/nvim/testdir/runtest.vim | 12 ++++++++++-- src/nvim/version.c | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index 117ba52eb6..39ffabc024 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -79,7 +79,11 @@ let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log' func RunTheTest(test) echo 'Executing ' . a:test if exists("*SetUp") - call SetUp() + try + call SetUp() + catch + call add(v:errors, 'Caught exception in SetUp() before ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint) + endtry endif call add(s:messages, 'Executing ' . a:test) @@ -94,7 +98,11 @@ func RunTheTest(test) endtry if exists("*TearDown") - call TearDown() + try + call TearDown() + catch + call add(v:errors, 'Caught exception in TearDown() after ' . a:test . ': ' . v:exception . ' @ ' . v:throwpoint) + endtry endif " Close any extra windows and make the current one not modified. diff --git a/src/nvim/version.c b/src/nvim/version.c index d07a1c2d68..b585c3ad9a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -641,7 +641,7 @@ static const int included_patches[] = { // 91, // 90, // 89 NA - // 88, + 88, // 87 NA // 86, 85, -- cgit From dc685387a3d60e9ea3d09c80c74d4613b618cf14 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 21 Mar 2017 03:21:53 +0100 Subject: viml: introduce menu_get() function #6322 menu_get({path}, {modes}). See :h menu_get. --- src/nvim/eval.c | 14 +++ src/nvim/eval.lua | 7 +- src/nvim/ex_cmds.lua | 2 +- src/nvim/getchar.h | 15 +-- src/nvim/mbyte.c | 13 +-- src/nvim/menu.c | 296 ++++++++++++++++++++++++++++++++++----------------- src/nvim/menu.h | 47 ++++---- 7 files changed, 262 insertions(+), 132 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 3ec8deb666..2988225110 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -47,6 +47,7 @@ #include "nvim/mbyte.h" #include "nvim/memline.h" #include "nvim/memory.h" +#include "nvim/menu.h" #include "nvim/message.h" #include "nvim/misc1.h" #include "nvim/keymap.h" @@ -8173,6 +8174,19 @@ static void f_expand(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } + +/// "menu_get(path [, modes])" function +static void f_menu_get(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + tv_list_alloc_ret(rettv); + int modes = MENU_ALL_MODES; + if (argvars[1].v_type == VAR_STRING) { + const char_u *const strmodes = (char_u *)tv_get_string(&argvars[1]); + modes = get_menu_cmd_modes(strmodes, false, NULL, NULL); + } + menu_get((char_u *)tv_get_string(&argvars[0]), modes, rettv->vval.v_list); +} + /* * "extend(list, list [, idx])" function * "extend(dict, dict [, action])" function diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 30766a0734..08baae4086 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -2,10 +2,10 @@ -- -- Keys: -- --- args Number of arguments, list with maximum and minimum number of arguments --- or list with a minimum number of arguments only. Defaults to zero +-- args Number of arguments, list with maximum and minimum number of arguments +-- or list with a minimum number of arguments only. Defaults to zero -- arguments. --- func Name of the C function which implements the VimL function. Defaults to +-- func Name of the C function which implements the VimL function. Defaults to -- `f_{funcname}`. local varargs = function(nr) @@ -208,6 +208,7 @@ return { matchstr={args={2, 4}}, matchstrpos={args={2,4}}, max={args=1}, + menu_get={args={1, 2}}, min={args=1}, mkdir={args={1, 3}}, mode={args={0, 1}}, diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index 7203fbd97d..46f7a7bc40 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -1,4 +1,4 @@ -bit = require 'bit' +local bit = require 'bit' -- Description of the values below is contained in ex_cmds_defs.h file. local RANGE = 0x001 diff --git a/src/nvim/getchar.h b/src/nvim/getchar.h index 28584e0534..e634273e0d 100644 --- a/src/nvim/getchar.h +++ b/src/nvim/getchar.h @@ -5,12 +5,15 @@ #include "nvim/buffer_defs.h" #include "nvim/ex_cmds_defs.h" -/* Values for "noremap" argument of ins_typebuf(). Also used for - * map->m_noremap and menu->noremap[]. */ -#define REMAP_YES 0 /* allow remapping */ -#define REMAP_NONE -1 /* no remapping */ -#define REMAP_SCRIPT -2 /* remap script-local mappings only */ -#define REMAP_SKIP -3 /* no remapping for first char */ +/// Values for "noremap" argument of ins_typebuf(). Also used for +/// map->m_noremap and menu->noremap[]. +/// @addtogroup REMAP_VALUES +/// @{ +#define REMAP_YES 0 ///< allow remapping +#define REMAP_NONE -1 ///< no remapping +#define REMAP_SCRIPT -2 ///< remap script-local mappings only +#define REMAP_SKIP -3 ///< no remapping for first char +/// @} #define KEYLEN_PART_KEY -1 /* keylen value for incomplete key-code */ #define KEYLEN_PART_MAP -2 /* keylen value for incomplete mapping */ diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 2acfb896d8..4440300640 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -932,12 +932,13 @@ int utf_char2len(int c) return 6; } -/* - * Convert Unicode character "c" to UTF-8 string in "buf[]". - * Returns the number of bytes. - * This does not include composing characters. - */ -int utf_char2bytes(int c, char_u *buf) +/// Convert Unicode character to UTF-8 string +/// +/// @param c character to convert to \p buf +/// @param[out] buf UTF-8 string generated from \p c, does not add \0 +/// @return the number of bytes (between 1 and 6) +/// @note This does not include composing characters. +int utf_char2bytes(int c, char_u *const buf) { if (c < 0x80) { /* 7 bits */ buf[0] = c; diff --git a/src/nvim/menu.c b/src/nvim/menu.c index c8e6012e5c..91b615be30 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -26,7 +26,7 @@ #include "nvim/state.h" #include "nvim/strings.h" #include "nvim/ui.h" - +#include "nvim/eval/typval.h" #define MENUDEPTH 10 /* maximum depth of menus */ @@ -38,8 +38,8 @@ -/* The character for each menu mode */ -static char_u menu_mode_chars[] = {'n', 'v', 's', 'o', 'i', 'c', 't'}; +/// The character for each menu mode +static char_u menu_mode_chars[] = { 'n', 'v', 's', 'o', 'i', 'c', 't' }; static char_u e_notsubmenu[] = N_( "E327: Part of menu-item path is not sub-menu"); @@ -47,17 +47,14 @@ static char_u e_othermode[] = N_("E328: Menu only exists in another mode"); static char_u e_nomenu[] = N_("E329: No menu \"%s\""); -/* - * Do the :menu command and relatives. - */ -void -ex_menu ( - exarg_T *eap /* Ex command arguments */ -) +/// Do the :menu command and relatives. +/// @param eap Ex command arguments +void +ex_menu(exarg_T *eap) { char_u *menu_path; int modes; - char_u *map_to; + char_u *map_to; // command mapped to the menu entry int noremap; bool silent = false; int unmenu; @@ -93,9 +90,12 @@ ex_menu ( } - /* Locate an optional "icon=filename" argument. */ + // Locate an optional "icon=filename" argument + // Kept just the command parsing from vim for compativility but no further + // processing is done if (STRNCMP(arg, "icon=", 5) == 0) { arg += 5; + // icon = arg; while (*arg != NUL && *arg != ' ') { if (*arg == '\\') STRMOVE(arg, arg + 1); @@ -107,12 +107,12 @@ ex_menu ( } } - /* - * Fill in the priority table. - */ - for (p = arg; *p; ++p) - if (!ascii_isdigit(*p) && *p != '.') + // Fill in the priority table. + for (p = arg; *p; p++) { + if (!ascii_isdigit(*p) && *p != '.') { break; + } + } if (ascii_iswhite(*p)) { for (i = 0; i < MENUDEPTH && !ascii_iswhite(*arg); ++i) { pri_tab[i] = getdigits_long(&arg); @@ -226,8 +226,7 @@ ex_menu ( menuarg.modes = modes; menuarg.noremap[0] = noremap; menuarg.silent[0] = silent; - add_menu_path(menu_path, &menuarg, pri_tab, map_to - ); + add_menu_path(menu_path, &menuarg, pri_tab, map_to); /* * For the PopUp menu, add a menu for each mode separately. @@ -252,16 +251,18 @@ theend: ; } -/* - * Add the menu with the given name to the menu hierarchy - */ -static int -add_menu_path ( - char_u *menu_path, - vimmenu_T *menuarg, /* passes modes, iconfile, iconidx, - icon_builtin, silent[0], noremap[0] */ - long *pri_tab, - char_u *call_data + +/// Add the menu with the given name to the menu hierarchy +/// +/// @param[out] menuarg menu entry +/// @param[] pri_tab priority table +/// @param[in] call_data Right hand side command +static int +add_menu_path( + const char_u *const menu_path, + vimmenu_T *menuarg, + const long *const pri_tab, + const char_u *const call_data ) { char_u *path_name; @@ -296,8 +297,9 @@ add_menu_path ( if (map_to != NULL) { en_name = name; name = map_to; - } else + } else { en_name = NULL; + } dname = menu_text(name, NULL, NULL); if (*dname == NUL) { /* Only a mnemonic or accelerator is not valid. */ @@ -311,14 +313,15 @@ add_menu_path ( while (menu != NULL) { if (menu_name_equal(name, menu) || menu_name_equal(dname, menu)) { if (*next_name == NUL && menu->children != NULL) { - if (!sys_menu) + if (!sys_menu) { EMSG(_("E330: Menu path must not lead to a sub-menu")); + } goto erret; } - if (*next_name != NUL && menu->children == NULL - ) { - if (!sys_menu) + if (*next_name != NUL && menu->children == NULL) { + if (!sys_menu) { EMSG(_(e_notsubmenu)); + } goto erret; } break; @@ -352,7 +355,7 @@ add_menu_path ( menu->modes = modes; menu->enabled = MENU_ALL_MODES; menu->name = vim_strsave(name); - /* separate mnemonic and accelerator text from actual menu name */ + // separate mnemonic and accelerator text from actual menu name menu->dname = menu_text(name, &menu->mnemonic, &menu->actext); if (en_name != NULL) { menu->en_name = vim_strsave(en_name); @@ -364,9 +367,7 @@ add_menu_path ( menu->priority = pri_tab[pri_idx]; menu->parent = parent; - /* - * Add after menu that has lower priority. - */ + // Add after menu that has lower priority. menu->next = *lower_pri; *lower_pri = menu; @@ -392,8 +393,9 @@ add_menu_path ( name = next_name; xfree(dname); dname = NULL; - if (pri_tab[pri_idx + 1] != -1) - ++pri_idx; + if (pri_tab[pri_idx + 1] != -1) { + pri_idx++; + } } xfree(path_name); @@ -419,8 +421,7 @@ add_menu_path ( // Don't do this for "". c = 0; d = 0; - if (amenu && call_data != NULL && *call_data != NUL - ) { + if (amenu && call_data != NULL && *call_data != NUL) { switch (1 << i) { case MENU_VISUAL_MODE: case MENU_SELECT_MODE: @@ -438,9 +439,9 @@ add_menu_path ( if (c != 0) { menu->strings[i] = xmalloc(STRLEN(call_data) + 5 ); menu->strings[i][0] = c; - if (d == 0) + if (d == 0) { STRCPY(menu->strings[i] + 1, call_data); - else { + } else { menu->strings[i][1] = d; STRCPY(menu->strings[i] + 2, call_data); } @@ -452,8 +453,9 @@ add_menu_path ( menu->strings[i][len + 1] = Ctrl_G; menu->strings[i][len + 2] = NUL; } - } else + } else { menu->strings[i] = p; + } menu->noremap[i] = menuarg->noremap[0]; menu->silent[i] = menuarg->silent[0]; } @@ -657,20 +659,109 @@ static void free_menu_string(vimmenu_T *menu, int idx) menu->strings[idx] = NULL; } -/* - * Show the mapping associated with a menu item or hierarchy in a sub-menu. - */ -static int show_menus(char_u *path_name, int modes) +/// Export menus +/// +/// @param[in] menu if null, starts from root_menu +/// @param modes, a choice of \ref MENU_MODES +/// @return a dict with name/commands +/// @see menu_get +static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes) +{ + dict_T *dict; + char buf[sizeof(menu->mnemonic)]; + int mnemonic_len; + + if (!menu || (menu->modes & modes) == 0x0) { + return NULL; + } + + dict = tv_dict_alloc(); + tv_dict_add_str(dict, S_LEN("name"), (char *)menu->dname); + tv_dict_add_nr(dict, S_LEN("priority"), (int)menu->priority); + tv_dict_add_nr(dict, S_LEN("hidden"), menu_is_hidden(menu->dname)); + + if (menu->mnemonic) { + mnemonic_len = utf_char2bytes(menu->mnemonic, (u_char *)buf); + buf[mnemonic_len] = '\0'; + tv_dict_add_str(dict, S_LEN("shortcut"), buf); + } + + if (menu->modes & MENU_TIP_MODE && menu->strings[MENU_INDEX_TIP]) { + tv_dict_add_str(dict, S_LEN("tooltip"), + (char *)menu->strings[MENU_INDEX_TIP]); + } + + if (!menu->children) { + // leaf menu + dict_T *commands = tv_dict_alloc(); + tv_dict_add_dict(dict, S_LEN("mappings"), commands); + + for (int bit = 0; bit < MENU_MODES; bit++) { + if ((menu->modes & modes & (1 << bit)) != 0) { + dict_T *impl = tv_dict_alloc(); + if (*menu->strings[bit] == NUL) { + tv_dict_add_str(impl, S_LEN("rhs"), (char *)""); + } else { + tv_dict_add_str(impl, S_LEN("rhs"), (char *)menu->strings[bit]); + } + tv_dict_add_nr(impl, S_LEN("silent"), menu->silent[bit]); + tv_dict_add_nr(impl, S_LEN("enabled"), + (menu->enabled & (1 << bit)) ? 1 : 0); + tv_dict_add_nr(impl, S_LEN("noremap"), + (menu->noremap[bit] & REMAP_NONE) ? 1 : 0); + tv_dict_add_nr(impl, S_LEN("sid"), + (menu->noremap[bit] & REMAP_SCRIPT) ? 1 : 0); + tv_dict_add_dict(commands, (char *)&menu_mode_chars[bit], 1, impl); + } + } + } else { + // visit recursively all children + list_T *children_list = tv_list_alloc(); + for (menu = menu->children; menu != NULL; menu = menu->next) { + dict_T *dic = menu_get_recursive(menu, modes); + if (dict && tv_dict_len(dict) > 0) { + tv_list_append_dict(children_list, dic); + } + } + tv_dict_add_list(dict, S_LEN("submenus"), children_list); + } + return dict; +} + + +/// Export menus matching path \p path_name +/// +/// @param path_name +/// @param modes supported modes, see \ref MENU_MODES +/// @param[in,out] list must be allocated +/// @return false if could not find path_name +bool menu_get(char_u *const path_name, int modes, list_T *list) { - char_u *p; - char_u *name; vimmenu_T *menu; - vimmenu_T *parent = NULL; + menu = find_menu(root_menu, path_name, modes); + if (!menu) { + return false; + } + for (; menu != NULL; menu = menu->next) { + dict_T *dict = menu_get_recursive(menu, modes); + if (dict && tv_dict_len(dict) > 0) { + tv_list_append_dict(list, dict); + } + } + return true; +} - menu = root_menu; - name = path_name = vim_strsave(path_name); - /* First, find the (sub)menu with the given name */ +/// Find menu matching required name and modes +/// +/// @param menu top menu to start looking from +/// @param name path towards the menu +/// @return menu if \p name is null, found menu or NULL +vimmenu_T * +find_menu(vimmenu_T *menu, char_u * name, int modes) +{ + char_u *p; + while (*name) { p = menu_name_skip(name); while (menu != NULL) { @@ -678,39 +769,46 @@ static int show_menus(char_u *path_name, int modes) /* Found menu */ if (*p != NUL && menu->children == NULL) { EMSG(_(e_notsubmenu)); - xfree(path_name); - return FAIL; + return NULL; } else if ((menu->modes & modes) == 0x0) { EMSG(_(e_othermode)); - xfree(path_name); - return FAIL; + return NULL; } break; } menu = menu->next; } + if (menu == NULL) { EMSG2(_(e_nomenu), name); - xfree(path_name); - return FAIL; + return NULL; } name = p; - parent = menu; menu = menu->children; } - xfree(path_name); + return menu; +} + +/// Show the mapping associated with a menu item or hierarchy in a sub-menu. +static int show_menus(char_u *const path_name, int modes) +{ + vimmenu_T *menu; + + // First, find the (sub)menu with the given name + menu = find_menu(root_menu, path_name, modes); + if (!menu) { + return FAIL; + } /* Now we have found the matching menu, and we list the mappings */ /* Highlight title */ MSG_PUTS_TITLE(_("\n--- Menus ---")); - show_menus_recursive(parent, modes, 0); + show_menus_recursive(menu->parent, modes, 0); return OK; } -/* - * Recursively show the mappings associated with the menus under the given one - */ +/// Recursively show the mappings associated with the menus under the given one static void show_menus_recursive(vimmenu_T *menu, int modes, int depth) { int i; @@ -993,12 +1091,13 @@ char_u *get_menu_names(expand_T *xp, int idx) return str; } -/* - * Skip over this element of the menu path and return the start of the next - * element. Any \ and ^Vs are removed from the current element. - * "name" may be modified. - */ -char_u *menu_name_skip(char_u *name) + +/// Skip over this element of the menu path and return the start of the next +/// element. Any \ and ^Vs are removed from the current element. +/// +/// @param name may be modified. +/// @return start of the next element +char_u *menu_name_skip(char_u *const name) { char_u *p; @@ -1018,16 +1117,16 @@ char_u *menu_name_skip(char_u *name) * Return TRUE when "name" matches with menu "menu". The name is compared in * two ways: raw menu name and menu name without '&'. ignore part after a TAB. */ -static int menu_name_equal(char_u *name, vimmenu_T *menu) +static bool menu_name_equal(const char_u *const name, vimmenu_T *const menu) { if (menu->en_name != NULL && (menu_namecmp(name, menu->en_name) || menu_namecmp(name, menu->en_dname))) - return TRUE; + return true; return menu_namecmp(name, menu->name) || menu_namecmp(name, menu->dname); } -static int menu_namecmp(char_u *name, char_u *mname) +static bool menu_namecmp(const char_u *const name, const char_u *const mname) { int i; @@ -1038,18 +1137,20 @@ static int menu_namecmp(char_u *name, char_u *mname) && (mname[i] == NUL || mname[i] == TAB); } -/* - * Return the modes specified by the given menu command (eg :menu! returns - * MENU_CMDLINE_MODE | MENU_INSERT_MODE). - * If "noremap" is not NULL, then the flag it points to is set according to - * whether the command is a "nore" command. - * If "unmenu" is not NULL, then the flag it points to is set according to - * whether the command is an "unmenu" command. - */ -static int -get_menu_cmd_modes ( - char_u *cmd, - int forceit, /* Was there a "!" after the command? */ + +/// converts a string into a combination of \ref MENU_MODES +/// (eg :menu! returns MENU_CMDLINE_MODE | MENU_INSERT_MODE) +/// +/// @param[in] cmd a string like 'n' (normal) or 'a' (all) +/// @param[in] forceit Was there a "!" after the command? +/// @param[out] If "noremap" is not NULL, then the flag it points to is set +/// according to whether the command is a "nore" command. +/// @param[out] unmenu is not NULL, then the flag it points to is set according +/// to whether the command is an "unmenu" command. +int +get_menu_cmd_modes( + const char_u * cmd, + bool forceit, int *noremap, int *unmenu ) @@ -1090,12 +1191,15 @@ get_menu_cmd_modes ( } /* FALLTHROUGH */ default: - --cmd; - if (forceit) /* menu!! */ + cmd--; + if (forceit) { + // menu!! modes = MENU_INSERT_MODE | MENU_CMDLINE_MODE; - else /* menu */ + } else { + // menu modes = MENU_NORMAL_MODE | MENU_VISUAL_MODE | MENU_SELECT_MODE | MENU_OP_PENDING_MODE; + } } if (noremap != NULL) @@ -1201,12 +1305,14 @@ int menu_is_separator(char_u *name) return name[0] == '-' && name[STRLEN(name) - 1] == '-'; } -/* - * Return TRUE if the menu is hidden: Starts with ']' - */ + +/// True if a popup menu or starts with \ref MNU_HIDDEN_CHAR +/// +/// @return true if the menu is hidden static int menu_is_hidden(char_u *name) { - return (name[0] == ']') || (menu_is_popup(name) && name[5] != NUL); + return (name[0] == MNU_HIDDEN_CHAR) + || (menu_is_popup(name) && name[5] != NUL); } /* diff --git a/src/nvim/menu.h b/src/nvim/menu.h index a84b7d812e..5ff979f2bf 100644 --- a/src/nvim/menu.h +++ b/src/nvim/menu.h @@ -6,7 +6,9 @@ #include "nvim/types.h" // for char_u and expand_T #include "nvim/ex_cmds_defs.h" // for exarg_T -/* Indices into vimmenu_T->strings[] and vimmenu_T->noremap[] for each mode */ +/// Indices into vimmenu_T->strings[] and vimmenu_T->noremap[] for each mode +/// \addtogroup MENU_INDEX +/// @{ #define MENU_INDEX_INVALID -1 #define MENU_INDEX_NORMAL 0 #define MENU_INDEX_VISUAL 1 @@ -16,8 +18,12 @@ #define MENU_INDEX_CMDLINE 5 #define MENU_INDEX_TIP 6 #define MENU_MODES 7 +/// @} +/// note MENU_INDEX_TIP is not a 'real' mode -/* Menu modes */ +/// Menu modes +/// \addtogroup MENU_MODES +/// @{ #define MENU_NORMAL_MODE (1 << MENU_INDEX_NORMAL) #define MENU_VISUAL_MODE (1 << MENU_INDEX_VISUAL) #define MENU_SELECT_MODE (1 << MENU_INDEX_SELECT) @@ -26,31 +32,30 @@ #define MENU_CMDLINE_MODE (1 << MENU_INDEX_CMDLINE) #define MENU_TIP_MODE (1 << MENU_INDEX_TIP) #define MENU_ALL_MODES ((1 << MENU_INDEX_TIP) - 1) -/*note MENU_INDEX_TIP is not a 'real' mode*/ +/// @} -/* Start a menu name with this to not include it on the main menu bar */ +/// Start a menu name with this to not include it on the main menu bar #define MNU_HIDDEN_CHAR ']' typedef struct VimMenu vimmenu_T; struct VimMenu { - int modes; /* Which modes is this menu visible for? */ - int enabled; /* for which modes the menu is enabled */ - char_u *name; /* Name of menu, possibly translated */ - char_u *dname; /* Displayed Name ("name" without '&') */ - char_u *en_name; /* "name" untranslated, NULL when "name" - * was not translated */ - char_u *en_dname; /* "dname" untranslated, NULL when "dname" - * was not translated */ - int mnemonic; /* mnemonic key (after '&') */ - char_u *actext; /* accelerator text (after TAB) */ - long priority; /* Menu order priority */ - char_u *strings[MENU_MODES]; /* Mapped string for each mode */ - int noremap[MENU_MODES]; /* A REMAP_ flag for each mode */ - bool silent[MENU_MODES]; /* A silent flag for each mode */ - vimmenu_T *children; /* Children of sub-menu */ - vimmenu_T *parent; /* Parent of menu */ - vimmenu_T *next; /* Next item in menu */ + int modes; ///< Which modes is this menu visible for + int enabled; ///< for which modes the menu is enabled + char_u *name; ///< Name of menu, possibly translated + char_u *dname; ///< Displayed Name ("name" without '&') + char_u *en_name; ///< "name" untranslated, NULL when + ///< was not translated + char_u *en_dname; ///< NULL when "dname" untranslated + int mnemonic; ///< mnemonic key (after '&') + char_u *actext; ///< accelerator text (after TAB) + long priority; ///< Menu order priority + char_u *strings[MENU_MODES]; ///< Mapped string for each mode + int noremap[MENU_MODES]; ///< A \ref REMAP_VALUES flag for each mode + bool silent[MENU_MODES]; ///< A silent flag for each mode + vimmenu_T *children; ///< Children of sub-menu + vimmenu_T *parent; ///< Parent of menu + vimmenu_T *next; ///< Next item in menu }; -- cgit From 3b45f676c0f07aa2826f191f555ba0d5f53e6d7c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 28 Jul 2017 02:31:03 +0200 Subject: menu_get(): doc --- src/nvim/mbyte.c | 3 +-- src/nvim/menu.c | 18 ++++++++---------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 4440300640..3fad6c789d 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -936,8 +936,7 @@ int utf_char2len(int c) /// /// @param c character to convert to \p buf /// @param[out] buf UTF-8 string generated from \p c, does not add \0 -/// @return the number of bytes (between 1 and 6) -/// @note This does not include composing characters. +/// @return Number of bytes (1-6). Does not include composing characters. int utf_char2bytes(int c, char_u *const buf) { if (c < 0x80) { /* 7 bits */ diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 91b615be30..a498916e5e 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -91,11 +91,9 @@ ex_menu(exarg_T *eap) // Locate an optional "icon=filename" argument - // Kept just the command parsing from vim for compativility but no further - // processing is done + // TODO(nvim): Currently this is only parsed. Should expose it to UIs. if (STRNCMP(arg, "icon=", 5) == 0) { arg += 5; - // icon = arg; while (*arg != NUL && *arg != ' ') { if (*arg == '\\') STRMOVE(arg, arg + 1); @@ -1138,15 +1136,15 @@ static bool menu_namecmp(const char_u *const name, const char_u *const mname) } -/// converts a string into a combination of \ref MENU_MODES +/// Returns the \ref MENU_MODES specified by menu command `cmd`. /// (eg :menu! returns MENU_CMDLINE_MODE | MENU_INSERT_MODE) /// -/// @param[in] cmd a string like 'n' (normal) or 'a' (all) -/// @param[in] forceit Was there a "!" after the command? -/// @param[out] If "noremap" is not NULL, then the flag it points to is set -/// according to whether the command is a "nore" command. -/// @param[out] unmenu is not NULL, then the flag it points to is set according -/// to whether the command is an "unmenu" command. +/// @param[in] cmd string like "nmenu", "vmenu", etc. +/// @param[in] forceit bang (!) was given after the command +/// @param[out] noremap If not NULL, the flag it points to is set according +/// to whether the command is a "nore" command. +/// @param[out] unmenu If not NULL, the flag it points to is set according +/// to whether the command is an "unmenu" command. int get_menu_cmd_modes( const char_u * cmd, -- cgit From 707bb3749459fb30c02701b63553af7a3460f980 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sat, 29 Jul 2017 06:00:53 +0800 Subject: vim-patch:8.0.0100 (#7085) vim-patch:8.0.0100 Problem: Options that are a file name may contain non-filename characters. Solution: Check for more invalid characters. https://github.com/vim/vim/commit/319afe3804741db5a6c188bd69535fa7ed044c62 --- src/nvim/option.c | 11 +++++------ src/nvim/version.c | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index a6ae022e79..98ca72b2bb 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2457,12 +2457,11 @@ did_set_string_option ( if ((secure || sandbox != 0) && (options[opt_idx].flags & P_SECURE)) { errmsg = e_secure; - } - /* Check for a "normal" file name in some options. Disallow a path - * separator (slash and/or backslash), wildcards and characters that are - * often illegal in a file name. */ - else if ((options[opt_idx].flags & P_NFNAME) - && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL) { + } else if ((options[opt_idx].flags & P_NFNAME) + && vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL) { + // Check for a "normal" file name in some options. Disallow a path + // separator (slash and/or backslash), wildcards and characters that are + // often illegal in a file name. errmsg = e_invarg; } /* 'backupcopy' */ diff --git a/src/nvim/version.c b/src/nvim/version.c index b585c3ad9a..f0048fb234 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -629,7 +629,7 @@ static const int included_patches[] = { // 103 NA // 102, // 101, - // 100, + 100, 99, // 98 NA // 97 NA -- cgit From 5acda12419858da202ce7ea962fae75102a75b2b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 29 Jul 2017 04:53:40 +0200 Subject: coverity/155506: null dereference (#7089) Coverity warning is a false positive: if rbuffer_read_ptr() returns NULL then `cnt` is zero. Revert 76ea97c809e50fccc5ca6615943ac6da1db1e030 (which caused the TSan build to hang often--possibly because of the missing ui_flush()). Instead, modify out_data_append_to_screen() to check for NULL. ref #6862 --- src/nvim/os/shell.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 9d80a43718..32e9a70e57 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -447,7 +447,7 @@ static void out_data_append_to_screen(char *output, size_t remaining, size_t off = 0; int last_row = (int)Rows - 1; - while (off < remaining) { + while (output != NULL && off < remaining) { // Found end of line? if (output[off] == NL) { // Can we start a new line or do we need to continue the last one? @@ -473,7 +473,7 @@ static void out_data_append_to_screen(char *output, size_t remaining, off++; } - if (remaining) { + if (output != NULL && remaining) { if (last_col == 0) { screen_del_lines(0, 0, 1, (int)Rows, NULL); } @@ -496,12 +496,8 @@ static void out_data_cb(Stream *stream, RBuffer *buf, size_t count, void *data, size_t cnt; char *ptr = rbuffer_read_ptr(buf, &cnt); - if (ptr == NULL || cnt == 0) { - // Nothing to read; - return; - } - - if (out_data_decide_throttle(cnt)) { // Skip output above a threshold. + if (ptr != NULL && cnt > 0 + && out_data_decide_throttle(cnt)) { // Skip output above a threshold. // Save the skipped output. If it is the final chunk, we display it later. out_data_ring(ptr, cnt); } else { -- cgit From fe0bcc08003c82af7742636d3f7a95a1c91cf909 Mon Sep 17 00:00:00 2001 From: Jurica Bradaric Date: Tue, 25 Jul 2017 14:18:08 +0200 Subject: vim-patch:8.0.0020 Problem: The regexp engines are not reentrant. Solution: Add regexec_T and save/restore the state when needed. https://github.com/vim/vim/commit/6100d02aab7c8294b581cb299250eea164b50e9d --- src/nvim/regexp.c | 994 +++++++++++++++++++++++------------------ src/nvim/regexp_nfa.c | 221 ++++----- src/nvim/testdir/test_expr.vim | 5 +- src/nvim/version.c | 2 +- 4 files changed, 668 insertions(+), 554 deletions(-) (limited to 'src') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 41070aebf4..847b2f273e 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -3172,61 +3172,56 @@ static int need_clear_zsubexpr = FALSE; /* extmatch subexpressions int regnarrate = 0; #endif -/* - * Internal copy of 'ignorecase'. It is set at each call to vim_regexec(). - * Normally it gets the value of "rm_ic" or "rmm_ic", but when the pattern - * contains '\c' or '\C' the value is overruled. - */ -static int ireg_ic; - -/* - * Similar to ireg_ic, but only for 'combining' characters. Set with \Z flag - * in the regexp. Defaults to false, always. - */ -static int ireg_icombine; - -/* - * Copy of "rmm_maxcol": maximum column to search for a match. Zero when - * there is no maximum. - */ -static colnr_T ireg_maxcol; - -/* - * Sometimes need to save a copy of a line. Since alloc()/free() is very - * slow, we keep one allocated piece of memory and only re-allocate it when - * it's too small. It's freed in bt_regexec_both() when finished. - */ +// Sometimes need to save a copy of a line. Since alloc()/free() is very +// slow, we keep one allocated piece of memory and only re-allocate it when +// it's too small. It's freed in bt_regexec_both() when finished. static char_u *reg_tofree = NULL; static unsigned reg_tofreelen; -/* - * These variables are set when executing a regexp to speed up the execution. - * Which ones are set depends on whether a single-line or multi-line match is - * done: - * single-line multi-line - * reg_match ®match_T NULL - * reg_mmatch NULL ®mmatch_T - * reg_startp reg_match->startp - * reg_endp reg_match->endp - * reg_startpos reg_mmatch->startpos - * reg_endpos reg_mmatch->endpos - * reg_win NULL window in which to search - * reg_buf curbuf buffer in which to search - * reg_firstlnum first line in which to search - * reg_maxline 0 last line nr - * reg_line_lbr FALSE or TRUE FALSE - */ -static regmatch_T *reg_match; -static regmmatch_T *reg_mmatch; -static char_u **reg_startp = NULL; -static char_u **reg_endp = NULL; -static lpos_T *reg_startpos = NULL; -static lpos_T *reg_endpos = NULL; -static win_T *reg_win; -static buf_T *reg_buf; -static linenr_T reg_firstlnum; -static linenr_T reg_maxline; -static int reg_line_lbr; /* "\n" in string is line break */ +// Structure used to store the execution state of the regex engine. +// Which ones are set depends on whether a single-line or multi-line match is +// done: +// single-line multi-line +// reg_match ®match_T NULL +// reg_mmatch NULL ®mmatch_T +// reg_startp reg_match->startp +// reg_endp reg_match->endp +// reg_startpos reg_mmatch->startpos +// reg_endpos reg_mmatch->endpos +// reg_win NULL window in which to search +// reg_buf curbuf buffer in which to search +// reg_firstlnum first line in which to search +// reg_maxline 0 last line nr +// reg_line_lbr false or true false +typedef struct { + regmatch_T *reg_match; + regmmatch_T *reg_mmatch; + char_u **reg_startp; + char_u **reg_endp; + lpos_T *reg_startpos; + lpos_T *reg_endpos; + win_T *reg_win; + buf_T *reg_buf; + linenr_T reg_firstlnum; + linenr_T reg_maxline; + bool reg_line_lbr; // "\n" in string is line break + + // Internal copy of 'ignorecase'. It is set at each call to vim_regexec(). + // Normally it gets the value of "rm_ic" or "rmm_ic", but when the pattern + // contains '\c' or '\C' the value is overruled. + bool reg_ic; + + // Similar to rex.reg_ic, but only for 'combining' characters. Set with \Z + // flag in the regexp. Defaults to false, always. + bool reg_icombine; + + // Copy of "rmm_maxcol": maximum column to search for a match. Zero when + // there is no maximum. + colnr_T reg_maxcol; +} regexec_T; + +static regexec_T rex; +static bool rex_in_use = false; /* * "regstack" and "backpos" are used by regmatch(). They are kept over calls @@ -3268,14 +3263,16 @@ void free_regexp_stuff(void) */ static char_u *reg_getline(linenr_T lnum) { - /* when looking behind for a match/no-match lnum is negative. But we - * can't go before line 1 */ - if (reg_firstlnum + lnum < 1) + // when looking behind for a match/no-match lnum is negative. But we + // can't go before line 1 + if (rex.reg_firstlnum + lnum < 1) { return NULL; - if (lnum > reg_maxline) - /* Must have matched the "\n" in the last line. */ + } + if (lnum > rex.reg_maxline) { + // Must have matched the "\n" in the last line. return (char_u *)""; - return ml_get_buf(reg_buf, reg_firstlnum + lnum, FALSE); + } + return ml_get_buf(rex.reg_buf, rex.reg_firstlnum + lnum, false); } static regsave_T behind_pos; @@ -3285,9 +3282,8 @@ static char_u *reg_endzp[NSUBEXP]; /* and end of \z(...\) matches */ static lpos_T reg_startzpos[NSUBEXP]; /* idem, beginning pos */ static lpos_T reg_endzpos[NSUBEXP]; /* idem, end pos */ -/* TRUE if using multi-line regexp. */ -#define REG_MULTI (reg_match == NULL) - +// TRUE if using multi-line regexp. +#define REG_MULTI (rex.reg_match == NULL) /* * Match a regexp against a string. @@ -3305,15 +3301,15 @@ bt_regexec_nl ( bool line_lbr ) { - reg_match = rmp; - reg_mmatch = NULL; - reg_maxline = 0; - reg_line_lbr = line_lbr; - reg_buf = curbuf; - reg_win = NULL; - ireg_ic = rmp->rm_ic; - ireg_icombine = FALSE; - ireg_maxcol = 0; + rex.reg_match = rmp; + rex.reg_mmatch = NULL; + rex.reg_maxline = 0; + rex.reg_line_lbr = line_lbr; + rex.reg_buf = curbuf; + rex.reg_win = NULL; + rex.reg_ic = rmp->rm_ic; + rex.reg_icombine = false; + rex.reg_maxcol = 0; long r = bt_regexec_both(line, col, NULL); assert(r <= INT_MAX); @@ -3336,16 +3332,16 @@ bt_regexec_nl ( static long bt_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm) { - reg_match = NULL; - reg_mmatch = rmp; - reg_buf = buf; - reg_win = win; - reg_firstlnum = lnum; - reg_maxline = reg_buf->b_ml.ml_line_count - lnum; - reg_line_lbr = FALSE; - ireg_ic = rmp->rmm_ic; - ireg_icombine = FALSE; - ireg_maxcol = rmp->rmm_maxcol; + rex.reg_match = NULL; + rex.reg_mmatch = rmp; + rex.reg_buf = buf; + rex.reg_win = win; + rex.reg_firstlnum = lnum; + rex.reg_maxline = rex.reg_buf->b_ml.ml_line_count - lnum; + rex.reg_line_lbr = false; + rex.reg_ic = rmp->rmm_ic; + rex.reg_icombine = false; + rex.reg_maxcol = rmp->rmm_maxcol; return bt_regexec_both(NULL, col, tm); } @@ -3383,14 +3379,14 @@ static long bt_regexec_both(char_u *line, } if (REG_MULTI) { - prog = (bt_regprog_T *)reg_mmatch->regprog; + prog = (bt_regprog_T *)rex.reg_mmatch->regprog; line = reg_getline((linenr_T)0); - reg_startpos = reg_mmatch->startpos; - reg_endpos = reg_mmatch->endpos; + rex.reg_startpos = rex.reg_mmatch->startpos; + rex.reg_endpos = rex.reg_mmatch->endpos; } else { - prog = (bt_regprog_T *)reg_match->regprog; - reg_startp = reg_match->startp; - reg_endp = reg_match->endp; + prog = (bt_regprog_T *)rex.reg_match->regprog; + rex.reg_startp = rex.reg_match->startp; + rex.reg_endp = rex.reg_match->endp; } /* Be paranoid... */ @@ -3403,19 +3399,22 @@ static long bt_regexec_both(char_u *line, if (prog_magic_wrong()) goto theend; - /* If the start column is past the maximum column: no need to try. */ - if (ireg_maxcol > 0 && col >= ireg_maxcol) + // If the start column is past the maximum column: no need to try. + if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol) { goto theend; + } - /* If pattern contains "\c" or "\C": overrule value of ireg_ic */ - if (prog->regflags & RF_ICASE) - ireg_ic = TRUE; - else if (prog->regflags & RF_NOICASE) - ireg_ic = FALSE; + // If pattern contains "\c" or "\C": overrule value of rex.reg_ic + if (prog->regflags & RF_ICASE) { + rex.reg_ic = true; + } else if (prog->regflags & RF_NOICASE) { + rex.reg_ic = false; + } - /* If pattern contains "\Z" overrule value of ireg_icombine */ - if (prog->regflags & RF_ICOMBINE) - ireg_icombine = TRUE; + // If pattern contains "\Z" overrule value of rex.reg_icombine + if (prog->regflags & RF_ICOMBINE) { + rex.reg_icombine = true; + } /* If there is a "must appear" string, look for it. */ if (prog->regmust != NULL) { @@ -3429,7 +3428,7 @@ static long bt_regexec_both(char_u *line, // This is used very often, esp. for ":global". Use two versions of // the loop to avoid overhead of conditions. - if (!ireg_ic) { + if (!rex.reg_ic) { while ((s = vim_strchr(s, c)) != NULL) { if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) { break; // Found it. @@ -3463,7 +3462,7 @@ static long bt_regexec_both(char_u *line, c = regline[col]; if (prog->regstart == NUL || prog->regstart == c - || (ireg_ic + || (rex.reg_ic && (((enc_utf8 && utf_fold(prog->regstart) == utf_fold(c))) || (c < 255 && prog->regstart < 255 && mb_tolower(prog->regstart) == mb_tolower(c))))) { @@ -3485,8 +3484,8 @@ static long bt_regexec_both(char_u *line, col = (int)(s - regline); } - /* Check for maximum column to try. */ - if (ireg_maxcol > 0 && col >= ireg_maxcol) { + // Check for maximum column to try. + if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol) { retval = 0; break; } @@ -3583,21 +3582,24 @@ static long regtry(bt_regprog_T *prog, colnr_T col) cleanup_subexpr(); if (REG_MULTI) { - if (reg_startpos[0].lnum < 0) { - reg_startpos[0].lnum = 0; - reg_startpos[0].col = col; + if (rex.reg_startpos[0].lnum < 0) { + rex.reg_startpos[0].lnum = 0; + rex.reg_startpos[0].col = col; + } + if (rex.reg_endpos[0].lnum < 0) { + rex.reg_endpos[0].lnum = reglnum; + rex.reg_endpos[0].col = (int)(reginput - regline); + } else { + // Use line number of "\ze". + reglnum = rex.reg_endpos[0].lnum; } - if (reg_endpos[0].lnum < 0) { - reg_endpos[0].lnum = reglnum; - reg_endpos[0].col = (int)(reginput - regline); - } else - /* Use line number of "\ze". */ - reglnum = reg_endpos[0].lnum; } else { - if (reg_startp[0] == NULL) - reg_startp[0] = regline + col; - if (reg_endp[0] == NULL) - reg_endp[0] = reginput; + if (rex.reg_startp[0] == NULL) { + rex.reg_startp[0] = regline + col; + } + if (rex.reg_endp[0] == NULL) { + rex.reg_endp[0] = reginput; + } } /* Package any found \z(...\) matches for export. Default is none. */ unref_extmatch(re_extmatch_out); @@ -3632,36 +3634,33 @@ static long regtry(bt_regprog_T *prog, colnr_T col) } -/* - * Get class of previous character. - */ +// Get class of previous character. static int reg_prev_class(void) { if (reginput > regline) { return mb_get_class_tab(reginput - 1 - (*mb_head_off)(regline, reginput - 1), - reg_buf->b_chartab); + rex.reg_buf->b_chartab); } return -1; } -/* - * Return TRUE if the current reginput position matches the Visual area. - */ +// Return TRUE if the current reginput position matches the Visual area. static int reg_match_visual(void) { pos_T top, bot; linenr_T lnum; colnr_T col; - win_T *wp = reg_win == NULL ? curwin : reg_win; + win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win; int mode; colnr_T start, end; colnr_T start2, end2; - /* Check if the buffer is the current buffer. */ - if (reg_buf != curbuf || VIsual.lnum == 0) - return FALSE; + // Check if the buffer is the current buffer. + if (rex.reg_buf != curbuf || VIsual.lnum == 0) { + return false; + } if (VIsual_active) { if (lt(VIsual, wp->w_cursor)) { @@ -3682,9 +3681,10 @@ static int reg_match_visual(void) } mode = curbuf->b_visual.vi_mode; } - lnum = reglnum + reg_firstlnum; - if (lnum < top.lnum || lnum > bot.lnum) - return FALSE; + lnum = reglnum + rex.reg_firstlnum; + if (lnum < top.lnum || lnum > bot.lnum) { + return false; + } if (mode == 'v') { col = (colnr_T)(reginput - regline); @@ -3803,11 +3803,11 @@ regmatch ( next = regnext(scan); op = OP(scan); - /* Check for character class with NL added. */ - if (!reg_line_lbr && WITH_NL(op) && REG_MULTI - && *reginput == NUL && reglnum <= reg_maxline) { + // Check for character class with NL added. + if (!rex.reg_line_lbr && WITH_NL(op) && REG_MULTI + && *reginput == NUL && reglnum <= rex.reg_maxline) { reg_nextline(); - } else if (reg_line_lbr && WITH_NL(op) && *reginput == '\n') { + } else if (rex.reg_line_lbr && WITH_NL(op) && *reginput == '\n') { ADVANCE_REGINPUT(); } else { if (WITH_NL(op)) @@ -3828,26 +3828,29 @@ regmatch ( break; case RE_BOF: - /* We're not at the beginning of the file when below the first - * line where we started, not at the start of the line or we - * didn't start at the first line of the buffer. */ + // We're not at the beginning of the file when below the first + // line where we started, not at the start of the line or we + // didn't start at the first line of the buffer. if (reglnum != 0 || reginput != regline - || (REG_MULTI && reg_firstlnum > 1)) + || (REG_MULTI && rex.reg_firstlnum > 1)) { status = RA_NOMATCH; + } break; case RE_EOF: - if (reglnum != reg_maxline || c != NUL) + if (reglnum != rex.reg_maxline || c != NUL) { status = RA_NOMATCH; + } break; case CURSOR: - /* Check if the buffer is in a window and compare the - * reg_win->w_cursor position to the match position. */ - if (reg_win == NULL - || (reglnum + reg_firstlnum != reg_win->w_cursor.lnum) - || ((colnr_T)(reginput - regline) != reg_win->w_cursor.col)) + // Check if the buffer is in a window and compare the + // rex.reg_win->w_cursor position to the match position. + if (rex.reg_win == NULL + || (reglnum + rex.reg_firstlnum != rex.reg_win->w_cursor.lnum) + || ((colnr_T)(reginput - regline) != rex.reg_win->w_cursor.col)) { status = RA_NOMATCH; + } break; case RE_MARK: @@ -3857,19 +3860,20 @@ regmatch ( int cmp = OPERAND(scan)[1]; pos_T *pos; - pos = getmark_buf(reg_buf, mark, FALSE); - if (pos == NULL /* mark doesn't exist */ - || pos->lnum <= 0 /* mark isn't set in reg_buf */ - || (pos->lnum == reglnum + reg_firstlnum + pos = getmark_buf(rex.reg_buf, mark, false); + if (pos == NULL // mark doesn't exist + || pos->lnum <= 0 // mark isn't set in reg_buf + || (pos->lnum == reglnum + rex.reg_firstlnum ? (pos->col == (colnr_T)(reginput - regline) ? (cmp == '<' || cmp == '>') : (pos->col < (colnr_T)(reginput - regline) ? cmp != '>' : cmp != '<')) - : (pos->lnum < reglnum + reg_firstlnum + : (pos->lnum < reglnum + rex.reg_firstlnum ? cmp != '>' - : cmp != '<'))) + : cmp != '<'))) { status = RA_NOMATCH; + } } break; @@ -3879,11 +3883,12 @@ regmatch ( break; case RE_LNUM: - assert(reglnum + reg_firstlnum >= 0 - && (uintmax_t)(reglnum + reg_firstlnum) <= UINT32_MAX); - if (!REG_MULTI || !re_num_cmp((uint32_t)(reglnum + reg_firstlnum), - scan)) + assert(reglnum + rex.reg_firstlnum >= 0 + && (uintmax_t)(reglnum + rex.reg_firstlnum) <= UINT32_MAX); + if (!REG_MULTI + || !re_num_cmp((uint32_t)(reglnum + rex.reg_firstlnum), scan)) { status = RA_NOMATCH; + } break; case RE_COL: @@ -3894,11 +3899,13 @@ regmatch ( break; case RE_VCOL: - if (!re_num_cmp(win_linetabsize(reg_win == NULL ? curwin : reg_win, + if (!re_num_cmp(win_linetabsize(rex.reg_win == NULL + ? curwin : rex.reg_win, regline, (colnr_T)(reginput - regline)) + 1, - scan)) + scan)) { status = RA_NOMATCH; + } break; case BOW: /* \b_chartab); + this_class = mb_get_class_tab(reginput, rex.reg_buf->b_chartab); if (this_class <= 1) { status = RA_NOMATCH; // Not on a word at all. } else if (reg_prev_class() == this_class) { status = RA_NOMATCH; // Previous char is in same word. } } else { - if (!vim_iswordc_buf(c, reg_buf) || (reginput > regline - && vim_iswordc_buf(reginput[-1 - ], reg_buf))) + if (!vim_iswordc_buf(c, rex.reg_buf) + || (reginput > regline + && vim_iswordc_buf(reginput[-1], rex.reg_buf))) { status = RA_NOMATCH; + } } break; @@ -3929,15 +3937,16 @@ regmatch ( int this_class, prev_class; // Get class of current and previous char (if it exists). - this_class = mb_get_class_tab(reginput, reg_buf->b_chartab); + this_class = mb_get_class_tab(reginput, rex.reg_buf->b_chartab); prev_class = reg_prev_class(); if (this_class == prev_class || prev_class == 0 || prev_class == 1) status = RA_NOMATCH; } else { - if (!vim_iswordc_buf(reginput[-1], reg_buf) - || (reginput[0] != NUL && vim_iswordc_buf(c, reg_buf))) + if (!vim_iswordc_buf(reginput[-1], rex.reg_buf) + || (reginput[0] != NUL && vim_iswordc_buf(c, rex.reg_buf))) { status = RA_NOMATCH; + } } break; /* Matched with EOW */ @@ -3964,17 +3973,20 @@ regmatch ( break; case KWORD: - if (!vim_iswordp_buf(reginput, reg_buf)) + if (!vim_iswordp_buf(reginput, rex.reg_buf)) { status = RA_NOMATCH; - else + } else { ADVANCE_REGINPUT(); + } break; case SKWORD: - if (ascii_isdigit(*reginput) || !vim_iswordp_buf(reginput, reg_buf)) + if (ascii_isdigit(*reginput) + || !vim_iswordp_buf(reginput, rex.reg_buf)) { status = RA_NOMATCH; - else + } else { ADVANCE_REGINPUT(); + } break; case FNAME: @@ -4139,7 +4151,7 @@ regmatch ( opnd = OPERAND(scan); // Inline the first byte, for speed. if (*opnd != *reginput - && (!ireg_ic + && (!rex.reg_ic || (!enc_utf8 && mb_tolower(*opnd) != mb_tolower(*reginput)))) { status = RA_NOMATCH; @@ -4147,8 +4159,8 @@ regmatch ( // match empty string always works; happens when "~" is // empty. } else { - if (opnd[1] == NUL && !(enc_utf8 && ireg_ic)) { - len = 1; /* matched a single byte above */ + if (opnd[1] == NUL && !(enc_utf8 && rex.reg_ic)) { + len = 1; // matched a single byte above } else { // Need to match first byte again for multi-byte. len = (int)STRLEN(opnd); @@ -4160,7 +4172,7 @@ regmatch ( // follows (skips over all composing chars). if (status != RA_NOMATCH && enc_utf8 && UTF_COMPOSINGLIKE(reginput, reginput + len) - && !ireg_icombine + && !rex.reg_icombine && OP(next) != RE_COMPOSING) { // raaron: This code makes a composing character get // ignored, which is the correct behavior (sometimes) @@ -4284,9 +4296,9 @@ regmatch ( status = RA_FAIL; else { rp->rs_no = no; - save_se(&rp->rs_un.sesave, ®_startpos[no], - ®_startp[no]); - /* We simply continue and handle the result when done. */ + save_se(&rp->rs_un.sesave, &rex.reg_startpos[no], + &rex.reg_startp[no]); + // We simply continue and handle the result when done. } } break; @@ -4336,12 +4348,12 @@ regmatch ( no = op - MCLOSE; cleanup_subexpr(); rp = regstack_push(RS_MCLOSE, scan); - if (rp == NULL) + if (rp == NULL) { status = RA_FAIL; - else { + } else { rp->rs_no = no; - save_se(&rp->rs_un.sesave, ®_endpos[no], ®_endp[no]); - /* We simply continue and handle the result when done. */ + save_se(&rp->rs_un.sesave, &rex.reg_endpos[no], &rex.reg_endp[no]); + // We simply continue and handle the result when done. } } break; @@ -4384,41 +4396,40 @@ regmatch ( no = op - BACKREF; cleanup_subexpr(); - if (!REG_MULTI) { /* Single-line regexp */ - if (reg_startp[no] == NULL || reg_endp[no] == NULL) { - /* Backref was not set: Match an empty string. */ + if (!REG_MULTI) { // Single-line regexp + if (rex.reg_startp[no] == NULL || rex.reg_endp[no] == NULL) { + // Backref was not set: Match an empty string. len = 0; } else { - /* Compare current input with back-ref in the same - * line. */ - len = (int)(reg_endp[no] - reg_startp[no]); - if (cstrncmp(reg_startp[no], reginput, &len) != 0) + // Compare current input with back-ref in the same line. + len = (int)(rex.reg_endp[no] - rex.reg_startp[no]); + if (cstrncmp(rex.reg_startp[no], reginput, &len) != 0) { status = RA_NOMATCH; + } } - } else { /* Multi-line regexp */ - if (reg_startpos[no].lnum < 0 || reg_endpos[no].lnum < 0) { - /* Backref was not set: Match an empty string. */ + } else { // Multi-line regexp + if (rex.reg_startpos[no].lnum < 0 || rex.reg_endpos[no].lnum < 0) { + // Backref was not set: Match an empty string. len = 0; } else { - if (reg_startpos[no].lnum == reglnum - && reg_endpos[no].lnum == reglnum) { - /* Compare back-ref within the current line. */ - len = reg_endpos[no].col - reg_startpos[no].col; - if (cstrncmp(regline + reg_startpos[no].col, - reginput, &len) != 0) + if (rex.reg_startpos[no].lnum == reglnum + && rex.reg_endpos[no].lnum == reglnum) { + // Compare back-ref within the current line. + len = rex.reg_endpos[no].col - rex.reg_startpos[no].col; + if (cstrncmp(regline + rex.reg_startpos[no].col, + reginput, &len) != 0) { status = RA_NOMATCH; + } } else { - /* Messy situation: Need to compare between two - * lines. */ - int r = match_with_backref( - reg_startpos[no].lnum, - reg_startpos[no].col, - reg_endpos[no].lnum, - reg_endpos[no].col, - &len); - - if (r != RA_MATCH) + // Messy situation: Need to compare between two lines. + int r = match_with_backref(rex.reg_startpos[no].lnum, + rex.reg_startpos[no].col, + rex.reg_endpos[no].lnum, + rex.reg_endpos[no].col, + &len); + if (r != RA_MATCH) { status = r; + } } } } @@ -4558,7 +4569,7 @@ regmatch ( */ if (OP(next) == EXACTLY) { rst.nextb = *OPERAND(next); - if (ireg_ic) { + if (rex.reg_ic) { if (mb_isupper(rst.nextb)) { rst.nextb_ic = mb_tolower(rst.nextb); } else { @@ -4665,13 +4676,14 @@ regmatch ( break; case NEWL: - if ((c != NUL || !REG_MULTI || reglnum > reg_maxline - || reg_line_lbr) && (c != '\n' || !reg_line_lbr)) + if ((c != NUL || !REG_MULTI || reglnum > rex.reg_maxline + || rex.reg_line_lbr) && (c != '\n' || !rex.reg_line_lbr)) { status = RA_NOMATCH; - else if (reg_line_lbr) + } else if (rex.reg_line_lbr) { ADVANCE_REGINPUT(); - else + } else { reg_nextline(); + } break; case END: @@ -4710,10 +4722,11 @@ regmatch ( break; case RS_MOPEN: - /* Pop the state. Restore pointers when there is no match. */ - if (status == RA_NOMATCH) - restore_se(&rp->rs_un.sesave, ®_startpos[rp->rs_no], - ®_startp[rp->rs_no]); + // Pop the state. Restore pointers when there is no match. + if (status == RA_NOMATCH) { + restore_se(&rp->rs_un.sesave, &rex.reg_startpos[rp->rs_no], + &rex.reg_startp[rp->rs_no]); + } regstack_pop(&scan); break; @@ -4726,10 +4739,11 @@ regmatch ( break; case RS_MCLOSE: - /* Pop the state. Restore pointers when there is no match. */ - if (status == RA_NOMATCH) - restore_se(&rp->rs_un.sesave, ®_endpos[rp->rs_no], - ®_endp[rp->rs_no]); + // Pop the state. Restore pointers when there is no match. + if (status == RA_NOMATCH) { + restore_se(&rp->rs_un.sesave, &rex.reg_endpos[rp->rs_no], + &rex.reg_endp[rp->rs_no]); + } regstack_pop(&scan); break; @@ -5109,10 +5123,11 @@ regrepeat ( ++count; mb_ptr_adv(scan); } - if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline - || reg_line_lbr || count == maxcount) + if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline + || rex.reg_line_lbr || count == maxcount) { break; - ++count; /* count the line-break */ + } + count++; // count the line-break reg_nextline(); scan = reginput; if (got_int) @@ -5130,17 +5145,19 @@ regrepeat ( if (vim_isIDc(PTR2CHAR(scan)) && (testval || !ascii_isdigit(*scan))) { mb_ptr_adv(scan); } else if (*scan == NUL) { - if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline - || reg_line_lbr) + if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline + || rex.reg_line_lbr) { break; + } reg_nextline(); scan = reginput; if (got_int) break; - } else if (reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) - ++scan; - else + } else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) { + scan++; + } else { break; + } ++count; } break; @@ -5152,22 +5169,25 @@ regrepeat ( case SKWORD: case SKWORD + ADD_NL: while (count < maxcount) { - if (vim_iswordp_buf(scan, reg_buf) + if (vim_iswordp_buf(scan, rex.reg_buf) && (testval || !ascii_isdigit(*scan))) { mb_ptr_adv(scan); } else if (*scan == NUL) { - if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline - || reg_line_lbr) + if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline + || rex.reg_line_lbr) { break; + } reg_nextline(); scan = reginput; - if (got_int) + if (got_int) { break; - } else if (reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) - ++scan; - else + } + } else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) { + scan++; + } else { break; - ++count; + } + count++; } break; @@ -5181,18 +5201,21 @@ regrepeat ( if (vim_isfilec(PTR2CHAR(scan)) && (testval || !ascii_isdigit(*scan))) { mb_ptr_adv(scan); } else if (*scan == NUL) { - if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline - || reg_line_lbr) + if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline + || rex.reg_line_lbr) { break; + } reg_nextline(); scan = reginput; - if (got_int) + if (got_int) { break; - } else if (reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) - ++scan; - else + } + } else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) { + scan++; + } else { break; - ++count; + } + count++; } break; @@ -5204,21 +5227,24 @@ regrepeat ( case SPRINT + ADD_NL: while (count < maxcount) { if (*scan == NUL) { - if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline - || reg_line_lbr) + if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline + || rex.reg_line_lbr) { break; + } reg_nextline(); scan = reginput; - if (got_int) + if (got_int) { break; + } } else if (vim_isprintc(PTR2CHAR(scan)) == 1 && (testval || !ascii_isdigit(*scan))) { mb_ptr_adv(scan); - } else if (reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) - ++scan; - else + } else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) { + scan++; + } else { break; - ++count; + } + count++; } break; @@ -5229,9 +5255,10 @@ do_class: while (count < maxcount) { int l; if (*scan == NUL) { - if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline - || reg_line_lbr) + if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline + || rex.reg_line_lbr) { break; + } reg_nextline(); scan = reginput; if (got_int) @@ -5240,12 +5267,13 @@ do_class: if (testval != 0) break; scan += l; - } else if ((class_tab[*scan] & mask) == testval) - ++scan; - else if (reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) - ++scan; - else + } else if ((class_tab[*scan] & mask) == testval) { + scan++; + } else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) { + scan++; + } else { break; + } ++count; } break; @@ -5323,10 +5351,10 @@ do_class: { int cu, cl; - /* This doesn't do a multi-byte character, because a MULTIBYTECODE - * would have been used for it. It does handle single-byte - * characters, such as latin1. */ - if (ireg_ic) { + // This doesn't do a multi-byte character, because a MULTIBYTECODE + // would have been used for it. It does handle single-byte + // characters, such as latin1. + if (rex.reg_ic) { cu = mb_toupper(*opnd); cl = mb_tolower(*opnd); while (count < maxcount && (*scan == cu || *scan == cl)) { @@ -5350,17 +5378,19 @@ do_class: /* Safety check (just in case 'encoding' was changed since * compiling the program). */ if ((len = (*mb_ptr2len)(opnd)) > 1) { - if (ireg_ic && enc_utf8) + if (rex.reg_ic && enc_utf8) { cf = utf_fold(utf_ptr2char(opnd)); + } while (count < maxcount && (*mb_ptr2len)(scan) >= len) { for (i = 0; i < len; ++i) { if (opnd[i] != scan[i]) { break; } } - if (i < len && (!ireg_ic || !enc_utf8 - || utf_fold(utf_ptr2char(scan)) != cf)) + if (i < len && (!rex.reg_ic || !enc_utf8 + || utf_fold(utf_ptr2char(scan)) != cf)) { break; + } scan += len; ++count; } @@ -5378,18 +5408,21 @@ do_class: while (count < maxcount) { int len; if (*scan == NUL) { - if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > reg_maxline - || reg_line_lbr) + if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline + || rex.reg_line_lbr) { break; + } reg_nextline(); scan = reginput; - if (got_int) + if (got_int) { break; - } else if (reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) - ++scan; - else if (has_mbyte && (len = (*mb_ptr2len)(scan)) > 1) { - if ((cstrchr(opnd, (*mb_ptr2char)(scan)) == NULL) == testval) + } + } else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) { + scan++; + } else if (has_mbyte && (len = (*mb_ptr2len)(scan)) > 1) { + if ((cstrchr(opnd, (*mb_ptr2char)(scan)) == NULL) == testval) { break; + } scan += len; } else { if ((cstrchr(opnd, *scan) == NULL) == testval) @@ -5402,13 +5435,14 @@ do_class: case NEWL: while (count < maxcount - && ((*scan == NUL && reglnum <= reg_maxline && !reg_line_lbr - && REG_MULTI) || (*scan == '\n' && reg_line_lbr))) { + && ((*scan == NUL && reglnum <= rex.reg_maxline && !rex.reg_line_lbr + && REG_MULTI) || (*scan == '\n' && rex.reg_line_lbr))) { count++; - if (reg_line_lbr) + if (rex.reg_line_lbr) { ADVANCE_REGINPUT(); - else + } else { reg_nextline(); + } scan = reginput; if (got_int) break; @@ -5458,10 +5492,11 @@ static int prog_magic_wrong(void) { regprog_T *prog; - prog = REG_MULTI ? reg_mmatch->regprog : reg_match->regprog; - if (prog->engine == &nfa_regengine) - /* For NFA matcher we don't check the magic */ - return FALSE; + prog = REG_MULTI ? rex.reg_mmatch->regprog : rex.reg_match->regprog; + if (prog->engine == &nfa_regengine) { + // For NFA matcher we don't check the magic + return false; + } if (UCHARAT(((bt_regprog_T *)prog)->program) != REGMAGIC) { EMSG(_(e_re_corr)); @@ -5479,12 +5514,12 @@ static void cleanup_subexpr(void) { if (need_clear_subexpr) { if (REG_MULTI) { - /* Use 0xff to set lnum to -1 */ - memset(reg_startpos, 0xff, sizeof(lpos_T) * NSUBEXP); - memset(reg_endpos, 0xff, sizeof(lpos_T) * NSUBEXP); + // Use 0xff to set lnum to -1 + memset(rex.reg_startpos, 0xff, sizeof(lpos_T) * NSUBEXP); + memset(rex.reg_endpos, 0xff, sizeof(lpos_T) * NSUBEXP); } else { - memset(reg_startp, 0, sizeof(char_u *) * NSUBEXP); - memset(reg_endp, 0, sizeof(char_u *) * NSUBEXP); + memset(rex.reg_startp, 0, sizeof(char_u *) * NSUBEXP); + memset(rex.reg_endp, 0, sizeof(char_u *) * NSUBEXP); } need_clear_subexpr = FALSE; } @@ -5513,17 +5548,17 @@ static void save_subexpr(regbehind_T *bp) { int i; - /* When "need_clear_subexpr" is set we don't need to save the values, only - * remember that this flag needs to be set again when restoring. */ + // When "need_clear_subexpr" is set we don't need to save the values, only + // remember that this flag needs to be set again when restoring. bp->save_need_clear_subexpr = need_clear_subexpr; if (!need_clear_subexpr) { for (i = 0; i < NSUBEXP; ++i) { if (REG_MULTI) { - bp->save_start[i].se_u.pos = reg_startpos[i]; - bp->save_end[i].se_u.pos = reg_endpos[i]; + bp->save_start[i].se_u.pos = rex.reg_startpos[i]; + bp->save_end[i].se_u.pos = rex.reg_endpos[i]; } else { - bp->save_start[i].se_u.ptr = reg_startp[i]; - bp->save_end[i].se_u.ptr = reg_endp[i]; + bp->save_start[i].se_u.ptr = rex.reg_startp[i]; + bp->save_end[i].se_u.ptr = rex.reg_endp[i]; } } } @@ -5541,11 +5576,11 @@ static void restore_subexpr(regbehind_T *bp) if (!need_clear_subexpr) { for (i = 0; i < NSUBEXP; ++i) { if (REG_MULTI) { - reg_startpos[i] = bp->save_start[i].se_u.pos; - reg_endpos[i] = bp->save_end[i].se_u.pos; + rex.reg_startpos[i] = bp->save_start[i].se_u.pos; + rex.reg_endpos[i] = bp->save_end[i].se_u.pos; } else { - reg_startp[i] = bp->save_start[i].se_u.ptr; - reg_endp[i] = bp->save_end[i].se_u.ptr; + rex.reg_startp[i] = bp->save_start[i].se_u.ptr; + rex.reg_endp[i] = bp->save_end[i].se_u.ptr; } } } @@ -5681,10 +5716,12 @@ static int match_with_backref(linenr_T start_lnum, colnr_T start_col, linenr_T e return RA_NOMATCH; /* doesn't match */ if (bytelen != NULL) *bytelen += len; - if (clnum == end_lnum) - break; /* match and at end! */ - if (reglnum >= reg_maxline) - return RA_NOMATCH; /* text too short */ + if (clnum == end_lnum) { + break; // match and at end! + } + if (reglnum >= rex.reg_maxline) { + return RA_NOMATCH; // text too short + } /* Advance to next line. */ reg_nextline(); @@ -6232,24 +6269,22 @@ static void mb_decompose(int c, int *c1, int *c2, int *c3) } } -/* - * Compare two strings, ignore case if ireg_ic set. - * Return 0 if strings match, non-zero otherwise. - * Correct the length "*n" when composing characters are ignored. - */ +// Compare two strings, ignore case if rex.reg_ic set. +// Return 0 if strings match, non-zero otherwise. +// Correct the length "*n" when composing characters are ignored. static int cstrncmp(char_u *s1, char_u *s2, int *n) { int result; - if (!ireg_ic) + if (!rex.reg_ic) { result = STRNCMP(s1, s2, *n); - else { + } else { assert(*n >= 0); result = mb_strnicmp(s1, s2, (size_t)*n); } - /* if it failed and it's utf8 and we want to combineignore: */ - if (result != 0 && enc_utf8 && ireg_icombine) { + // if it failed and it's utf8 and we want to combineignore: + if (result != 0 && enc_utf8 && rex.reg_icombine) { char_u *str1, *str2; int c1, c2, c11, c12; int junk; @@ -6266,14 +6301,15 @@ static int cstrncmp(char_u *s1, char_u *s2, int *n) /* decompose the character if necessary, into 'base' characters * because I don't care about Arabic, I will hard-code the Hebrew * which I *do* care about! So sue me... */ - if (c1 != c2 && (!ireg_ic || utf_fold(c1) != utf_fold(c2))) { - /* decomposition necessary? */ + if (c1 != c2 && (!rex.reg_ic || utf_fold(c1) != utf_fold(c2))) { + // decomposition necessary? mb_decompose(c1, &c11, &junk, &junk); mb_decompose(c2, &c12, &junk, &junk); c1 = c11; c2 = c12; - if (c11 != c12 && (!ireg_ic || utf_fold(c11) != utf_fold(c12))) + if (c11 != c12 && (!rex.reg_ic || utf_fold(c11) != utf_fold(c12))) { break; + } } } result = c2 - c1; @@ -6291,7 +6327,7 @@ static inline char_u *cstrchr(const char_u *const s, const int c) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE { - if (!ireg_ic) { + if (!rex.reg_ic) { return vim_strchr(s, c); } @@ -6419,14 +6455,18 @@ char_u *regtilde(char_u *source, int magic) static int can_f_submatch = FALSE; /* TRUE when submatch() can be used */ -/* These pointers are used instead of reg_match and reg_mmatch for - * reg_submatch(). Needed for when the substitution string is an expression - * that contains a call to substitute() and submatch(). */ -static regmatch_T *submatch_match; -static regmmatch_T *submatch_mmatch; -static linenr_T submatch_firstlnum; -static linenr_T submatch_maxline; -static int submatch_line_lbr; +// These pointers are used for reg_submatch(). Needed for when the +// substitution string is an expression that contains a call to substitute() +// and submatch(). +typedef struct { + regmatch_T *sm_match; + regmmatch_T *sm_mmatch; + linenr_T sm_firstlnum; + linenr_T sm_maxline; + int sm_line_lbr; +} regsubmatch_T; + +static regsubmatch_T rsm; // can only be used when can_f_submatch is true /// Put the submatches in "argv[0]" which is a list passed into call_func() by /// vim_regsub_both(). @@ -6447,11 +6487,11 @@ static int fill_submatch_list(int argc, typval_T *argv, int argcount) // There are always 10 list items in staticList10_T. li = argv->vval.v_list->lv_first; for (i = 0; i < 10; i++) { - s = submatch_match->startp[i]; - if (s == NULL || submatch_match->endp[i] == NULL) { + s = rsm.sm_match->startp[i]; + if (s == NULL || rsm.sm_match->endp[i] == NULL) { s = NULL; } else { - s = vim_strnsave(s, (int)(submatch_match->endp[i] - s)); + s = vim_strnsave(s, (int)(rsm.sm_match->endp[i] - s)); } li->li_tv.v_type = VAR_STRING; li->li_tv.vval.v_string = s; @@ -6488,23 +6528,55 @@ static void clear_submatch_list(staticList10_T *sl) int vim_regsub(regmatch_T *rmp, char_u *source, typval_T *expr, char_u *dest, int copy, int magic, int backslash) { - reg_match = rmp; - reg_mmatch = NULL; - reg_maxline = 0; - reg_buf = curbuf; - reg_line_lbr = true; - return vim_regsub_both(source, expr, dest, copy, magic, backslash); + regexec_T rex_save; + bool rex_in_use_save = rex_in_use; + + if (rex_in_use) { + // Being called recursively, save the state. + rex_save = rex; + } + rex_in_use = true; + + rex.reg_match = rmp; + rex.reg_mmatch = NULL; + rex.reg_maxline = 0; + rex.reg_buf = curbuf; + rex.reg_line_lbr = true; + int result = vim_regsub_both(source, expr, dest, copy, magic, backslash); + + rex_in_use = rex_in_use_save; + if (rex_in_use) { + rex = rex_save; + } + + return result; } int vim_regsub_multi(regmmatch_T *rmp, linenr_T lnum, char_u *source, char_u *dest, int copy, int magic, int backslash) { - reg_match = NULL; - reg_mmatch = rmp; - reg_buf = curbuf; /* always works on the current buffer! */ - reg_firstlnum = lnum; - reg_maxline = curbuf->b_ml.ml_line_count - lnum; - reg_line_lbr = false; - return vim_regsub_both(source, NULL, dest, copy, magic, backslash); + regexec_T rex_save; + bool rex_in_use_save = rex_in_use; + + if (rex_in_use) { + // Being called recursively, save the state. + rex_save = rex; + } + rex_in_use = true; + + rex.reg_match = NULL; + rex.reg_mmatch = rmp; + rex.reg_buf = curbuf; // always works on the current buffer! + rex.reg_firstlnum = lnum; + rex.reg_maxline = curbuf->b_ml.ml_line_count - lnum; + rex.reg_line_lbr = false; + int result = vim_regsub_both(source, NULL, dest, copy, magic, backslash); + + rex_in_use = rex_in_use_save; + if (rex_in_use) { + rex = rex_save; + } + + return result; } static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, @@ -6533,8 +6605,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, dst = dest; // When the substitute part starts with "\=" evaluate it as an expression. - if (expr != NULL || (source[0] == '\\' && source[1] == '=' - && !can_f_submatch)) { // can't do this recursively + if (expr != NULL || (source[0] == '\\' && source[1] == '=')) { // To make sure that the length doesn't change between checking the // length and copying the string, and to speed up things, the // resulting string is saved from the call with "copy" == FALSE to the @@ -6547,24 +6618,23 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, eval_result = NULL; } } else { - win_T *save_reg_win; - int save_ireg_ic; - bool prev_can_f_submatch = can_f_submatch; + int prev_can_f_submatch = can_f_submatch; + regsubmatch_T rsm_save; xfree(eval_result); - /* The expression may contain substitute(), which calls us - * recursively. Make sure submatch() gets the text from the first - * level. Don't need to save "reg_buf", because - * vim_regexec_multi() can't be called recursively. */ - submatch_match = reg_match; - submatch_mmatch = reg_mmatch; - submatch_firstlnum = reg_firstlnum; - submatch_maxline = reg_maxline; - submatch_line_lbr = reg_line_lbr; - save_reg_win = reg_win; - save_ireg_ic = ireg_ic; + // The expression may contain substitute(), which calls us + // recursively. Make sure submatch() gets the text from the first + // level. + if (can_f_submatch) { + rsm_save = rsm; + } can_f_submatch = true; + rsm.sm_match = rex.reg_match; + rsm.sm_mmatch = rex.reg_mmatch; + rsm.sm_firstlnum = rex.reg_firstlnum; + rsm.sm_maxline = rex.reg_maxline; + rsm.sm_line_lbr = rex.reg_line_lbr; if (expr != NULL) { typval_T argv[2]; @@ -6574,29 +6644,25 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, rettv.v_type = VAR_STRING; rettv.vval.v_string = NULL; - if (prev_can_f_submatch) { - // can't do this recursively - } else { - argv[0].v_type = VAR_LIST; - argv[0].vval.v_list = &matchList.sl_list; - matchList.sl_list.lv_len = 0; - if (expr->v_type == VAR_FUNC) { - s = expr->vval.v_string; - call_func(s, (int)STRLEN(s), &rettv, 1, argv, - fill_submatch_list, 0L, 0L, &dummy, - true, NULL, NULL); - } else if (expr->v_type == VAR_PARTIAL) { - partial_T *partial = expr->vval.v_partial; - - s = partial_name(partial); - call_func(s, (int)STRLEN(s), &rettv, 1, argv, - fill_submatch_list, 0L, 0L, &dummy, - true, partial, NULL); - } - if (matchList.sl_list.lv_len > 0) { - // fill_submatch_list() was called. - clear_submatch_list(&matchList); - } + argv[0].v_type = VAR_LIST; + argv[0].vval.v_list = &matchList.sl_list; + matchList.sl_list.lv_len = 0; + if (expr->v_type == VAR_FUNC) { + s = expr->vval.v_string; + call_func(s, (int)STRLEN(s), &rettv, 1, argv, + fill_submatch_list, 0L, 0L, &dummy, + true, NULL, NULL); + } else if (expr->v_type == VAR_PARTIAL) { + partial_T *partial = expr->vval.v_partial; + + s = partial_name(partial); + call_func(s, (int)STRLEN(s), &rettv, 1, argv, + fill_submatch_list, 0L, 0L, &dummy, + true, partial, NULL); + } + if (matchList.sl_list.lv_len > 0) { + // fill_submatch_list() was called. + clear_submatch_list(&matchList); } char buf[NUMBUFLEN]; eval_result = (char_u *)tv_get_string_buf_chk(&rettv, buf); @@ -6612,22 +6678,23 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, int had_backslash = FALSE; for (s = eval_result; *s != NUL; mb_ptr_adv(s)) { - /* Change NL to CR, so that it becomes a line break, - * unless called from vim_regexec_nl(). - * Skip over a backslashed character. */ - if (*s == NL && !submatch_line_lbr) + // Change NL to CR, so that it becomes a line break, + // unless called from vim_regexec_nl(). + // Skip over a backslashed character. + if (*s == NL && !rsm.sm_line_lbr) { *s = CAR; - else if (*s == '\\' && s[1] != NUL) { - ++s; + } else if (*s == '\\' && s[1] != NUL) { + s++; /* Change NL to CR here too, so that this works: * :s/abc\\\ndef/\="aaa\\\nbbb"/ on text: * abc\ * def * Not when called from vim_regexec_nl(). */ - if (*s == NL && !submatch_line_lbr) + if (*s == NL && !rsm.sm_line_lbr) { *s = CAR; - had_backslash = TRUE; + } + had_backslash = true; } } if (had_backslash && backslash) { @@ -6640,14 +6707,10 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, dst += STRLEN(eval_result); } - reg_match = submatch_match; - reg_mmatch = submatch_mmatch; - reg_firstlnum = submatch_firstlnum; - reg_maxline = submatch_maxline; - reg_line_lbr = submatch_line_lbr; - reg_win = save_reg_win; - ireg_ic = save_ireg_ic; - can_f_submatch = FALSE; + can_f_submatch = prev_can_f_submatch; + if (can_f_submatch) { + rsm = rsm_save; + } } } else while ((c = *src++) != NUL) { @@ -6745,43 +6808,50 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, dst++; } else { if (REG_MULTI) { - clnum = reg_mmatch->startpos[no].lnum; - if (clnum < 0 || reg_mmatch->endpos[no].lnum < 0) + clnum = rex.reg_mmatch->startpos[no].lnum; + if (clnum < 0 || rex.reg_mmatch->endpos[no].lnum < 0) { s = NULL; - else { - s = reg_getline(clnum) + reg_mmatch->startpos[no].col; - if (reg_mmatch->endpos[no].lnum == clnum) - len = reg_mmatch->endpos[no].col - - reg_mmatch->startpos[no].col; - else + } else { + s = reg_getline(clnum) + rex.reg_mmatch->startpos[no].col; + if (rex.reg_mmatch->endpos[no].lnum == clnum) { + len = rex.reg_mmatch->endpos[no].col + - rex.reg_mmatch->startpos[no].col; + } else { len = (int)STRLEN(s); + } } } else { - s = reg_match->startp[no]; - if (reg_match->endp[no] == NULL) + s = rex.reg_match->startp[no]; + if (rex.reg_match->endp[no] == NULL) { s = NULL; - else - len = (int)(reg_match->endp[no] - s); + } else { + len = (int)(rex.reg_match->endp[no] - s); + } } if (s != NULL) { for (;; ) { if (len == 0) { if (REG_MULTI) { - if (reg_mmatch->endpos[no].lnum == clnum) + if (rex.reg_mmatch->endpos[no].lnum == clnum) { break; - if (copy) + } + if (copy) { *dst = CAR; - ++dst; + } + dst++; s = reg_getline(++clnum); - if (reg_mmatch->endpos[no].lnum == clnum) - len = reg_mmatch->endpos[no].col; - else + if (rex.reg_mmatch->endpos[no].lnum == clnum) { + len = rex.reg_mmatch->endpos[no].col; + } else { len = (int)STRLEN(s); - } else + } + } else { break; - } else if (*s == NUL) { /* we hit NUL. */ - if (copy) + } + } else if (*s == NUL) { // we hit NUL. + if (copy) { EMSG(_(e_re_damg)); + } goto exit; } else { if (backslash && (*s == CAR || *s == '\\')) { @@ -6855,16 +6925,16 @@ exit: static char_u *reg_getline_submatch(linenr_T lnum) { char_u *s; - linenr_T save_first = reg_firstlnum; - linenr_T save_max = reg_maxline; + linenr_T save_first = rex.reg_firstlnum; + linenr_T save_max = rex.reg_maxline; - reg_firstlnum = submatch_firstlnum; - reg_maxline = submatch_maxline; + rex.reg_firstlnum = rsm.sm_firstlnum; + rex.reg_maxline = rsm.sm_maxline; s = reg_getline(lnum); - reg_firstlnum = save_first; - reg_maxline = save_max; + rex.reg_firstlnum = save_first; + rex.reg_maxline = save_max; return s; } @@ -6883,39 +6953,41 @@ char_u *reg_submatch(int no) if (!can_f_submatch || no < 0) return NULL; - if (submatch_match == NULL) { + if (rsm.sm_match == NULL) { ssize_t len; /* * First round: compute the length and allocate memory. * Second round: copy the text. */ - for (round = 1; round <= 2; ++round) { - lnum = submatch_mmatch->startpos[no].lnum; - if (lnum < 0 || submatch_mmatch->endpos[no].lnum < 0) + for (round = 1; round <= 2; round++) { + lnum = rsm.sm_mmatch->startpos[no].lnum; + if (lnum < 0 || rsm.sm_mmatch->endpos[no].lnum < 0) { return NULL; + } - s = reg_getline_submatch(lnum) + submatch_mmatch->startpos[no].col; - if (s == NULL) /* anti-crash check, cannot happen? */ + s = reg_getline_submatch(lnum) + rsm.sm_mmatch->startpos[no].col; + if (s == NULL) { // anti-crash check, cannot happen? break; - if (submatch_mmatch->endpos[no].lnum == lnum) { - /* Within one line: take form start to end col. */ - len = submatch_mmatch->endpos[no].col - - submatch_mmatch->startpos[no].col; - if (round == 2) + } + if (rsm.sm_mmatch->endpos[no].lnum == lnum) { + // Within one line: take form start to end col. + len = rsm.sm_mmatch->endpos[no].col - rsm.sm_mmatch->startpos[no].col; + if (round == 2) { STRLCPY(retval, s, len + 1); - ++len; + } + len++; } else { - /* Multiple lines: take start line from start col, middle - * lines completely and end line up to end col. */ - len = STRLEN(s); + // Multiple lines: take start line from start col, middle + // lines completely and end line up to end col. + len = (ssize_t)STRLEN(s); if (round == 2) { STRCPY(retval, s); retval[len] = '\n'; } - ++len; - ++lnum; - while (lnum < submatch_mmatch->endpos[no].lnum) { + len++; + lnum++; + while (lnum < rsm.sm_mmatch->endpos[no].lnum) { s = reg_getline_submatch(lnum++); if (round == 2) STRCPY(retval + len, s); @@ -6924,10 +6996,11 @@ char_u *reg_submatch(int no) retval[len] = '\n'; ++len; } - if (round == 2) + if (round == 2) { STRNCPY(retval + len, reg_getline_submatch(lnum), - submatch_mmatch->endpos[no].col); - len += submatch_mmatch->endpos[no].col; + rsm.sm_mmatch->endpos[no].col); + } + len += rsm.sm_mmatch->endpos[no].col; if (round == 2) { retval[len] = NUL; // -V595 } @@ -6939,11 +7012,12 @@ char_u *reg_submatch(int no) } } } else { - s = submatch_match->startp[no]; - if (s == NULL || submatch_match->endp[no] == NULL) + s = rsm.sm_match->startp[no]; + if (s == NULL || rsm.sm_match->endp[no] == NULL) { retval = NULL; - else - retval = vim_strnsave(s, (int)(submatch_match->endp[no] - s)); + } else { + retval = vim_strnsave(s, (int)(rsm.sm_match->endp[no] - s)); + } } return retval; @@ -6965,15 +7039,15 @@ list_T *reg_submatch_list(int no) list_T *list; const char *s; - if (submatch_match == NULL) { - slnum = submatch_mmatch->startpos[no].lnum; - elnum = submatch_mmatch->endpos[no].lnum; + if (rsm.sm_match == NULL) { + slnum = rsm.sm_mmatch->startpos[no].lnum; + elnum = rsm.sm_mmatch->endpos[no].lnum; if (slnum < 0 || elnum < 0) { return NULL; } - colnr_T scol = submatch_mmatch->startpos[no].col; - colnr_T ecol = submatch_mmatch->endpos[no].col; + colnr_T scol = rsm.sm_mmatch->startpos[no].col; + colnr_T ecol = rsm.sm_mmatch->endpos[no].col; list = tv_list_alloc(); @@ -6990,12 +7064,12 @@ list_T *reg_submatch_list(int no) tv_list_append_string(list, s, ecol); } } else { - s = (const char *)submatch_match->startp[no]; - if (s == NULL || submatch_match->endp[no] == NULL) { + s = (const char *)rsm.sm_match->startp[no]; + if (s == NULL || rsm.sm_match->endp[no] == NULL) { return NULL; } list = tv_list_alloc(); - tv_list_append_string(list, s, (const char *)submatch_match->endp[no] - s); + tv_list_append_string(list, s, (const char *)rsm.sm_match->endp[no] - s); } return list; @@ -7149,6 +7223,19 @@ static void report_re_switch(char_u *pat) /// @return TRUE if there is a match, FALSE if not. static int vim_regexec_both(regmatch_T *rmp, char_u *line, colnr_T col, bool nl) { + regexec_T rex_save; + bool rex_in_use_save = rex_in_use; + + if (rex_in_use) { + // Being called recursively, save the state. + rex_save = rex; + } + rex_in_use = true; + rex.reg_startp = NULL; + rex.reg_endp = NULL; + rex.reg_startpos = NULL; + rex.reg_endpos = NULL; + int result = rmp->regprog->engine->regexec_nl(rmp, line, col, nl); // NFA engine aborted because it's very slow, use backtracking engine instead. @@ -7170,6 +7257,11 @@ static int vim_regexec_both(regmatch_T *rmp, char_u *line, colnr_T col, bool nl) p_re = save_p_re; } + rex_in_use = rex_in_use_save; + if (rex_in_use) { + rex = rex_save; + } + return result > 0; } @@ -7217,6 +7309,15 @@ long vim_regexec_multi( proftime_T *tm /* timeout limit or NULL */ ) { + regexec_T rex_save; + bool rex_in_use_save = rex_in_use; + + if (rex_in_use) { + // Being called recursively, save the state. + rex_save = rex; + } + rex_in_use = true; + int result = rmp->regprog->engine->regexec_multi(rmp, win, buf, lnum, col, tm); @@ -7240,5 +7341,10 @@ long vim_regexec_multi( p_re = save_p_re; } + rex_in_use = rex_in_use_save; + if (rex_in_use) { + rex = rex_save; + } + return result <= 0 ? 0 : result; } diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 491693a371..5d708febea 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -4882,7 +4882,7 @@ static long find_match_text(colnr_T startcol, int regstart, char_u *match_text) int c2_len = PTR2LEN(s2); int c2 = PTR2CHAR(s2); - if ((c1 != c2 && (!ireg_ic || mb_tolower(c1) != mb_tolower(c2))) + if ((c1 != c2 && (!rex.reg_ic || mb_tolower(c1) != mb_tolower(c2))) || c1_len != c2_len) { match = false; break; @@ -4895,13 +4895,13 @@ static long find_match_text(colnr_T startcol, int regstart, char_u *match_text) && !(enc_utf8 && utf_iscomposing(PTR2CHAR(s2)))) { cleanup_subexpr(); if (REG_MULTI) { - reg_startpos[0].lnum = reglnum; - reg_startpos[0].col = col; - reg_endpos[0].lnum = reglnum; - reg_endpos[0].col = s2 - regline; + rex.reg_startpos[0].lnum = reglnum; + rex.reg_startpos[0].col = col; + rex.reg_endpos[0].lnum = reglnum; + rex.reg_endpos[0].col = s2 - regline; } else { - reg_startp[0] = regline + col; - reg_endp[0] = s2; + rex.reg_startp[0] = regline + col; + rex.reg_endp[0] = s2; } return 1L; } @@ -5116,8 +5116,8 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, 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)) { + // rex.reg_icombine is not set, that is not really a match. + if (enc_utf8 && !rex.reg_icombine && utf_iscomposing(curc)) { break; } nfa_match = true; @@ -5400,15 +5400,15 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, int this_class; // Get class of current and previous char (if it exists). - this_class = mb_get_class_tab(reginput, reg_buf->b_chartab); + this_class = mb_get_class_tab(reginput, rex.reg_buf->b_chartab); if (this_class <= 1) { result = false; } else if (reg_prev_class() == this_class) { result = false; } - } else if (!vim_iswordc_buf(curc, reg_buf) + } else if (!vim_iswordc_buf(curc, rex.reg_buf) || (reginput > regline - && vim_iswordc_buf(reginput[-1], reg_buf))) { + && vim_iswordc_buf(reginput[-1], rex.reg_buf))) { result = false; } if (result) { @@ -5425,15 +5425,15 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, int this_class, prev_class; // Get class of current and previous char (if it exists). - this_class = mb_get_class_tab(reginput, reg_buf->b_chartab); + this_class = mb_get_class_tab(reginput, rex.reg_buf->b_chartab); prev_class = reg_prev_class(); if (this_class == prev_class || prev_class == 0 || prev_class == 1) { result = false; } - } else if (!vim_iswordc_buf(reginput[-1], reg_buf) + } else if (!vim_iswordc_buf(reginput[-1], rex.reg_buf) || (reginput[0] != NUL - && vim_iswordc_buf(curc, reg_buf))) { + && vim_iswordc_buf(curc, rex.reg_buf))) { result = false; } if (result) { @@ -5444,14 +5444,14 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, case NFA_BOF: if (reglnum == 0 && reginput == regline - && (!REG_MULTI || reg_firstlnum == 1)) { + && (!REG_MULTI || rex.reg_firstlnum == 1)) { add_here = true; add_state = t->state->out; } break; case NFA_EOF: - if (reglnum == reg_maxline && curc == NUL) { + if (reglnum == rex.reg_maxline && curc == NUL) { add_here = true; add_state = t->state->out; } @@ -5475,7 +5475,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, // (no preceding character). len += mb_char2len(mc); } - if (ireg_icombine && len == 0) { + if (rex.reg_icombine && len == 0) { // If \Z was present, then ignore composing characters. // When ignoring the base character this always matches. if (sta->c != curc) { @@ -5526,14 +5526,14 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, } case NFA_NEWL: - if (curc == NUL && !reg_line_lbr && REG_MULTI - && reglnum <= reg_maxline) { + if (curc == NUL && !rex.reg_line_lbr && REG_MULTI + && reglnum <= rex.reg_maxline) { go_to_nextline = true; // Pass -1 for the offset, which means taking the position // at the start of the next line. add_state = t->state->out; add_off = -1; - } else if (curc == '\n' && reg_line_lbr) { + } else if (curc == '\n' && rex.reg_line_lbr) { // match \n as if it is an ordinary character add_state = t->state->out; add_off = 1; @@ -5574,7 +5574,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, result = result_if_matched; break; } - if (ireg_ic) { + if (rex.reg_ic) { int curc_low = mb_tolower(curc); int done = false; @@ -5591,7 +5591,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, } } else if (state->c < 0 ? check_char_class(state->c, curc) : (curc == state->c - || (ireg_ic && mb_tolower(curc) + || (rex.reg_ic && mb_tolower(curc) == mb_tolower(state->c)))) { result = result_if_matched; break; @@ -5639,13 +5639,13 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, break; case NFA_KWORD: // \k - result = vim_iswordp_buf(reginput, reg_buf); + result = vim_iswordp_buf(reginput, rex.reg_buf); ADD_STATE_IF_MATCH(t->state); break; case NFA_SKWORD: // \K result = !ascii_isdigit(curc) - && vim_iswordp_buf(reginput, reg_buf); + && vim_iswordp_buf(reginput, rex.reg_buf); ADD_STATE_IF_MATCH(t->state); break; @@ -5760,24 +5760,24 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, break; case NFA_LOWER_IC: // [a-z] - result = ri_lower(curc) || (ireg_ic && ri_upper(curc)); + result = ri_lower(curc) || (rex.reg_ic && ri_upper(curc)); ADD_STATE_IF_MATCH(t->state); break; case NFA_NLOWER_IC: // [^a-z] result = curc != NUL - && !(ri_lower(curc) || (ireg_ic && ri_upper(curc))); + && !(ri_lower(curc) || (rex.reg_ic && ri_upper(curc))); ADD_STATE_IF_MATCH(t->state); break; case NFA_UPPER_IC: // [A-Z] - result = ri_upper(curc) || (ireg_ic && ri_lower(curc)); + result = ri_upper(curc) || (rex.reg_ic && ri_lower(curc)); ADD_STATE_IF_MATCH(t->state); break; case NFA_NUPPER_IC: // [^A-Z] result = curc != NUL - && !(ri_upper(curc) || (ireg_ic && ri_lower(curc))); + && !(ri_upper(curc) || (rex.reg_ic && ri_lower(curc))); ADD_STATE_IF_MATCH(t->state); break; @@ -5851,13 +5851,15 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, case NFA_LNUM_GT: case NFA_LNUM_LT: assert(t->state->val >= 0 - && !((reg_firstlnum > 0 && reglnum > LONG_MAX - reg_firstlnum) - || (reg_firstlnum <0 && reglnum < LONG_MIN + reg_firstlnum)) - && reglnum + reg_firstlnum >= 0); + && !((rex.reg_firstlnum > 0 + && reglnum > LONG_MAX - rex.reg_firstlnum) + || (rex.reg_firstlnum < 0 + && reglnum < LONG_MIN + rex.reg_firstlnum)) + && reglnum + rex.reg_firstlnum >= 0); result = (REG_MULTI && nfa_re_num_cmp((uintmax_t)t->state->val, t->state->c - NFA_LNUM, - (uintmax_t)(reglnum + reg_firstlnum))); + (uintmax_t)(reglnum + rex.reg_firstlnum))); if (result) { add_here = true; add_state = t->state->out; @@ -5893,7 +5895,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, } result = false; - win_T *wp = reg_win == NULL ? curwin : reg_win; + win_T *wp = rex.reg_win == NULL ? curwin : rex.reg_win; if (op == 1 && col - 1 > t->state->val && col > 100) { long ts = wp->w_buffer->b_p_ts; @@ -5920,18 +5922,18 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, case NFA_MARK_GT: case NFA_MARK_LT: { - pos_T *pos = getmark_buf(reg_buf, t->state->val, FALSE); + pos_T *pos = getmark_buf(rex.reg_buf, t->state->val, false); // Compare the mark position to the match position. result = (pos != NULL // mark doesn't exist && pos->lnum > 0 // mark isn't set in reg_buf - && (pos->lnum == reglnum + reg_firstlnum + && (pos->lnum == reglnum + rex.reg_firstlnum ? (pos->col == (colnr_T)(reginput - regline) ? t->state->c == NFA_MARK : (pos->col < (colnr_T)(reginput - regline) ? t->state->c == NFA_MARK_GT : t->state->c == NFA_MARK_LT)) - : (pos->lnum < reglnum + reg_firstlnum + : (pos->lnum < reglnum + rex.reg_firstlnum ? t->state->c == NFA_MARK_GT : t->state->c == NFA_MARK_LT))); if (result) { @@ -5942,10 +5944,10 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, } case NFA_CURSOR: - result = (reg_win != NULL - && (reglnum + reg_firstlnum == reg_win->w_cursor.lnum) + result = (rex.reg_win != NULL + && (reglnum + rex.reg_firstlnum == rex.reg_win->w_cursor.lnum) && ((colnr_T)(reginput - regline) - == reg_win->w_cursor.col)); + == rex.reg_win->w_cursor.col)); if (result) { add_here = true; add_state = t->state->out; @@ -5995,13 +5997,13 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, #endif result = (c == curc); - if (!result && ireg_ic) { + if (!result && rex.reg_ic) { result = mb_tolower(c) == mb_tolower(curc); } - // If ireg_icombine is not set only skip over the character + // If rex.reg_icombine is not set only skip over the character // itself. When it is set skip over composing characters. - if (result && enc_utf8 && !ireg_icombine) { + if (result && enc_utf8 && !rex.reg_icombine) { clen = utf_ptr2len(reginput); } @@ -6109,8 +6111,8 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, && ((toplevel && reglnum == 0 && clen != 0 - && (ireg_maxcol == 0 - || (colnr_T)(reginput - regline) < ireg_maxcol)) + && (rex.reg_maxcol == 0 + || (colnr_T)(reginput - regline) < rex.reg_maxcol)) || (nfa_endp != NULL && (REG_MULTI ? (reglnum < nfa_endp->se_u.pos.lnum @@ -6145,7 +6147,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, // Checking if the required start character matches is // cheaper than adding a state that won't match. c = PTR2CHAR(reginput + clen); - if (c != prog->regstart && (!ireg_ic || mb_tolower(c) + if (c != prog->regstart && (!rex.reg_ic || mb_tolower(c) != mb_tolower(prog->regstart))) { #ifdef REGEXP_DEBUG fprintf(log_fd, @@ -6271,34 +6273,37 @@ static long nfa_regtry(nfa_regprog_T *prog, colnr_T col, proftime_T *tm) cleanup_subexpr(); if (REG_MULTI) { for (i = 0; i < subs.norm.in_use; i++) { - reg_startpos[i].lnum = subs.norm.list.multi[i].start_lnum; - reg_startpos[i].col = subs.norm.list.multi[i].start_col; + rex.reg_startpos[i].lnum = subs.norm.list.multi[i].start_lnum; + rex.reg_startpos[i].col = subs.norm.list.multi[i].start_col; - reg_endpos[i].lnum = subs.norm.list.multi[i].end_lnum; - reg_endpos[i].col = subs.norm.list.multi[i].end_col; + rex.reg_endpos[i].lnum = subs.norm.list.multi[i].end_lnum; + rex.reg_endpos[i].col = subs.norm.list.multi[i].end_col; } - if (reg_startpos[0].lnum < 0) { - reg_startpos[0].lnum = 0; - reg_startpos[0].col = col; + if (rex.reg_startpos[0].lnum < 0) { + rex.reg_startpos[0].lnum = 0; + rex.reg_startpos[0].col = col; + } + if (rex.reg_endpos[0].lnum < 0) { + // pattern has a \ze but it didn't match, use current end + rex.reg_endpos[0].lnum = reglnum; + rex.reg_endpos[0].col = (int)(reginput - regline); + } else { + // Use line number of "\ze". + reglnum = rex.reg_endpos[0].lnum; } - if (reg_endpos[0].lnum < 0) { - /* pattern has a \ze but it didn't match, use current end */ - reg_endpos[0].lnum = reglnum; - reg_endpos[0].col = (int)(reginput - regline); - } else - /* Use line number of "\ze". */ - reglnum = reg_endpos[0].lnum; } else { for (i = 0; i < subs.norm.in_use; i++) { - reg_startp[i] = subs.norm.list.line[i].start; - reg_endp[i] = subs.norm.list.line[i].end; + rex.reg_startp[i] = subs.norm.list.line[i].start; + rex.reg_endp[i] = subs.norm.list.line[i].end; } - if (reg_startp[0] == NULL) - reg_startp[0] = regline + col; - if (reg_endp[0] == NULL) - reg_endp[0] = reginput; + if (rex.reg_startp[0] == NULL) { + rex.reg_startp[0] = regline + col; + } + if (rex.reg_endp[0] == NULL) { + rex.reg_endp[0] = reginput; + } } /* Package any found \z(...\) matches for export. Default is none. */ @@ -6352,14 +6357,14 @@ static long nfa_regexec_both(char_u *line, colnr_T startcol, proftime_T *tm) colnr_T col = startcol; if (REG_MULTI) { - prog = (nfa_regprog_T *)reg_mmatch->regprog; - line = reg_getline((linenr_T)0); /* relative to the cursor */ - reg_startpos = reg_mmatch->startpos; - reg_endpos = reg_mmatch->endpos; + prog = (nfa_regprog_T *)rex.reg_mmatch->regprog; + line = reg_getline((linenr_T)0); // relative to the cursor + rex.reg_startpos = rex.reg_mmatch->startpos; + rex.reg_endpos = rex.reg_mmatch->endpos; } else { - prog = (nfa_regprog_T *)reg_match->regprog; - reg_startp = reg_match->startp; - reg_endp = reg_match->endp; + prog = (nfa_regprog_T *)rex.reg_match->regprog; + rex.reg_startp = rex.reg_match->startp; + rex.reg_endp = rex.reg_match->endp; } /* Be paranoid... */ @@ -6368,15 +6373,17 @@ static long nfa_regexec_both(char_u *line, colnr_T startcol, proftime_T *tm) goto theend; } - /* If pattern contains "\c" or "\C": overrule value of ireg_ic */ - if (prog->regflags & RF_ICASE) - ireg_ic = TRUE; - else if (prog->regflags & RF_NOICASE) - ireg_ic = FALSE; + // If pattern contains "\c" or "\C": overrule value of rex.reg_ic + if (prog->regflags & RF_ICASE) { + rex.reg_ic = true; + } else if (prog->regflags & RF_NOICASE) { + rex.reg_ic = false; + } - /* If pattern contains "\Z" overrule value of ireg_icombine */ - if (prog->regflags & RF_ICOMBINE) - ireg_icombine = TRUE; + // If pattern contains "\Z" overrule value of rex.reg_icombine + if (prog->regflags & RF_ICOMBINE) { + rex.reg_icombine = true; + } regline = line; reglnum = 0; /* relative to line */ @@ -6405,17 +6412,17 @@ static long nfa_regexec_both(char_u *line, colnr_T startcol, proftime_T *tm) if (skip_to_start(prog->regstart, &col) == FAIL) return 0L; - /* If match_text is set it contains the full text that must match. - * Nothing else to try. Doesn't handle combining chars well. */ - if (prog->match_text != NULL - && !ireg_icombine - ) + // If match_text is set it contains the full text that must match. + // Nothing else to try. Doesn't handle combining chars well. + if (prog->match_text != NULL && !rex.reg_icombine) { return find_match_text(col, prog->regstart, prog->match_text); + } } - /* If the start column is past the maximum column: no need to try. */ - if (ireg_maxcol > 0 && col >= ireg_maxcol) + // If the start column is past the maximum column: no need to try. + if (rex.reg_maxcol > 0 && col >= rex.reg_maxcol) { goto theend; + } nstate = prog->nstate; for (i = 0; i < nstate; ++i) { @@ -6567,15 +6574,15 @@ nfa_regexec_nl ( bool line_lbr ) { - reg_match = rmp; - reg_mmatch = NULL; - reg_maxline = 0; - reg_line_lbr = line_lbr; - reg_buf = curbuf; - reg_win = NULL; - ireg_ic = rmp->rm_ic; - ireg_icombine = FALSE; - ireg_maxcol = 0; + rex.reg_match = rmp; + rex.reg_mmatch = NULL; + rex.reg_maxline = 0; + rex.reg_line_lbr = line_lbr; + rex.reg_buf = curbuf; + rex.reg_win = NULL; + rex.reg_ic = rmp->rm_ic; + rex.reg_icombine = false; + rex.reg_maxcol = 0; return nfa_regexec_both(line, col, NULL); } @@ -6616,16 +6623,16 @@ nfa_regexec_nl ( static long nfa_regexec_multi(regmmatch_T *rmp, win_T *win, buf_T *buf, linenr_T lnum, colnr_T col, proftime_T *tm) { - reg_match = NULL; - reg_mmatch = rmp; - reg_buf = buf; - reg_win = win; - reg_firstlnum = lnum; - reg_maxline = reg_buf->b_ml.ml_line_count - lnum; - reg_line_lbr = FALSE; - ireg_ic = rmp->rmm_ic; - ireg_icombine = FALSE; - ireg_maxcol = rmp->rmm_maxcol; + rex.reg_match = NULL; + rex.reg_mmatch = rmp; + rex.reg_buf = buf; + rex.reg_win = win; + rex.reg_firstlnum = lnum; + rex.reg_maxline = rex.reg_buf->b_ml.ml_line_count - lnum; + rex.reg_line_lbr = false; + rex.reg_ic = rmp->rmm_ic; + rex.reg_icombine = false; + rex.reg_maxcol = rmp->rmm_maxcol; return nfa_regexec_both(NULL, col, tm); } diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim index 710eae9b8b..d32facaa98 100644 --- a/src/nvim/testdir/test_expr.vim +++ b/src/nvim/testdir/test_expr.vim @@ -384,9 +384,10 @@ func Test_substitute_expr() \ {-> submatch(2) . submatch(3) . submatch(1)}, '')) func Recurse() - return substitute('yyy', 'y*', {-> g:val}, '') + return substitute('yyy', 'y\(.\)y', {-> submatch(1)}, '') endfunc - call assert_equal('--', substitute('xxx', 'x*', {-> '-' . Recurse() . '-'}, '')) + " recursive call works + call assert_equal('-y-x-', substitute('xxx', 'x\(.\)x', {-> '-' . Recurse() . '-' . submatch(1) . '-'}, '')) endfunc func Test_invalid_submatch() diff --git a/src/nvim/version.c b/src/nvim/version.c index f0048fb234..31d3122f95 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -709,7 +709,7 @@ static const int included_patches[] = { 23, // 22 NA // 21, - // 20, + 20, 19, // 18, 17, -- cgit From a118134af1ef08884dfceb9e9cd9bf2ba662b7d8 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 29 Jul 2017 16:36:54 +0200 Subject: test/legacy: avoid TSAN CI build hang This delete() sometimes hangs the TSAN build. Work around it by using a unique filename. Do it at the start instead of the end, for hygiene (though it doesn't actually matter on CI, it helps local dev). --- src/nvim/testdir/test_normal.vim | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 6261625801..4747d5704d 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -1255,21 +1255,27 @@ func! Test_normal22_zet() " Test for ZZ " let shell = &shell " let &shell = 'sh' - call writefile(['1', '2'], 'Xfile') + + " Remove any stale test files from previous run. + for file in ['Xfile_Test_normal22_zet'] + call delete(file) + endfor + + call writefile(['1', '2'], 'Xfile_Test_normal22_zet') let args = ' --headless -u NONE -N -U NONE -i NONE --noplugins' - call system(v:progpath . args . ' -c "%d" -c ":norm! ZZ" Xfile') - let a = readfile('Xfile') + call system(v:progpath . args . ' -c "%d" -c ":norm! ZZ" Xfile_Test_normal22_zet') + let a = readfile('Xfile_Test_normal22_zet') call assert_equal([], a) " Test for ZQ - call writefile(['1', '2'], 'Xfile') - call system(v:progpath . args . ' -c "%d" -c ":norm! ZQ" Xfile') - let a = readfile('Xfile') + call writefile(['1', '2'], 'Xfile_Test_normal22_zet') + call system(v:progpath . args . ' -c "%d" -c ":norm! ZQ" Xfile_Test_normal22_zet') + let a = readfile('Xfile_Test_normal22_zet') call assert_equal(['1', '2'], a) - " clean up - for file in ['Xfile'] - call delete(file) - endfor + " Nvim: This sometimes hangs the TSAN build. + " for file in ['Xfile_Test_normal22_zet'] + " call delete(file) + " endfor " let &shell = shell endfunc -- cgit From 743993eb553302a461ee0ef9cffa57f93c10c955 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 30 Jul 2017 07:36:44 +0800 Subject: vim-patch:8.0.0119 (#7091) Problem: No test for using CTRL-R on the command line. Solution: Add a test. (Dominique Pelle) And some more. https://github.com/vim/vim/commit/21efc3633edb58809c5dd89b025d34d7002e731c --- src/nvim/testdir/test_cmdline.vim | 23 +++++++++++++++++++++++ src/nvim/version.c | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index f7a6aba6e7..c3bfae1b7b 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -209,3 +209,26 @@ func Test_expand_star_star() bwipe! call delete('a', 'rf') endfunc + +func Test_paste_in_cmdline() + let @a = "def" + call feedkeys(":abc \a ghi\\"\", 'tx') + call assert_equal('"abc def ghi', @:) + + new + call setline(1, 'asdf.x /tmp/some verylongword a;b-c*d ') + + call feedkeys(":aaa \\ bbb\\"\", 'tx') + call assert_equal('"aaa asdf bbb', @:) + + call feedkeys("ft:aaa \\ bbb\\"\", 'tx') + call assert_equal('"aaa /tmp/some bbb', @:) + + set incsearch + call feedkeys("fy:aaa veryl\\ bbb\\"\", 'tx') + call assert_equal('"aaa verylongword bbb', @:) + + call feedkeys("f;:aaa \\ bbb\\"\", 'tx') + call assert_equal('"aaa a;b-c*d bbb', @:) + bwipe! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 31d3122f95..4f83b09e1b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -610,7 +610,7 @@ static const int included_patches[] = { // 122 NA 121, // 120 NA - // 119, + 119, // 118, // 117 NA 116, -- cgit From 5cd68b39003dc51c5b80147d689cf7e8b67443b0 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sat, 29 Jul 2017 10:24:07 +0800 Subject: vim-patch:8.0.0124 #7092 Problem: Internal error for assert_inrange(1, 1). Solution: Adjust number of allowed arguments. (Dominique Pelle) https://github.com/vim/vim/commit/3421566376b5723213af502bd3c2b9debe025ef1 --- src/nvim/eval.lua | 2 +- src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 08baae4086..0e359fb61c 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -29,7 +29,7 @@ return { assert_exception={args={1, 2}}, assert_fails={args={1, 2}}, assert_false={args={1, 2}}, - assert_inrange={args={2, 3}}, + assert_inrange={args={3, 4}}, assert_match={args={2, 3}}, assert_notequal={args={2, 3}}, assert_notmatch={args={2, 3}}, diff --git a/src/nvim/version.c b/src/nvim/version.c index 4f83b09e1b..962096000a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -605,7 +605,7 @@ static const int included_patches[] = { 127, // 126, // 125, - // 124, + 124, // 123 NA // 122 NA 121, -- cgit From cb13ef3596ee9d952a2d12c78d9036b7fd134c89 Mon Sep 17 00:00:00 2001 From: DarkDefender Date: Sun, 16 Jul 2017 12:20:06 +0200 Subject: tui: fix truecolor in libvte, tmux #7037 Closes #7041 --- src/nvim/tui/tui.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 0975b87ea3..c29ec09638 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1537,11 +1537,11 @@ static void augment_terminfo(TUIData *data, const char *term, bool teraterm = terminfo_is_term_family(term, "teraterm"); bool putty = terminfo_is_term_family(term, "putty"); bool screen = terminfo_is_term_family(term, "screen"); + bool tmux = terminfo_is_term_family(term, "tmux") || !!os_getenv("TMUX"); bool iterm = terminfo_is_term_family(term, "iterm") || terminfo_is_term_family(term, "iTerm.app"); // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; - bool tmux_wrap = screen && !!os_getenv("TMUX"); const char * xterm_version = os_getenv("XTERM_VERSION"); bool true_xterm = xterm && !!xterm_version; @@ -1573,12 +1573,11 @@ static void augment_terminfo(TUIData *data, const char *term, // specific ones. // can use colons like ISO 8613-6:1994/ITU T.416:1993 says. - bool has_colon_rgb = false - // per GNOME bug #685759 and bug #704449 - || (vte_version >= 3600) - || iterm || iterm_pretending_xterm // per analysis of VT100Terminal.m - // per http://invisible-island.net/xterm/xterm.log.html#xterm_282 - || true_xterm; + bool has_colon_rgb = !tmux && !screen + && ((vte_version >= 3600) // per GNOME bug #685759, #704449 + || iterm || iterm_pretending_xterm // per analysis of VT100Terminal.m + // per http://invisible-island.net/xterm/xterm.log.html#xterm_282 + || true_xterm); data->unibi_ext.set_rgb_foreground = unibi_find_ext_str(ut, "setrgbf"); if (-1 == data->unibi_ext.set_rgb_foreground) { @@ -1606,7 +1605,7 @@ static void augment_terminfo(TUIData *data, const char *term, // all panes, which is not particularly desirable. A better approach // would use a tmux control sequence and an extra if(screen) test. data->unibi_ext.set_cursor_color = (int)unibi_add_ext_str( - ut, NULL, TMUX_WRAP(tmux_wrap, "\033]Pl%p1%06x\033\\")); + ut, NULL, TMUX_WRAP(tmux, "\033]Pl%p1%06x\033\\")); } else if (xterm || (vte_version != 0) || rxvt) { // This seems to be supported for a long time in VTE // urxvt also supports this -- cgit From a7538371fec595641bed2d5e2d92e5ae2ce89b94 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 30 Jul 2017 23:02:41 +0200 Subject: build: linux does not always have execinfo.h (#7101) Closes #7099 --- src/nvim/log.c | 7 +++++-- src/nvim/log.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/log.c b/src/nvim/log.c index 252fe5438d..b64aef3cac 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -25,6 +25,10 @@ static uv_mutex_t mutex; # include "log.c.generated.h" #endif +#ifdef HAVE_EXECINFO_BACKTRACE +# include +#endif + static bool log_try_create(char *fname) { if (fname == NULL || fname[0] == '\0') { @@ -173,8 +177,7 @@ FILE *open_log_file(void) return stderr; } -#if defined(__linux__) -# include +#ifdef HAVE_EXECINFO_BACKTRACE void log_callstack(const char *const func_name, const int line_num) { void *trace[100]; diff --git a/src/nvim/log.h b/src/nvim/log.h index 2bd18f5776..743a8d17aa 100644 --- a/src/nvim/log.h +++ b/src/nvim/log.h @@ -61,7 +61,7 @@ __VA_ARGS__) #endif -#if defined(__linux__) +#ifdef HAVE_EXECINFO_BACKTRACE # define LOG_CALLSTACK() log_callstack(__func__, __LINE__) #endif -- cgit From 0795dd3c9031a7151f41838fb8a9970d60e7d864 Mon Sep 17 00:00:00 2001 From: lonerover Date: Mon, 31 Jul 2017 05:10:09 +0800 Subject: vim-patch: 8.0.00{12, 46, 93} (#7098) vim-patch:8.0.0012 Problem: Typos in comments. Solution: Change "its" to "it's". (Matthew Brener, closes vim/vim#1088) https://github.com/vim/vim/commit/9af418427652562384744648d7d173a4bfebba95 vim-patch:8.0.0046 version.c: mark 8.0.0046 applied vim-patch:8.0.0063 version.c: mark 8.0.0063 as NA patch --- src/nvim/quickfix.c | 2 +- src/nvim/version.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 4997209556..e6b1e7b95a 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3127,7 +3127,7 @@ static char_u *get_mef_name(void) STRCPY(name, p_mef); sprintf((char *)name + (p - p_mef), "%d%d", start, off); STRCAT(name, p + 2); - // Don't accept a symbolic link, its a security risk. + // Don't accept a symbolic link, it's a security risk. FileInfo file_info; bool file_or_link_found = os_fileinfo_link((char *)name, &file_info); if (!file_or_link_found) { diff --git a/src/nvim/version.c b/src/nvim/version.c index 962096000a..6662dff437 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -666,7 +666,7 @@ static const int included_patches[] = { 66, // 65 NA 64, - // 63, + // 63 NA 62, // 61 NA 60, @@ -683,7 +683,7 @@ static const int included_patches[] = { 49, // 48 NA 47, - // 46, + 46, // 45 NA // 44, 43, @@ -717,7 +717,7 @@ static const int included_patches[] = { // 15 NA // 14 NA // 13 NA - // 12, + 12, // 11 NA // 10 NA // 9 NA -- cgit From b5e713e70d2db3017e9582c6165f2f62eb112826 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 31 Jul 2017 02:50:34 +0200 Subject: options: remove ghost of `:set termcap` (#7102) Closes #6763 --- src/nvim/eval.c | 18 +++++++++++------- src/nvim/option.c | 8 ++------ 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 2988225110..78c8dd02db 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -19546,18 +19546,22 @@ static const char *find_option_end(const char **const arg, int *const opt_flags) } else if (*p == 'l' && p[1] == ':') { *opt_flags = OPT_LOCAL; p += 2; - } else + } else { *opt_flags = 0; + } - if (!ASCII_ISALPHA(*p)) + if (!ASCII_ISALPHA(*p)) { return NULL; + } *arg = p; - if (p[0] == 't' && p[1] == '_' && p[2] != NUL && p[3] != NUL) - p += 4; /* termcap option */ - else - while (ASCII_ISALPHA(*p)) - ++p; + if (p[0] == 't' && p[1] == '_' && p[2] != NUL && p[3] != NUL) { + p += 4; // t_xx/termcap option + } else { + while (ASCII_ISALPHA(*p)) { + p++; + } + } return p; } diff --git a/src/nvim/option.c b/src/nvim/option.c index 98ca72b2bb..8ba10fd38a 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1185,10 +1185,6 @@ do_set ( showoptions(1, opt_flags); did_show = TRUE; } - } else if (STRNCMP(arg, "termcap", - 7) == 0 && !(opt_flags & OPT_MODELINE)) { - did_show = TRUE; - arg += 7; } else { prefix = 1; if (STRNCMP(arg, "no", 2) == 0) { @@ -6070,8 +6066,8 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u *** int count = 0; char_u *str; int loop; - static char *(names[]) = {"all", "termcap"}; - int ic = regmatch->rm_ic; /* remember the ignore-case flag */ + static char *(names[]) = { "all" }; + int ic = regmatch->rm_ic; // remember the ignore-case flag /* do this loop twice: * loop == 0: count the number of matching options -- cgit From 347dd9476ae2c77ebfc96abda928a342f26fe677 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 30 Jul 2017 20:52:00 -0400 Subject: oldtests: Run nvim using --headless to avoid requesting user input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Certain functions (e.g. feedkeys(…, 'x!') and input()) will attempt to read from stdin, which shouldn't be expected to work during oldtests. In Debian/Ubuntu's build environment, it explicitly can't work because /dev/null is redirected to stdin, which causes read_error_exit() to exit. Running oldtests with --headless prevents nvim from setting up its input handling, thus avoiding the problem altogether. Reference #6794 --- src/nvim/testdir/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 510e8820f4..b45bd6ee14 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -132,7 +132,7 @@ $(SCRIPTS) $(SCRIPTS_GUI): $(NVIM_PRG) test1.out RM_ON_RUN := test.out X* viminfo RM_ON_START := test.ok -RUN_VIM := VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(TOOL) $(NVIM_PRG) -u unix.vim -U NONE -i viminfo --noplugin -s dotest.in +RUN_VIM := VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(TOOL) $(NVIM_PRG) -u unix.vim -U NONE -i viminfo --headless --noplugin -s dotest.in clean: -rm -rf *.out \ @@ -201,7 +201,7 @@ nolog: # New style of tests uses Vim script with assert calls. These are easier # to write and a lot easier to read and debug. # Limitation: Only works with the +eval feature. -RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(NVIM_PRG) -u unix.vim -U NONE --noplugin +RUN_VIMTEST = VIMRUNTIME=$(SCRIPTSOURCE); export VIMRUNTIME; $(VALGRIND) $(NVIM_PRG) -u unix.vim -U NONE --headless --noplugin newtests: newtestssilent @/bin/sh -c "if test -f messages && grep -q 'FAILED' messages; then \ -- cgit From 10399165e5dd93a3cfda5082f4aa544a13273e5d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 31 Jul 2017 03:54:18 +0200 Subject: vim-patch:8.0.0498 (#7103) Problem: Two autocmd tests are skipped on MS-Windows. Solution: Make the test pass on MS-Windows. Write the messages in a file instead of getting the output of system(). https://github.com/vim/vim/commit/e94260f3582cf928cc59e792b3b6ede57794a4a6 --- src/nvim/testdir/test_autocmd.vim | 58 ++++++++++++++++++++------------------- src/nvim/version.c | 2 +- 2 files changed, 31 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index c4110eba94..835df42a10 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -342,7 +342,10 @@ func Test_BufEnter() call mkdir('Xdir') split Xdir call assert_equal('+++', g:val) - bwipe! + + " On MS-Windows we can't edit the directory, make sure we wipe the right + " buffer. + bwipe! Xdir call delete('Xdir', 'd') au! BufEnter @@ -351,40 +354,37 @@ endfunc " Closing a window might cause an endless loop " E814 for older Vims function Test_autocmd_bufwipe_in_SessLoadPost() - if has('win32') - throw 'Skipped: test hangs on MS-Windows' - endif tabnew set noswapfile - let g:bufnr=bufnr('%') mksession! - let content=['set nocp noswapfile', + let content = ['set nocp noswapfile', \ 'let v:swapchoice="e"', \ 'augroup test_autocmd_sessionload', \ 'autocmd!', - \ 'autocmd SessionLoadPost * 4bw!|qall!', + \ 'autocmd SessionLoadPost * 4bw!', \ 'augroup END', + \ '', + \ 'func WriteErrors()', + \ ' call writefile([execute("messages")], "Xerrors")', + \ 'endfunc', + \ 'au VimLeave * call WriteErrors()', \ ] call writefile(content, 'Xvimrc') - let a=system(v:progpath. ' --headless -i NONE -u Xvimrc --noplugins -S Session.vim') - call assert_match('E814', a) + call system(v:progpath. ' --headless -i NONE -u Xvimrc --noplugins -S Session.vim -c cq') + let errors = join(readfile('Xerrors')) + call assert_match('E814', errors) - unlet! g:bufnr set swapfile - for file in ['Session.vim', 'Xvimrc'] + for file in ['Session.vim', 'Xvimrc', 'Xerrors'] call delete(file) endfor endfunc " SEGV occurs in older versions. function Test_autocmd_bufwipe_in_SessLoadPost2() - if has('win32') - throw 'Skipped: test hangs on MS-Windows' - endif tabnew set noswapfile - let g:bufnr=bufnr('%') mksession! let content = ['set nocp noswapfile', @@ -399,22 +399,24 @@ function Test_autocmd_bufwipe_in_SessLoadPost2() \ ' exec ''bwipeout '' . b', \ ' endif', \ ' endfor', - \ 'redraw!', - \ 'echon "SessionLoadPost DONE"', - \ 'qall!', + \ ' echomsg "SessionLoadPost DONE"', \ 'endfunction', - \ 'au SessionLoadPost * call DeleteInactiveBufs()'] + \ 'au SessionLoadPost * call DeleteInactiveBufs()', + \ '', + \ 'func WriteErrors()', + \ ' call writefile([execute("messages")], "Xerrors")', + \ 'endfunc', + \ 'au VimLeave * call WriteErrors()', + \ ] call writefile(content, 'Xvimrc') - let a=system(v:progpath. ' --headless -i NONE -u Xvimrc --noplugins -S Session.vim') - " this probably only matches on unix - if has("unix") - call assert_notmatch('Caught deadly signal SEGV', a) - endif - call assert_match('SessionLoadPost DONE', a) - - unlet! g:bufnr + call system(v:progpath. ' --headless -i NONE -u Xvimrc --noplugins -S Session.vim -c cq') + let errors = join(readfile('Xerrors')) + " This probably only ever matches on unix. + call assert_notmatch('Caught deadly signal SEGV', errors) + call assert_match('SessionLoadPost DONE', errors) + set swapfile - for file in ['Session.vim', 'Xvimrc'] + for file in ['Session.vim', 'Xvimrc', 'Xerrors'] call delete(file) endfor endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 6662dff437..1035963136 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -231,7 +231,7 @@ static const int included_patches[] = { // 501, // 500, 499, - // 498, + 498, // 497, // 496, // 495, -- cgit From eb40b7ec404e8651137513ced43d503bc6656f17 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Wed, 2 Aug 2017 16:22:04 +0800 Subject: vim-patch:8.0.0133 (#7107) Problem: "2;'(" causes ml_get errors in an empty buffer. (Dominique Pelle) Solution: Check the cursor line earlier. https://github.com/vim/vim/commit/fe38b494fff56cd9b2fcaeef26a8fd7b6557d69c --- src/nvim/ex_docmd.c | 13 +++++++------ src/nvim/testdir/test_cmdline.vim | 7 +++++++ src/nvim/version.c | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index d7821fc636..80c75f24c4 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1665,11 +1665,15 @@ static char_u * do_one_cmd(char_u **cmdlinep, ea.addr_count++; if (*ea.cmd == ';') { - if (!ea.skip) + if (!ea.skip) { curwin->w_cursor.lnum = ea.line2; - } else if (*ea.cmd != ',') + // Don't leave the cursor on an illegal line (caused by ';') + check_cursor_lnum(); + } + } else if (*ea.cmd != ',') { break; - ++ea.cmd; + } + ea.cmd++; } /* One address given: set start and end lines */ @@ -1680,9 +1684,6 @@ static char_u * do_one_cmd(char_u **cmdlinep, ea.addr_count = 0; } - /* Don't leave the cursor on an illegal line (caused by ';') */ - check_cursor_lnum(); - /* * 5. Parse the command. */ diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index c3bfae1b7b..09f4b942ad 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -232,3 +232,10 @@ func Test_paste_in_cmdline() call assert_equal('"aaa a;b-c*d bbb', @:) bwipe! endfunc + +func Test_illegal_address() + new + 2;'( + 2;') + quit +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 1035963136..a018585976 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -596,7 +596,7 @@ static const int included_patches[] = { 136, 135, // 134, - // 133, + 133, // 132, // 131, // 130 NA -- cgit From 8160a0e04244d054c4555a5a1af09963470964a1 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 3 Aug 2017 09:31:05 +0200 Subject: Revert "vim-patch:8.0.0133 (#7107)" This reverts commit eb40b7ec404e8651137513ced43d503bc6656f17. The change caused this error on QuickBuild: INFO - # test/functional/core/job_spec.lua @ 668: pty process teardown does not prevent/delay exit. #4798 #4900 INFO - not ok 321 - pty process teardown does not prevent/delay exit. #4798 #4900 INFO - # test/functional/core/job_spec.lua @ 668 INFO - # Failure message: ./test/functional/ui/screen.lua:302: Row 1 did not match. INFO - # Expected: INFO - # |* | INFO - # |[Process exited 0] | INFO - # | | INFO - # | | INFO - # | | INFO - # |-- TERMINAL -- | INFO - # Actual: INFO - # |*E575: Error while reading ShaD| INFO - # |a file: mark entry at position| INFO - # | 92 has invalid line number | INFO - # |Press ENTER or type command to| INFO - # | continue | INFO - # |-- TERMINAL -- | INFO - # INFO - # To print the expect() call that would assert the current screen state, use INFO - # screen:snaphot_util(). In case of non-deterministic failures, use INFO - # screen:redraw_debug() to show all intermediate screen states. INFO - # stack traceback: INFO - # ./test/functional/ui/screen.lua:302: in function 'wait' INFO - # ./test/functional/ui/screen.lua:216: in function 'expect' INFO - # test/functional/core/job_spec.lua:677: in function --- src/nvim/ex_docmd.c | 13 ++++++------- src/nvim/testdir/test_cmdline.vim | 7 ------- src/nvim/version.c | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 80c75f24c4..d7821fc636 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1665,15 +1665,11 @@ static char_u * do_one_cmd(char_u **cmdlinep, ea.addr_count++; if (*ea.cmd == ';') { - if (!ea.skip) { + if (!ea.skip) curwin->w_cursor.lnum = ea.line2; - // Don't leave the cursor on an illegal line (caused by ';') - check_cursor_lnum(); - } - } else if (*ea.cmd != ',') { + } else if (*ea.cmd != ',') break; - } - ea.cmd++; + ++ea.cmd; } /* One address given: set start and end lines */ @@ -1684,6 +1680,9 @@ static char_u * do_one_cmd(char_u **cmdlinep, ea.addr_count = 0; } + /* Don't leave the cursor on an illegal line (caused by ';') */ + check_cursor_lnum(); + /* * 5. Parse the command. */ diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 09f4b942ad..c3bfae1b7b 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -232,10 +232,3 @@ func Test_paste_in_cmdline() call assert_equal('"aaa a;b-c*d bbb', @:) bwipe! endfunc - -func Test_illegal_address() - new - 2;'( - 2;') - quit -endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index a018585976..1035963136 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -596,7 +596,7 @@ static const int included_patches[] = { 136, 135, // 134, - 133, + // 133, // 132, // 131, // 130 NA -- cgit From 99aeb607f4753907529e13d4d347ca3551da9cc5 Mon Sep 17 00:00:00 2001 From: lonerover Date: Fri, 4 Aug 2017 19:58:10 +0800 Subject: vim-patch:8.0.0081 Problem: Inconsistent function names. Solution: Rename do_cscope to ex_cscope. Clean up comments. https://github.com/vim/vim/commit/d4db7719bdfbc54df396eac08d8cbb2389feacf4 --- src/nvim/ex_cmds.lua | 8 ++-- src/nvim/ex_docmd.c | 2 +- src/nvim/if_cscope.c | 129 ++++++++++++++------------------------------------- src/nvim/version.c | 2 +- 4 files changed, 40 insertions(+), 101 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index 46f7a7bc40..5757964f0f 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -628,13 +628,13 @@ return { command='cscope', flags=bit.bor(EXTRA, NOTRLCOM, XFILE), addr_type=ADDR_LINES, - func='do_cscope', + func='ex_cscope', }, { command='cstag', flags=bit.bor(BANG, TRLBAR, WORD1), addr_type=ADDR_LINES, - func='do_cstag', + func='ex_cstag', }, { command='cunmap', @@ -1324,7 +1324,7 @@ return { command='lcscope', flags=bit.bor(EXTRA, NOTRLCOM, XFILE), addr_type=ADDR_LINES, - func='do_cscope', + func='ex_cscope', }, { command='ldo', @@ -2334,7 +2334,7 @@ return { command='scscope', flags=bit.bor(EXTRA, NOTRLCOM), addr_type=ADDR_LINES, - func='do_scscope', + func='ex_scscope', }, { command='set', diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index d7821fc636..30156621d6 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -8321,7 +8321,7 @@ static void ex_tag_cmd(exarg_T *eap, char_u *name) break; default: /* ":tag" */ if (p_cst && *eap->arg != NUL) { - do_cstag(eap); + ex_cstag(eap); return; } cmd = DT_TAG; diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index f7706f5a0d..607fd2bbee 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -173,8 +173,6 @@ void set_context_in_cscope_cmd(expand_T *xp, const char *arg, cmdidx_T cmdidx) /* - * PRIVATE: do_cscope_general - * * Find the command, print help if invalid, and then call the corresponding * command function. */ @@ -209,28 +207,25 @@ do_cscope_general ( } /* - * PUBLIC: do_cscope + * Implementation of ":cscope" and ":lcscope" */ -void do_cscope(exarg_T *eap) +void ex_cscope(exarg_T *eap) { do_cscope_general(eap, FALSE); } /* - * PUBLIC: do_scscope - * - * same as do_cscope, but splits window, too. + * Implementation of ":scscope". Same as ex_cscope(), but splits window, too. */ -void do_scscope(exarg_T *eap) +void ex_scscope(exarg_T *eap) { do_cscope_general(eap, TRUE); } /* - * PUBLIC: do_cstag - * + * Implementation of ":cstag" */ -void do_cstag(exarg_T *eap) +void ex_cstag(exarg_T *eap) { int ret = FALSE; @@ -286,13 +281,11 @@ void do_cstag(exarg_T *eap) g_do_tagpreview = 0; } -} /* do_cscope */ +} /* - * PUBLIC: cs_find - * - * this simulates a vim_fgets(), but for cscope, returns the next line + * This simulates a vim_fgets(), but for cscope, returns the next line * from the cscope output. should only be called from find_tags() * * returns TRUE if eof, FALSE otherwise @@ -310,9 +303,7 @@ int cs_fgets(char_u *buf, int size) /* - * PUBLIC: cs_free_tags - * - * called only from do_tag(), when popping the tag stack + * Called only from do_tag(), when popping the tag stack. */ void cs_free_tags(void) { @@ -320,9 +311,7 @@ void cs_free_tags(void) } /* - * PUBLIC: cs_print_tags - * - * called from do_tag() + * Called from do_tag(). */ void cs_print_tags(void) { @@ -405,12 +394,8 @@ int cs_connection(int num, char_u *dbpath, char_u *ppath) ****************************************************************************/ /* - * PRIVATE: cs_add - * - * add cscope database or a directory name (to look for cscope.out) - * to the cscope connection list - * - * MAXPATHL 256 + * Add cscope database or a directory name (to look for cscope.out) + * to the cscope connection list. */ static int cs_add(exarg_T *eap) { @@ -438,10 +423,8 @@ static void cs_stat_emsg(char *fname) /* - * PRIVATE: cs_add_common - * - * the common routine to add a new cscope connection. called by - * cs_add() and cs_reset(). i really don't like to do this, but this + * The common routine to add a new cscope connection. Called by + * cs_add() and cs_reset(). I really don't like to do this, but this * routine uses a number of goto statements. */ static int @@ -562,9 +545,7 @@ static int cs_check_for_tags(void) } /* cs_check_for_tags */ /* - * PRIVATE: cs_cnt_connections - * - * count the number of cscope connections + * Count the number of cscope connections. */ static size_t cs_cnt_connections(void) { @@ -586,9 +567,7 @@ static void cs_reading_emsg( #define CSREAD_BUFSIZE 2048 /* - * PRIVATE: cs_cnt_matches - * - * count the number of matches for a given cscope connection. + * Count the number of matches for a given cscope connection. */ static int cs_cnt_matches(size_t idx) { @@ -640,8 +619,6 @@ static int cs_cnt_matches(size_t idx) /* - * PRIVATE: cs_create_cmd - * * Creates the actual cscope command query from what the user entered. */ static char *cs_create_cmd(char *csoption, char *pattern) @@ -700,8 +677,6 @@ static char *cs_create_cmd(char *csoption, char *pattern) /* - * PRIVATE: cs_create_connection - * * This piece of code was taken/adapted from nvi. do we need to add * the BSD license notice? */ @@ -894,10 +869,8 @@ err_closing: /* - * PRIVATE: cs_find - * - * query cscope using command line interface. parse the output and use tselect - * to allow choices. like Nvi, creates a pipe to send to/from query/cscope. + * Query cscope using command line interface. Parse the output and use tselect + * to allow choices. Like Nvi, creates a pipe to send to/from query/cscope. * * returns TRUE if we jump to a tag or abort, FALSE if not. */ @@ -935,9 +908,7 @@ static int cs_find(exarg_T *eap) /* - * PRIVATE: cs_find_common - * - * common code for cscope find, shared by cs_find() and do_cstag() + * Common code for cscope find, shared by cs_find() and ex_cstag(). */ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int use_ll, char_u *cmdline) @@ -1112,9 +1083,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, } /* cs_find_common */ /* - * PRIVATE: cs_help - * - * print help + * Print help. */ static int cs_help(exarg_T *eap) { @@ -1164,9 +1133,7 @@ static void clear_csinfo(size_t i) } /* - * PRIVATE: cs_insert_filelist - * - * insert a new cscope database filename into the filelist + * Insert a new cscope database filename into the filelist. */ static int cs_insert_filelist(char *fname, char *ppath, char *flags, FileInfo *file_info) @@ -1228,9 +1195,7 @@ static int cs_insert_filelist(char *fname, char *ppath, char *flags, /* - * PRIVATE: cs_lookup_cmd - * - * find cscope command in command table + * Find cscope command in command table. */ static cscmd_T * cs_lookup_cmd(exarg_T *eap) { @@ -1257,9 +1222,7 @@ static cscmd_T * cs_lookup_cmd(exarg_T *eap) /* - * PRIVATE: cs_kill - * - * nuke em + * Nuke em. */ static int cs_kill(exarg_T *eap) { @@ -1318,8 +1281,6 @@ static int cs_kill(exarg_T *eap) /* - * PRIVATE: cs_kill_execute - * * Actually kills a specific cscope connection. */ static void cs_kill_execute( @@ -1337,22 +1298,20 @@ static void cs_kill_execute( /* - * PRIVATE: cs_make_vim_style_matches - * - * convert the cscope output into a ctags style entry (as might be found + * Convert the cscope output into a ctags style entry (as might be found * in a ctags tags file). there's one catch though: cscope doesn't tell you * the type of the tag you are looking for. for example, in Darren Hiebert's * ctags (the one that comes with vim), #define's use a line number to find the * tag in a file while function definitions use a regexp search pattern. * - * i'm going to always use the line number because cscope does something + * I'm going to always use the line number because cscope does something * quirky (and probably other things i don't know about): * * if you have "# define" in your source file, which is * perfectly legal, cscope thinks you have "#define". this * will result in a failed regexp search. :( * - * besides, even if this particular case didn't happen, the search pattern + * Besides, even if this particular case didn't happen, the search pattern * would still have to be modified to escape all the special regular expression * characters to comply with ctags formatting. */ @@ -1390,9 +1349,7 @@ static char *cs_make_vim_style_matches(char *fname, char *slno, char *search, /* - * PRIVATE: cs_manage_matches - * - * this is kind of hokey, but i don't see an easy way round this.. + * This is kind of hokey, but i don't see an easy way round this. * * Store: keep a ptr to the (malloc'd) memory of matches originally * generated from cs_find(). the matches are originally lines directly @@ -1462,9 +1419,7 @@ static char *cs_manage_matches(char **matches, char **contexts, /* - * PRIVATE: cs_parse_results - * - * parse cscope output + * Parse cscope output. */ static char *cs_parse_results(size_t cnumber, char *buf, int bufsize, char **context, char **linenumber, char **search) @@ -1516,9 +1471,7 @@ static char *cs_parse_results(size_t cnumber, char *buf, int bufsize, } /* - * PRIVATE: cs_file_results - * - * write cscope find results to file + * Write cscope find results to file. */ static void cs_file_results(FILE *f, int *nummatches_a) { @@ -1561,10 +1514,8 @@ static void cs_file_results(FILE *f, int *nummatches_a) } /* - * PRIVATE: cs_fill_results - * - * get parsed cscope output and calls cs_make_vim_style_matches to convert - * into ctags format + * Get parsed cscope output and calls cs_make_vim_style_matches to convert + * into ctags format. * When there are no matches sets "*matches_p" to NULL. */ static void cs_fill_results(char *tagstr, size_t totmatches, int *nummatches_a, @@ -1759,9 +1710,7 @@ static void cs_print_tags_priv(char **matches, char **cntxts, } /* - * PRIVATE: cs_read_prompt - * - * read a cscope prompt (basically, skip over the ">> ") + * Read a cscope prompt (basically, skip over the ">> "). */ static int cs_read_prompt(size_t i) { @@ -1848,8 +1797,6 @@ static void sig_handler(int s) { #endif /* - * PRIVATE: cs_release_csp - * * Does the actual free'ing for the cs ptr with an optional flag of whether * or not to free the filename. Called by cs_kill and cs_reset. */ @@ -1965,9 +1912,7 @@ static void cs_release_csp(size_t i, int freefnpp) /* - * PRIVATE: cs_reset - * - * calls cs_kill on all cscope connections then reinits + * Calls cs_kill on all cscope connections then reinits. */ static int cs_reset(exarg_T *eap) { @@ -2019,8 +1964,6 @@ static int cs_reset(exarg_T *eap) /* - * PRIVATE: cs_resolve_file - * * Construct the full pathname to a file found in the cscope database. * (Prepends ppath, if there is one and if it's not already prepended, * otherwise just uses the name found.) @@ -2075,9 +2018,7 @@ static char *cs_resolve_file(size_t i, char *name) /* - * PRIVATE: cs_show - * - * show all cscope connections + * Show all cscope connections. */ static int cs_show(exarg_T *eap) { @@ -2107,8 +2048,6 @@ static int cs_show(exarg_T *eap) /* - * PUBLIC: cs_end - * * Only called when VIM exits to quit any cscope sessions. */ void cs_end(void) diff --git a/src/nvim/version.c b/src/nvim/version.c index 1035963136..c68bc6351e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -648,7 +648,7 @@ static const int included_patches[] = { 84, 83, // 82 NA - // 81, + 81, // 80 NA 79, 78, -- cgit From 0c3f4f39211bf7247397a53d4d5f8de80fc97cdc Mon Sep 17 00:00:00 2001 From: lonerover Date: Fri, 4 Aug 2017 21:47:40 +0800 Subject: fix lint error --- src/nvim/if_cscope.c | 233 +++++++++++++++++++-------------------------------- 1 file changed, 85 insertions(+), 148 deletions(-) (limited to 'src') diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 607fd2bbee..0f9ecdf2d7 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -172,12 +172,10 @@ void set_context_in_cscope_cmd(expand_T *xp, const char *arg, cmdidx_T cmdidx) } -/* - * Find the command, print help if invalid, and then call the corresponding - * command function. - */ -static void -do_cscope_general ( +/// Find the command, print help if invalid, and then call the corresponding +/// command function. +static void +do_cscope_general( exarg_T *eap, int make_split /* whether to split window */ ) @@ -206,25 +204,19 @@ do_cscope_general ( postponed_split_tab = 0; } -/* - * Implementation of ":cscope" and ":lcscope" - */ +/// Implementation of ":cscope" and ":lcscope" void ex_cscope(exarg_T *eap) { do_cscope_general(eap, FALSE); } -/* - * Implementation of ":scscope". Same as ex_cscope(), but splits window, too. - */ +/// Implementation of ":scscope". Same as ex_cscope(), but splits window, too. void ex_scscope(exarg_T *eap) { do_cscope_general(eap, TRUE); } -/* - * Implementation of ":cstag" - */ +/// Implementation of ":cstag" void ex_cstag(exarg_T *eap) { int ret = FALSE; @@ -280,16 +272,13 @@ void ex_cstag(exarg_T *eap) (void)EMSG(_("E257: cstag: tag not found")); g_do_tagpreview = 0; } - } -/* - * This simulates a vim_fgets(), but for cscope, returns the next line - * from the cscope output. should only be called from find_tags() - * - * returns TRUE if eof, FALSE otherwise - */ +/// This simulates a vim_fgets(), but for cscope, returns the next line +/// from the cscope output. should only be called from find_tags() +/// +/// @return TRUE if eof, FALSE otherwise int cs_fgets(char_u *buf, int size) { char *p; @@ -302,17 +291,13 @@ int cs_fgets(char_u *buf, int size) } /* cs_fgets */ -/* - * Called only from do_tag(), when popping the tag stack. - */ +/// Called only from do_tag(), when popping the tag stack. void cs_free_tags(void) { cs_manage_matches(NULL, NULL, 0, Free); } -/* - * Called from do_tag(). - */ +/// Called from do_tag(). void cs_print_tags(void) { cs_manage_matches(NULL, NULL, 0, Print); @@ -393,10 +378,8 @@ int cs_connection(int num, char_u *dbpath, char_u *ppath) * PRIVATE functions ****************************************************************************/ -/* - * Add cscope database or a directory name (to look for cscope.out) - * to the cscope connection list. - */ +/// Add cscope database or a directory name (to look for cscope.out) +/// to the cscope connection list. static int cs_add(exarg_T *eap) { char *fname, *ppath, *flags = NULL; @@ -422,15 +405,13 @@ static void cs_stat_emsg(char *fname) } -/* - * The common routine to add a new cscope connection. Called by - * cs_add() and cs_reset(). I really don't like to do this, but this - * routine uses a number of goto statements. - */ -static int -cs_add_common ( - char *arg1, /* filename - may contain environment variables */ - char *arg2, /* prepend path - may contain environment variables */ +/// The common routine to add a new cscope connection. Called by +/// cs_add() and cs_reset(). I really don't like to do this, but this +/// routine uses a number of goto statements. +static int +cs_add_common( + char *arg1, // filename - may contain environment variables + char *arg2, // prepend path - may contain environment variables char *flags ) { @@ -544,9 +525,7 @@ static int cs_check_for_tags(void) return p_tags[0] != NUL && curbuf->b_p_tags != NULL; } /* cs_check_for_tags */ -/* - * Count the number of cscope connections. - */ +/// Count the number of cscope connections. static size_t cs_cnt_connections(void) { size_t cnt = 0; @@ -566,9 +545,7 @@ static void cs_reading_emsg( } #define CSREAD_BUFSIZE 2048 -/* - * Count the number of matches for a given cscope connection. - */ +/// Count the number of matches for a given cscope connection. static int cs_cnt_matches(size_t idx) { char *stok; @@ -618,9 +595,7 @@ static int cs_cnt_matches(size_t idx) } /* cs_cnt_matches */ -/* - * Creates the actual cscope command query from what the user entered. - */ +/// Creates the actual cscope command query from what the user entered. static char *cs_create_cmd(char *csoption, char *pattern) { char *cmd; @@ -676,10 +651,8 @@ static char *cs_create_cmd(char *csoption, char *pattern) } /* cs_create_cmd */ -/* - * This piece of code was taken/adapted from nvi. do we need to add - * the BSD license notice? - */ +/// This piece of code was taken/adapted from nvi. do we need to add +/// the BSD license notice? static int cs_create_connection(size_t i) { #ifdef UNIX @@ -868,12 +841,10 @@ err_closing: } /* cs_create_connection */ -/* - * Query cscope using command line interface. Parse the output and use tselect - * to allow choices. Like Nvi, creates a pipe to send to/from query/cscope. - * - * returns TRUE if we jump to a tag or abort, FALSE if not. - */ +/// Query cscope using command line interface. Parse the output and use tselect +/// to allow choices. Like Nvi, creates a pipe to send to/from query/cscope. +/// +/// @return TRUE if we jump to a tag or abort, FALSE if not. static int cs_find(exarg_T *eap) { char *opt, *pat; @@ -907,9 +878,7 @@ static int cs_find(exarg_T *eap) } /* cs_find */ -/* - * Common code for cscope find, shared by cs_find() and ex_cstag(). - */ +/// Common code for cscope find, shared by cs_find() and ex_cstag(). static int cs_find_common(char *opt, char *pat, int forceit, int verbose, int use_ll, char_u *cmdline) { @@ -1082,9 +1051,7 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, } /* cs_find_common */ -/* - * Print help. - */ +/// Print help. static int cs_help(exarg_T *eap) { cscmd_T *cmdp = cs_cmds; @@ -1132,9 +1099,7 @@ static void clear_csinfo(size_t i) csinfo[i].to_fp = NULL; } -/* - * Insert a new cscope database filename into the filelist. - */ +/// Insert a new cscope database filename into the filelist. static int cs_insert_filelist(char *fname, char *ppath, char *flags, FileInfo *file_info) { @@ -1194,9 +1159,7 @@ static int cs_insert_filelist(char *fname, char *ppath, char *flags, } /* cs_insert_filelist */ -/* - * Find cscope command in command table. - */ +/// Find cscope command in command table. static cscmd_T * cs_lookup_cmd(exarg_T *eap) { cscmd_T *cmdp; @@ -1221,9 +1184,7 @@ static cscmd_T * cs_lookup_cmd(exarg_T *eap) } /* cs_lookup_cmd */ -/* - * Nuke em. - */ +/// Nuke em. static int cs_kill(exarg_T *eap) { char *stok; @@ -1280,9 +1241,7 @@ static int cs_kill(exarg_T *eap) } /* cs_kill */ -/* - * Actually kills a specific cscope connection. - */ +/// Actually kills a specific cscope connection. static void cs_kill_execute( size_t i, /* cscope table index */ char *cname /* cscope database name */ @@ -1297,24 +1256,22 @@ static void cs_kill_execute( } -/* - * Convert the cscope output into a ctags style entry (as might be found - * in a ctags tags file). there's one catch though: cscope doesn't tell you - * the type of the tag you are looking for. for example, in Darren Hiebert's - * ctags (the one that comes with vim), #define's use a line number to find the - * tag in a file while function definitions use a regexp search pattern. - * - * I'm going to always use the line number because cscope does something - * quirky (and probably other things i don't know about): - * - * if you have "# define" in your source file, which is - * perfectly legal, cscope thinks you have "#define". this - * will result in a failed regexp search. :( - * - * Besides, even if this particular case didn't happen, the search pattern - * would still have to be modified to escape all the special regular expression - * characters to comply with ctags formatting. - */ +/// Convert the cscope output into a ctags style entry (as might be found +/// in a ctags tags file). there's one catch though: cscope doesn't tell you +/// the type of the tag you are looking for. for example, in Darren Hiebert's +/// ctags (the one that comes with vim), #define's use a line number to find the +/// tag in a file while function definitions use a regexp search pattern. +/// +/// I'm going to always use the line number because cscope does something +/// quirky (and probably other things i don't know about): +/// +/// if you have "# define" in your source file, which is +/// perfectly legal, cscope thinks you have "#define". this +/// will result in a failed regexp search. :( +/// +/// Besides, even if this particular case didn't happen, the search pattern +/// would still have to be modified to escape all the special regular expression +/// characters to comply with ctags formatting. static char *cs_make_vim_style_matches(char *fname, char *slno, char *search, char *tagstr) { @@ -1348,22 +1305,20 @@ static char *cs_make_vim_style_matches(char *fname, char *slno, char *search, } /* cs_make_vim_style_matches */ -/* - * This is kind of hokey, but i don't see an easy way round this. - * - * Store: keep a ptr to the (malloc'd) memory of matches originally - * generated from cs_find(). the matches are originally lines directly - * from cscope output, but transformed to look like something out of a - * ctags. see cs_make_vim_style_matches for more details. - * - * Get: used only from cs_fgets(), this simulates a vim_fgets() to return - * the next line from the cscope output. it basically keeps track of which - * lines have been "used" and returns the next one. - * - * Free: frees up everything and resets - * - * Print: prints the tags - */ +/// This is kind of hokey, but i don't see an easy way round this. +/// +/// Store: keep a ptr to the (malloc'd) memory of matches originally +/// generated from cs_find(). the matches are originally lines directly +/// from cscope output, but transformed to look like something out of a +/// ctags. see cs_make_vim_style_matches for more details. +/// +/// Get: used only from cs_fgets(), this simulates a vim_fgets() to return +/// the next line from the cscope output. it basically keeps track of which +/// lines have been "used" and returns the next one. +/// +/// Free: frees up everything and resets +/// +/// Print: prints the tags static char *cs_manage_matches(char **matches, char **contexts, size_t totmatches, mcmd_e cmd) { @@ -1418,9 +1373,7 @@ static char *cs_manage_matches(char **matches, char **contexts, } /* cs_manage_matches */ -/* - * Parse cscope output. - */ +/// Parse cscope output. static char *cs_parse_results(size_t cnumber, char *buf, int bufsize, char **context, char **linenumber, char **search) { @@ -1470,9 +1423,7 @@ static char *cs_parse_results(size_t cnumber, char *buf, int bufsize, return name; } -/* - * Write cscope find results to file. - */ +/// Write cscope find results to file. static void cs_file_results(FILE *f, int *nummatches_a) { char *search, *slno; @@ -1513,11 +1464,9 @@ static void cs_file_results(FILE *f, int *nummatches_a) xfree(buf); } -/* - * Get parsed cscope output and calls cs_make_vim_style_matches to convert - * into ctags format. - * When there are no matches sets "*matches_p" to NULL. - */ +/// Get parsed cscope output and calls cs_make_vim_style_matches to convert +/// into ctags format. +/// When there are no matches sets "*matches_p" to NULL. static void cs_fill_results(char *tagstr, size_t totmatches, int *nummatches_a, char ***matches_p, char ***cntxts_p, size_t *matched) @@ -1709,9 +1658,7 @@ static void cs_print_tags_priv(char **matches, char **cntxts, xfree(buf); } -/* - * Read a cscope prompt (basically, skip over the ">> "). - */ +/// Read a cscope prompt (basically, skip over the ">> "). static int cs_read_prompt(size_t i) { int ch; @@ -1796,10 +1743,8 @@ static void sig_handler(int s) { #endif -/* - * Does the actual free'ing for the cs ptr with an optional flag of whether - * or not to free the filename. Called by cs_kill and cs_reset. - */ +/// Does the actual free'ing for the cs ptr with an optional flag of whether +/// or not to free the filename. Called by cs_kill and cs_reset. static void cs_release_csp(size_t i, int freefnpp) { // Trying to exit normally (not sure whether it is fit to Unix cscope) @@ -1911,9 +1856,7 @@ static void cs_release_csp(size_t i, int freefnpp) } /* cs_release_csp */ -/* - * Calls cs_kill on all cscope connections then reinits. - */ +/// Calls cs_kill on all cscope connections then reinits. static int cs_reset(exarg_T *eap) { char **dblist = NULL, **pplist = NULL, **fllist = NULL; @@ -1963,15 +1906,13 @@ static int cs_reset(exarg_T *eap) } /* cs_reset */ -/* - * Construct the full pathname to a file found in the cscope database. - * (Prepends ppath, if there is one and if it's not already prepended, - * otherwise just uses the name found.) - * - * We need to prepend the prefix because on some cscope's (e.g., the one that - * ships with Solaris 2.6), the output never has the prefix prepended. - * Contrast this with my development system (Digital Unix), which does. - */ +/// Construct the full pathname to a file found in the cscope database. +/// (Prepends ppath, if there is one and if it's not already prepended, +/// otherwise just uses the name found.) +/// +/// We need to prepend the prefix because on some cscope's (e.g., the one that +/// ships with Solaris 2.6), the output never has the prefix prepended. +/// Contrast this with my development system (Digital Unix), which does. static char *cs_resolve_file(size_t i, char *name) { char *fullname; @@ -2017,9 +1958,7 @@ static char *cs_resolve_file(size_t i, char *name) } -/* - * Show all cscope connections. - */ +/// Show all cscope connections. static int cs_show(exarg_T *eap) { if (cs_cnt_connections() == 0) @@ -2047,9 +1986,7 @@ static int cs_show(exarg_T *eap) } /* cs_show */ -/* - * Only called when VIM exits to quit any cscope sessions. - */ +/// Only called when VIM exits to quit any cscope sessions. void cs_end(void) { for (size_t i = 0; i < csinfo_size; i++) -- cgit From 348229b1d32010292013eee415c28926e2b7009b Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Wed, 2 Aug 2017 16:22:04 +0800 Subject: vim-patch:8.0.0133 (#7107) Problem: "2;'(" causes ml_get errors in an empty buffer. (Dominique Pelle) Solution: Check the cursor line earlier. https://github.com/vim/vim/commit/fe38b494fff56cd9b2fcaeef26a8fd7b6557d69c --- src/nvim/ex_docmd.c | 13 +++++++------ src/nvim/testdir/test_cmdline.vim | 7 +++++++ src/nvim/version.c | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 30156621d6..d1ce589db1 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1665,11 +1665,15 @@ static char_u * do_one_cmd(char_u **cmdlinep, ea.addr_count++; if (*ea.cmd == ';') { - if (!ea.skip) + if (!ea.skip) { curwin->w_cursor.lnum = ea.line2; - } else if (*ea.cmd != ',') + // Don't leave the cursor on an illegal line (caused by ';') + check_cursor_lnum(); + } + } else if (*ea.cmd != ',') { break; - ++ea.cmd; + } + ea.cmd++; } /* One address given: set start and end lines */ @@ -1680,9 +1684,6 @@ static char_u * do_one_cmd(char_u **cmdlinep, ea.addr_count = 0; } - /* Don't leave the cursor on an illegal line (caused by ';') */ - check_cursor_lnum(); - /* * 5. Parse the command. */ diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index c3bfae1b7b..09f4b942ad 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -232,3 +232,10 @@ func Test_paste_in_cmdline() call assert_equal('"aaa a;b-c*d bbb', @:) bwipe! endfunc + +func Test_illegal_address() + new + 2;'( + 2;') + quit +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index c68bc6351e..7f0b45e896 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -596,7 +596,7 @@ static const int included_patches[] = { 136, 135, // 134, - // 133, + 133, // 132, // 131, // 130 NA -- cgit From 678e87b90a08915d4fc16e3aada133f6482ba7a3 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 4 Aug 2017 21:48:43 +0200 Subject: test/oldtest: avoid delete() on files used by a subprocess This should avoid the hangs observed in the TSAN build on travis CI. TODO: Find the root cause ... --- src/nvim/testdir/test49.vim | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test49.vim b/src/nvim/testdir/test49.vim index 467abcd9b9..a0e170dea4 100644 --- a/src/nvim/testdir/test49.vim +++ b/src/nvim/testdir/test49.vim @@ -481,9 +481,12 @@ function! ExtraVim(...) bwipeout let g:Xpath = g:Xpath + sum + " FIXME(nvim): delete() of a file used by a subprocess hangs TSAN build on travis CI. + if !empty($TRAVIS) " Delete the extra script and the resultfile. call delete(extra_script) call delete(resultfile) + endif " Switch back to the buffer that was active when this function was entered. exec "buffer" current_buffnr -- cgit From 55c0401dfd137a5e173d8551f763cb4c6fed56e1 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sat, 5 Aug 2017 10:17:30 +0800 Subject: vim-patch:8.0.0134 (#7109) Problem: Null pointer access reported by UBsan. Solution: Check curwin->w_buffer is not NULL. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/c4bfedabe057c05f09a455a5851089e177fa9c00 src/nvim/ex_cmds.c have been merged by someone. while version.c remain unmerged. --- src/nvim/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 7f0b45e896..f2b56e0108 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -595,7 +595,7 @@ static const int included_patches[] = { // 137, 136, 135, - // 134, + 134, 133, // 132, // 131, -- cgit From c6954437277175c9e2b8eb7e7e753314725aef8b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 3 Aug 2017 00:41:52 +0200 Subject: win_redr_status(): skip if wildmenu is showing This might be too coarse, but it passes all tests ... A more nuanced approach might be: only skip the windows whose statuslines are overwritten by the wildmenu. Closes #2255 Closes #7108 vim-patch:8.0.0710 N/A because of the changes in this commit. --- src/nvim/screen.c | 36 ++++----- src/nvim/version.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 241 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index bcc996679b..cd4f4de40f 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -86,6 +86,7 @@ #include #include +#include "nvim/log.h" #include "nvim/vim.h" #include "nvim/ascii.h" #include "nvim/arabic.h" @@ -4874,11 +4875,14 @@ void win_redr_status(win_T *wp) int this_ru_col; static int busy = FALSE; - /* It's possible to get here recursively when 'statusline' (indirectly) - * invokes ":redrawstatus". Simply ignore the call then. */ - if (busy) + // May get here recursively when 'statusline' (indirectly) + // invokes ":redrawstatus". Simply ignore the call then. + if (busy + // Also ignore if wildmenu is showing. + || (wild_menu_showing != 0 && !ui_is_external(kUIWildmenu))) { return; - busy = TRUE; + } + busy = true; wp->w_redr_status = FALSE; if (wp->w_status_height == 0) { @@ -6441,13 +6445,11 @@ void setcursor(void) } } -/* - * insert 'line_count' lines at 'row' in window 'wp' - * if 'invalid' is TRUE the wp->w_lines[].wl_lnum is invalidated. - * if 'mayclear' is TRUE the screen will be cleared if it is faster than - * scrolling. - * Returns FAIL if the lines are not inserted, OK for success. - */ +/// Insert 'line_count' lines at 'row' in window 'wp'. +/// If 'invalid' is TRUE the wp->w_lines[].wl_lnum is invalidated. +/// If 'mayclear' is TRUE the screen will be cleared if it is faster than +/// scrolling. +/// Returns FAIL if the lines are not inserted, OK for success. int win_ins_lines(win_T *wp, int row, int line_count, int invalid, int mayclear) { int did_delete; @@ -6510,13 +6512,11 @@ int win_ins_lines(win_T *wp, int row, int line_count, int invalid, int mayclear) return OK; } -/* - * delete "line_count" window lines at "row" in window "wp" - * If "invalid" is TRUE curwin->w_lines[] is invalidated. - * If "mayclear" is TRUE the screen will be cleared if it is faster than - * scrolling - * Return OK for success, FAIL if the lines are not deleted. - */ +/// Delete "line_count" window lines at "row" in window "wp". +/// If "invalid" is TRUE curwin->w_lines[] is invalidated. +/// If "mayclear" is TRUE the screen will be cleared if it is faster than +/// scrolling +/// Return OK for success, FAIL if the lines are not deleted. int win_del_lines(win_T *wp, int row, int line_count, int invalid, int mayclear) { int retval; diff --git a/src/nvim/version.c b/src/nvim/version.c index f2b56e0108..c443b63bb0 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -77,6 +77,229 @@ static char *features[] = { // clang-format off static const int included_patches[] = { + // 875, + // 874, + // 873, + // 872, + // 871, + // 870, + // 869, + // 868, + // 867, + // 866, + // 865, + // 864, + // 863, + // 862, + // 861, + // 860, + // 859, + // 858, + // 857, + // 856, + // 855, + // 854, + // 853, + // 852, + // 851, + // 850, + // 849, + // 848, + // 847, + // 846, + // 845, + // 844, + // 843, + // 842, + // 841, + // 840, + // 839, + // 838, + // 837, + // 836, + // 835, + // 834, + // 833, + // 832, + // 831, + // 830, + // 829, + // 828, + // 827, + // 826, + // 825, + // 824, + // 823, + // 822, + // 821, + // 820, + // 819, + // 818, + // 817, + // 816, + // 815, + // 814, + // 813, + // 812, + // 811, + // 810, + // 809, + // 808, + // 807, + // 806, + // 805, + // 804, + // 803, + // 802, + // 801, + // 800, + // 799, + // 798, + // 797, + // 796, + // 795, + // 794, + // 793, + // 792, + // 791, + // 790, + // 789, + // 788, + // 787, + // 786, + // 785, + // 784, + // 783, + // 782, + // 781, + // 780, + // 779, + // 778, + // 777, + // 776, + // 775, + // 774, + // 773, + // 772, + // 771, + // 770, + // 769, + // 768, + // 767, + // 766, + // 765, + // 764, + // 763, + // 762, + // 761, + // 760, + // 759, + // 758, + // 757, + // 756, + // 755, + // 754, + // 753, + // 752, + // 751, + // 750, + // 749, + // 748, + // 747, + // 746, + // 745, + // 744, + // 743, + // 742, + // 741, + // 740, + // 739, + // 738, + // 737, + // 736, + // 735, + // 734, + // 733, + // 732, + // 731, + // 730, + // 729, + // 728, + // 727, + // 726, + // 725, + // 724, + // 723, + // 722, + // 721, + // 720, + // 719, + // 718, + // 717, + // 716, + // 715, + // 714, + // 713, + // 712, + // 711, + 710, + // 709, + // 708, + // 707, + // 706, + // 705, + // 704, + // 703, + // 702, + // 701, + // 700, + // 699, + // 698, + // 697, + // 696, + // 695, + // 694, + // 693, + // 692, + // 691, + // 690, + // 689, + // 688, + // 687, + // 686, + // 685, + // 684, + // 683, + // 682, + // 681, + // 680, + // 679, + // 678, + // 677, + // 676, + // 675, + // 674, + // 673, + // 672, + // 671, + // 670, + // 669, + // 668, + // 667, + // 666, + // 665, + // 664, + // 663, + // 662, + // 661, + // 660, + // 659, + // 658, + // 657, + // 656, + // 655, + // 654, + // 653, 652, // 651, // 650, -- cgit From a31482db4dcaa479b09e2683037fee3d6ee56408 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 5 Aug 2017 03:34:38 +0200 Subject: terminal: block redraw during c_CTRL-D Unlike the normal wildmenu, the CTRL-D wild-list is not restored by statusline redraw. (Semantics: ^D is controlled by 'wildoptions' option, so it's in the "wild..." family.) TODO: externalize the c_CTRL-D wild-list. --- src/nvim/ex_getln.c | 9 ++++++--- src/nvim/globals.h | 7 +++++-- src/nvim/state.c | 1 + src/nvim/terminal.c | 6 +++++- 4 files changed, 17 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 1d81a39dfe..a41e78d44a 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -12,6 +12,7 @@ #include #include "nvim/assert.h" +#include "nvim/log.h" #include "nvim/vim.h" #include "nvim/ascii.h" #include "nvim/arabic.h" @@ -472,11 +473,12 @@ static int command_line_execute(VimState *state, int key) } // free expanded names when finished walking through matches - if (s->xpc.xp_numfiles != -1 - && !(s->c == p_wc && KeyTyped) && s->c != p_wcm + if (!(s->c == p_wc && KeyTyped) && s->c != p_wcm && s->c != Ctrl_N && s->c != Ctrl_P && s->c != Ctrl_A && s->c != Ctrl_L) { - (void)ExpandOne(&s->xpc, NULL, NULL, 0, WILD_FREE); + if (s->xpc.xp_numfiles != -1) { + (void)ExpandOne(&s->xpc, NULL, NULL, 0, WILD_FREE); + } s->did_wild_list = false; if (!p_wmnu || (s->c != K_UP && s->c != K_DOWN)) { s->xpc.xp_context = EXPAND_NOTHING; @@ -1222,6 +1224,7 @@ static int command_line_handle_key(CommandLineState *s) break; // Use ^D as normal char instead } + wild_menu_showing = WM_LIST; redrawcmd(); return 1; // don't do incremental search now diff --git a/src/nvim/globals.h b/src/nvim/globals.h index f08812600f..13ecafcbe3 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -931,8 +931,11 @@ EXTERN char_u langmap_mapchar[256]; /* mapping for language keys */ EXTERN int save_p_ls INIT(= -1); /* Save 'laststatus' setting */ EXTERN int save_p_wmh INIT(= -1); /* Save 'winminheight' setting */ EXTERN int wild_menu_showing INIT(= 0); -# define WM_SHOWN 1 /* wildmenu showing */ -# define WM_SCROLLED 2 /* wildmenu showing with scroll */ +enum { + WM_SHOWN = 1, ///< wildmenu showing + WM_SCROLLED = 2, ///< wildmenu showing with scroll + WM_LIST = 3, ///< cmdline CTRL-D +}; EXTERN char breakat_flags[256]; /* which characters are in 'breakat' */ diff --git a/src/nvim/state.c b/src/nvim/state.c index be6aa21664..eb0b590a9b 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -6,6 +6,7 @@ #include "nvim/lib/kvec.h" #include "nvim/ascii.h" +#include "nvim/log.h" #include "nvim/state.h" #include "nvim/vim.h" #include "nvim/main.h" diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 099f49f09b..deec930ebd 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -43,6 +43,7 @@ #include +#include "nvim/log.h" #include "nvim/vim.h" #include "nvim/terminal.h" #include "nvim/message.h" @@ -1010,7 +1011,10 @@ static void refresh_terminal(Terminal *term) // Calls refresh_terminal() on all invalidated_terminals. static void refresh_timer_cb(TimeWatcher *watcher, void *data) { - if (exiting) { // Cannot redraw (requires event loop) during teardown/exit. + if (exiting // Cannot redraw (requires event loop) during teardown/exit. + // WM_LIST (^D) is not redrawn, unlike the normal wildmenu. So we must + // skip redraws to keep it visible. + || wild_menu_showing == WM_LIST) { goto end; } Terminal *term; -- cgit From 30996359efbba90ce03ac3de7e39f20db9ce486b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 5 Aug 2017 21:10:21 +0200 Subject: clint: allow starting brace after `enum` --- src/clint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/clint.py b/src/clint.py index 69a061d2ab..4a41650ec4 100755 --- a/src/clint.py +++ b/src/clint.py @@ -2613,7 +2613,8 @@ def CheckBraces(filename, clean_lines, linenum, error): func_start_linenum += 1 else: - if clean_lines.lines[func_start_linenum].endswith('{'): + func_start = clean_lines.lines[func_start_linenum] + if not func_start.startswith('enum ') and func_start.endswith('{'): error(filename, func_start_linenum, 'readability/braces', 5, 'Brace starting function body must be placed ' -- cgit From 50c8f19d614d4752ac1d2d19b5bc7c05f6d354f9 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 5 Aug 2017 21:53:03 +0200 Subject: build: silence maybe-uninitialized warning False positive. From C:\msys64\mingw64\bin\gcc.exe (appveyor CI) --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index a41e78d44a..ecd5c81822 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1455,7 +1455,7 @@ static int command_line_handle_key(CommandLineState *s) if (s->hiscnt != s->i) { // jumped to other entry char_u *p; - int len; + int len = 0; int old_firstc; xfree(ccline.cmdbuff); -- cgit From d801ce70c1fb8dd8b3735ca9e06158aaf48203ba Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 5 Aug 2017 23:29:02 +0200 Subject: win_defs.h: redefine RGB macro after undefining Before this change, if os_defs.h was included after macros.h then win_defs.h would undefine our own RGB macro. vim-patch:8.0.0146 --- src/nvim/os/win_defs.h | 9 +++++++-- src/nvim/version.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h index 7ed70f6092..8fd2e51f8b 100644 --- a/src/nvim/os/win_defs.h +++ b/src/nvim/os/win_defs.h @@ -30,8 +30,13 @@ #define USE_CRNL -// We have our own RGB macro in macros.h. -#undef RGB +// Windows defines a RGB macro that produces 0x00bbggrr color values for use +// with GDI. Our macro is different, and we don't use GDI. +#if defined(RGB) +# undef RGB + // Duplicated from macros.h to avoid include-order sensitivity. +# define RGB(r, g, b) ((r << 16) | (g << 8) | b) +#endif #ifdef _MSC_VER # ifndef inline diff --git a/src/nvim/version.c b/src/nvim/version.c index c443b63bb0..81152bbaa4 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -806,7 +806,7 @@ static const int included_patches[] = { // 149, // 148, // 147, - // 146, + 146, // 145 NA // 144 NA // 143, -- cgit From 3827d5bc713d9ed149bc793f411debb5b89a4eba Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 6 Aug 2017 02:44:15 +0200 Subject: input: skip dialogs if no UI is active Treat dialogs in the same way as "silent mode" (`nvim -es`). References #1984 References #3901 --- src/nvim/main.c | 15 +++++++-------- src/nvim/message.c | 8 +++++--- src/nvim/misc1.c | 2 +- src/nvim/testdir/test49.vim | 3 --- 4 files changed, 13 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index 7dcf00c26b..a46c1a58f8 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -98,10 +98,8 @@ typedef struct { bool input_isatty; // stdin is a terminal bool output_isatty; // stdout is a terminal bool err_isatty; // stderr is a terminal - bool headless; // Dont try to start an user interface - // or read/write to stdio(unless - // embedding) - int no_swap_file; /* "-n" argument used */ + bool headless; // Do not start the builtin UI. + int no_swap_file; // "-n" argument used int use_debug_break_level; int window_count; /* number of windows to use */ int window_layout; /* 0, WIN_HOR, WIN_VER or WIN_TABS */ @@ -932,10 +930,11 @@ static void command_line_scan(mparm_T *parmp) break; case 's': - if (exmode_active) /* "-s" silent (batch) mode */ - silent_mode = TRUE; - else /* "-s {scriptin}" read from script file */ - want_argument = TRUE; + if (exmode_active) { // "-es" silent (batch) mode + silent_mode = true; + } else { // "-s {scriptin}" read from script file + want_argument = true; + } break; case 't': /* "-t {tag}" or "-t{tag}" jump to tag */ diff --git a/src/nvim/message.c b/src/nvim/message.c index 36f9ca84ed..28c88f5a14 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2722,9 +2722,11 @@ do_dialog ( int c; int i; - /* Don't output anything in silent mode ("ex -s") */ - if (silent_mode) - return dfltbutton; /* return default option */ + if (silent_mode // No dialogs in silent mode ("ex -s") + || !ui_active() // Without a UI Nvim waits for input forever. + ) { + return dfltbutton; // return default option + } oldState = State; diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 835b9c7b20..5270687a4d 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -2203,7 +2203,7 @@ change_warning ( set_vim_var_string(VV_WARNINGMSG, _(w_readonly), -1); msg_clr_eos(); (void)msg_end(); - if (msg_silent == 0 && !silent_mode) { + if (msg_silent == 0 && !silent_mode && ui_active()) { ui_flush(); os_delay(1000L, true); /* give the user time to think about it */ } diff --git a/src/nvim/testdir/test49.vim b/src/nvim/testdir/test49.vim index a0e170dea4..467abcd9b9 100644 --- a/src/nvim/testdir/test49.vim +++ b/src/nvim/testdir/test49.vim @@ -481,12 +481,9 @@ function! ExtraVim(...) bwipeout let g:Xpath = g:Xpath + sum - " FIXME(nvim): delete() of a file used by a subprocess hangs TSAN build on travis CI. - if !empty($TRAVIS) " Delete the extra script and the resultfile. call delete(extra_script) call delete(resultfile) - endif " Switch back to the buffer that was active when this function was entered. exec "buffer" current_buffnr -- cgit From 4d8ff5ec012cd517cf8010144f158d6f5c96d5bb Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 6 Aug 2017 14:38:54 +0300 Subject: api/helpers: Clarify try_start() usage --- src/nvim/api/private/helpers.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index cdaceddc11..021d1d43ff 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -96,6 +96,13 @@ bool try_leave(const TryState *const tstate, Error *const err) } /// Start block that may cause vimscript exceptions +/// +/// Each try_start() call should be mirrorred by try_end() call. +/// +/// To be used as a replacement of `:try … catch … endtry` in C code, in cases +/// when error flag could not already be set. If there may be pending error +/// state at the time try_start() is executed which needs to be preserved, +/// try_enter()/try_leave() pair should be used instead. void try_start(void) { ++trylevel; -- cgit From 36acfce4eac9dd131a39c4dbdff2836ab3e21d73 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 6 Aug 2017 15:23:05 +0300 Subject: api/helpers: Fix typo --- src/nvim/api/private/helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 021d1d43ff..e736e29e2d 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -97,7 +97,7 @@ bool try_leave(const TryState *const tstate, Error *const err) /// Start block that may cause vimscript exceptions /// -/// Each try_start() call should be mirrorred by try_end() call. +/// Each try_start() call should be mirrored by try_end() call. /// /// To be used as a replacement of `:try … catch … endtry` in C code, in cases /// when error flag could not already be set. If there may be pending error -- cgit From 36ceb9397c7fc383356e54ea8eab8fa3d6cefb1f Mon Sep 17 00:00:00 2001 From: lonerover Date: Mon, 7 Aug 2017 05:00:19 +0800 Subject: vim-patch:8.0.0086 (#7118) Problem: Cannot add a comment after ":hide". (Norio Takagi) Solution: Make it work, add a test. (Hirohito Higashi) https://github.com/vim/vim/commit/2256c9947164229c0960803e2a2992b793c23298 --- src/nvim/ex_cmds.lua | 2 +- src/nvim/ex_docmd.c | 58 ++++++++++++------------- src/nvim/testdir/Makefile | 1 + src/nvim/testdir/test_hide.vim | 97 ++++++++++++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 5 files changed, 127 insertions(+), 33 deletions(-) create mode 100644 src/nvim/testdir/test_hide.vim (limited to 'src') diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index 5757964f0f..5a578cd088 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -1076,7 +1076,7 @@ return { }, { command='hide', - flags=bit.bor(BANG, RANGE, NOTADR, COUNT, EXTRA, NOTRLCOM), + flags=bit.bor(BANG, RANGE, NOTADR, COUNT, EXTRA, TRLBAR), addr_type=ADDR_WINDOWS, func='ex_hide', }, diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index d1ce589db1..1a766821a9 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4674,17 +4674,17 @@ char_u *find_nextcmd(const char_u *p) return (char_u *)p + 1; } -/* - * Check if *p is a separator between Ex commands. - * Return NULL if it isn't, (p + 1) if it is. - */ +/// Check if *p is a separator between Ex commands, skipping over white space. +/// Return NULL if it isn't, the following character if it is. char_u *check_nextcmd(char_u *p) { - p = skipwhite(p); - if (*p == '|' || *p == '\n') - return p + 1; - else - return NULL; + char_u *s = skipwhite(p); + + if (*s == '|' || *s == '\n') { + return (s + 1); + } else { + return NULL; + } } /* @@ -6254,31 +6254,27 @@ void ex_all(exarg_T *eap) static void ex_hide(exarg_T *eap) { - if (*eap->arg != NUL && check_nextcmd(eap->arg) == NULL) - eap->errmsg = e_invarg; - else { - /* ":hide" or ":hide | cmd": hide current window */ - eap->nextcmd = check_nextcmd(eap->arg); + // ":hide" or ":hide | cmd": hide current window if (!eap->skip) { - if (eap->addr_count == 0) - win_close(curwin, FALSE); /* don't free buffer */ - else { - int winnr = 0; - win_T *win = NULL; - - FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { - winnr++; - if (winnr == eap->line2) { - win = wp; - break; - } + if (eap->addr_count == 0) { + win_close(curwin, false); // don't free buffer + } else { + int winnr = 0; + win_T *win = NULL; + + FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { + winnr++; + if (winnr == eap->line2) { + win = wp; + break; + } + } + if (win == NULL) { + win = lastwin; + } + win_close(win, false); } - if (win == NULL) - win = lastwin; - win_close(win, FALSE); - } } - } } /* diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index b45bd6ee14..944222dbb6 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -45,6 +45,7 @@ NEW_TESTS ?= \ test_gn.res \ test_hardcopy.res \ test_help_tagjump.res \ + test_hide.res \ test_history.res \ test_hlsearch.res \ test_increment.res \ diff --git a/src/nvim/testdir/test_hide.vim b/src/nvim/testdir/test_hide.vim new file mode 100644 index 0000000000..128b8ff945 --- /dev/null +++ b/src/nvim/testdir/test_hide.vim @@ -0,0 +1,97 @@ +" Tests for :hide command/modifier and 'hidden' option + +function SetUp() + let s:save_hidden = &hidden + let s:save_bufhidden = &bufhidden + let s:save_autowrite = &autowrite + set nohidden + set bufhidden= + set noautowrite +endfunc + +function TearDown() + let &hidden = s:save_hidden + let &bufhidden = s:save_bufhidden + let &autowrite = s:save_autowrite +endfunc + +function Test_hide() + let orig_bname = bufname('') + let orig_winnr = winnr('$') + + new Xf1 + set modified + call assert_fails('edit Xf2') + bwipeout! Xf1 + + new Xf1 + set modified + edit! Xf2 + call assert_equal(['Xf2', 2], [bufname(''), winnr('$')]) + call assert_equal([1, 0], [buflisted('Xf1'), bufloaded('Xf1')]) + bwipeout! Xf1 + bwipeout! Xf2 + + new Xf1 + set modified + " :hide as a command + hide + call assert_equal([orig_bname, orig_winnr], [bufname(''), winnr('$')]) + call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')]) + bwipeout! Xf1 + + new Xf1 + set modified + " :hide as a command with trailing comment + hide " comment + call assert_equal([orig_bname, orig_winnr], [bufname(''), winnr('$')]) + call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')]) + bwipeout! Xf1 + + new Xf1 + set modified + " :hide as a command with bar + hide | new Xf2 " comment + call assert_equal(['Xf2', 2], [bufname(''), winnr('$')]) + call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')]) + bwipeout! Xf1 + bwipeout! Xf2 + + new Xf1 + set modified + " :hide as a modifier with trailing comment + hide edit Xf2 " comment + call assert_equal(['Xf2', 2], [bufname(''), winnr('$')]) + call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')]) + bwipeout! Xf1 + bwipeout! Xf2 + + new Xf1 + set modified + " To check that the bar is not recognized to separate commands + hide echo "one|two" + call assert_equal(['Xf1', 2], [bufname(''), winnr('$')]) + call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')]) + bwipeout! Xf1 + + " set hidden + new Xf1 + set hidden + set modified + edit Xf2 " comment + call assert_equal(['Xf2', 2], [bufname(''), winnr('$')]) + call assert_equal([1, 1], [buflisted('Xf1'), bufloaded('Xf1')]) + bwipeout! Xf1 + bwipeout! Xf2 + + " set hidden bufhidden=wipe + new Xf1 + set bufhidden=wipe + set modified + hide edit! Xf2 " comment + call assert_equal(['Xf2', 2], [bufname(''), winnr('$')]) + call assert_equal([0, 0], [buflisted('Xf1'), bufloaded('Xf1')]) + bwipeout! Xf2 +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index 81152bbaa4..9305618eae 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -866,7 +866,7 @@ static const int included_patches[] = { // 89 NA 88, // 87 NA - // 86, + 86, 85, 84, 83, -- cgit From d1f0b5aa5d594f3041c3fc6c026ff720c07beaeb Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 7 Aug 2017 05:03:08 +0800 Subject: vim-patch:8.0.0137 (#7119) Problem: When 'maxfuncdepth' is set above 200 the nesting is limited to 200. (Brett Stahlman) Solution: Allow for Ex command recursion depending on 'maxfuncdepth'. https://github.com/vim/vim/commit/777b30f827bcbe10a40640b1bf0361cb93a16be1 --- src/nvim/ex_docmd.c | 11 ++++++----- src/nvim/testdir/test_nested_function.vim | 21 +++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 28 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 1a766821a9..29788a9865 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -340,12 +340,13 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, msg_list = &private_msg_list; private_msg_list = NULL; - /* It's possible to create an endless loop with ":execute", catch that - * here. The value of 200 allows nested function calls, ":source", etc. */ - if (call_depth == 200) { + // It's possible to create an endless loop with ":execute", catch that + // here. The value of 200 allows nested function calls, ":source", etc. + // Allow 200 or 'maxfuncdepth', whatever is larger. + if (call_depth >= 200 && call_depth >= p_mfd) { EMSG(_("E169: Command too recursive")); - /* When converting to an exception, we do not include the command name - * since this is not an error of the specific command. */ + // When converting to an exception, we do not include the command name + // since this is not an error of the specific command. do_errthrow((struct condstack *)NULL, (char_u *)NULL); msg_list = saved_msg_list; return FAIL; diff --git a/src/nvim/testdir/test_nested_function.vim b/src/nvim/testdir/test_nested_function.vim index 7e301ed33e..afaaea6ceb 100644 --- a/src/nvim/testdir/test_nested_function.vim +++ b/src/nvim/testdir/test_nested_function.vim @@ -40,3 +40,24 @@ func Test_nested_argument() delfunc g:X unlet g:Y endfunc + +func Recurse(count) + if a:count > 0 + call Recurse(a:count - 1) + endif +endfunc + +func Test_max_nesting() + let call_depth_here = 2 + let ex_depth_here = 5 + set mfd& + + call Recurse(99 - call_depth_here) + call assert_fails('call Recurse(' . (100 - call_depth_here) . ')', 'E132:') + + set mfd=210 + call Recurse(209 - ex_depth_here) + call assert_fails('call Recurse(' . (210 - ex_depth_here) . ')', 'E169:') + + set mfd& +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 9305618eae..fd2f1fd212 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -815,7 +815,7 @@ static const int included_patches[] = { // 140, // 139 NA // 138 NA - // 137, + 137, 136, 135, 134, -- cgit From 644fa6537cfda6281f6ac6c837b9a08fa35fb516 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 7 Aug 2017 05:04:50 +0800 Subject: vim-patch:8.0.0143 (#7120) Problem: Line number of current buffer in getbufinfo() is wrong. Solution: For the current buffer use the current line number. (Ken Takata) https://github.com/vim/vim/commit/f845b87f2b3a45cbee160e28d7a3f50e54054809 --- src/nvim/eval.c | 3 ++- src/nvim/version.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 78c8dd02db..ef3a8cada1 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -9079,7 +9079,8 @@ static dict_T *get_buffer_info(buf_T *buf) tv_dict_add_nr(dict, S_LEN("bufnr"), buf->b_fnum); tv_dict_add_str(dict, S_LEN("name"), buf->b_ffname != NULL ? (const char *)buf->b_ffname : ""); - tv_dict_add_nr(dict, S_LEN("lnum"), buflist_findlnum(buf)); + tv_dict_add_nr(dict, S_LEN("lnum"), + buf == curbuf ? curwin->w_cursor.lnum : buflist_findlnum(buf)); tv_dict_add_nr(dict, S_LEN("loaded"), buf->b_ml.ml_mfp != NULL); tv_dict_add_nr(dict, S_LEN("listed"), buf->b_p_bl); tv_dict_add_nr(dict, S_LEN("changed"), bufIsChanged(buf)); diff --git a/src/nvim/version.c b/src/nvim/version.c index fd2f1fd212..aa7c613f3a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -809,7 +809,7 @@ static const int included_patches[] = { 146, // 145 NA // 144 NA - // 143, + 143, // 142, // 141, // 140, -- cgit From 120d1b80c9aa3ad39902310a99f5d19f41ca4bb8 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sat, 5 Aug 2017 13:26:36 +0800 Subject: vim-patch:8.0.0147 #7121 Problem: searchpair() does not work when 'magic' is off. (Chris Paul) Solution: Add \m in the pattern. (Christian Brabandt, closes vim/vim#1341) https://github.com/vim/vim/commit/6e450a57541676036203a72d40b2e604e938371e --- src/nvim/eval.c | 26 ++++++++++++++++---------- src/nvim/testdir/test_search.vim | 15 +++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 32 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index ef3a8cada1..c42929ef7c 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -14203,6 +14203,8 @@ do_searchpair ( int nest = 1; int options = SEARCH_KEEP; proftime_T tm; + size_t pat2_len; + size_t pat3_len; /* Make 'cpoptions' empty, the 'l' flag should not be used here. */ save_cpo = p_cpo; @@ -14211,18 +14213,22 @@ do_searchpair ( /* Set the time limit, if there is one. */ tm = profile_setlimit(time_limit); - /* Make two search patterns: start/end (pat2, for in nested pairs) and - * start/middle/end (pat3, for the top pair). */ - pat2 = xmalloc(STRLEN(spat) + STRLEN(epat) + 15); - pat3 = xmalloc(STRLEN(spat) + STRLEN(mpat) + STRLEN(epat) + 23); - sprintf((char *)pat2, "\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat); - if (*mpat == NUL) + // Make two search patterns: start/end (pat2, for in nested pairs) and + // start/middle/end (pat3, for the top pair). + pat2_len = STRLEN(spat) + STRLEN(epat) + 17; + pat2 = xmalloc(pat2_len); + pat3_len = STRLEN(spat) + STRLEN(mpat) + STRLEN(epat) + 25; + pat3 = xmalloc(pat3_len); + snprintf((char *)pat2, pat2_len, "\\m\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat); + if (*mpat == NUL) { STRCPY(pat3, pat2); - else - sprintf((char *)pat3, "\\(%s\\m\\)\\|\\(%s\\m\\)\\|\\(%s\\m\\)", - spat, epat, mpat); - if (flags & SP_START) + } else { + snprintf((char *)pat3, pat3_len, + "\\m\\(%s\\m\\)\\|\\(%s\\m\\)\\|\\(%s\\m\\)", spat, epat, mpat); + } + if (flags & SP_START) { options |= SEARCH_START; + } save_cursor = curwin->w_cursor; pos = curwin->w_cursor; diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index 2106fc2dec..a333e7f206 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -283,3 +283,18 @@ func Test_use_sub_pat() call X() bwipe! endfunc + +func Test_searchpair() + new + call setline(1, ['other code here', '', '[', '" cursor here', ']']) + 4 + let a=searchpair('\[','',']','bW') + call assert_equal(3, a) + set nomagic + 4 + let a=searchpair('\[','',']','bW') + call assert_equal(3, a) + set magic + q! +endfunc + diff --git a/src/nvim/version.c b/src/nvim/version.c index aa7c613f3a..d4d2af2f26 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -805,7 +805,7 @@ static const int included_patches[] = { 150, // 149, // 148, - // 147, + 147, 146, // 145 NA // 144 NA -- cgit From 2753d61e4cb037323d78ed3fd978a10694c902c6 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 7 Aug 2017 05:42:52 +0800 Subject: vim-patch:8.0.0111 (#7090) Problem: The :history command is not tested. Solution: Add tests. (Dominique Pelle) https://github.com/vim/vim/commit/eebd84eb94ed7f59a06a52cb4863563642f58899 --- src/nvim/testdir/test_history.vim | 24 ++++++++++++++++++++++++ src/nvim/version.c | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_history.vim b/src/nvim/testdir/test_history.vim index 3163b344d3..ca31e3f06c 100644 --- a/src/nvim/testdir/test_history.vim +++ b/src/nvim/testdir/test_history.vim @@ -31,6 +31,30 @@ function History_Tests(hist) call assert_equal('ls', histget(a:hist, -1)) call assert_equal(4, histnr(a:hist)) + let a=execute('history ' . a:hist) + call assert_match("^\n # \\S* history\n 3 buffers\n> 4 ls$", a) + let a=execute('history all') + call assert_match("^\n # .* history\n 3 buffers\n> 4 ls", a) + + if len(a:hist) > 0 + let a=execute('history ' . a:hist . ' 2') + call assert_match("^\n # \\S* history$", a) + let a=execute('history ' . a:hist . ' 3') + call assert_match("^\n # \\S* history\n 3 buffers$", a) + let a=execute('history ' . a:hist . ' 4') + call assert_match("^\n # \\S* history\n> 4 ls$", a) + let a=execute('history ' . a:hist . ' 3,4') + call assert_match("^\n # \\S* history\n 3 buffers\n> 4 ls$", a) + let a=execute('history ' . a:hist . ' -1') + call assert_match("^\n # \\S* history\n> 4 ls$", a) + let a=execute('history ' . a:hist . ' -2') + call assert_match("^\n # \\S* history\n 3 buffers$", a) + let a=execute('history ' . a:hist . ' -2,') + call assert_match("^\n # \\S* history\n 3 buffers\n> 4 ls$", a) + let a=execute('history ' . a:hist . ' -3') + call assert_match("^\n # \\S* history$", a) + endif + " Test for removing entries matching a pattern for i in range(1, 3) call histadd(a:hist, 'text_' . i) diff --git a/src/nvim/version.c b/src/nvim/version.c index d4d2af2f26..1ecda654d1 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -841,7 +841,7 @@ static const int included_patches[] = { // 114 NA // 113 NA // 112, - // 111, + 111, 110, // 109 NA // 108 NA -- cgit From e13b4a21cac9d173885249034fe20fb209b157df Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Tue, 8 Aug 2017 09:32:47 +0800 Subject: vim-patch:8.0.0149 (#7127) Problem: ":earlier" and ":later" do not work after startup or reading the undo file. Solution: Use absolute time stamps instead of relative to the Vim start time. (Christian Brabandt, Pavel Juhas, closes vim/vim#1300, closes vim/vim#1254) https://github.com/vim/vim/commit/cbd4de44e8d08fba3c09eb40ad6e36e83faf020a --- src/nvim/testdir/test_undo.vim | 28 ++++++++++++++++++++++++++++ src/nvim/undo.c | 29 +++++++++++++++-------------- src/nvim/version.c | 2 +- 3 files changed, 44 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_undo.vim b/src/nvim/testdir/test_undo.vim index 9ff73fd870..171618f6f7 100644 --- a/src/nvim/testdir/test_undo.vim +++ b/src/nvim/testdir/test_undo.vim @@ -237,3 +237,31 @@ func Test_insert_expr() close! endfunc + +func Test_undofile_earlier() + throw 'skipped: Nvim does not support test_settime()' + + let t0 = localtime() - 43200 + call test_settime(t0) + new Xfile + call feedkeys("ione\", 'xt') + set ul=100 + call test_settime(t0 + 1) + call feedkeys("otwo\", 'xt') + set ul=100 + call test_settime(t0 + 2) + call feedkeys("othree\", 'xt') + set ul=100 + w + wundo Xundofile + bwipe! + " restore normal timestamps. + call test_settime(0) + new Xfile + rundo Xundofile + earlier 1d + call assert_equal('', getline(1)) + bwipe! + call delete('Xfile') + call delete('Xundofile') +endfunc diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 81af3bfda9..3d7ebc8837 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -1838,11 +1838,9 @@ void undo_time(long step, int sec, int file, int absolute) } closest = -1; } else { - /* When doing computations with time_t subtract starttime, because - * time_t converted to a long may result in a wrong number. */ - if (dosec) - target = (long)(curbuf->b_u_time_cur - starttime) + step; - else if (dofile) { + if (dosec) { + target = (long)(curbuf->b_u_time_cur) + step; + } else if (dofile) { if (step < 0) { /* Going back to a previous write. If there were changes after * the last write, count that as moving one file-write, so @@ -1880,14 +1878,16 @@ void undo_time(long step, int sec, int file, int absolute) target = 0; closest = -1; } else { - if (dosec) - closest = (long)(time(NULL) - starttime + 1); - else if (dofile) + if (dosec) { + closest = (long)(os_time() + 1); + } else if (dofile) { closest = curbuf->b_u_save_nr_last + 2; - else + } else { closest = curbuf->b_u_seq_last + 2; - if (target >= closest) + } + if (target >= closest) { target = closest - 1; + } } } closest_start = closest; @@ -1916,12 +1916,13 @@ void undo_time(long step, int sec, int file, int absolute) while (uhp != NULL) { uhp->uh_walk = mark; - if (dosec) - val = (long)(uhp->uh_time - starttime); - else if (dofile) + if (dosec) { + val = (long)(uhp->uh_time); + } else if (dofile) { val = uhp->uh_save_nr; - else + } else { val = uhp->uh_seq; + } if (round == 1 && !(dofile && val == 0)) { /* Remember the header that is closest to the target. diff --git a/src/nvim/version.c b/src/nvim/version.c index 1ecda654d1..fa179b4f63 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -803,7 +803,7 @@ static const int included_patches[] = { // 152 NA // 151, 150, - // 149, + 149, // 148, 147, 146, -- cgit From 9506ee037083ff047a3601b3d97acf91521a58fb Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 8 Aug 2017 20:50:41 +0200 Subject: buf_write(): wrong argument to os_fileinfo_hardlinks This was broken in ye olde refactor from 2014: e85fe0957d40080f43cbfcbe9eb8864475325b09 References #4370 --- src/nvim/fileio.c | 6 ++++-- src/nvim/os/fs.c | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index a0536d456d..643020df5e 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -3162,8 +3162,8 @@ nobackup: #ifdef UNIX FileInfo file_info; - /* Don't delete the file when it's a hard or symbolic link. */ - if ((!newfile && os_fileinfo_hardlinks(&file_info) > 1) + // Don't delete the file when it's a hard or symbolic link. + if ((!newfile && os_fileinfo_hardlinks(&file_info_old) > 1) || (os_fileinfo_link((char *)fname, &file_info) && !os_fileinfo_id_equal(&file_info, &file_info_old))) { SET_ERRMSG(_("E166: Can't open linked file for writing")); @@ -4547,6 +4547,7 @@ int put_time(FILE *fd, time_t time_) /// /// @return -1 for failure, 0 for success int vim_rename(const char_u *from, const char_u *to) + FUNC_ATTR_NONNULL_ALL { int fd_in; int fd_out; @@ -4822,6 +4823,7 @@ buf_check_timestamp ( buf_T *buf, int focus /* called for GUI focus event */ ) + FUNC_ATTR_NONNULL_ALL { int retval = 0; char_u *path; diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 14dacd97c4..9e3025cf89 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -131,6 +131,7 @@ bool os_isdir(const char_u *name) /// NODE_WRITABLE: writable device, socket, fifo, etc. /// NODE_OTHER: non-writable things int os_nodetype(const char *name) + FUNC_ATTR_NONNULL_ALL { #ifdef WIN32 // Edge case from Vim os_win32.c: -- cgit From 9854fc4657d7cd0791f8abd7c9128fdf20d14d15 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 8 Aug 2017 20:29:41 +0200 Subject: oldtest: use TMPDIR --- src/nvim/testdir/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 944222dbb6..7f1e25900b 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -3,10 +3,12 @@ # NVIM_PRG ?= ../../../build/bin/nvim +TMPDIR ?= Xtest-tmpdir SCRIPTSOURCE := ../../../runtime export SHELL := sh export NVIM_PRG := $(NVIM_PRG) +export TMPDIR SCRIPTS ?= \ test13.out \ @@ -149,10 +151,12 @@ clean: .*.swp \ .*.swo \ .gdbinit \ + $(TMPDIR) \ del test1.out: .gdbinit test1.in -rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize + mkdir -p $(TMPDIR) $(RUN_VIM) $*.in @/bin/sh -c "if test -e wrongtermsize; then \ echo; \ @@ -170,6 +174,7 @@ test1.out: .gdbinit test1.in %.out: %.in .gdbinit -rm -rf $*.failed test.ok $(RM_ON_RUN) + mkdir -p $(TMPDIR) cp $*.ok test.ok # Sleep a moment to avoid that the xterm title is messed up. # 200 msec is sufficient, but only modern sleep supports a fraction of @@ -212,4 +217,5 @@ newtests: newtestssilent newtestssilent: $(NEW_TESTS) %.res: %.vim .gdbinit + mkdir -p $(TMPDIR) $(RUN_VIMTEST) -u NONE -S runtest.vim $*.vim -- cgit From f7e99fd8b09b574e21e377903503b7ea9bcdff15 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 9 Aug 2017 11:02:35 -0400 Subject: oldtest: test_cmdline: Complete "Xtestf" so "Xtest-tmpdir" isn't matched --- src/nvim/testdir/test_cmdline.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 09f4b942ad..bab700284f 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -2,7 +2,7 @@ func Test_complete_tab() call writefile(['testfile'], 'Xtestfile') - call feedkeys(":e Xtest\t\r", "tx") + call feedkeys(":e Xtestf\t\r", "tx") call assert_equal('testfile', getline(1)) call delete('Xtestfile') endfunc @@ -17,7 +17,7 @@ func Test_complete_wildmenu() call writefile(['testfile1'], 'Xtestfile1') call writefile(['testfile2'], 'Xtestfile2') set wildmenu - call feedkeys(":e Xtest\t\t\r", "tx") + call feedkeys(":e Xtestf\t\t\r", "tx") call assert_equal('testfile2', getline(1)) call delete('Xtestfile1') -- cgit From 17eb20b22ef9fe5e621a4b6eff1c1a83e9489645 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 9 Aug 2017 13:30:34 -0400 Subject: log: Add log_callstack_to_file() This makes it trivial to log the callstack to, e.g., stderr, which can simplify debug cycles. --- src/nvim/README.md | 5 +++-- src/nvim/log.c | 25 ++++++++++++++++--------- src/nvim/log.h | 1 + 3 files changed, 20 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/README.md b/src/nvim/README.md index 1c1c3c364e..0caf71e2c5 100644 --- a/src/nvim/README.md +++ b/src/nvim/README.md @@ -11,8 +11,9 @@ Logs Low-level log messages sink to `$NVIM_LOG_FILE`. -You can use `LOG_CALLSTACK()` anywhere in the source to log the current -stacktrace. (Currently Linux-only.) +You can use `LOG_CALLSTACK();` anywhere in the source to log the current +stacktrace. To log in an alternate file, e.g. stderr, use +`LOG_CALLSTACK_TO_FILE(FILE*)`. (Currently Linux-only.) UI events are logged at level 0 (`DEBUG_LOG_LEVEL`). diff --git a/src/nvim/log.c b/src/nvim/log.c index b64aef3cac..3baf0b2ebd 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -178,7 +178,8 @@ FILE *open_log_file(void) } #ifdef HAVE_EXECINFO_BACKTRACE -void log_callstack(const char *const func_name, const int line_num) +void log_callstack_to_file(FILE *log_file, const char *const func_name, + const int line_num) { void *trace[100]; int trace_size = backtrace(trace, ARRAY_SIZE(trace)); @@ -190,8 +191,6 @@ void log_callstack(const char *const func_name, const int line_num) } assert(24 + exepathlen < IOSIZE); // Must fit in `cmdbuf` below. - do_log(DEBUG_LOG_LEVEL, func_name, line_num, true, "trace:"); - char cmdbuf[IOSIZE + (20 * ARRAY_SIZE(trace))]; snprintf(cmdbuf, sizeof(cmdbuf), "addr2line -e %s -f -p", exepath); for (int i = 1; i < trace_size; i++) { @@ -202,12 +201,8 @@ void log_callstack(const char *const func_name, const int line_num) // Now we have a command string like: // addr2line -e /path/to/exe -f -p 0x123 0x456 ... - log_lock(); - FILE *log_file = open_log_file(); - if (log_file == NULL) { - goto end; - } - + do_log_to_file(log_file, DEBUG_LOG_LEVEL, func_name, line_num, true, + "trace:"); FILE *fp = popen(cmdbuf, "r"); char linebuf[IOSIZE]; while (fgets(linebuf, sizeof(linebuf) - 1, fp) != NULL) { @@ -218,6 +213,18 @@ void log_callstack(const char *const func_name, const int line_num) if (log_file != stderr && log_file != stdout) { fclose(log_file); } +} + +void log_callstack(const char *const func_name, const int line_num) +{ + log_lock(); + FILE *log_file = open_log_file(); + if (log_file == NULL) { + goto end; + } + + log_callstack_to_file(log_file, func_name, line_num); + end: log_unlock(); } diff --git a/src/nvim/log.h b/src/nvim/log.h index 743a8d17aa..5064d9333b 100644 --- a/src/nvim/log.h +++ b/src/nvim/log.h @@ -63,6 +63,7 @@ #ifdef HAVE_EXECINFO_BACKTRACE # define LOG_CALLSTACK() log_callstack(__func__, __LINE__) +# define LOG_CALLSTACK_TO_FILE(fp) log_callstack_to_file(fp, __func__, __LINE__) #endif #ifdef INCLUDE_GENERATED_DECLARATIONS -- cgit From ac055d677aa9eff9fca11cecb5ac7f7a4edb0265 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 8 Aug 2017 22:18:50 +0200 Subject: os_stat: return ENOENT on NULL filename arg Closes #4370 Explication: In the backtrace in #4370, we see that `buf_write()` was called with non-NULL `fname` and `sfname` arguments, but they've since _become_ NULL. #7 0x00000000004de09d in buf_write (buf=0x1dee040, fname=0x0, fname@entry=0x1e985b0 "/home/sean/src/github.com/snczl/virta/pkg/meld/segment.go", sfname=0x0, sfname@entry=0x1ddfa60 "segment.go", start=1, end=72, eap=eap@entry=0x7ffc6b032e60, append=0, forceit=0, reset_changed=1, filtering=0) at /home/travis/build/neovim/bot-ci/build/neovim/src/nvim/fileio.c:2576 This is most likely due to the code that restores those values from `buf`, which happens just before the fatal call to `os_fileinfo` ```c /* * The autocommands may have changed the name of the buffer, which may * be kept in fname, ffname and sfname. */ if (buf_ffname) ffname = buf->b_ffname; if (buf_sfname) sfname = buf->b_sfname; if (buf_fname_f) fname = buf->b_ffname; if (buf_fname_s) fname = buf->b_sfname; ``` It's worth noting that at this point `ffname` is still non-NULL, so it _could_ be used. However, our current code is purely more strict than Vim in this area, which has caused us problems before (e.g., `getdigits()`). The commentary for `struct file_buffer` clearly indicate that all of `b_ffname`, `b_sfname`, and `b_fname` may be NULL: ```c /* * b_ffname has the full path of the file (NULL for no name). * b_sfname is the name as the user typed it (or NULL). * b_fname is the same as b_sfname, unless ":cd" has been done, * then it is the same as b_ffname (NULL for no name). */ char_u *b_ffname; /* full path file name */ char_u *b_sfname; /* short file name */ char_u *b_fname; /* current file name */ ``` Vim directly calls `stat(2)` which, although it is annotated to tell the compiler that the path argument is non-NULL, does handle a NULL pointer by returning a `-1` value and setting `errno` to `EFAULT`. This satisfies Vim's check, since it treats any `-1` return from `stat(2)` to mean the file doesn't exist (at least in this code path). Note that Vim's mch_stat() implementations on win32 and solaris clearly cannot accept NULL `name`. But the codepaths that call mch_stat will NULL `name` tend to be unix-only (eg: u_read_undo)! --- src/nvim/os/fs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 9e3025cf89..6ac9d682d7 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -605,8 +605,11 @@ int os_fsync(int fd) /// /// @return libuv return code. static int os_stat(const char *name, uv_stat_t *statbuf) - FUNC_ATTR_NONNULL_ALL + FUNC_ATTR_NONNULL_ARG(2) { + if (!name) { + return UV_ENOENT; + } uv_fs_t request; int result = uv_fs_stat(&fs_loop, &request, name, NULL); *statbuf = request.statbuf; @@ -618,7 +621,6 @@ static int os_stat(const char *name, uv_stat_t *statbuf) /// /// @return libuv error code on error. int32_t os_getperm(const char *name) - FUNC_ATTR_NONNULL_ALL { uv_stat_t statbuf; int stat_result = os_stat(name, &statbuf); @@ -657,7 +659,6 @@ int os_fchown(int fd, uv_uid_t owner, uv_gid_t group) /// /// @return `true` if `path` exists bool os_path_exists(const char_u *path) - FUNC_ATTR_NONNULL_ALL { uv_stat_t statbuf; return os_stat((char *)path, &statbuf) == kLibuvSuccess; @@ -847,7 +848,7 @@ int os_remove(const char *path) /// @param[out] file_info Pointer to a FileInfo to put the information in. /// @return `true` on success, `false` for failure. bool os_fileinfo(const char *path, FileInfo *file_info) - FUNC_ATTR_NONNULL_ALL + FUNC_ATTR_NONNULL_ARG(2) { return os_stat(path, &(file_info->stat)) == kLibuvSuccess; } -- cgit From 4cd2749b102864a3e194b136cc88f4846b412dfe Mon Sep 17 00:00:00 2001 From: ckelsel Date: Thu, 10 Aug 2017 08:36:31 +0800 Subject: vim-patch:8.0.0174 Problem: For completion "locale -a" is executed on MS-Windows, even though it most likely won't work. Solution: Skip executing "locale -a" on MS-Windows. (Ken Takata) https://github.com/vim/vim/commit/b8f7bd68f6fdff51ca4db5b145dcde42ee7b804b --- src/nvim/ex_cmds2.c | 25 +++++++++++++++---------- src/nvim/version.c | 2 +- 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 1a728647ca..0fd74ccde7 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -3610,18 +3610,11 @@ void ex_language(exarg_T *eap) static char_u **locales = NULL; // Array of all available locales -static bool did_init_locales = false; -/// Lazy initialization of all available locales. -static void init_locales(void) -{ - if (!did_init_locales) { - did_init_locales = true; - locales = find_locales(); - } -} +#ifndef WIN32 +static bool did_init_locales = false; -// Return an array of strings for all available locales + NULL for the +/// Return an array of strings for all available locales + NULL for the /// last element. Return NULL in case of error. static char_u **find_locales(void) { @@ -3653,6 +3646,18 @@ static char_u **find_locales(void) ((char_u **)locales_ga.ga_data)[locales_ga.ga_len] = NULL; return (char_u **)locales_ga.ga_data; } +#endif + +/// Lazy initialization of all available locales. +static void init_locales(void) +{ +#ifndef WIN32 + if (!did_init_locales) { + did_init_locales = true; + locales = find_locales(); + } +#endif +} # if defined(EXITFREE) void free_locales(void) diff --git a/src/nvim/version.c b/src/nvim/version.c index fa179b4f63..bc5035f215 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -778,7 +778,7 @@ static const int included_patches[] = { 177, 176, // 175, - // 174, + 174, // 173 NA 172, // 171, -- cgit From 7ae744b93d80fd169507732931606276844150b6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 10 Aug 2017 01:40:21 +0200 Subject: buf_write(): handle NULL fname on non-unix --- src/nvim/fileio.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 643020df5e..feb16f44d4 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2570,11 +2570,9 @@ buf_write ( perm = -1; } } -#else /* win32 */ - /* - * Check for a writable device name. - */ - c = os_nodetype((char *)fname); +#else // win32 + // Check for a writable device name. + c = fname == NULL ? NODE_OTHER : os_nodetype((char *)fname); if (c == NODE_OTHER) { SET_ERRMSG_NUM("E503", _("is not a file or writable device")); goto fail; @@ -2594,9 +2592,8 @@ buf_write ( if (overwriting) { os_fileinfo((char *)fname, &file_info_old); } - } -#endif /* !UNIX */ +#endif // !UNIX if (!device && !newfile) { /* -- cgit From b7e84de7d2385670aadcea9c02bc68206db98862 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Thu, 10 Aug 2017 10:20:55 +0800 Subject: vim-patch:8.0.0165 (#7132) Problem: Ubsan warns for integer overflow. Solution: Swap two conditions. (Dominique Pelle) https://github.com/vim/vim/commit/f446b48ff0bffae2b453cd4f9e3c25dfe363d29d --- src/nvim/regexp_nfa.c | 16 ++++++++-------- src/nvim/version.c | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 5d708febea..93ba9ce097 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -56,13 +56,13 @@ enum { NFA_RANGE_MIN, /* low end of a range */ NFA_RANGE_MAX, /* high end of a range */ - NFA_CONCAT, /* concatenate two previous items (postfix - * only) */ - NFA_OR, /* \| (postfix only) */ - NFA_STAR, /* greedy * (posfix only) */ - NFA_STAR_NONGREEDY, /* non-greedy * (postfix only) */ - NFA_QUEST, /* greedy \? (postfix only) */ - NFA_QUEST_NONGREEDY, /* non-greedy \? (postfix only) */ + NFA_CONCAT, // concatenate two previous items (postfix + // only) + NFA_OR, // \| (postfix only) + NFA_STAR, // greedy * (postfix only) + NFA_STAR_NONGREEDY, // non-greedy * (postfix only) + NFA_QUEST, // greedy \? (postfix only) + NFA_QUEST_NONGREEDY, // non-greedy \? (postfix only) NFA_BOL, /* ^ Begin line */ NFA_EOL, /* $ End line */ @@ -1988,7 +1988,7 @@ static int nfa_regpiece(void) // The engine is very inefficient (uses too many states) when the maximum // is much larger than the minimum and when the maximum is large. Bail out // if we can use the other engine. - if ((nfa_re_flags & RE_AUTO) && (maxval > minval + 200 || maxval > 500)) { + if ((nfa_re_flags & RE_AUTO) && (maxval > 500 || maxval > minval + 200)) { return FAIL; } diff --git a/src/nvim/version.c b/src/nvim/version.c index fa179b4f63..72af7dbafd 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -787,7 +787,7 @@ static const int included_patches[] = { 168, 167, // 166, - // 165, + 165, // 164, // 163 NA // 162 NA -- cgit From 9edf00bddf6802044e06bd15daad4a5735ccade8 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 11 Aug 2017 10:30:38 -0400 Subject: coverity/166184: Check length of str, not term 32396b5879b429def1c48948069c55366d41b9be add length checks to TERMINAL_FAMILY/STARTS_WITH to ensure memcmp() wouldn't read past the end of the string. However, "term" was copy/pasted from TERMINAL_FAMILY so STARTS_WITH() was unnecessarily reading the, potentially NULL, term variable. --- src/nvim/tui/tui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index c29ec09638..97a0398c80 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -45,7 +45,7 @@ #define OUTBUF_SIZE 0xffff #define TOO_MANY_EVENTS 1000000 -#define STARTS_WITH(str, prefix) (strlen(term) >= (sizeof(prefix) - 1) \ +#define STARTS_WITH(str, prefix) (strlen(str) >= (sizeof(prefix) - 1) \ && 0 == memcmp((str), (prefix), sizeof(prefix) - 1)) #define TMUX_WRAP(is_tmux, seq) ((is_tmux) \ ? "\x1bPtmux;\x1b" seq "\x1b\\" : seq) -- cgit From df02f9cc37be38b8189991f9e76bfcafa6e271c6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 29 Jul 2017 01:51:08 +0200 Subject: vim-patch:8.0.0090 fix breakindent bug (original Vim commit-message is bogus) https://github.com/vim/vim/commit/6c896867c4f5d759616028ef7cbfce2a9ed32600 --- src/nvim/screen.c | 8 +- src/nvim/testdir/test_breakindent.vim | 241 ++++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 247 insertions(+), 4 deletions(-) create mode 100644 src/nvim/testdir/test_breakindent.vim (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index cd4f4de40f..e3a2c1ffec 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2195,7 +2195,7 @@ win_line ( int change_start = MAXCOL; /* first col of changed area */ int change_end = -1; /* last col of changed area */ colnr_T trailcol = MAXCOL; /* start of trailing spaces */ - int need_showbreak = FALSE; + int need_showbreak = false; // overlong line, skip first x chars int line_attr = 0; /* attribute for the whole line */ matchitem_T *cur; /* points to the match list */ match_T *shl; /* points to search_hl or a match */ @@ -2805,8 +2805,10 @@ win_line ( // draw 'breakindent': indent wrapped text accodringly if (draw_state == WL_BRI - 1 && n_extra == 0) { draw_state = WL_BRI; - if (wp->w_p_bri && row != startrow && filler_lines == 0) { - char_attr = wp->w_hl_attr_normal; // was: hl_attr(HLF_AT); + // if need_showbreak is set, breakindent also applies + if (wp->w_p_bri && (row != startrow || need_showbreak) + && filler_lines == 0) { + char_attr = wp->w_hl_attr_normal; if (diff_hlf != (hlf_T)0) { char_attr = win_hl_attr(wp, diff_hlf); diff --git a/src/nvim/testdir/test_breakindent.vim b/src/nvim/testdir/test_breakindent.vim new file mode 100644 index 0000000000..bf363dcf8c --- /dev/null +++ b/src/nvim/testdir/test_breakindent.vim @@ -0,0 +1,241 @@ +" Test for breakindent +" +" Note: if you get strange failures when adding new tests, it might be that +" while the test is run, the breakindent cacheing gets in its way. +" It helps to change the tabastop setting and force a redraw (e.g. see +" Test_breakindent08()) +if !exists('+breakindent') + finish +endif + +let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP" + +function s:screenline(lnum, width) abort + " always get 4 screen lines + redraw! + let line = [] + for j in range(3) + for c in range(1, a:width) + call add(line, nr2char(screenchar(a:lnum+j, c))) + endfor + call add(line, "\n") + endfor + return join(line, '') +endfunction + +function s:testwindows(...) + 10new + vsp + vert resize 20 + setl ts=4 sw=4 sts=4 breakindent + put =s:input + if a:0 + exe a:1 + endif +endfunction + +function s:close_windows(...) + bw! + if a:0 + exe a:1 + endif + unlet! g:line g:expect +endfunction + +function Test_breakindent01() + " simple breakindent test + call s:testwindows('setl briopt=min:0') + let g:line=s:screenline(line('.'),8) + let g:expect=" abcd\n qrst\n GHIJ\n" + call assert_equal(g:expect, g:line) + call s:close_windows() +endfunction + +function Test_breakindent02() + " simple breakindent test with showbreak set + call s:testwindows('setl briopt=min:0 sbr=>>') + let g:line=s:screenline(line('.'),8) + let g:expect=" abcd\n >>qr\n >>EF\n" + call assert_equal(g:expect, g:line) + call s:close_windows('set sbr=') +endfunction + +function Test_breakindent03() + " simple breakindent test with showbreak set and briopt including sbr + call s:testwindows('setl briopt=sbr,min:0 sbr=++') + let g:line=s:screenline(line('.'),8) + let g:expect=" abcd\n++ qrst\n++ GHIJ\n" + call assert_equal(g:expect, g:line) + " clean up + call s:close_windows('set sbr=') +endfunction + +function Test_breakindent04() + " breakindent set with min width 18 + call s:testwindows('setl sbr= briopt=min:18') + let g:line=s:screenline(line('.'),8) + let g:expect=" abcd\n qrstuv\n IJKLMN\n" + call assert_equal(g:expect, g:line) + " clean up + call s:close_windows('set sbr=') +endfunction + +function Test_breakindent05() + " breakindent set and shift by 2 + call s:testwindows('setl briopt=shift:2,min:0') + let g:line=s:screenline(line('.'),8) + let g:expect=" abcd\n qr\n EF\n" + call assert_equal(g:expect, g:line) + call s:close_windows() +endfunction + +function Test_breakindent06() + " breakindent set and shift by -1 + call s:testwindows('setl briopt=shift:-1,min:0') + let g:line=s:screenline(line('.'),8) + let g:expect=" abcd\n qrstu\n HIJKL\n" + call assert_equal(g:expect, g:line) + call s:close_windows() +endfunction + +function Test_breakindent07() + " breakindent set and shift by 1, Number set sbr=? and briopt:sbr + call s:testwindows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n') + let g:line=s:screenline(line('.'),10) + let g:expect=" 2 ab\n? m\n? x\n" + call assert_equal(g:expect, g:line) + " clean up + call s:close_windows('set sbr= cpo-=n') +endfunction + +function Test_breakindent07a() + " breakindent set and shift by 1, Number set sbr=? and briopt:sbr + call s:testwindows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4') + let g:line=s:screenline(line('.'),10) + let g:expect=" 2 ab\n ? m\n ? x\n" + call assert_equal(g:expect, g:line) + " clean up + call s:close_windows('set sbr=') +endfunction + +function Test_breakindent08() + " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr + call s:testwindows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4') + " make sure, cache is invalidated! + set ts=8 + redraw! + set ts=4 + redraw! + let g:line=s:screenline(line('.'),10) + let g:expect=" 2 ^Iabcd\n# opq\n# BCD\n" + call assert_equal(g:expect, g:line) + call s:close_windows('set sbr= cpo-=n') +endfunction + +function Test_breakindent08a() + " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr + call s:testwindows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list') + let g:line=s:screenline(line('.'),10) + let g:expect=" 2 ^Iabcd\n # opq\n # BCD\n" + call assert_equal(g:expect, g:line) + call s:close_windows('set sbr=') +endfunction + +function Test_breakindent09() + " breakindent set and shift by 1, Number and list set sbr=# + call s:testwindows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list') + let g:line=s:screenline(line('.'),10) + let g:expect=" 2 ^Iabcd\n #op\n #AB\n" + call assert_equal(g:expect, g:line) + call s:close_windows('set sbr=') +endfunction + +function Test_breakindent10() + " breakindent set, Number set sbr=~ + call s:testwindows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0') + " make sure, cache is invalidated! + set ts=8 + redraw! + set ts=4 + redraw! + let g:line=s:screenline(line('.'),10) + let g:expect=" 2 ab\n~ mn\n~ yz\n" + call assert_equal(g:expect, g:line) + call s:close_windows('set sbr= cpo-=n') +endfunction + +function Test_breakindent11() + " test strdisplaywidth() + call s:testwindows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4') + let text=getline(2) + let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times + call assert_equal(width, strdisplaywidth(text)) + call s:close_windows('set sbr=') +endfunction + +function Test_breakindent12() + " test breakindent with long indent + let s:input="\t\t\t\t\t{" + call s:testwindows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>-') + let g:line=s:screenline(2,16) + let g:expect=" 2 >--->--->--->\n ---{ \n~ \n" + call assert_equal(g:expect, g:line) + call s:close_windows('set nuw=4 listchars=') +endfunction + +function Test_breakindent13() + let s:input="" + call s:testwindows('setl breakindent briopt=min:10 ts=8') + vert resize 20 + call setline(1, [" a\tb\tc\td\te", " z y x w v"]) + 1 + norm! fbgj"ayl + 2 + norm! fygj"byl + call assert_equal('d', @a) + call assert_equal('w', @b) + call s:close_windows() +endfunction + +function Test_breakindent14() + let s:input="" + call s:testwindows('setl breakindent briopt= ts=8') + vert resize 30 + norm! 3a1234567890 + norm! a abcde + exec "norm! 0\tex" + let g:line=s:screenline(line('.'),8) + let g:expect="e \n~ \n~ \n" + call assert_equal(g:expect, g:line) + call s:close_windows() +endfunction + +function Test_breakindent15() + let s:input="" + call s:testwindows('setl breakindent briopt= ts=8 sw=8') + vert resize 30 + norm! 4a1234567890 + exe "normal! >>\3f0x" + let g:line=s:screenline(line('.'),20) + let g:expect=" 1234567890 \n~ \n~ \n" + call assert_equal(g:expect, g:line) + call s:close_windows() +endfunction + +function Test_breakindent16() + " Check that overlong lines are indented correctly. + " TODO: currently it does not fail even when the bug is not fixed. + let s:input="" + call s:testwindows('setl breakindent briopt=min:0 ts=4') + call setline(1, "\t".repeat("1234567890", 10)) + resize 6 + norm! 1gg$ + redraw! + let g:line=s:screenline(1,10) + let g:expect=" 123456\n 789012\n 345678\n" + call assert_equal(g:expect, g:line) + let g:line=s:screenline(4,10) + let g:expect=" 901234\n 567890\n 123456\n" + call assert_equal(g:expect, g:line) + call s:close_windows() +endfunction diff --git a/src/nvim/version.c b/src/nvim/version.c index 72af7dbafd..69d5cb8e8d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -862,7 +862,7 @@ static const int included_patches[] = { // 93 NA // 92, // 91, - // 90, + 90, // 89 NA 88, // 87 NA -- cgit From 1bcb3ed0e29e924167c8429fde2338dd9a6c29d4 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 29 Jul 2017 02:26:21 +0200 Subject: vim-patch:8.0.0126 Problem: Display problem with 'foldcolumn' and a wide character. (esiegerman) Solution: Don't use "extra" but an allocated buffer. (Christian Brabandt, closes vim/vim#1310) https://github.com/vim/vim/commit/6270660611a151c5d0f614a5f0248ccdc80ed971 --- src/nvim/screen.c | 19 ++++++++++++------- src/nvim/testdir/test_display.vim | 37 +++++++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 src/nvim/testdir/test_display.vim (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index e3a2c1ffec..3d558bdbdd 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2705,13 +2705,18 @@ win_line ( draw_state = WL_FOLD; if (fdc > 0) { - // Draw the 'foldcolumn'. - fill_foldcolumn(extra, wp, false, lnum); - n_extra = fdc; - p_extra = extra; - p_extra[n_extra] = NUL; - c_extra = NUL; - char_attr = win_hl_attr(wp, HLF_FC); + // Draw the 'foldcolumn'. Allocate a buffer, "extra" may + // already be in used. + p_extra_free = xmalloc(12 + 1); + + if (p_extra_free != NULL) { + fill_foldcolumn(p_extra_free, wp, false, lnum); + n_extra = fdc; + p_extra_free[n_extra] = NUL; + p_extra = p_extra_free; + c_extra = NUL; + char_attr = win_hl_attr(wp, HLF_FC); + } } } diff --git a/src/nvim/testdir/test_display.vim b/src/nvim/testdir/test_display.vim new file mode 100644 index 0000000000..ba7b7d7626 --- /dev/null +++ b/src/nvim/testdir/test_display.vim @@ -0,0 +1,37 @@ +" Test for displaying stuff +if !has('gui_running') && has('unix') + set term=ansi +endif + +function! s:screenline(lnum, nr) abort + let line = [] + for j in range(a:nr) + for c in range(1, winwidth(0)) + call add(line, nr2char(screenchar(a:lnum+j, c))) + endfor + call add(line, "\n") + endfor + return join(line, '') +endfunction + +function! Test_display_foldcolumn() + new + vnew + vert resize 25 + + 1put='e more noise blah blah‚ more stuff here' + + let expect = "e more noise blah blah<82\n> more stuff here \n" + + call cursor(2, 1) + norm! zt + redraw! + call assert_equal(expect, s:screenline(1,2)) + set fdc=2 + redraw! + let expect = " e more noise blah blah<\n 82> more stuff here \n" + call assert_equal(expect, s:screenline(1,2)) + + quit! + quit! +endfunction diff --git a/src/nvim/version.c b/src/nvim/version.c index 69d5cb8e8d..ca1d64ac56 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -826,7 +826,7 @@ static const int included_patches[] = { // 129 NA // 128, 127, - // 126, + 126, // 125, 124, // 123 NA -- cgit From b7320471de524ffa0e2ba3f561e4c117c1600b62 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 29 Jul 2017 02:30:54 +0200 Subject: vim-patch:8.0.0128 Problem: Display test fails on MS-Windows. Solution: Set 'isprint' to "@". https://github.com/vim/vim/commit/7089237885218eb8a19805bc2b75481c4efcd6ba --- src/nvim/testdir/test_display.vim | 2 ++ src/nvim/version.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_display.vim b/src/nvim/testdir/test_display.vim index ba7b7d7626..609e16c737 100644 --- a/src/nvim/testdir/test_display.vim +++ b/src/nvim/testdir/test_display.vim @@ -18,6 +18,8 @@ function! Test_display_foldcolumn() new vnew vert resize 25 + call assert_equal(25, winwidth(winnr())) + set isprint=@ 1put='e more noise blah blah‚ more stuff here' diff --git a/src/nvim/version.c b/src/nvim/version.c index ca1d64ac56..dfee84c1b2 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -824,7 +824,7 @@ static const int included_patches[] = { // 131, // 130 NA // 129 NA - // 128, + 128, 127, 126, // 125, -- cgit From c747b53f84bfd64ec9f36d4b5912a980a6da8b3e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 29 Jul 2017 01:46:43 +0200 Subject: vim-patch:8.0.0311 Problem: Linebreak tests are old style. Solution: Turn the tests into new style. Share utility functions. (Ozaki Kiichi, closes vim/vim#1444) https://github.com/vim/vim/commit/544d3bc9f0e494cb712a33b61558b8e8e12b1e0b --- src/nvim/testdir/test_breakindent.vim | 250 ++++++++++++++++++++------------- src/nvim/testdir/test_listlbr.vim | 219 +++++++++++++++++++++++++++++ src/nvim/testdir/test_listlbr_utf8.vim | 195 +++++++++++++++++++++++++ src/nvim/testdir/view_util.vim | 30 ++++ src/nvim/version.c | 2 +- 5 files changed, 599 insertions(+), 97 deletions(-) create mode 100644 src/nvim/testdir/test_listlbr.vim create mode 100644 src/nvim/testdir/test_listlbr_utf8.vim create mode 100644 src/nvim/testdir/view_util.vim (limited to 'src') diff --git a/src/nvim/testdir/test_breakindent.vim b/src/nvim/testdir/test_breakindent.vim index bf363dcf8c..8721b35cdf 100644 --- a/src/nvim/testdir/test_breakindent.vim +++ b/src/nvim/testdir/test_breakindent.vim @@ -2,171 +2,209 @@ " " Note: if you get strange failures when adding new tests, it might be that " while the test is run, the breakindent cacheing gets in its way. -" It helps to change the tabastop setting and force a redraw (e.g. see +" It helps to change the tabstop setting and force a redraw (e.g. see " Test_breakindent08()) if !exists('+breakindent') finish endif +source view_util.vim + let s:input ="\tabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP" -function s:screenline(lnum, width) abort - " always get 4 screen lines - redraw! - let line = [] - for j in range(3) - for c in range(1, a:width) - call add(line, nr2char(screenchar(a:lnum+j, c))) - endfor - call add(line, "\n") - endfor - return join(line, '') -endfunction - -function s:testwindows(...) - 10new - vsp - vert resize 20 - setl ts=4 sw=4 sts=4 breakindent +function s:screen_lines(lnum, width) abort + return ScreenLines([a:lnum, a:lnum + 2], a:width) +endfunction + +function! s:compare_lines(expect, actual) + call assert_equal(join(a:expect, "\n"), join(a:actual, "\n")) +endfunction + +function s:test_windows(...) + call NewWindow(10, 20) + setl ts=4 sw=4 sts=4 breakindent put =s:input - if a:0 - exe a:1 - endif + exe get(a:000, 0, '') endfunction function s:close_windows(...) - bw! - if a:0 - exe a:1 - endif - unlet! g:line g:expect + call CloseWindow() + exe get(a:000, 0, '') endfunction function Test_breakindent01() " simple breakindent test - call s:testwindows('setl briopt=min:0') - let g:line=s:screenline(line('.'),8) - let g:expect=" abcd\n qrst\n GHIJ\n" - call assert_equal(g:expect, g:line) + call s:test_windows('setl briopt=min:0') + let lines=s:screen_lines(line('.'),8) + let expect=[ +\ " abcd", +\ " qrst", +\ " GHIJ", +\ ] + call s:compare_lines(expect, lines) call s:close_windows() endfunction function Test_breakindent02() " simple breakindent test with showbreak set - call s:testwindows('setl briopt=min:0 sbr=>>') - let g:line=s:screenline(line('.'),8) - let g:expect=" abcd\n >>qr\n >>EF\n" - call assert_equal(g:expect, g:line) + call s:test_windows('setl briopt=min:0 sbr=>>') + let lines=s:screen_lines(line('.'),8) + let expect=[ +\ " abcd", +\ " >>qr", +\ " >>EF", +\ ] + call s:compare_lines(expect, lines) call s:close_windows('set sbr=') endfunction function Test_breakindent03() " simple breakindent test with showbreak set and briopt including sbr - call s:testwindows('setl briopt=sbr,min:0 sbr=++') - let g:line=s:screenline(line('.'),8) - let g:expect=" abcd\n++ qrst\n++ GHIJ\n" - call assert_equal(g:expect, g:line) + call s:test_windows('setl briopt=sbr,min:0 sbr=++') + let lines=s:screen_lines(line('.'),8) + let expect=[ +\ " abcd", +\ "++ qrst", +\ "++ GHIJ", +\ ] + call s:compare_lines(expect, lines) " clean up call s:close_windows('set sbr=') endfunction function Test_breakindent04() " breakindent set with min width 18 - call s:testwindows('setl sbr= briopt=min:18') - let g:line=s:screenline(line('.'),8) - let g:expect=" abcd\n qrstuv\n IJKLMN\n" - call assert_equal(g:expect, g:line) + call s:test_windows('setl sbr= briopt=min:18') + let lines=s:screen_lines(line('.'),8) + let expect=[ +\ " abcd", +\ " qrstuv", +\ " IJKLMN", +\ ] + call s:compare_lines(expect, lines) " clean up call s:close_windows('set sbr=') endfunction function Test_breakindent05() " breakindent set and shift by 2 - call s:testwindows('setl briopt=shift:2,min:0') - let g:line=s:screenline(line('.'),8) - let g:expect=" abcd\n qr\n EF\n" - call assert_equal(g:expect, g:line) + call s:test_windows('setl briopt=shift:2,min:0') + let lines=s:screen_lines(line('.'),8) + let expect=[ +\ " abcd", +\ " qr", +\ " EF", +\ ] + call s:compare_lines(expect, lines) call s:close_windows() endfunction function Test_breakindent06() " breakindent set and shift by -1 - call s:testwindows('setl briopt=shift:-1,min:0') - let g:line=s:screenline(line('.'),8) - let g:expect=" abcd\n qrstu\n HIJKL\n" - call assert_equal(g:expect, g:line) + call s:test_windows('setl briopt=shift:-1,min:0') + let lines=s:screen_lines(line('.'),8) + let expect=[ +\ " abcd", +\ " qrstu", +\ " HIJKL", +\ ] + call s:compare_lines(expect, lines) call s:close_windows() endfunction function Test_breakindent07() " breakindent set and shift by 1, Number set sbr=? and briopt:sbr - call s:testwindows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n') - let g:line=s:screenline(line('.'),10) - let g:expect=" 2 ab\n? m\n? x\n" - call assert_equal(g:expect, g:line) + call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4 cpo+=n') + let lines=s:screen_lines(line('.'),10) + let expect=[ +\ " 2 ab", +\ "? m", +\ "? x", +\ ] + call s:compare_lines(expect, lines) " clean up call s:close_windows('set sbr= cpo-=n') endfunction function Test_breakindent07a() " breakindent set and shift by 1, Number set sbr=? and briopt:sbr - call s:testwindows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4') - let g:line=s:screenline(line('.'),10) - let g:expect=" 2 ab\n ? m\n ? x\n" - call assert_equal(g:expect, g:line) + call s:test_windows('setl briopt=shift:1,sbr,min:0 nu sbr=? nuw=4') + let lines=s:screen_lines(line('.'),10) + let expect=[ +\ " 2 ab", +\ " ? m", +\ " ? x", +\ ] + call s:compare_lines(expect, lines) " clean up call s:close_windows('set sbr=') endfunction function Test_breakindent08() " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr - call s:testwindows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4') + call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list cpo+=n ts=4') " make sure, cache is invalidated! set ts=8 redraw! set ts=4 redraw! - let g:line=s:screenline(line('.'),10) - let g:expect=" 2 ^Iabcd\n# opq\n# BCD\n" - call assert_equal(g:expect, g:line) + let lines=s:screen_lines(line('.'),10) + let expect=[ +\ " 2 ^Iabcd", +\ "# opq", +\ "# BCD", +\ ] + call s:compare_lines(expect, lines) call s:close_windows('set sbr= cpo-=n') endfunction function Test_breakindent08a() " breakindent set and shift by 1, Number and list set sbr=# and briopt:sbr - call s:testwindows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list') - let g:line=s:screenline(line('.'),10) - let g:expect=" 2 ^Iabcd\n # opq\n # BCD\n" - call assert_equal(g:expect, g:line) + call s:test_windows('setl briopt=shift:1,sbr,min:0 nu nuw=4 sbr=# list') + let lines=s:screen_lines(line('.'),10) + let expect=[ +\ " 2 ^Iabcd", +\ " # opq", +\ " # BCD", +\ ] + call s:compare_lines(expect, lines) call s:close_windows('set sbr=') endfunction function Test_breakindent09() " breakindent set and shift by 1, Number and list set sbr=# - call s:testwindows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list') - let g:line=s:screenline(line('.'),10) - let g:expect=" 2 ^Iabcd\n #op\n #AB\n" - call assert_equal(g:expect, g:line) + call s:test_windows('setl briopt=shift:1,min:0 nu nuw=4 sbr=# list') + let lines=s:screen_lines(line('.'),10) + let expect=[ +\ " 2 ^Iabcd", +\ " #op", +\ " #AB", +\ ] + call s:compare_lines(expect, lines) call s:close_windows('set sbr=') endfunction function Test_breakindent10() " breakindent set, Number set sbr=~ - call s:testwindows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0') + call s:test_windows('setl cpo+=n sbr=~ nu nuw=4 nolist briopt=sbr,min:0') " make sure, cache is invalidated! set ts=8 redraw! set ts=4 redraw! - let g:line=s:screenline(line('.'),10) - let g:expect=" 2 ab\n~ mn\n~ yz\n" - call assert_equal(g:expect, g:line) + let lines=s:screen_lines(line('.'),10) + let expect=[ +\ " 2 ab", +\ "~ mn", +\ "~ yz", +\ ] + call s:compare_lines(expect, lines) call s:close_windows('set sbr= cpo-=n') endfunction function Test_breakindent11() " test strdisplaywidth() - call s:testwindows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4') + call s:test_windows('setl cpo-=n sbr=>> nu nuw=4 nolist briopt= ts=4') let text=getline(2) let width = strlen(text[1:])+indent(2)+strlen(&sbr)*3 " text wraps 3 times call assert_equal(width, strdisplaywidth(text)) @@ -176,16 +214,20 @@ endfunction function Test_breakindent12() " test breakindent with long indent let s:input="\t\t\t\t\t{" - call s:testwindows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>-') - let g:line=s:screenline(2,16) - let g:expect=" 2 >--->--->--->\n ---{ \n~ \n" - call assert_equal(g:expect, g:line) + call s:test_windows('setl breakindent linebreak briopt=min:10 nu numberwidth=3 ts=4 list listchars=tab:>-') + let lines=s:screen_lines(2,16) + let expect=[ +\ " 2 >--->--->--->", +\ " ---{ ", +\ "~ ", +\ ] + call s:compare_lines(expect, lines) call s:close_windows('set nuw=4 listchars=') endfunction function Test_breakindent13() let s:input="" - call s:testwindows('setl breakindent briopt=min:10 ts=8') + call s:test_windows('setl breakindent briopt=min:10 ts=8') vert resize 20 call setline(1, [" a\tb\tc\td\te", " z y x w v"]) 1 @@ -199,26 +241,34 @@ endfunction function Test_breakindent14() let s:input="" - call s:testwindows('setl breakindent briopt= ts=8') + call s:test_windows('setl breakindent briopt= ts=8') vert resize 30 norm! 3a1234567890 norm! a abcde exec "norm! 0\tex" - let g:line=s:screenline(line('.'),8) - let g:expect="e \n~ \n~ \n" - call assert_equal(g:expect, g:line) + let lines=s:screen_lines(line('.'),8) + let expect=[ +\ "e ", +\ "~ ", +\ "~ ", +\ ] + call s:compare_lines(expect, lines) call s:close_windows() endfunction function Test_breakindent15() let s:input="" - call s:testwindows('setl breakindent briopt= ts=8 sw=8') + call s:test_windows('setl breakindent briopt= ts=8 sw=8') vert resize 30 norm! 4a1234567890 exe "normal! >>\3f0x" - let g:line=s:screenline(line('.'),20) - let g:expect=" 1234567890 \n~ \n~ \n" - call assert_equal(g:expect, g:line) + let lines=s:screen_lines(line('.'),20) + let expect=[ +\ " 1234567890 ", +\ "~ ", +\ "~ ", +\ ] + call s:compare_lines(expect, lines) call s:close_windows() endfunction @@ -226,16 +276,24 @@ function Test_breakindent16() " Check that overlong lines are indented correctly. " TODO: currently it does not fail even when the bug is not fixed. let s:input="" - call s:testwindows('setl breakindent briopt=min:0 ts=4') + call s:test_windows('setl breakindent briopt=min:0 ts=4') call setline(1, "\t".repeat("1234567890", 10)) resize 6 norm! 1gg$ redraw! - let g:line=s:screenline(1,10) - let g:expect=" 123456\n 789012\n 345678\n" - call assert_equal(g:expect, g:line) - let g:line=s:screenline(4,10) - let g:expect=" 901234\n 567890\n 123456\n" - call assert_equal(g:expect, g:line) + let lines=s:screen_lines(1,10) + let expect=[ +\ " 123456", +\ " 789012", +\ " 345678", +\ ] + call s:compare_lines(expect, lines) + let lines=s:screen_lines(4,10) + let expect=[ +\ " 901234", +\ " 567890", +\ " 123456", +\ ] + call s:compare_lines(expect, lines) call s:close_windows() endfunction diff --git a/src/nvim/testdir/test_listlbr.vim b/src/nvim/testdir/test_listlbr.vim new file mode 100644 index 0000000000..71366a161e --- /dev/null +++ b/src/nvim/testdir/test_listlbr.vim @@ -0,0 +1,219 @@ +" Test for linebreak and list option (non-utf8) + +set encoding=latin1 +scriptencoding latin1 + +if !exists("+linebreak") || !has("conceal") + finish +endif + +source view_util.vim + +function s:screen_lines(lnum, width) abort + return ScreenLines(a:lnum, a:width) +endfunction + +function! s:compare_lines(expect, actual) + call assert_equal(join(a:expect, "\n"), join(a:actual, "\n")) +endfunction + +function s:test_windows(...) + call NewWindow(10, 20) + setl ts=8 sw=4 sts=4 linebreak sbr= wrap + exe get(a:000, 0, '') +endfunction + +function s:close_windows(...) + call CloseWindow() + exe get(a:000, 0, '') +endfunction + +func Test_set_linebreak() + call s:test_windows('setl ts=4 sbr=+') + call setline(1, "\tabcdef hijklmn\tpqrstuvwxyz_1060ABCDEFGHIJKLMNOP ") + let lines = s:screen_lines([1, 4], winwidth(0)) + let expect = [ +\ " abcdef ", +\ "+hijklmn ", +\ "+pqrstuvwxyz_1060ABC", +\ "+DEFGHIJKLMNOP ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_linebreak_with_list() + call s:test_windows('setl ts=4 sbr=+ list listchars=') + call setline(1, "\tabcdef hijklmn\tpqrstuvwxyz_1060ABCDEFGHIJKLMNOP ") + let lines = s:screen_lines([1, 4], winwidth(0)) + let expect = [ +\ "^Iabcdef hijklmn^I ", +\ "+pqrstuvwxyz_1060ABC", +\ "+DEFGHIJKLMNOP ", +\ "~ ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_linebreak_with_nolist() + call s:test_windows('setl ts=4 sbr=+ nolist') + call setline(1, "\tabcdef hijklmn\tpqrstuvwxyz_1060ABCDEFGHIJKLMNOP ") + let lines = s:screen_lines([1, 4], winwidth(0)) + let expect = [ +\ " abcdef ", +\ "+hijklmn ", +\ "+pqrstuvwxyz_1060ABC", +\ "+DEFGHIJKLMNOP ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_should_break() + call s:test_windows('setl sbr=+ nolist') + call setline(1, "1\t" . repeat('a', winwidth(0)-2)) + let lines = s:screen_lines([1, 4], winwidth(0)) + let expect = [ +\ "1 ", +\ "+aaaaaaaaaaaaaaaaaa ", +\ "~ ", +\ "~ ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_linebreak_with_conceal() + call s:test_windows('setl cpo&vim sbr=+ list conceallevel=2 concealcursor=nv listchars=tab:ab') + call setline(1, "_S_\t bla") + syn match ConcealVar contained /_/ conceal + syn match All /.*/ contains=ConcealVar + let lines = s:screen_lines([1, 4], winwidth(0)) + let expect = [ +\ "Sabbbbbb bla ", +\ "~ ", +\ "~ ", +\ "~ ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_virtual_block() + call s:test_windows('setl sbr=+') + call setline(1, [ +\ "REMOVE: this not", +\ "REMOVE: aaaaaaaaaaaaa", +\ ]) + exe "norm! 1/^REMOVE:" + exe "norm! 0\jf x" + $put + let lines = s:screen_lines([1, 4], winwidth(0)) + let expect = [ +\ "this not ", +\ "aaaaaaaaaaaaa ", +\ "REMOVE: ", +\ "REMOVE: ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_virtual_block_and_vbA() + call s:test_windows() + call setline(1, "long line: " . repeat("foobar ", 40) . "TARGET at end") + exe "norm! $3B\eAx\" + let lines = s:screen_lines([1, 10], winwidth(0)) + let expect = [ +\ "foobar foobar ", +\ "foobar foobar ", +\ "foobar foobar ", +\ "foobar foobar ", +\ "foobar foobar ", +\ "foobar foobar ", +\ "foobar foobar ", +\ "foobar foobar ", +\ "foobar foobar ", +\ "foobar TARGETx at ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_virtual_char_and_block() + call s:test_windows() + call setline(1, "1111-1111-1111-11-1111-1111-1111") + exe "norm! 0f-lv3lc2222\bgj." + let lines = s:screen_lines([1, 2], winwidth(0)) + let expect = [ +\ "1111-2222-1111-11- ", +\ "1111-2222-1111 ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_undo_after_block_visual() + call s:test_windows() + call setline(1, ["aaa", "aaa", "a"]) + exe "norm! gg\2j~e." + let lines = s:screen_lines([1, 3], winwidth(0)) + let expect = [ +\ "AaA ", +\ "AaA ", +\ "A ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_norm_after_block_visual() + call s:test_windows() + call setline(1, ["abcd{ef", "ghijklm", "no}pgrs"]) + exe "norm! ggf{\\c%" + let lines = s:screen_lines([1, 3], winwidth(0)) + let expect = [ +\ "abcdpgrs ", +\ "~ ", +\ "~ ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_block_replace_after_wrapping() + call s:test_windows() + call setline(1, repeat("a", 150)) + exe "norm! 0yypk147|\jr0" + call assert_equal(repeat("a", 146) . "0aaa", getline(1)) + call assert_equal(repeat("a", 146) . "0aaa", getline(2)) + let lines = s:screen_lines([1, 10], winwidth(0)) + let expect = [ +\ "aaaaaaaaaaaaaaaaaaaa", +\ "aaaaaaaaaaaaaaaaaaaa", +\ "aaaaaaaaaaaaaaaaaaaa", +\ "aaaaaaaaaaaaaaaaaaaa", +\ "aaaaaaaaaaaaaaaaaaaa", +\ "aaaaaaaaaaaaaaaaaaaa", +\ "aaaaaaaaaaaaaaaaaaaa", +\ "aaaaaa0aaa ", +\ "@ ", +\ "@ ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_list_with_listchars() + call s:test_windows('setl list listchars=space:_,trail:-,tab:>-,eol:$') + call setline(1, "a aaaaaaaaaaaaaaaaaaaaaa\ta ") + let lines = s:screen_lines([1, 3], winwidth(0)) + let expect = [ +\ "a_ ", +\ "aaaaaaaaaaaaaaaaaaaa", +\ "aa>-----a-$ ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc diff --git a/src/nvim/testdir/test_listlbr_utf8.vim b/src/nvim/testdir/test_listlbr_utf8.vim new file mode 100644 index 0000000000..807b6ad31a --- /dev/null +++ b/src/nvim/testdir/test_listlbr_utf8.vim @@ -0,0 +1,195 @@ +" Test for linebreak and list option in utf-8 mode + +set encoding=utf-8 +scriptencoding utf-8 + +if !exists("+linebreak") || !has("conceal") || !has("signs") + finish +endif + +source view_util.vim + +function s:screen_lines(lnum, width) abort + return ScreenLines(a:lnum, a:width) +endfunction + +function! s:compare_lines(expect, actual) + call assert_equal(a:expect, a:actual) +endfunction + +function s:screen_attr(lnum, chars, ...) abort + let line = getline(a:lnum) + let attr = [] + let prefix = get(a:000, 0, 0) + for i in range(a:chars[0], a:chars[1]) + let scol = strdisplaywidth(strcharpart(line, 0, i-1)) + 1 + let attr += [screenattr(a:lnum, scol + prefix)] + endfor + return attr +endfunction + +function s:test_windows(...) + call NewWindow(10, 20) + setl ts=4 sw=4 sts=4 linebreak sbr=+ wrap + exe get(a:000, 0, '') +endfunction + +function s:close_windows(...) + call CloseWindow() + exe get(a:000, 0, '') +endfunction + +func Test_linebreak_with_fancy_listchars() + call s:test_windows("setl list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6") + call setline(1, "\tabcdef hijklmn\tpqrstuvwxyz\u00a01060ABCDEFGHIJKLMNOP ") + redraw! + let lines = s:screen_lines([1, 4], winwidth(0)) + let expect = [ +\ "▕———abcdef ", +\ "+hijklmn▕——— ", +\ "+pqrstuvwxyzâ£1060ABC", +\ "+DEFGHIJKLMNOPˑ¶ ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_nolinebreak_with_list() + call s:test_windows("setl nolinebreak list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6") + call setline(1, "\tabcdef hijklmn\tpqrstuvwxyz\u00a01060ABCDEFGHIJKLMNOP ") + redraw! + let lines = s:screen_lines([1, 4], winwidth(0)) + let expect = [ +\ "▕———abcdef hijklmn▕—", +\ "+pqrstuvwxyzâ£1060ABC", +\ "+DEFGHIJKLMNOPˑ¶ ", +\ "~ ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_linebreak_with_nolist() + call s:test_windows('setl nolist') + call setline(1, "\t*mask = nil;") + redraw! + let lines = s:screen_lines([1, 4], winwidth(0)) + let expect = [ +\ " *mask = nil; ", +\ "~ ", +\ "~ ", +\ "~ ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_list_and_concealing1() + call s:test_windows('setl list listchars=tab:>- cole=1') + call setline(1, [ +\ "#define ABCDE\t\t1", +\ "#define ABCDEF\t\t1", +\ "#define ABCDEFG\t\t1", +\ "#define ABCDEFGH\t1", +\ "#define MSG_MODE_FILE\t\t\t1", +\ "#define MSG_MODE_CONSOLE\t\t2", +\ "#define MSG_MODE_FILE_AND_CONSOLE\t3", +\ "#define MSG_MODE_FILE_THEN_CONSOLE\t4", +\ ]) + vert resize 40 + syn match Conceal conceal cchar=>'AB\|MSG_MODE' + redraw! + let lines = s:screen_lines([1, 7], winwidth(0)) + let expect = [ +\ "#define ABCDE>-->---1 ", +\ "#define >CDEF>-->---1 ", +\ "#define >CDEFG>->---1 ", +\ "#define >CDEFGH>----1 ", +\ "#define >_FILE>--------->--->---1 ", +\ "#define >_CONSOLE>---------->---2 ", +\ "#define >_FILE_AND_CONSOLE>---------3 ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_list_and_concealing2() + call s:test_windows('setl nowrap ts=2 list listchars=tab:>- cole=2 concealcursor=n') + call setline(1, "bbeeeeee\t\t;\tsome text") + vert resize 40 + syn clear + syn match meaning /;\s*\zs.*/ + syn match hasword /^\x\{8}/ contains=word + syn match word /\<\x\{8}\>/ contains=beginword,endword contained + syn match beginword /\<\x\x/ contained conceal + syn match endword /\x\{6}\>/ contained + hi meaning guibg=blue + hi beginword guibg=green + hi endword guibg=red + redraw! + let lines = s:screen_lines([1, 1], winwidth(0)) + let expect = [ +\ "eeeeee>--->-;>some text ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_screenattr_for_comment() + call s:test_windows("setl ft=c ts=7 list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6") + call setline(1, " /*\t\t and some more */") + norm! gg0 + syntax on + hi SpecialKey term=underline ctermfg=red guifg=red + redraw! + let line = getline(1) + let attr = s:screen_attr(1, [1, 6]) + call assert_notequal(attr[0], attr[1]) + call assert_notequal(attr[1], attr[3]) + call assert_notequal(attr[3], attr[5]) + call s:close_windows() +endfunc + +func Test_visual_block_and_selection_exclusive() + call s:test_windows('setl selection=exclusive') + call setline(1, "long line: " . repeat("foobar ", 40) . "TARGETÃ' at end") + exe "norm! $3B\eAx\" + let lines = s:screen_lines([1, 10], winwidth(0)) + let expect = [ +\ "+foobar foobar ", +\ "+foobar foobar ", +\ "+foobar foobar ", +\ "+foobar foobar ", +\ "+foobar foobar ", +\ "+foobar foobar ", +\ "+foobar foobar ", +\ "+foobar foobar ", +\ "+foobar foobar ", +\ "+foobar TARGETÃx' ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc + +func Test_multibyte_sign_and_colorcolumn() + call s:test_windows("setl nolinebreak cc=3 list listchars=nbsp:\u2423,tab:\u2595\u2014,trail:\u02d1,eol:\ub6") + call setline(1, ["", "a b c", "a b c"]) + exe "sign define foo text=\uff0b" + exe "sign place 1 name=foo line=2 buffer=" . bufnr('%') + redraw! + norm! ggj0 + let signwidth = strdisplaywidth("\uff0b") + let attr1 = s:screen_attr(2, [1, 3], signwidth) + let attr2 = s:screen_attr(3, [1, 3], signwidth) + call assert_equal(attr1[0], attr2[0]) + call assert_equal(attr1[1], attr2[1]) + call assert_equal(attr1[2], attr2[2]) + let lines = s:screen_lines([1, 3], winwidth(0)) + let expect = [ +\ " ¶ ", +\ "+a b c¶ ", +\ " a b c¶ ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfunc diff --git a/src/nvim/testdir/view_util.vim b/src/nvim/testdir/view_util.vim new file mode 100644 index 0000000000..eb92630761 --- /dev/null +++ b/src/nvim/testdir/view_util.vim @@ -0,0 +1,30 @@ +" Functions about view shared by several tests + +" ScreenLines(lnum, width) or +" ScreenLines([start, end], width) +function! ScreenLines(lnum, width) abort + redraw! + if type(a:lnum) == v:t_list + let start = a:lnum[0] + let end = a:lnum[1] + else + let start = a:lnum + let end = a:lnum + endif + let lines = [] + for l in range(start, end) + let lines += [join(map(range(1, a:width), 'nr2char(screenchar(l, v:val))'), '')] + endfor + return lines +endfunction + +function! NewWindow(height, width) abort + exe a:height . 'new' + exe a:width . 'vsp' + redraw! +endfunction + +function! CloseWindow() abort + bw! + redraw! +endfunction diff --git a/src/nvim/version.c b/src/nvim/version.c index dfee84c1b2..7fca8aee82 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -641,7 +641,7 @@ static const int included_patches[] = { // 314, // 313, // 312, - // 311, + 311, // 310, // 309, // 308, -- cgit From 49b671f8f1c93dcd317aec464352206cc705748a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 29 Jul 2017 02:11:31 +0200 Subject: vim-patch:8.0.0290 vim-patch:8.0.0394 vim-patch:8.0.0290: cursor positioning wrong if wide character wraps Problem: If a wide character doesn't fit at the end of the screen line, and the line doesn't fit on the screen, then the cursor position may be wrong. (anliting) Solution: Don't skip over wide character. (Christian Brabandt, closes vim/1408) vim-patch:8.0.0394 Problem: Tabs are not aligned when scrolling horizontally and a Tab doesn't fit. (Axel Bender) Solution: Handle a Tab as a not fitting character. (Christian Brabandt) Also fix that ":redraw" does not scroll horizontally to show the cursor. And fix the test that depended on the old behavior. https://github.com/vim/vim/commit/abc39ab642791ae3d22a524516eeedb673a95d9d --- src/nvim/ex_docmd.c | 1 + src/nvim/screen.c | 24 ++++++++++++++---------- src/nvim/testdir/test_breakindent.vim | 5 ++--- src/nvim/testdir/test_listlbr.vim | 16 ++++++++++++++++ src/nvim/testdir/test_listlbr_utf8.vim | 34 ++++++++++++++++++++++++++++++++++ src/nvim/version.c | 4 ++-- 6 files changed, 69 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 29788a9865..6e7938046a 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -7690,6 +7690,7 @@ static void ex_redraw(exarg_T *eap) RedrawingDisabled = 0; p_lz = FALSE; + validate_cursor(); update_topline(); update_screen(eap->forceit ? CLEAR : VIsual_active ? INVERTED : diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 3d558bdbdd..27701c4643 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2112,16 +2112,16 @@ win_line ( bool nochange /* not updating for changed text */ ) { - int col; /* visual column on screen */ - unsigned off; /* offset in ScreenLines/ScreenAttrs */ - int c = 0; /* init for GCC */ - long vcol = 0; /* virtual column (for tabs) */ + int col = 0; // visual column on screen + unsigned off; // offset in ScreenLines/ScreenAttrs + int c = 0; // init for GCC + long vcol = 0; // virtual column (for tabs) long vcol_sbr = -1; // virtual column after showbreak - long vcol_prev = -1; /* "vcol" of previous character */ - char_u *line; /* current line */ - char_u *ptr; /* current position in "line" */ - int row; /* row in the window, excl w_winrow */ - int screen_row; /* row on the screen, incl w_winrow */ + long vcol_prev = -1; // "vcol" of previous character + char_u *line; // current line + char_u *ptr; // current position in "line" + int row; // row in the window, excl w_winrow + int screen_row; // row on the screen, incl w_winrow char_u extra[18]; /* line number and 'fdc' must fit in here */ int n_extra = 0; /* number of extra chars */ @@ -2522,7 +2522,11 @@ win_line ( if (vcol > v) { vcol -= c; ptr = prev_ptr; - n_skip = v - vcol; + // If the character fits on the screen, don't need to skip it. + // Except for a TAB. + if (((*mb_ptr2cells)(ptr) >= c || *ptr == TAB) && col == 0) { + n_skip = v - vcol; + } } /* diff --git a/src/nvim/testdir/test_breakindent.vim b/src/nvim/testdir/test_breakindent.vim index 8721b35cdf..7deffbe452 100644 --- a/src/nvim/testdir/test_breakindent.vim +++ b/src/nvim/testdir/test_breakindent.vim @@ -274,7 +274,6 @@ endfunction function Test_breakindent16() " Check that overlong lines are indented correctly. - " TODO: currently it does not fail even when the bug is not fixed. let s:input="" call s:test_windows('setl breakindent briopt=min:0 ts=4') call setline(1, "\t".repeat("1234567890", 10)) @@ -283,16 +282,16 @@ function Test_breakindent16() redraw! let lines=s:screen_lines(1,10) let expect=[ -\ " 123456", \ " 789012", \ " 345678", +\ " 901234", \ ] call s:compare_lines(expect, lines) let lines=s:screen_lines(4,10) let expect=[ -\ " 901234", \ " 567890", \ " 123456", +\ " 7890 ", \ ] call s:compare_lines(expect, lines) call s:close_windows() diff --git a/src/nvim/testdir/test_listlbr.vim b/src/nvim/testdir/test_listlbr.vim index 71366a161e..7856ee82ab 100644 --- a/src/nvim/testdir/test_listlbr.vim +++ b/src/nvim/testdir/test_listlbr.vim @@ -217,3 +217,19 @@ func Test_list_with_listchars() call s:compare_lines(expect, lines) call s:close_windows() endfunc + +func Test_list_with_tab_and_skipping_first_chars() + call s:test_windows('setl list listchars=tab:>- ts=70 nowrap') + call setline(1, ["iiiiiiiiiiiiiiii\taaaaaaaaaaaaaaaaaa", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\taaaaaaaaaaaaaaaaaa", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\taaaaaaaaaaaaaaaaaa", "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\taaaaaaaaaaaaaaaaaa"]) + call cursor(4,64) + norm! 2zl + let lines = s:screen_lines([1, 4], winwidth(0)) + let expect = [ +\ "---------------aaaaa", +\ "---------------aaaaa", +\ "---------------aaaaa", +\ "iiiiiiiii>-----aaaaa", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows() +endfu diff --git a/src/nvim/testdir/test_listlbr_utf8.vim b/src/nvim/testdir/test_listlbr_utf8.vim index 807b6ad31a..980d67d49d 100644 --- a/src/nvim/testdir/test_listlbr_utf8.vim +++ b/src/nvim/testdir/test_listlbr_utf8.vim @@ -193,3 +193,37 @@ func Test_multibyte_sign_and_colorcolumn() call s:compare_lines(expect, lines) call s:close_windows() endfunc + +func Test_chinese_char_on_wrap_column() + call s:test_windows("setl nolbr wrap sbr=") + syntax off + call setline(1, [ +\ 'aaaaaaaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaaaaa中'. +\ 'aaaaaaaaaaaaaaaaa中'. +\ 'hello']) + call cursor(1,1) + norm! $ + redraw! + let expect=[ +\ '中aaaaaaaaaaaaaaaaa>', +\ '中aaaaaaaaaaaaaaaaa>', +\ '中aaaaaaaaaaaaaaaaa>', +\ '中aaaaaaaaaaaaaaaaa>', +\ '中aaaaaaaaaaaaaaaaa>', +\ '中aaaaaaaaaaaaaaaaa>', +\ '中aaaaaaaaaaaaaaaaa>', +\ '中aaaaaaaaaaaaaaaaa>', +\ '中aaaaaaaaaaaaaaaaa>', +\ '中hello '] + let lines = s:screen_lines([1, 10], winwidth(0)) + call s:compare_lines(expect, lines) + call s:close_windows() +endfu diff --git a/src/nvim/version.c b/src/nvim/version.c index 7fca8aee82..a7479c6b18 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -558,7 +558,7 @@ static const int included_patches[] = { // 397, // 396, // 395, - // 394, + 394, 393, // 392, // 391, @@ -662,7 +662,7 @@ static const int included_patches[] = { // 293, // 292, // 291, - // 290, + 290, // 289, // 288 NA // 287, -- cgit From cddd4e613e2fefaa1c3fe8c20617f5ee02845617 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 29 Jul 2017 01:44:58 +0200 Subject: vim-patch:8.0.0518 Closes #7086 Problem: Storing a zero byte from a multi-byte character causes fold text to show up wrong. Solution: Avoid putting zero in ScreenLines. (Christian Brabandt, closes vim/vim#1567) https://github.com/vim/vim/commit/c6cd8409c2993b1476e123fba11cb4b8d743b896 --- src/nvim/screen.c | 8 ++++-- src/nvim/testdir/test_display.vim | 56 ++++++++++++++++++++++++++------------- src/nvim/version.c | 2 +- 3 files changed, 45 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 27701c4643..c302ac695e 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1924,10 +1924,14 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T if (fill_fold >= 0x80) { ScreenLinesUC[off + col] = fill_fold; ScreenLinesC[0][off + col] = 0; - } else + ScreenLines[off + col] = 0x80; // avoid storing zero + } else { ScreenLinesUC[off + col] = 0; + } + col++; + } else { + ScreenLines[off + col++] = fill_fold; } - ScreenLines[off + col++] = fill_fold; } if (text != buf) diff --git a/src/nvim/testdir/test_display.vim b/src/nvim/testdir/test_display.vim index 609e16c737..4253b56933 100644 --- a/src/nvim/testdir/test_display.vim +++ b/src/nvim/testdir/test_display.vim @@ -3,18 +3,12 @@ if !has('gui_running') && has('unix') set term=ansi endif -function! s:screenline(lnum, nr) abort - let line = [] - for j in range(a:nr) - for c in range(1, winwidth(0)) - call add(line, nr2char(screenchar(a:lnum+j, c))) - endfor - call add(line, "\n") - endfor - return join(line, '') -endfunction +source view_util.vim -function! Test_display_foldcolumn() +func! Test_display_foldcolumn() + if !has("folding") + return + endif new vnew vert resize 25 @@ -23,17 +17,43 @@ function! Test_display_foldcolumn() 1put='e more noise blah blah‚ more stuff here' - let expect = "e more noise blah blah<82\n> more stuff here \n" + let expect = [ + \ "e more noise blah blah<82", + \ "> more stuff here " + \ ] call cursor(2, 1) norm! zt - redraw! - call assert_equal(expect, s:screenline(1,2)) + let lines=ScreenLines([1,2], winwidth(0)) + call assert_equal(expect, lines) set fdc=2 - redraw! - let expect = " e more noise blah blah<\n 82> more stuff here \n" - call assert_equal(expect, s:screenline(1,2)) + let lines=ScreenLines([1,2], winwidth(0)) + let expect = [ + \ " e more noise blah blah<", + \ " 82> more stuff here " + \ ] + call assert_equal(expect, lines) quit! quit! -endfunction +endfunc + +func! Test_display_foldtext_mbyte() + if !has("folding") || !has("multi_byte") + return + endif + call NewWindow(10, 40) + call append(0, range(1,20)) + exe "set foldmethod=manual foldtext=foldtext() fillchars=fold:\u2500,vert:\u2502 fdc=2" + call cursor(2, 1) + norm! zf13G + let lines=ScreenLines([1,3], winwidth(0)+1) + let expect=[ + \ " 1 \u2502", + \ "+ +-- 12 lines: 2". repeat("\u2500", 23). "\u2502", + \ " 14 \u2502", + \ ] + call assert_equal(expect, lines) + set foldtext& fillchars& foldmethod& fdc& + bw! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index a7479c6b18..b6386049bf 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -434,7 +434,7 @@ static const int included_patches[] = { // 521, // 520, // 519, - // 518, + 518, // 517, // 516, // 515, -- cgit From a0c7e35eeed489840f1d063b3b8265d01024e340 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 29 Jul 2017 02:40:25 +0200 Subject: vim-patch:8.0.0524 Problem: Folds are messed up when 'encodin' is "utf-8". Solution: Also set the fold character when it's not multi-byte. https://github.com/vim/vim/commit/8da1e6cedf839902e15987a98733ebd31b5f1b81 --- src/nvim/screen.c | 1 + src/nvim/testdir/test_display.vim | 10 ++++++++++ src/nvim/version.c | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index c302ac695e..dd958eec80 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -1927,6 +1927,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T ScreenLines[off + col] = 0x80; // avoid storing zero } else { ScreenLinesUC[off + col] = 0; + ScreenLines[off + col] = fill_fold; } col++; } else { diff --git a/src/nvim/testdir/test_display.vim b/src/nvim/testdir/test_display.vim index 4253b56933..48b7a2318e 100644 --- a/src/nvim/testdir/test_display.vim +++ b/src/nvim/testdir/test_display.vim @@ -54,6 +54,16 @@ func! Test_display_foldtext_mbyte() \ " 14 \u2502", \ ] call assert_equal(expect, lines) + + set fillchars=fold:-,vert:\| + let lines=ScreenLines([1,3], winwidth(0)+1) + let expect=[ + \ " 1 |", + \ "+ +-- 12 lines: 2". repeat("-", 23). "|", + \ " 14 |", + \ ] + call assert_equal(expect, lines) + set foldtext& fillchars& foldmethod& fdc& bw! endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index b6386049bf..a1655f1caa 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -428,7 +428,7 @@ static const int included_patches[] = { // 527, // 526, // 525, - // 524, + 524, // 523, // 522, // 521, -- cgit From 7dc5e8fb8b9265dcb97e8fe4c7c6ee902be33614 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 10 Aug 2017 04:11:35 +0200 Subject: oldtest: cannot `:set term` in Nvim --- src/nvim/testdir/test_display.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_display.vim b/src/nvim/testdir/test_display.vim index 48b7a2318e..0ed672d577 100644 --- a/src/nvim/testdir/test_display.vim +++ b/src/nvim/testdir/test_display.vim @@ -1,7 +1,9 @@ " Test for displaying stuff -if !has('gui_running') && has('unix') - set term=ansi -endif + +" Nvim: `:set term` is not supported. +" if !has('gui_running') && has('unix') +" set term=ansi +" endif source view_util.vim -- cgit From c87dbadc44f7d3705c7cf4e4dc7345da33f63e1a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 12 Aug 2017 18:22:47 +0200 Subject: vim-patch:8.0.0235 Problem: Memory leak detected when running tests for diff mode. Solution: Free p_extra_free. https://github.com/vim/vim/commit/b031c4ea04eb1e37a873fbb85e90d835aa1e2b1c --- src/nvim/screen.c | 21 +++++++++++---------- src/nvim/version.c | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index dd958eec80..f8d519ab36 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2715,17 +2715,15 @@ win_line ( draw_state = WL_FOLD; if (fdc > 0) { // Draw the 'foldcolumn'. Allocate a buffer, "extra" may - // already be in used. + // already be in use. + xfree(p_extra_free); p_extra_free = xmalloc(12 + 1); - - if (p_extra_free != NULL) { - fill_foldcolumn(p_extra_free, wp, false, lnum); - n_extra = fdc; - p_extra_free[n_extra] = NUL; - p_extra = p_extra_free; - c_extra = NUL; - char_attr = win_hl_attr(wp, HLF_FC); - } + fill_foldcolumn(p_extra_free, wp, false, lnum); + n_extra = fdc; + p_extra_free[n_extra] = NUL; + p_extra = p_extra_free; + c_extra = NUL; + char_attr = win_hl_attr(wp, HLF_FC); } } @@ -3526,6 +3524,7 @@ win_line ( p = xmalloc(len + 1); memset(p, ' ', len); p[len] = NUL; + xfree(p_extra_free); p_extra_free = p; for (i = 0; i < tab_len; i++) { mb_char2bytes(lcs_tab2, p); @@ -3641,6 +3640,7 @@ win_line ( memset(p, ' ', n_extra); STRNCPY(p, p_extra + 1, STRLEN(p_extra) - 1); p[n_extra] = NUL; + xfree(p_extra_free); p_extra_free = p_extra = p; } else { n_extra = byte2cells(c) - 1; @@ -4314,6 +4314,7 @@ win_line ( cap_col = 0; } + xfree(p_extra_free); return row; } diff --git a/src/nvim/version.c b/src/nvim/version.c index a1655f1caa..f4984864f3 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -717,7 +717,7 @@ static const int included_patches[] = { // 238, // 237, // 236, - // 235, + 235, // 234, // 233, // 232 NA -- cgit From 1f9c139fd3a060924daf8ce1df32fc3204c6231d Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Mon, 10 Jul 2017 09:37:54 +0200 Subject: tui: fix DECSCUSR logic #6997 Fix linuxvt cursor shape codes Fix konsole cursor_shapes (even when inside tmux) Do not trust old VTE terminal lies Closes #6978 Closes #7002 Closes #7049 --- src/nvim/tui/tui.c | 90 +++++++++++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 97a0398c80..b5af5b0333 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1256,7 +1256,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool teraterm = terminfo_is_term_family(term, "teraterm"); bool putty = terminfo_is_term_family(term, "putty"); bool screen = terminfo_is_term_family(term, "screen"); - bool tmux = terminfo_is_term_family(term, "tmux"); + bool tmux = terminfo_is_term_family(term, "tmux") || !!os_getenv("TMUX"); bool st = terminfo_is_term_family(term, "st"); bool gnome = terminfo_is_term_family(term, "gnome") || terminfo_is_term_family(term, "vte"); @@ -1270,7 +1270,6 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool mate_pretending_xterm = xterm && colorterm && strstr(colorterm, "mate-terminal"); bool true_xterm = xterm && !!xterm_version; - bool tmux_pretending_screen = screen && !!os_getenv("TMUX"); char *fix_normal = (char *)unibi_get_str(ut, unibi_cursor_normal); if (fix_normal) { @@ -1347,7 +1346,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // per the screen manual; 2017-04 terminfo.src lacks these. unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); - } else if (terminfo_is_term_family(term, "tmux")) { + } else if (tmux) { unibi_set_if_empty(ut, unibi_to_status_line, "\x1b_"); unibi_set_if_empty(ut, unibi_from_status_line, "\x1b\\"); } else if (terminfo_is_term_family(term, "interix")) { @@ -1408,12 +1407,11 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256_COLON); unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256_COLON); } else if (konsole || xterm || gnome || rxvt || st || putty - || linuxvt // Linux 4.8+ supports 256-colour SGR. - || mate_pretending_xterm || gnome_pretending_xterm - || tmux || tmux_pretending_screen - || (colorterm && strstr(colorterm, "256")) - || (term && strstr(term, "256")) - ) { + || linuxvt // Linux 4.8+ supports 256-colour SGR. + || mate_pretending_xterm || gnome_pretending_xterm + || tmux + || (colorterm && strstr(colorterm, "256")) + || (term && strstr(term, "256"))) { unibi_set_num(ut, unibi_max_colors, 256); unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256); unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); @@ -1429,12 +1427,17 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } } - // Dickey ncurses terminfo has included the Ss and Se capabilities, pioneered - // by tmux, since 2011-07-14. So adding them to terminal types, that do - // actually have such control sequences but lack the correct definitions in - // terminfo, is a fixup, not an augmentation. - data->unibi_ext.reset_cursor_style = unibi_find_ext_str(ut, "Se"); - data->unibi_ext.set_cursor_style = unibi_find_ext_str(ut, "Ss"); + // Some terminals can not currently be trusted to report if they support + // DECSCUSR or not. So we need to have a blacklist for when we should not + // trust the reported features. + if (!((vte_version != 0 && vte_version < 3900) || konsole)) { + // Dickey ncurses terminfo has included the Ss and Se capabilities, + // pioneered by tmux, since 2011-07-14. So adding them to terminal types, + // that do actually have such control sequences but lack the correct + // definitions in terminfo, is a fixup, not an augmentation. + data->unibi_ext.reset_cursor_style = unibi_find_ext_str(ut, "Se"); + data->unibi_ext.set_cursor_style = unibi_find_ext_str(ut, "Ss"); + } if (-1 == data->unibi_ext.set_cursor_style) { // The DECSCUSR sequence to change the cursor shape is widely // supported by several terminal types and should be in many @@ -1442,6 +1445,13 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // https://github.com/gnachman/iTerm2/pull/92 for more. // xterm even has an extended version that has a vertical bar. if (true_xterm // per xterm ctlseqs doco (since version 282) + // per MinTTY 0.4.3-1 release notes from 2009 + || putty + // per https://bugzilla.gnome.org/show_bug.cgi?id=720821 + || (vte_version >= 3900) + || tmux // per tmux manual page + // https://lists.gnu.org/archive/html/screen-devel/2013-03/msg00000.html + || screen || rxvt // per command.C // per analysis of VT100Terminal.m || iterm || iterm_pretending_xterm @@ -1454,50 +1464,34 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, (int)unibi_add_ext_str(ut, "Ss", "\x1b[%p1%d q"); if (-1 == data->unibi_ext.reset_cursor_style) { data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", - ""); + ""); } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[ q"); - } else if ( - // per MinTTY 0.4.3-1 release notes from 2009 - putty - // per https://bugzilla.gnome.org/show_bug.cgi?id=720821 - || (vte_version >= 3900) - // per tmux manual page and per - // https://lists.gnu.org/archive/html/screen-devel/2013-03/msg00000.html - || screen) { - // Since we use the xterm extension, we must map it to the unextended form - data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", - "\x1b[%?" - "%p1%{4}%>" "%t%p1%{2}%-" // a bit of a bodge for extension values - "%e%p1" // the conventional codes are just passed through - "%;%d q"); - if (-1 == data->unibi_ext.reset_cursor_style) { - data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", - ""); - } - unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, - "\x1b[ q"); } else if (linuxvt) { // Linux uses an idiosyncratic escape code to set the cursor shape and // does not support DECSCUSR. + // See http://linuxgazette.net/137/anonymous.html for more info data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", "\x1b[?" "%?" // The parameter passed to Ss is the DECSCUSR parameter, so the // terminal capability has to translate into the Linux idiosyncratic // parameter. - "%p1%{2}%<" "%t%{8}" // blink block - "%p1%{2}%=" "%t%{24}" // steady block - "%p1%{3}%=" "%t%{1}" // blink underline - "%p1%{4}%=" "%t%{17}" // steady underline - "%p1%{5}%=" "%t%{1}" // blink bar - "%p1%{6}%=" "%t%{17}" // steady bar - "%e%{0}" // anything else + // + // linuxvt only supports block and underline. It is also only + // possible to have a steady block (no steady underline) + "%p1%{2}%<" "%t%{8}" // blink block + "%e%p1%{2}%=" "%t%{112}" // steady block + "%e%p1%{3}%=" "%t%{4}" // blink underline (set to half block) + "%e%p1%{4}%=" "%t%{4}" // steady underline + "%e%p1%{5}%=" "%t%{2}" // blink bar (set to underline) + "%e%p1%{6}%=" "%t%{2}" // steady bar + "%e%{0}" // anything else "%;" "%dc"); if (-1 == data->unibi_ext.reset_cursor_style) { data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", - ""); + ""); } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b[?c"); @@ -1507,17 +1501,17 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // nonce profile, which has side-effects on temporary font resizing. // In an ideal world, Konsole would just support DECSCUSR. data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", - "\x1b]50;CursorShape=%?" + TMUX_WRAP(tmux, "\x1b]50;CursorShape=%?" "%p1%{3}%<" "%t%{0}" // block - "%e%p1%{4}%<" "%t%{2}" // underline + "%e%p1%{5}%<" "%t%{2}" // underline "%e%{1}" // everything else is bar "%;%d;BlinkingCursorEnabled=%?" "%p1%{1}%<" "%t%{1}" // Fortunately if we exclude zero as special, "%e%p1%{1}%&" // in all other cases we can treat bit #0 as a flag. - "%;%d\x07"); + "%;%d\x07")); if (-1 == data->unibi_ext.reset_cursor_style) { data->unibi_ext.reset_cursor_style = (int)unibi_add_ext_str(ut, "Se", - ""); + ""); } unibi_set_ext_str(ut, (size_t)data->unibi_ext.reset_cursor_style, "\x1b]50;\x07"); -- cgit From bf1b1ea6eebf254ed975b743241a598c6aeeb132 Mon Sep 17 00:00:00 2001 From: Nikolai Aleksandrovich Pavlov Date: Sun, 13 Aug 2017 18:37:35 +0300 Subject: lua/executor: Fix crash when printing empty string (#7157) --- src/nvim/lua/executor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 9ec5bfb8ad..eb821f7831 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -519,7 +519,7 @@ static int nlua_print(lua_State *const lstate) } msg((char_u *)str + start); } - if (str[len - 1] == NUL) { // Last was newline + if (len && str[len - 1] == NUL) { // Last was newline msg((char_u *)""); } } -- cgit From d258ac8ed21b3a202212792688b237d0741f6844 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 13 Aug 2017 18:46:09 +0200 Subject: io: more guards against NULL filename (#7159) References ac055d677aa9 References #4370 --- src/nvim/main.c | 1 + src/nvim/memfile.c | 1 + src/nvim/memline.c | 2 ++ src/nvim/os/fs.c | 5 ++++- 4 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index a46c1a58f8..3f828d7be9 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1825,6 +1825,7 @@ static int process_env(char *env, bool is_viminit) /// os_fileinfo_link() respectively for extra security. static bool file_owned(const char *fname) { + assert(fname != NULL); uid_t uid = getuid(); FileInfo file_info; bool file_owned = os_fileinfo(fname, &file_info) diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index 9429703620..4428dd42aa 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -895,6 +895,7 @@ static bool mf_do_open(memfile_T *mfp, char_u *fname, int flags) { // fname cannot be NameBuff, because it must have been allocated. mf_set_fnames(mfp, fname); + assert(mfp->mf_fname != NULL); /// Extra security check: When creating a swap file it really shouldn't /// exist yet. If there is a symbolic link, this is most likely an attack. diff --git a/src/nvim/memline.c b/src/nvim/memline.c index 55e7e01825..f28a9e60f4 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1460,6 +1460,7 @@ static int process_still_running; */ static time_t swapfile_info(char_u *fname) { + assert(fname != NULL); int fd; struct block0 b0; time_t x = (time_t)0; @@ -3135,6 +3136,7 @@ attention_message ( char_u *fname /* swap file name */ ) { + assert(buf->b_fname != NULL); time_t x, sx; char *p; diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 6ac9d682d7..78627f8703 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -859,8 +859,11 @@ bool os_fileinfo(const char *path, FileInfo *file_info) /// @param[out] file_info Pointer to a FileInfo to put the information in. /// @return `true` on success, `false` for failure. bool os_fileinfo_link(const char *path, FileInfo *file_info) - FUNC_ATTR_NONNULL_ALL + FUNC_ATTR_NONNULL_ARG(2) { + if (path == NULL) { + return false; + } uv_fs_t request; int result = uv_fs_lstat(&fs_loop, &request, path, NULL); file_info->stat = request.statbuf; -- cgit From 19a28352a925b0a8502d57ec4f42b1412639aa6c Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 14 Aug 2017 01:56:48 +0300 Subject: ex_getln: Make error messages look better --- src/nvim/ex_getln.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 6d839f0aa4..5e216925df 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2420,7 +2420,7 @@ static bool color_cmdline(const CmdlineInfo *const colored_ccline, } else if (colored_ccline->cmdfirstc == ':') { try_enter(&tstate); err_errmsg = N_( - "E5408: Unable to get Nvim_color_cmdline callback from g:: %s"); + "E5408: Unable to get g:Nvim_color_cmdline callback: %s"); dgc_ret = tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_cmdline"), &color_cb); tl_ret = try_leave(&tstate, &err); @@ -2428,7 +2428,7 @@ static bool color_cmdline(const CmdlineInfo *const colored_ccline, } else if (colored_ccline->cmdfirstc == '=') { try_enter(&tstate); err_errmsg = N_( - "E5409: Unable to get Nvim_color_expr callback from g:: %s"); + "E5409: Unable to get g:Nvim_color_expr callback: %s"); dgc_ret = tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_expr"), &color_cb); tl_ret = try_leave(&tstate, &err); -- cgit From 34e5654f2166fea0ae78a6260e8b961be4b07f1d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 11 Mar 2017 15:58:51 +0100 Subject: ui: disable 'lazyredraw' during ui_refresh. Could also try `do_redraw = true` instead of save/restore `p_lz`, but the nice thing about save/restore of `p_lz` is that it is "atomic". The semantics of `do_redraw` are not clear to me. Closes #4884 References #6202 References https://github.com/neovim/neovim/pull/6202#issuecomment-284379503 References #3929 #5692 #6157 References #5866 --- src/nvim/screen.c | 12 +++++------- src/nvim/ui.c | 5 +++++ 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index f8d519ab36..0c2c4a9bee 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -7440,13 +7440,11 @@ int number_width(win_T *wp) return n; } -/* - * Set size of the Vim shell. - * If 'mustset' is TRUE, we must set Rows and Columns, do not get the real - * window size (this is used for the :win command). - * If 'mustset' is FALSE, we may try to get the real window size and if - * it fails use 'width' and 'height'. - */ +/// Set size of the Vim shell. +/// If 'mustset' is TRUE, we must set Rows and Columns, do not get the real +/// window size (this is used for the :win command). +/// If 'mustset' is FALSE, we may try to get the real window size and if +/// it fails use 'width' and 'height'. void screen_resize(int width, int height) { static int busy = FALSE; diff --git a/src/nvim/ui.c b/src/nvim/ui.c index a60c061949..b85a01814d 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -193,7 +193,12 @@ void ui_refresh(void) } row = col = 0; + + int save_p_lz = p_lz; + p_lz = false; // convince redrawing() to return true ... screen_resize(width, height); + p_lz = save_p_lz; + for (UIWidget i = 0; (int)i < UI_WIDGETS; i++) { ui_set_external(i, ext_widgets[i]); } -- cgit From f5938d9bcfdfb92d26a13659b4afe1e77d4df637 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 14 Aug 2017 01:26:45 +0200 Subject: doc: screen_resize(): remove mention of "mustset" "mustset" is from Vim term.c:set_shellsize(), not relevant here: we behave as if mustset=true always. --- src/nvim/screen.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 0c2c4a9bee..95973354bc 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -7440,11 +7440,7 @@ int number_width(win_T *wp) return n; } -/// Set size of the Vim shell. -/// If 'mustset' is TRUE, we must set Rows and Columns, do not get the real -/// window size (this is used for the :win command). -/// If 'mustset' is FALSE, we may try to get the real window size and if -/// it fails use 'width' and 'height'. +/// Set dimensions of the Nvim application "shell". void screen_resize(int width, int height) { static int busy = FALSE; @@ -7529,8 +7525,8 @@ void screen_resize(int width, int height) --busy; } -// Check if the new shell size is valid, correct it if it's too small or way -// too big. +/// Check if the new Nvim application "shell" dimensions are valid. +/// Correct it if it's too small or way too big. void check_shellsize(void) { if (Rows < min_rows()) { -- cgit From ef6641ba6952fd868d3efafb2a23234ac9bd0d3f Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 15 Aug 2017 16:30:32 +0300 Subject: lua/executor: Make stricmp function work with strings with NULs --- src/nvim/lua/executor.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index eb821f7831..4ed477ea36 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -124,9 +124,36 @@ static void nlua_error(lua_State *const lstate, const char *const msg) /// omitted. static int nlua_stricmp(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL { - const char *s1 = luaL_checklstring(lstate, 1, NULL); - const char *s2 = luaL_checklstring(lstate, 2, NULL); - const int ret = STRICMP(s1, s2); + size_t s1_len; + size_t s2_len; + const char *s1 = luaL_checklstring(lstate, 1, &s1_len); + const char *s2 = luaL_checklstring(lstate, 2, &s2_len); + char *nul1; + char *nul2; + int ret = 0; + assert(s1[s1_len] == NUL); + assert(s2[s2_len] == NUL); + do { + nul1 = memchr(s1, NUL, s1_len); + nul2 = memchr(s2, NUL, s2_len); + ret = STRICMP(s1, s2); + // Compare "a\0" greater then "a". + if (ret == 0 && (nul1 == NULL) != (nul2 == NULL)) { + ret = ((nul1 != NULL) - (nul2 != NULL)); + break; + } + if (nul1 != NULL) { + assert(nul2 != NULL); + // Due to lowercase letter having possibly different byte length then + // uppercase letter can’t shift both strings by the same amount of bytes. + s1_len -= (size_t)(nul1 - s1) + 1; + s2_len -= (size_t)(nul2 - s2) + 1; + s1 = nul1 + 1; + s2 = nul2 + 1; + } else { + break; + } + } while (ret == 0); lua_pop(lstate, 2); lua_pushnumber(lstate, (lua_Number)((ret > 0) - (ret < 0))); return 1; -- cgit From 93ef823f5e5347e685b4a69fff487278d0b4ed87 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 15 Aug 2017 16:32:06 +0300 Subject: lua/executor: Move stricmp to vim “module†and document it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nvim/lua/executor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 4ed477ea36..90333be541 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -281,10 +281,6 @@ static int nlua_exec_lua_file(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL /// Called by lua interpreter itself to initialize state. static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL { - // stricmp - lua_pushcfunction(lstate, &nlua_stricmp); - lua_setglobal(lstate, "stricmp"); - // print lua_pushcfunction(lstate, &nlua_print); lua_setglobal(lstate, "print"); @@ -304,6 +300,10 @@ static int nlua_state_init(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL nlua_add_api_functions(lstate); // vim.types, vim.type_idx, vim.val_idx nlua_init_types(lstate); + // stricmp + lua_pushcfunction(lstate, &nlua_stricmp); + lua_setfield(lstate, -2, "stricmp"); + lua_setglobal(lstate, "vim"); return 0; } -- cgit From b1a8dcefeee0bb999a350de2cc38fc08df679bf6 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 15 Aug 2017 16:41:43 +0300 Subject: lua/executor: Fix crash when first string contains NUL and second not --- src/nvim/lua/executor.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 90333be541..54973a6e94 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -137,23 +137,28 @@ static int nlua_stricmp(lua_State *const lstate) FUNC_ATTR_NONNULL_ALL nul1 = memchr(s1, NUL, s1_len); nul2 = memchr(s2, NUL, s2_len); ret = STRICMP(s1, s2); - // Compare "a\0" greater then "a". - if (ret == 0 && (nul1 == NULL) != (nul2 == NULL)) { - ret = ((nul1 != NULL) - (nul2 != NULL)); - break; - } - if (nul1 != NULL) { - assert(nul2 != NULL); - // Due to lowercase letter having possibly different byte length then - // uppercase letter can’t shift both strings by the same amount of bytes. - s1_len -= (size_t)(nul1 - s1) + 1; - s2_len -= (size_t)(nul2 - s2) + 1; - s1 = nul1 + 1; - s2 = nul2 + 1; + if (ret == 0) { + // Compare "a\0" greater then "a". + if ((nul1 == NULL) != (nul2 == NULL)) { + ret = ((nul1 != NULL) - (nul2 != NULL)); + break; + } + if (nul1 != NULL) { + assert(nul2 != NULL); + // Due to lowercase letter having possibly different byte length then + // uppercase letter can’t shift both strings by the same amount of + // bytes. + s1_len -= (size_t)(nul1 - s1) + 1; + s2_len -= (size_t)(nul2 - s2) + 1; + s1 = nul1 + 1; + s2 = nul2 + 1; + } else { + break; + } } else { break; } - } while (ret == 0); + } while (true); lua_pop(lstate, 2); lua_pushnumber(lstate, (lua_Number)((ret > 0) - (ret < 0))); return 1; -- cgit From 1f4090011ef95e2bdf217405d28a1b48300965bd Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 15 Aug 2017 18:26:41 +0200 Subject: coverty: solve  #7149 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nvim/mbyte.h | 3 +++ src/nvim/menu.c | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h index ad9e38004c..f718d17923 100644 --- a/src/nvim/mbyte.h +++ b/src/nvim/mbyte.h @@ -18,6 +18,9 @@ #define MB_BYTE2LEN(b) utf8len_tab[b] #define MB_BYTE2LEN_CHECK(b) (((b) < 0 || (b) > 255) ? 1 : utf8len_tab[b]) +// max length of an unicode char +#define MB_MAXCHAR 6 + /* properties used in enc_canon_table[] (first three mutually exclusive) */ #define ENC_8BIT 0x01 #define ENC_DBCS 0x02 diff --git a/src/nvim/menu.c b/src/nvim/menu.c index a498916e5e..0db250d111 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -666,8 +666,6 @@ static void free_menu_string(vimmenu_T *menu, int idx) static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes) { dict_T *dict; - char buf[sizeof(menu->mnemonic)]; - int mnemonic_len; if (!menu || (menu->modes & modes) == 0x0) { return NULL; @@ -679,8 +677,8 @@ static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes) tv_dict_add_nr(dict, S_LEN("hidden"), menu_is_hidden(menu->dname)); if (menu->mnemonic) { - mnemonic_len = utf_char2bytes(menu->mnemonic, (u_char *)buf); - buf[mnemonic_len] = '\0'; + char buf[MB_MAXCHAR + 1] = { 0 }; // > max value of utf8_char2bytes + utf_char2bytes(menu->mnemonic, (char_u *)buf); tv_dict_add_str(dict, S_LEN("shortcut"), buf); } @@ -717,7 +715,7 @@ static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes) list_T *children_list = tv_list_alloc(); for (menu = menu->children; menu != NULL; menu = menu->next) { dict_T *dic = menu_get_recursive(menu, modes); - if (dict && tv_dict_len(dict) > 0) { + if (tv_dict_len(dict) > 0) { tv_list_append_dict(children_list, dic); } } -- cgit From 7f22a27a10655dc40528f35034cbdf8c9543241c Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Wed, 24 Feb 2016 02:14:19 -0600 Subject: win: integrate winpty (WIP) Handling of process exit is still broken. It detects the moment when the child process exits, then quickly stops polling for process output. It should continue polling for output until the agent has scraped all of the process' output. This problem is easy to notice by running a command like "dir && exit", but even typing "exit" can manifest the problem -- the "t" might not appear. winpty's Cygwin adapter handles shutdown by waiting for the agent to close the CONOUT pipe, which it does after it has scraped the child's last output. AFAIK, neovim doesn't do anything interesting when winpty closes the CONOUT pipe. --- src/nvim/CMakeLists.txt | 7 ++ src/nvim/os/pty_process_win.c | 189 ++++++++++++++++++++++++++++++++++++++++++ src/nvim/os/pty_process_win.h | 25 ++++-- 3 files changed, 214 insertions(+), 7 deletions(-) create mode 100644 src/nvim/os/pty_process_win.c (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index c46c0bed6d..5f9d08cfa3 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -111,6 +111,9 @@ foreach(sfile ${NVIM_SOURCES}) if(WIN32 AND ${f} MATCHES "^(pty_process_unix.c)$") list(APPEND to_remove ${sfile}) endif() + if(NOT WIN32 AND ${f} MATCHES "^(pty_process_win.c)$") + list(APPEND to_remove ${sfile}) + endif() endforeach() list(REMOVE_ITEM NVIM_SOURCES ${to_remove}) @@ -350,6 +353,10 @@ if(Iconv_LIBRARIES) list(APPEND NVIM_LINK_LIBRARIES ${Iconv_LIBRARIES}) endif() +if(WIN32) + list(APPEND NVIM_LINK_LIBRARIES ${WINPTY_LIBRARIES}) +endif() + # Put these last on the link line, since multiple things may depend on them. list(APPEND NVIM_LINK_LIBRARIES ${LIBUV_LIBRARIES} diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c new file mode 100644 index 0000000000..e75c92e7fb --- /dev/null +++ b/src/nvim/os/pty_process_win.c @@ -0,0 +1,189 @@ +#include +#include +#include + +#include "nvim/memory.h" +#include "nvim/os/pty_process_win.h" + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/pty_process_win.c.generated.h" +#endif + +static void CALLBACK pty_process_finish1(void *context, BOOLEAN unused) +{ + uv_async_t *finish_async = (uv_async_t *)context; + uv_async_send(finish_async); +} + +bool pty_process_spawn(PtyProcess *ptyproc) + FUNC_ATTR_NONNULL_ALL +{ + Process *proc = (Process *)ptyproc; + bool success = false; + winpty_error_ptr_t err = NULL; + winpty_config_t *cfg = NULL; + winpty_spawn_config_t *spawncfg = NULL; + winpty_t *wp = NULL; + char *in_name = NULL, *out_name = NULL; + HANDLE process_handle = NULL; + + assert(proc->in && proc->out && !proc->err); + + if (!(cfg = winpty_config_new( + WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION, &err))) { + goto cleanup; + } + winpty_config_set_initial_size(cfg, ptyproc->width, ptyproc->height); + + if (!(wp = winpty_open(cfg, &err))) { + goto cleanup; + } + + in_name = utf16_to_utf8(winpty_conin_name(wp)); + out_name = utf16_to_utf8(winpty_conout_name(wp)); + uv_pipe_connect( + xmalloc(sizeof(uv_connect_t)), + &proc->in->uv.pipe, + in_name, + pty_process_connect_cb); + uv_pipe_connect( + xmalloc(sizeof(uv_connect_t)), + &proc->out->uv.pipe, + out_name, + pty_process_connect_cb); + + // XXX: Provide the correct ptyprocess parameters (at least, the cmdline... + // probably cwd too? what about environ?) + if (!(spawncfg = winpty_spawn_config_new( + WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN, + L"C:\\Windows\\System32\\cmd.exe", + L"C:\\Windows\\System32\\cmd.exe", + NULL, NULL, + &err))) { + goto cleanup; + } + if (!winpty_spawn(wp, spawncfg, &process_handle, NULL, NULL, &err)) { + goto cleanup; + } + + uv_async_init(&proc->loop->uv, &ptyproc->finish_async, pty_process_finish2); + if (!RegisterWaitForSingleObject(&ptyproc->finish_wait, process_handle, + pty_process_finish1, &ptyproc->finish_async, INFINITE, 0)) { + abort(); + } + + ptyproc->wp = wp; + ptyproc->process_handle = process_handle; + wp = NULL; + process_handle = NULL; + success = true; + +cleanup: + winpty_error_free(err); + winpty_config_free(cfg); + winpty_spawn_config_free(spawncfg); + winpty_free(wp); + xfree(in_name); + xfree(out_name); + if (process_handle != NULL) { + CloseHandle(process_handle); + } + return success; +} + +void pty_process_resize(PtyProcess *ptyproc, uint16_t width, + uint16_t height) + FUNC_ATTR_NONNULL_ALL +{ + if (ptyproc->wp != NULL) { + winpty_set_size(ptyproc->wp, width, height, NULL); + } +} + +void pty_process_close(PtyProcess *ptyproc) + FUNC_ATTR_NONNULL_ALL +{ + Process *proc = (Process *)ptyproc; + + ptyproc->is_closing = true; + pty_process_close_master(ptyproc); + + uv_handle_t *finish_async_handle = (uv_handle_t *)&ptyproc->finish_async; + if (ptyproc->finish_wait != NULL) { + // Use INVALID_HANDLE_VALUE to block until either the wait is cancelled + // or the callback has signalled the uv_async_t. + UnregisterWaitEx(ptyproc->finish_wait, INVALID_HANDLE_VALUE); + uv_close(finish_async_handle, pty_process_finish_closing); + } else { + pty_process_finish_closing(finish_async_handle); + } +} + +void pty_process_close_master(PtyProcess *ptyproc) + FUNC_ATTR_NONNULL_ALL +{ + if (ptyproc->wp != NULL) { + winpty_free(ptyproc->wp); + ptyproc->wp = NULL; + } +} + +void pty_process_teardown(Loop *loop) + FUNC_ATTR_NONNULL_ALL +{ +} + +// Returns a string freeable with xfree. Never returns NULL (OOM is a fatal +// error). Windows appears to replace invalid UTF-16 code points (i.e. +// unpaired surrogates) using U+FFFD (the replacement character). +static char *utf16_to_utf8(LPCWSTR str) + FUNC_ATTR_NONNULL_ALL +{ + int len = WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL); + assert(len >= 1); // Even L"" has a non-zero length due to NUL terminator. + char *ret = xmalloc(len); + int len2 = WideCharToMultiByte(CP_UTF8, 0, str, -1, ret, len, NULL, NULL); + assert(len == len2); + return ret; +} + +static void pty_process_connect_cb(uv_connect_t *req, int status) +{ + assert(status == 0); + xfree(req); +} + +static void pty_process_finish2(uv_async_t *finish_async) +{ + PtyProcess *ptyproc = + (PtyProcess *)((char *)finish_async - offsetof(PtyProcess, finish_async)); + Process *proc = (Process *)ptyproc; + + if (!ptyproc->is_closing) { + // If pty_process_close has already been called, be consistent and never + // call the internal_exit callback. + + DWORD exit_code = 0; + GetExitCodeProcess(ptyproc->process_handle, &exit_code); + proc->status = exit_code; + + if (proc->internal_exit_cb) { + proc->internal_exit_cb(proc); + } + } +} + +static void pty_process_finish_closing(uv_handle_t *finish_async) +{ + PtyProcess *ptyproc = + (PtyProcess *)((char *)finish_async - offsetof(PtyProcess, finish_async)); + Process *proc = (Process *)ptyproc; + + if (ptyproc->process_handle != NULL) { + CloseHandle(ptyproc->process_handle); + ptyproc->process_handle = NULL; + } + if (proc->internal_close_cb) { + proc->internal_close_cb(proc); + } +} diff --git a/src/nvim/os/pty_process_win.h b/src/nvim/os/pty_process_win.h index 8e2b37a1c1..87b2b6545d 100644 --- a/src/nvim/os/pty_process_win.h +++ b/src/nvim/os/pty_process_win.h @@ -1,21 +1,23 @@ #ifndef NVIM_OS_PTY_PROCESS_WIN_H #define NVIM_OS_PTY_PROCESS_WIN_H +#include + +#include + #include "nvim/event/libuv_process.h" typedef struct pty_process { Process process; char *term_name; uint16_t width, height; + winpty_t *wp; + uv_async_t finish_async; + HANDLE finish_wait; + HANDLE process_handle; + bool is_closing; } PtyProcess; -#define pty_process_spawn(job) libuv_process_spawn((LibuvProcess *)job) -#define pty_process_close(job) libuv_process_close((LibuvProcess *)job) -#define pty_process_close_master(job) libuv_process_close((LibuvProcess *)job) -#define pty_process_resize(job, width, height) ( \ - (void)job, (void)width, (void)height, 0) -#define pty_process_teardown(loop) ((void)loop, 0) - static inline PtyProcess pty_process_init(Loop *loop, void *data) { PtyProcess rv; @@ -23,7 +25,16 @@ static inline PtyProcess pty_process_init(Loop *loop, void *data) rv.term_name = NULL; rv.width = 80; rv.height = 24; + rv.wp = NULL; + // XXX: Zero rv.finish_async somehow? + rv.finish_wait = NULL; + rv.process_handle = NULL; + rv.is_closing = false; return rv; } +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/pty_process_win.h.generated.h" +#endif + #endif // NVIM_OS_PTY_PROCESS_WIN_H -- cgit From a79785675564a4c1f02f9aa54249fc6000187c0d Mon Sep 17 00:00:00 2001 From: Rui Abreu Ferreira Date: Fri, 10 Feb 2017 00:04:27 +0000 Subject: win/install: winpty-agent.exe --- src/nvim/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 5f9d08cfa3..9bb3fbfcbe 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -422,6 +422,7 @@ if(WIN32) COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/tee.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/ COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/tidy.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/ COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/win32yank.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/ + COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/winpty-agent.exe" ${PROJECT_BINARY_DIR}/windows_runtime_deps/ COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/D3Dcompiler_47.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/ COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/libEGL.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/ -- cgit From 4b1f21de75f9981007d80aca8355239e8615d6bd Mon Sep 17 00:00:00 2001 From: erw7 Date: Tue, 28 Mar 2017 18:07:58 +0900 Subject: win: support :terminal --- src/nvim/CMakeLists.txt | 1 + src/nvim/os/pty_process_win.c | 232 ++++++++++++++++++++++++++++++------------ src/nvim/os/pty_process_win.h | 13 ++- 3 files changed, 177 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 9bb3fbfcbe..2e0a35d4ab 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -436,6 +436,7 @@ if(WIN32) COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Network.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/ COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Svg.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/ COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/Qt5Widgets.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/ + COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/winpty.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/ COMMAND ${CMAKE_COMMAND} -E copy "${DEPS_PREFIX}/bin/platforms/qwindows.dll" ${PROJECT_BINARY_DIR}/windows_runtime_deps/platforms/ ) diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index e75c92e7fb..ea95c1bb09 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -2,30 +2,53 @@ #include #include +#include "nvim/vim.h" +#include "nvim/ascii.h" #include "nvim/memory.h" +#include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8 #include "nvim/os/pty_process_win.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "os/pty_process_win.c.generated.h" #endif +static void wait_eof_timer_cb(uv_timer_t *wait_eof_timer) + FUNC_ATTR_NONNULL_ALL +{ + PtyProcess *ptyproc = + (PtyProcess *)((uv_handle_t *)wait_eof_timer->data); + Process *proc = (Process *)ptyproc; + + if (!uv_is_readable(proc->out->uvstream)) { + uv_timer_stop(&ptyproc->wait_eof_timer); + pty_process_finish2(ptyproc); + } +} + static void CALLBACK pty_process_finish1(void *context, BOOLEAN unused) + FUNC_ATTR_NONNULL_ALL { - uv_async_t *finish_async = (uv_async_t *)context; - uv_async_send(finish_async); + PtyProcess *ptyproc = (PtyProcess *)context; + Process *proc = (Process *)ptyproc; + + uv_timer_init(&proc->loop->uv, &ptyproc->wait_eof_timer); + ptyproc->wait_eof_timer.data = (void *)ptyproc; + uv_timer_start(&ptyproc->wait_eof_timer, wait_eof_timer_cb, 200, 200); } -bool pty_process_spawn(PtyProcess *ptyproc) +int pty_process_spawn(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL { Process *proc = (Process *)ptyproc; - bool success = false; + int status = 0; winpty_error_ptr_t err = NULL; winpty_config_t *cfg = NULL; winpty_spawn_config_t *spawncfg = NULL; winpty_t *wp = NULL; char *in_name = NULL, *out_name = NULL; HANDLE process_handle = NULL; + uv_connect_t *in_req = NULL, *out_req = NULL; + wchar_t *cmdline = NULL, *cwd = NULL; assert(proc->in && proc->out && !proc->err); @@ -33,52 +56,70 @@ bool pty_process_spawn(PtyProcess *ptyproc) WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION, &err))) { goto cleanup; } - winpty_config_set_initial_size(cfg, ptyproc->width, ptyproc->height); + winpty_config_set_initial_size( + cfg, + ptyproc->width, + ptyproc->height); if (!(wp = winpty_open(cfg, &err))) { goto cleanup; } - in_name = utf16_to_utf8(winpty_conin_name(wp)); - out_name = utf16_to_utf8(winpty_conout_name(wp)); + if ((status = utf16_to_utf8(winpty_conin_name(wp), &in_name))) { + goto cleanup; + } + if ((status = utf16_to_utf8(winpty_conout_name(wp), &out_name))) { + goto cleanup; + } + in_req = xmalloc(sizeof(uv_connect_t)); + out_req = xmalloc(sizeof(uv_connect_t)); uv_pipe_connect( - xmalloc(sizeof(uv_connect_t)), + in_req, &proc->in->uv.pipe, in_name, pty_process_connect_cb); uv_pipe_connect( - xmalloc(sizeof(uv_connect_t)), + out_req, &proc->out->uv.pipe, out_name, pty_process_connect_cb); - // XXX: Provide the correct ptyprocess parameters (at least, the cmdline... - // probably cwd too? what about environ?) + if (proc->cwd != NULL && (status = utf8_to_utf16(proc->cwd, &cwd))) { + goto cleanup; + } + if ((status = build_cmdline(proc->argv, &cmdline))) { + goto cleanup; + } if (!(spawncfg = winpty_spawn_config_new( WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN, - L"C:\\Windows\\System32\\cmd.exe", - L"C:\\Windows\\System32\\cmd.exe", - NULL, NULL, - &err))) { + NULL, cmdline, cwd, NULL, &err))) { goto cleanup; } if (!winpty_spawn(wp, spawncfg, &process_handle, NULL, NULL, &err)) { goto cleanup; } + proc->pid = GetProcessId(process_handle); - uv_async_init(&proc->loop->uv, &ptyproc->finish_async, pty_process_finish2); - if (!RegisterWaitForSingleObject(&ptyproc->finish_wait, process_handle, - pty_process_finish1, &ptyproc->finish_async, INFINITE, 0)) { + if (!RegisterWaitForSingleObject( + &ptyproc->finish_wait, + process_handle, pty_process_finish1, ptyproc, + INFINITE, WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE)) { abort(); } + while (in_req->handle || out_req->handle) { + uv_run(&proc->loop->uv, UV_RUN_ONCE); + } + ptyproc->wp = wp; ptyproc->process_handle = process_handle; wp = NULL; process_handle = NULL; - success = true; cleanup: + if (err != NULL) { + status = (int)winpty_error_code(err); + } winpty_error_free(err); winpty_config_free(cfg); winpty_spawn_config_free(spawncfg); @@ -88,7 +129,11 @@ cleanup: if (process_handle != NULL) { CloseHandle(process_handle); } - return success; + xfree(in_req); + xfree(out_req); + xfree(cmdline); + xfree(cwd); + return status; } void pty_process_resize(PtyProcess *ptyproc, uint16_t width, @@ -105,17 +150,10 @@ void pty_process_close(PtyProcess *ptyproc) { Process *proc = (Process *)ptyproc; - ptyproc->is_closing = true; pty_process_close_master(ptyproc); - uv_handle_t *finish_async_handle = (uv_handle_t *)&ptyproc->finish_async; - if (ptyproc->finish_wait != NULL) { - // Use INVALID_HANDLE_VALUE to block until either the wait is cancelled - // or the callback has signalled the uv_async_t. - UnregisterWaitEx(ptyproc->finish_wait, INVALID_HANDLE_VALUE); - uv_close(finish_async_handle, pty_process_finish_closing); - } else { - pty_process_finish_closing(finish_async_handle); + if (proc->internal_close_cb) { + proc->internal_close_cb(proc); } } @@ -133,57 +171,123 @@ void pty_process_teardown(Loop *loop) { } -// Returns a string freeable with xfree. Never returns NULL (OOM is a fatal -// error). Windows appears to replace invalid UTF-16 code points (i.e. -// unpaired surrogates) using U+FFFD (the replacement character). -static char *utf16_to_utf8(LPCWSTR str) - FUNC_ATTR_NONNULL_ALL -{ - int len = WideCharToMultiByte(CP_UTF8, 0, str, -1, NULL, 0, NULL, NULL); - assert(len >= 1); // Even L"" has a non-zero length due to NUL terminator. - char *ret = xmalloc(len); - int len2 = WideCharToMultiByte(CP_UTF8, 0, str, -1, ret, len, NULL, NULL); - assert(len == len2); - return ret; -} - static void pty_process_connect_cb(uv_connect_t *req, int status) + FUNC_ATTR_NONNULL_ALL { assert(status == 0); - xfree(req); + req->handle = NULL; } -static void pty_process_finish2(uv_async_t *finish_async) +static void pty_process_finish2(PtyProcess *ptyproc) + FUNC_ATTR_NONNULL_ALL { - PtyProcess *ptyproc = - (PtyProcess *)((char *)finish_async - offsetof(PtyProcess, finish_async)); Process *proc = (Process *)ptyproc; - if (!ptyproc->is_closing) { - // If pty_process_close has already been called, be consistent and never - // call the internal_exit callback. + UnregisterWaitEx(ptyproc->finish_wait, NULL); + uv_close((uv_handle_t *)&ptyproc->wait_eof_timer, NULL); + + DWORD exit_code = 0; + GetExitCodeProcess(ptyproc->process_handle, &exit_code); + proc->status = (int)exit_code; - DWORD exit_code = 0; - GetExitCodeProcess(ptyproc->process_handle, &exit_code); - proc->status = exit_code; + CloseHandle(ptyproc->process_handle); + ptyproc->process_handle = NULL; - if (proc->internal_exit_cb) { - proc->internal_exit_cb(proc); + proc->internal_exit_cb(proc); +} + +static int build_cmdline(char **argv, wchar_t **cmdline) + FUNC_ATTR_NONNULL_ALL +{ + char *args = NULL; + size_t args_len = 0, argc = 0; + int ret; + QUEUE q; + QUEUE_INIT(&q); + + while (*argv) { + arg_T *arg = xmalloc(sizeof(arg_T)); + arg->arg = (char *)xmalloc(strlen(*argv) * 2 + 3); + quote_cmd_arg(arg->arg, *argv); + args_len += strlen(arg->arg); + QUEUE_INIT(&arg->node); + QUEUE_INSERT_TAIL(&q, &arg->node); + argc++; + argv++; + } + args_len += argc; + args = xmalloc(args_len); + *args = NUL; + while (1) { + QUEUE *head = QUEUE_HEAD(&q); + QUEUE_REMOVE(head); + arg_T *arg = QUEUE_DATA(head, arg_T, node); + xstrlcat(args, arg->arg, args_len); + xfree(arg->arg); + xfree(arg); + if (QUEUE_EMPTY(&q)) { + break; + } else { + xstrlcat(args, " ", args_len); } } + ret = utf8_to_utf16(args, cmdline); + xfree(args); + return ret; } -static void pty_process_finish_closing(uv_handle_t *finish_async) +// Emulate quote_cmd_arg of libuv and quotes command line arguments +static void quote_cmd_arg(char *target, const char *source) + FUNC_ATTR_NONNULL_ALL { - PtyProcess *ptyproc = - (PtyProcess *)((char *)finish_async - offsetof(PtyProcess, finish_async)); - Process *proc = (Process *)ptyproc; + size_t len = strlen(source); + size_t i; + bool quote_hit = true; + char *start = target; + char tmp; - if (ptyproc->process_handle != NULL) { - CloseHandle(ptyproc->process_handle); - ptyproc->process_handle = NULL; + if (len == 0) { + *(target++) = '"'; + *(target++) = '"'; + *target = NUL; + return; } - if (proc->internal_close_cb) { - proc->internal_close_cb(proc); + + if (NULL == strpbrk(source, " \t\"")) { + strcpy(target, source); + return; + } + + if (NULL == strpbrk(source, "\"\\")) { + *(target++) = '"'; + strncpy(target, source, len); + target += len; + *(target++) = '"'; + *target = NUL; + return; + } + + *(target++) = NUL; + *(target++) = '"'; + for (i = len; i > 0; --i) { + *(target++) = source[i - 1]; + + if (quote_hit && source[i - 1] == '\\') { + *(target++) = '\\'; + } else if (source[i - 1] == '"') { + quote_hit = true; + *(target++) = '\\'; + } else { + quote_hit = false; + } + } + *target = '"'; + while (start < target) { + tmp = *start; + *start = *target; + *target = tmp; + start++; + target--; } + return; } diff --git a/src/nvim/os/pty_process_win.h b/src/nvim/os/pty_process_win.h index 87b2b6545d..806857f130 100644 --- a/src/nvim/os/pty_process_win.h +++ b/src/nvim/os/pty_process_win.h @@ -5,19 +5,24 @@ #include -#include "nvim/event/libuv_process.h" +#include "nvim/event/process.h" +#include "nvim/lib/queue.h" typedef struct pty_process { Process process; char *term_name; uint16_t width, height; winpty_t *wp; - uv_async_t finish_async; HANDLE finish_wait; HANDLE process_handle; - bool is_closing; + uv_timer_t wait_eof_timer; } PtyProcess; +typedef struct arg_S { + char *arg; + QUEUE node; +} arg_T; + static inline PtyProcess pty_process_init(Loop *loop, void *data) { PtyProcess rv; @@ -26,10 +31,8 @@ static inline PtyProcess pty_process_init(Loop *loop, void *data) rv.width = 80; rv.height = 24; rv.wp = NULL; - // XXX: Zero rv.finish_async somehow? rv.finish_wait = NULL; rv.process_handle = NULL; - rv.is_closing = false; return rv; } -- cgit From e635754e8e9a92d1537ccc980c63eaa2e9d732bb Mon Sep 17 00:00:00 2001 From: erw7 Date: Wed, 29 Mar 2017 21:39:58 +0900 Subject: win/pty: jobstart, jobstop: fix null-pointer dereference - Make sure that proc->in is not NULL, because nvim crashed when starting a job with pty. - Make sure that proc->out is not NULL, because nvim crashed when stopping a job opened with pty. --- src/nvim/os/pty_process_win.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index ea95c1bb09..101f468005 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -19,7 +19,7 @@ static void wait_eof_timer_cb(uv_timer_t *wait_eof_timer) (PtyProcess *)((uv_handle_t *)wait_eof_timer->data); Process *proc = (Process *)ptyproc; - if (!uv_is_readable(proc->out->uvstream)) { + if (!proc->out || !uv_is_readable(proc->out->uvstream)) { uv_timer_stop(&ptyproc->wait_eof_timer); pty_process_finish2(ptyproc); } @@ -50,7 +50,7 @@ int pty_process_spawn(PtyProcess *ptyproc) uv_connect_t *in_req = NULL, *out_req = NULL; wchar_t *cmdline = NULL, *cwd = NULL; - assert(proc->in && proc->out && !proc->err); + assert(!proc->err); if (!(cfg = winpty_config_new( WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION, &err))) { @@ -71,18 +71,22 @@ int pty_process_spawn(PtyProcess *ptyproc) if ((status = utf16_to_utf8(winpty_conout_name(wp), &out_name))) { goto cleanup; } - in_req = xmalloc(sizeof(uv_connect_t)); - out_req = xmalloc(sizeof(uv_connect_t)); - uv_pipe_connect( - in_req, - &proc->in->uv.pipe, - in_name, - pty_process_connect_cb); - uv_pipe_connect( - out_req, - &proc->out->uv.pipe, - out_name, - pty_process_connect_cb); + if (proc->in) { + in_req = xmalloc(sizeof(uv_connect_t)); + uv_pipe_connect( + in_req, + &proc->in->uv.pipe, + in_name, + pty_process_connect_cb); + } + if (proc->out) { + out_req = xmalloc(sizeof(uv_connect_t)); + uv_pipe_connect( + out_req, + &proc->out->uv.pipe, + out_name, + pty_process_connect_cb); + } if (proc->cwd != NULL && (status = utf8_to_utf16(proc->cwd, &cwd))) { goto cleanup; @@ -107,7 +111,7 @@ int pty_process_spawn(PtyProcess *ptyproc) abort(); } - while (in_req->handle || out_req->handle) { + while ((in_req && in_req->handle) || (out_req && out_req->handle)) { uv_run(&proc->loop->uv, UV_RUN_ONCE); } -- cgit From 3b992f16889b45215ab6f867edaec5201776d579 Mon Sep 17 00:00:00 2001 From: erw7 Date: Thu, 30 Mar 2017 18:30:40 +0900 Subject: win/pty: quote_cmd_arg(): check bounds --- src/nvim/os/pty_process_win.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index 101f468005..f3efe87d78 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -210,9 +210,10 @@ static int build_cmdline(char **argv, wchar_t **cmdline) QUEUE_INIT(&q); while (*argv) { + size_t buf_len = strlen(*argv) * 2 + 3; arg_T *arg = xmalloc(sizeof(arg_T)); - arg->arg = (char *)xmalloc(strlen(*argv) * 2 + 3); - quote_cmd_arg(arg->arg, *argv); + arg->arg = (char *)xmalloc(buf_len); + quote_cmd_arg(arg->arg, buf_len, *argv); args_len += strlen(arg->arg); QUEUE_INIT(&arg->node); QUEUE_INSERT_TAIL(&q, &arg->node); @@ -241,50 +242,50 @@ static int build_cmdline(char **argv, wchar_t **cmdline) } // Emulate quote_cmd_arg of libuv and quotes command line arguments -static void quote_cmd_arg(char *target, const char *source) +static void quote_cmd_arg(char *target, size_t remain, const char *source) FUNC_ATTR_NONNULL_ALL { - size_t len = strlen(source); + size_t src_len = strlen(source); size_t i; bool quote_hit = true; char *start = target; char tmp; - if (len == 0) { - *(target++) = '"'; - *(target++) = '"'; - *target = NUL; + if (src_len == 0) { + snprintf(target, remain, "\"\""); return; } if (NULL == strpbrk(source, " \t\"")) { - strcpy(target, source); + xstrlcpy(target, source, remain); return; } if (NULL == strpbrk(source, "\"\\")) { - *(target++) = '"'; - strncpy(target, source, len); - target += len; - *(target++) = '"'; - *target = NUL; + snprintf(target, remain, "\"%s\"", source); return; } + assert(remain--); *(target++) = NUL; + assert(remain--); *(target++) = '"'; - for (i = len; i > 0; --i) { + for (i = src_len; i > 0; i--) { + assert(remain--); *(target++) = source[i - 1]; if (quote_hit && source[i - 1] == '\\') { + assert(remain--); *(target++) = '\\'; } else if (source[i - 1] == '"') { quote_hit = true; + assert(remain--); *(target++) = '\\'; } else { quote_hit = false; } } + assert(remain); *target = '"'; while (start < target) { tmp = *start; -- cgit From 84fb794da653fc3bcc2832816ca0cab01b4e0400 Mon Sep 17 00:00:00 2001 From: erw7 Date: Sun, 2 Apr 2017 18:16:39 +0900 Subject: win/pyt: cleanup --- src/nvim/os/pty_process_win.c | 273 +++++++++++++++++++++++++----------------- src/nvim/os/pty_process_win.h | 13 +- 2 files changed, 173 insertions(+), 113 deletions(-) (limited to 'src') diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index f3efe87d78..6a08e2868b 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -12,19 +12,6 @@ # include "os/pty_process_win.c.generated.h" #endif -static void wait_eof_timer_cb(uv_timer_t *wait_eof_timer) - FUNC_ATTR_NONNULL_ALL -{ - PtyProcess *ptyproc = - (PtyProcess *)((uv_handle_t *)wait_eof_timer->data); - Process *proc = (Process *)ptyproc; - - if (!proc->out || !uv_is_readable(proc->out->uvstream)) { - uv_timer_stop(&ptyproc->wait_eof_timer); - pty_process_finish2(ptyproc); - } -} - static void CALLBACK pty_process_finish1(void *context, BOOLEAN unused) FUNC_ATTR_NONNULL_ALL { @@ -36,6 +23,7 @@ static void CALLBACK pty_process_finish1(void *context, BOOLEAN unused) uv_timer_start(&ptyproc->wait_eof_timer, wait_eof_timer_cb, 200, 200); } +/// @returns zero on sucess, or error code of winpty or MultiByteToWideChar. int pty_process_spawn(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL { @@ -44,34 +32,39 @@ int pty_process_spawn(PtyProcess *ptyproc) winpty_error_ptr_t err = NULL; winpty_config_t *cfg = NULL; winpty_spawn_config_t *spawncfg = NULL; - winpty_t *wp = NULL; - char *in_name = NULL, *out_name = NULL; + winpty_t *winpty_object = NULL; + char *in_name = NULL; + char *out_name = NULL; HANDLE process_handle = NULL; - uv_connect_t *in_req = NULL, *out_req = NULL; - wchar_t *cmdline = NULL, *cwd = NULL; + uv_connect_t *in_req = NULL; + uv_connect_t *out_req = NULL; + wchar_t *cmd_line = NULL; + wchar_t *cwd = NULL; assert(!proc->err); - if (!(cfg = winpty_config_new( - WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION, &err))) { + cfg = winpty_config_new(WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION, &err); + if (cfg == NULL) { goto cleanup; } - winpty_config_set_initial_size( - cfg, - ptyproc->width, - ptyproc->height); - if (!(wp = winpty_open(cfg, &err))) { + winpty_config_set_initial_size(cfg, ptyproc->width, ptyproc->height); + winpty_object = winpty_open(cfg, &err); + if (winpty_object == NULL) { goto cleanup; } - if ((status = utf16_to_utf8(winpty_conin_name(wp), &in_name))) { + status = utf16_to_utf8(winpty_conin_name(winpty_object), &in_name); + if (status != 0) { goto cleanup; } - if ((status = utf16_to_utf8(winpty_conout_name(wp), &out_name))) { + + status = utf16_to_utf8(winpty_conout_name(winpty_object), &out_name); + if (status != 0) { goto cleanup; } - if (proc->in) { + + if (proc->in != NULL) { in_req = xmalloc(sizeof(uv_connect_t)); uv_pipe_connect( in_req, @@ -79,7 +72,8 @@ int pty_process_spawn(PtyProcess *ptyproc) in_name, pty_process_connect_cb); } - if (proc->out) { + + if (proc->out != NULL) { out_req = xmalloc(sizeof(uv_connect_t)); uv_pipe_connect( out_req, @@ -88,46 +82,65 @@ int pty_process_spawn(PtyProcess *ptyproc) pty_process_connect_cb); } - if (proc->cwd != NULL && (status = utf8_to_utf16(proc->cwd, &cwd))) { - goto cleanup; + if (proc->cwd != NULL) { + status = utf8_to_utf16(proc->cwd, &cwd); + if (status != 0) { + goto cleanup; + } } - if ((status = build_cmdline(proc->argv, &cmdline))) { + + status = build_cmd_line(proc->argv, &cmd_line); + if (status != 0) { goto cleanup; } - if (!(spawncfg = winpty_spawn_config_new( + + spawncfg = winpty_spawn_config_new( WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN, - NULL, cmdline, cwd, NULL, &err))) { + NULL, // Optional application name + cmd_line, + cwd, + NULL, // Optional environment variables + &err); + if (spawncfg == NULL) { goto cleanup; } - if (!winpty_spawn(wp, spawncfg, &process_handle, NULL, NULL, &err)) { + + if (!winpty_spawn(winpty_object, + spawncfg, + &process_handle, + NULL, // Optional thread handle + NULL, // Optional create process error + &err)) { goto cleanup; } proc->pid = GetProcessId(process_handle); if (!RegisterWaitForSingleObject( &ptyproc->finish_wait, - process_handle, pty_process_finish1, ptyproc, - INFINITE, WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE)) { + process_handle, + pty_process_finish1, + ptyproc, + INFINITE, + WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE)) { abort(); } - while ((in_req && in_req->handle) || (out_req && out_req->handle)) { + // Wait until pty_process_connect_cb is called. + while ((in_req != NULL && in_req->handle != NULL) + || (out_req != NULL && out_req->handle != NULL)) { uv_run(&proc->loop->uv, UV_RUN_ONCE); } - ptyproc->wp = wp; + ptyproc->winpty_object = winpty_object; ptyproc->process_handle = process_handle; - wp = NULL; + winpty_object = NULL; process_handle = NULL; cleanup: - if (err != NULL) { - status = (int)winpty_error_code(err); - } winpty_error_free(err); winpty_config_free(cfg); winpty_spawn_config_free(spawncfg); - winpty_free(wp); + winpty_free(winpty_object); xfree(in_name); xfree(out_name); if (process_handle != NULL) { @@ -135,7 +148,7 @@ cleanup: } xfree(in_req); xfree(out_req); - xfree(cmdline); + xfree(cmd_line); xfree(cwd); return status; } @@ -144,8 +157,8 @@ void pty_process_resize(PtyProcess *ptyproc, uint16_t width, uint16_t height) FUNC_ATTR_NONNULL_ALL { - if (ptyproc->wp != NULL) { - winpty_set_size(ptyproc->wp, width, height, NULL); + if (ptyproc->winpty_object != NULL) { + winpty_set_size(ptyproc->winpty_object, width, height, NULL); } } @@ -164,9 +177,9 @@ void pty_process_close(PtyProcess *ptyproc) void pty_process_close_master(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL { - if (ptyproc->wp != NULL) { - winpty_free(ptyproc->wp); - ptyproc->wp = NULL; + if (ptyproc->winpty_object != NULL) { + winpty_free(ptyproc->winpty_object); + ptyproc->winpty_object = NULL; } } @@ -182,6 +195,19 @@ static void pty_process_connect_cb(uv_connect_t *req, int status) req->handle = NULL; } +static void wait_eof_timer_cb(uv_timer_t *wait_eof_timer) + FUNC_ATTR_NONNULL_ALL +{ + PtyProcess *ptyproc = + (PtyProcess *)((uv_handle_t *)wait_eof_timer->data); + Process *proc = (Process *)ptyproc; + + if (!proc->out || !uv_is_readable(proc->out->uvstream)) { + uv_timer_stop(&ptyproc->wait_eof_timer); + pty_process_finish2(ptyproc); + } +} + static void pty_process_finish2(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL { @@ -200,99 +226,132 @@ static void pty_process_finish2(PtyProcess *ptyproc) proc->internal_exit_cb(proc); } -static int build_cmdline(char **argv, wchar_t **cmdline) +/// Build the command line to pass to CreateProcessW. +/// +/// @param[in] argv Array with string arguments. +/// @param[out] cmd_line Location where saved bulded cmd line. +/// +/// @returns zero on sucess, or error code of MultiByteToWideChar function. +/// +static int build_cmd_line(char **argv, wchar_t **cmd_line) FUNC_ATTR_NONNULL_ALL { - char *args = NULL; - size_t args_len = 0, argc = 0; - int ret; - QUEUE q; - QUEUE_INIT(&q); + size_t utf8_cmd_line_len = 0; + size_t argc = 0; + QUEUE args_q; + QUEUE_INIT(&args_q); while (*argv) { size_t buf_len = strlen(*argv) * 2 + 3; - arg_T *arg = xmalloc(sizeof(arg_T)); - arg->arg = (char *)xmalloc(buf_len); - quote_cmd_arg(arg->arg, buf_len, *argv); - args_len += strlen(arg->arg); - QUEUE_INIT(&arg->node); - QUEUE_INSERT_TAIL(&q, &arg->node); + ArgNode *arg_node = xmalloc(sizeof(*arg_node)); + arg_node->arg = xmalloc(buf_len); + quote_cmd_arg(arg_node->arg, buf_len, *argv); + utf8_cmd_line_len += strlen(arg_node->arg); + QUEUE_INIT(&arg_node->node); + QUEUE_INSERT_TAIL(&args_q, &arg_node->node); argc++; argv++; } - args_len += argc; - args = xmalloc(args_len); - *args = NUL; + + utf8_cmd_line_len += argc; + char *utf8_cmd_line = xmalloc(utf8_cmd_line_len); + *utf8_cmd_line = NUL; while (1) { - QUEUE *head = QUEUE_HEAD(&q); + QUEUE *head = QUEUE_HEAD(&args_q); QUEUE_REMOVE(head); - arg_T *arg = QUEUE_DATA(head, arg_T, node); - xstrlcat(args, arg->arg, args_len); - xfree(arg->arg); - xfree(arg); - if (QUEUE_EMPTY(&q)) { + ArgNode *arg_node = QUEUE_DATA(head, ArgNode, node); + xstrlcat(utf8_cmd_line, arg_node->arg, utf8_cmd_line_len); + xfree(arg_node->arg); + xfree(arg_node); + if (QUEUE_EMPTY(&args_q)) { break; } else { - xstrlcat(args, " ", args_len); + xstrlcat(utf8_cmd_line, " ", utf8_cmd_line_len); } } - ret = utf8_to_utf16(args, cmdline); - xfree(args); - return ret; + + int result = utf8_to_utf16(utf8_cmd_line, cmd_line); + if (result != 0) { + } + xfree(utf8_cmd_line); + return result; } -// Emulate quote_cmd_arg of libuv and quotes command line arguments -static void quote_cmd_arg(char *target, size_t remain, const char *source) +/// Emulate quote_cmd_arg of libuv and quotes command line argument. +/// Most of the code came from libuv. +/// +/// @param[out] dist Location where saved quotes argument. +/// @param dist_remaining Deistnation buffer size. +/// @param[in] src Pointer to argument. +/// +static void quote_cmd_arg(char *dist, size_t dist_remaining, const char *src) FUNC_ATTR_NONNULL_ALL { - size_t src_len = strlen(source); - size_t i; + size_t src_len = strlen(src); bool quote_hit = true; - char *start = target; - char tmp; + char *start = dist; if (src_len == 0) { - snprintf(target, remain, "\"\""); + // Need double quotation for empty argument. + snprintf(dist, dist_remaining, "\"\""); return; } - if (NULL == strpbrk(source, " \t\"")) { - xstrlcpy(target, source, remain); + if (NULL == strpbrk(src, " \t\"")) { + // No quotation needed. + xstrlcpy(dist, src, dist_remaining); return; } - if (NULL == strpbrk(source, "\"\\")) { - snprintf(target, remain, "\"%s\"", source); + if (NULL == strpbrk(src, "\"\\")) { + // No embedded double quotes or backlashes, so I can just wrap quote marks. + // around the whole thing. + snprintf(dist, dist_remaining, "\"%s\"", src); return; } - assert(remain--); - *(target++) = NUL; - assert(remain--); - *(target++) = '"'; - for (i = src_len; i > 0; i--) { - assert(remain--); - *(target++) = source[i - 1]; - - if (quote_hit && source[i - 1] == '\\') { - assert(remain--); - *(target++) = '\\'; - } else if (source[i - 1] == '"') { + // Expected input/output: + // input : hello"world + // output: "hello\"world" + // input : hello""world + // output: "hello\"\"world" + // input : hello\world + // output: hello\world + // input : hello\\world + // output: hello\\world + // input : hello\"world + // output: "hello\\\"world" + // input : hello\\"world + // output: "hello\\\\\"world" + // input : hello world\ + // output: "hello world\\" + + assert(dist_remaining--); + *(dist++) = NUL; + assert(dist_remaining--); + *(dist++) = '"'; + for (size_t i = src_len; i > 0; i--) { + assert(dist_remaining--); + *(dist++) = src[i - 1]; + if (quote_hit && src[i - 1] == '\\') { + assert(dist_remaining--); + *(dist++) = '\\'; + } else if (src[i - 1] == '"') { quote_hit = true; - assert(remain--); - *(target++) = '\\'; + assert(dist_remaining--); + *(dist++) = '\\'; } else { quote_hit = false; } } - assert(remain); - *target = '"'; - while (start < target) { - tmp = *start; - *start = *target; - *target = tmp; + assert(dist_remaining); + *dist = '"'; + + while (start < dist) { + char tmp = *start; + *start = *dist; + *dist = tmp; start++; - target--; + dist--; } - return; } diff --git a/src/nvim/os/pty_process_win.h b/src/nvim/os/pty_process_win.h index 806857f130..59e0fad7f7 100644 --- a/src/nvim/os/pty_process_win.h +++ b/src/nvim/os/pty_process_win.h @@ -12,16 +12,17 @@ typedef struct pty_process { Process process; char *term_name; uint16_t width, height; - winpty_t *wp; + winpty_t *winpty_object; HANDLE finish_wait; HANDLE process_handle; uv_timer_t wait_eof_timer; } PtyProcess; -typedef struct arg_S { - char *arg; - QUEUE node; -} arg_T; +// Structure used by build_cmd_line() +typedef struct arg_node { + char *arg; // pointer to argument. + QUEUE node; // QUEUE structure. +} ArgNode; static inline PtyProcess pty_process_init(Loop *loop, void *data) { @@ -30,7 +31,7 @@ static inline PtyProcess pty_process_init(Loop *loop, void *data) rv.term_name = NULL; rv.width = 80; rv.height = 24; - rv.wp = NULL; + rv.winpty_object = NULL; rv.finish_wait = NULL; rv.process_handle = NULL; return rv; -- cgit From d3a8c4f99289f7b65a68bf9ed5eeab34aa688e0e Mon Sep 17 00:00:00 2001 From: erw7 Date: Sun, 2 Apr 2017 18:32:23 +0900 Subject: win/pty: log errors --- src/nvim/os/pty_process_win.c | 112 ++++++++++++++++++++++++++++++------------ src/nvim/os/pty_process_win.h | 1 - 2 files changed, 80 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index 6a08e2868b..4bb5f64455 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -2,7 +2,9 @@ #include #include -#include "nvim/vim.h" +#include + +#include "nvim/os/os.h" #include "nvim/ascii.h" #include "nvim/memory.h" #include "nvim/mbyte.h" // for utf8_to_utf16, utf16_to_utf8 @@ -23,7 +25,7 @@ static void CALLBACK pty_process_finish1(void *context, BOOLEAN unused) uv_timer_start(&ptyproc->wait_eof_timer, wait_eof_timer_cb, 200, 200); } -/// @returns zero on sucess, or error code of winpty or MultiByteToWideChar. +/// @returns zero on success, or negative error code. int pty_process_spawn(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL { @@ -40,27 +42,32 @@ int pty_process_spawn(PtyProcess *ptyproc) uv_connect_t *out_req = NULL; wchar_t *cmd_line = NULL; wchar_t *cwd = NULL; + const char *emsg = NULL; assert(!proc->err); cfg = winpty_config_new(WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION, &err); if (cfg == NULL) { + emsg = "Failed, winpty_config_new."; goto cleanup; } winpty_config_set_initial_size(cfg, ptyproc->width, ptyproc->height); winpty_object = winpty_open(cfg, &err); if (winpty_object == NULL) { + emsg = "Failed, winpty_open."; goto cleanup; } status = utf16_to_utf8(winpty_conin_name(winpty_object), &in_name); if (status != 0) { + emsg = "Failed to convert in_name from utf16 to utf8."; goto cleanup; } status = utf16_to_utf8(winpty_conout_name(winpty_object), &out_name); if (status != 0) { + emsg = "Failed to convert out_name from utf16 to utf8."; goto cleanup; } @@ -85,12 +92,14 @@ int pty_process_spawn(PtyProcess *ptyproc) if (proc->cwd != NULL) { status = utf8_to_utf16(proc->cwd, &cwd); if (status != 0) { + emsg = "Failed to convert pwd form utf8 to utf16."; goto cleanup; } } status = build_cmd_line(proc->argv, &cmd_line); if (status != 0) { + emsg = "Failed to convert cmd line form utf8 to utf16."; goto cleanup; } @@ -102,15 +111,23 @@ int pty_process_spawn(PtyProcess *ptyproc) NULL, // Optional environment variables &err); if (spawncfg == NULL) { + emsg = "Failed winpty_spawn_config_new."; goto cleanup; } + DWORD win_err = 0; if (!winpty_spawn(winpty_object, spawncfg, &process_handle, NULL, // Optional thread handle - NULL, // Optional create process error + &win_err, &err)) { + if (win_err) { + status = (int)win_err; + emsg = "Failed spawn process."; + } else { + emsg = "Failed winpty_spawn."; + } goto cleanup; } proc->pid = GetProcessId(process_handle); @@ -137,6 +154,15 @@ int pty_process_spawn(PtyProcess *ptyproc) process_handle = NULL; cleanup: + if (status) { + // In the case of an error of MultiByteToWideChar or CreateProcessW. + ELOG("%s error code: %d", emsg, status); + status = os_translate_sys_error(status); + } else if (err != NULL) { + status = (int)winpty_error_code(err); + ELOG("%s error code: %d", emsg, status); + status = translate_winpty_error(status); + } winpty_error_free(err); winpty_config_free(cfg); winpty_spawn_config_free(spawncfg); @@ -198,8 +224,7 @@ static void pty_process_connect_cb(uv_connect_t *req, int status) static void wait_eof_timer_cb(uv_timer_t *wait_eof_timer) FUNC_ATTR_NONNULL_ALL { - PtyProcess *ptyproc = - (PtyProcess *)((uv_handle_t *)wait_eof_timer->data); + PtyProcess *ptyproc = wait_eof_timer->data; Process *proc = (Process *)ptyproc; if (!proc->out || !uv_is_readable(proc->out->uvstream)) { @@ -229,9 +254,9 @@ static void pty_process_finish2(PtyProcess *ptyproc) /// Build the command line to pass to CreateProcessW. /// /// @param[in] argv Array with string arguments. -/// @param[out] cmd_line Location where saved bulded cmd line. +/// @param[out] cmd_line Location where saved builded cmd line. /// -/// @returns zero on sucess, or error code of MultiByteToWideChar function. +/// @returns zero on success, or error code of MultiByteToWideChar function. /// static int build_cmd_line(char **argv, wchar_t **cmd_line) FUNC_ATTR_NONNULL_ALL @@ -271,8 +296,6 @@ static int build_cmd_line(char **argv, wchar_t **cmd_line) } int result = utf8_to_utf16(utf8_cmd_line, cmd_line); - if (result != 0) { - } xfree(utf8_cmd_line); return result; } @@ -280,33 +303,33 @@ static int build_cmd_line(char **argv, wchar_t **cmd_line) /// Emulate quote_cmd_arg of libuv and quotes command line argument. /// Most of the code came from libuv. /// -/// @param[out] dist Location where saved quotes argument. -/// @param dist_remaining Deistnation buffer size. +/// @param[out] dest Location where saved quotes argument. +/// @param dest_remaining Destination buffer size. /// @param[in] src Pointer to argument. /// -static void quote_cmd_arg(char *dist, size_t dist_remaining, const char *src) +static void quote_cmd_arg(char *dest, size_t dest_remaining, const char *src) FUNC_ATTR_NONNULL_ALL { size_t src_len = strlen(src); bool quote_hit = true; - char *start = dist; + char *start = dest; if (src_len == 0) { // Need double quotation for empty argument. - snprintf(dist, dist_remaining, "\"\""); + snprintf(dest, dest_remaining, "\"\""); return; } if (NULL == strpbrk(src, " \t\"")) { // No quotation needed. - xstrlcpy(dist, src, dist_remaining); + xstrlcpy(dest, src, dest_remaining); return; } if (NULL == strpbrk(src, "\"\\")) { // No embedded double quotes or backlashes, so I can just wrap quote marks. // around the whole thing. - snprintf(dist, dist_remaining, "\"%s\"", src); + snprintf(dest, dest_remaining, "\"%s\"", src); return; } @@ -326,32 +349,57 @@ static void quote_cmd_arg(char *dist, size_t dist_remaining, const char *src) // input : hello world\ // output: "hello world\\" - assert(dist_remaining--); - *(dist++) = NUL; - assert(dist_remaining--); - *(dist++) = '"'; + assert(dest_remaining--); + *(dest++) = NUL; + assert(dest_remaining--); + *(dest++) = '"'; for (size_t i = src_len; i > 0; i--) { - assert(dist_remaining--); - *(dist++) = src[i - 1]; + assert(dest_remaining--); + *(dest++) = src[i - 1]; if (quote_hit && src[i - 1] == '\\') { - assert(dist_remaining--); - *(dist++) = '\\'; + assert(dest_remaining--); + *(dest++) = '\\'; } else if (src[i - 1] == '"') { quote_hit = true; - assert(dist_remaining--); - *(dist++) = '\\'; + assert(dest_remaining--); + *(dest++) = '\\'; } else { quote_hit = false; } } - assert(dist_remaining); - *dist = '"'; + assert(dest_remaining); + *dest = '"'; - while (start < dist) { + while (start < dest) { char tmp = *start; - *start = *dist; - *dist = tmp; + *start = *dest; + *dest = tmp; start++; - dist--; + dest--; + } +} + +/// Translate winpty error code to libuv error. +/// +/// @param[in] winpty_errno Winpty error code returned by winpty_error_code +/// function. +/// +/// @returns Error code of libuv error. +int translate_winpty_error(int winpty_errno) +{ + if (winpty_errno <= 0) { + return winpty_errno; // If < 0 then it's already a libuv error. + } + + switch (winpty_errno) { + case WINPTY_ERROR_OUT_OF_MEMORY: return UV_ENOMEM; + case WINPTY_ERROR_SPAWN_CREATE_PROCESS_FAILED: return UV_EAI_FAIL; + case WINPTY_ERROR_LOST_CONNECTION: return UV_ENOTCONN; + case WINPTY_ERROR_AGENT_EXE_MISSING: return UV_ENOENT; + case WINPTY_ERROR_UNSPECIFIED: return UV_UNKNOWN; + case WINPTY_ERROR_AGENT_DIED: return UV_ESRCH; + case WINPTY_ERROR_AGENT_TIMEOUT: return UV_ETIMEDOUT; + case WINPTY_ERROR_AGENT_CREATION_FAILED: return UV_EAI_FAIL; + default: return UV_UNKNOWN; } } diff --git a/src/nvim/os/pty_process_win.h b/src/nvim/os/pty_process_win.h index 59e0fad7f7..1a4019e654 100644 --- a/src/nvim/os/pty_process_win.h +++ b/src/nvim/os/pty_process_win.h @@ -2,7 +2,6 @@ #define NVIM_OS_PTY_PROCESS_WIN_H #include - #include #include "nvim/event/process.h" -- cgit From 8c1782b84070d786cc1a7dfd6242a9ebc0923ad3 Mon Sep 17 00:00:00 2001 From: erw7 Date: Fri, 14 Apr 2017 22:35:56 +0900 Subject: pty_process_win: avoid quoting for cmd.exe --- src/nvim/os/pty_process_win.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index 4bb5f64455..ef8a699c56 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -97,7 +97,8 @@ int pty_process_spawn(PtyProcess *ptyproc) } } - status = build_cmd_line(proc->argv, &cmd_line); + status = build_cmd_line(proc->argv, &cmd_line, + os_shell_is_cmdexe(proc->argv[0])); if (status != 0) { emsg = "Failed to convert cmd line form utf8 to utf16."; goto cleanup; @@ -258,7 +259,7 @@ static void pty_process_finish2(PtyProcess *ptyproc) /// /// @returns zero on success, or error code of MultiByteToWideChar function. /// -static int build_cmd_line(char **argv, wchar_t **cmd_line) +static int build_cmd_line(char **argv, wchar_t **cmd_line, bool is_cmdexe) FUNC_ATTR_NONNULL_ALL { size_t utf8_cmd_line_len = 0; @@ -267,10 +268,14 @@ static int build_cmd_line(char **argv, wchar_t **cmd_line) QUEUE_INIT(&args_q); while (*argv) { - size_t buf_len = strlen(*argv) * 2 + 3; + size_t buf_len = is_cmdexe ? (strlen(*argv) + 1) : (strlen(*argv) * 2 + 3); ArgNode *arg_node = xmalloc(sizeof(*arg_node)); arg_node->arg = xmalloc(buf_len); - quote_cmd_arg(arg_node->arg, buf_len, *argv); + if (is_cmdexe) { + xstrlcpy(arg_node->arg, *argv, buf_len); + } else { + quote_cmd_arg(arg_node->arg, buf_len, *argv); + } utf8_cmd_line_len += strlen(arg_node->arg); QUEUE_INIT(&arg_node->node); QUEUE_INSERT_TAIL(&args_q, &arg_node->node); -- cgit From 8642f05fd91d7285a7d8d2bb13b4d63fe5c371fa Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 6 Aug 2017 14:28:51 +0200 Subject: single-includes: ignore os/pty_process_win.h --- src/nvim/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 2e0a35d4ab..688912eda6 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -535,6 +535,7 @@ endfunction() set(NO_SINGLE_CHECK_HEADERS os/win_defs.h + os/pty_process_win.h regexp_defs.h syntax_defs.h terminal.h -- cgit From f0a9b7ff637b1c33988b8ec20530657ba71644fc Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 25 Jun 2017 06:43:26 +0200 Subject: vim-patch:8.0.0678 closing a window does not trigger resizing Closes #6748 Problem: When 'equalalways' is set and closing a window in a separate frame, not all window sizes are adjusted. (Glacambre) Solution: Resize all windows if the new current window is not in the same frame as the closed window. (closes vim/vim#1707) https://github.com/vim/vim/commit/8eeeba8c025ff844e6514c4a60cec11bf1fc1b35 --- src/nvim/testdir/test_window_cmd.vim | 44 ++++++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- src/nvim/window.c | 5 +++- 3 files changed, 49 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim index 188a7ed0f3..9d61921988 100644 --- a/src/nvim/testdir/test_window_cmd.vim +++ b/src/nvim/testdir/test_window_cmd.vim @@ -336,6 +336,50 @@ func Test_window_width() bw Xa Xb Xc endfunc +func Test_equalalways_on_close() + set equalalways + vsplit + windo split + split + wincmd J + " now we have a frame top-left with two windows, a frame top-right with two + " windows and a frame at the bottom, full-width. + let height_1 = winheight(1) + let height_2 = winheight(2) + let height_3 = winheight(3) + let height_4 = winheight(4) + " closing the bottom window causes all windows to be resized. + close + call assert_notequal(height_1, winheight(1)) + call assert_notequal(height_2, winheight(2)) + call assert_notequal(height_3, winheight(3)) + call assert_notequal(height_4, winheight(4)) + call assert_equal(winheight(1), winheight(3)) + call assert_equal(winheight(2), winheight(4)) + + 1wincmd w + split + 4wincmd w + resize + 5 + " left column has three windows, equalized heights. + " right column has two windows, top one a bit higher + let height_1 = winheight(1) + let height_2 = winheight(2) + let height_4 = winheight(4) + let height_5 = winheight(5) + 3wincmd w + " closing window in left column equalizes heights in left column but not in + " the right column + close + call assert_notequal(height_1, winheight(1)) + call assert_notequal(height_2, winheight(2)) + call assert_equal(height_4, winheight(3)) + call assert_equal(height_5, winheight(4)) + + only + set equalalways& +endfunc + func Test_window_jump_tag() help /iccf diff --git a/src/nvim/version.c b/src/nvim/version.c index f4984864f3..80b8b03258 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -274,7 +274,7 @@ static const int included_patches[] = { // 681, // 680, // 679, - // 678, + 678, // 677, // 676, // 675, diff --git a/src/nvim/window.c b/src/nvim/window.c index faf5bceb56..6a21844812 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1878,6 +1878,7 @@ int win_close(win_T *win, int free_buf) int dir; int help_window = FALSE; tabpage_T *prev_curtab = curtab; + frame_T *win_frame = win->w_frame; if (last_window()) { EMSG(_("E444: Cannot close last window")); @@ -2027,7 +2028,9 @@ int win_close(win_T *win, int free_buf) check_cursor(); } if (p_ea && (*p_ead == 'b' || *p_ead == dir)) { - win_equal(curwin, true, dir); + // If the frame of the closed window contains the new current window, + // only resize that frame. Otherwise resize all windows. + win_equal(curwin, curwin->w_frame->fr_parent == win_frame->fr_parent, dir); } else { win_comp_pos(); } -- cgit From 1fb3339844b2244daaee9b44264137c8c6c67164 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 27 Jun 2017 02:32:08 +0200 Subject: vim-patch:8.0.0679 Problem: Using freed memory. Solution: Get the parent frame pointer earlier. https://github.com/vim/vim/commit/41cc038ff83498c589c7d25b3d2984145528eb92 --- src/nvim/version.c | 2 +- src/nvim/window.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 80b8b03258..bd90f28629 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -273,7 +273,7 @@ static const int included_patches[] = { // 682, // 681, // 680, - // 679, + 679, 678, // 677, // 676, diff --git a/src/nvim/window.c b/src/nvim/window.c index 6a21844812..081fc98816 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1878,7 +1878,7 @@ int win_close(win_T *win, int free_buf) int dir; int help_window = FALSE; tabpage_T *prev_curtab = curtab; - frame_T *win_frame = win->w_frame; + frame_T *win_frame = win->w_frame->fr_parent; if (last_window()) { EMSG(_("E444: Cannot close last window")); @@ -2030,7 +2030,7 @@ int win_close(win_T *win, int free_buf) if (p_ea && (*p_ead == 'b' || *p_ead == dir)) { // If the frame of the closed window contains the new current window, // only resize that frame. Otherwise resize all windows. - win_equal(curwin, curwin->w_frame->fr_parent == win_frame->fr_parent, dir); + win_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir); } else { win_comp_pos(); } -- cgit From 8dddf5590796994254fb31b4cbe1736ec3faf9f6 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Wed, 19 Jul 2017 22:48:05 +0800 Subject: vim-patch:8.0.0044 Problem: In diff mode the cursor may end up below the last line, resulting in an ml_get error. Solution: Check the line to be valid. https://github.com/vim/vim/commit/025e3e0bafbc85cc4e365145af711edf99d0a90d --- src/nvim/diff.c | 67 ++++++++++++++++++-------------------- src/nvim/move.c | 12 +++---- src/nvim/testdir/test_diffmode.vim | 17 ++++++++++ src/nvim/version.c | 2 +- 4 files changed, 54 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 7da6665cb7..17de4284ce 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -1033,10 +1033,7 @@ void ex_diffsplit(exarg_T *eap) if (bufref_valid(&old_curbuf)) { // Move the cursor position to that of the old window. curwin->w_cursor.lnum = diff_get_corresponding_line( - old_curbuf.br_buf, - old_curwin->w_cursor.lnum, - curbuf, - curwin->w_cursor.lnum); + old_curbuf.br_buf, old_curwin->w_cursor.lnum); } } // Now that lines are folded scroll to show the cursor at the same @@ -2463,25 +2460,17 @@ int diff_move_to(int dir, long count) return OK; } -/// Finds the corresponding line in a diff. -/// -/// @param buf1 -/// @param lnum1 -/// @param buf2 -/// @param lnum3 -/// -/// @return The corresponding line. -linenr_T diff_get_corresponding_line(buf_T *buf1, linenr_T lnum1, buf_T *buf2, - linenr_T lnum3) +/// Return the line number in the current window that is closest to "lnum1" in +/// "buf1" in diff mode. +static linenr_T diff_get_corresponding_line_int(buf_T *buf1, linenr_T lnum1) { int idx1; int idx2; diff_T *dp; int baseline = 0; - linenr_T lnum2; idx1 = diff_buf_idx(buf1); - idx2 = diff_buf_idx(buf2); + idx2 = diff_buf_idx(curbuf); if ((idx1 == DB_COUNT) || (idx2 == DB_COUNT) @@ -2501,15 +2490,9 @@ linenr_T diff_get_corresponding_line(buf_T *buf1, linenr_T lnum1, buf_T *buf2, for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next) { if (dp->df_lnum[idx1] > lnum1) { - lnum2 = lnum1 - baseline; - - // don't end up past the end of the file - if (lnum2 > buf2->b_ml.ml_line_count) { - lnum2 = buf2->b_ml.ml_line_count; - } - - return lnum2; - } else if ((dp->df_lnum[idx1] + dp->df_count[idx1]) > lnum1) { + return lnum1 - baseline; + } + if ((dp->df_lnum[idx1] + dp->df_count[idx1]) > lnum1) { // Inside the diffblock baseline = lnum1 - dp->df_lnum[idx1]; @@ -2518,30 +2501,42 @@ linenr_T diff_get_corresponding_line(buf_T *buf1, linenr_T lnum1, buf_T *buf2, } return dp->df_lnum[idx2] + baseline; - } else if ((dp->df_lnum[idx1] == lnum1) - && (dp->df_count[idx1] == 0) - && (dp->df_lnum[idx2] <= lnum3) - && ((dp->df_lnum[idx2] + dp->df_count[idx2]) > lnum3)) { + } + if ((dp->df_lnum[idx1] == lnum1) + && (dp->df_count[idx1] == 0) + && (dp->df_lnum[idx2] <= curwin->w_cursor.lnum) + && ((dp->df_lnum[idx2] + dp->df_count[idx2]) + > curwin->w_cursor.lnum)) { // Special case: if the cursor is just after a zero-count // block (i.e. all filler) and the target cursor is already // inside the corresponding block, leave the target cursor // unmoved. This makes repeated CTRL-W W operations work // as expected. - return lnum3; + return curwin->w_cursor.lnum; } baseline = (dp->df_lnum[idx1] + dp->df_count[idx1]) - - (dp->df_lnum[idx2] + dp->df_count[idx2]); + - (dp->df_lnum[idx2] + dp->df_count[idx2]); } // If we get here then the cursor is after the last diff - lnum2 = lnum1 - baseline; + return lnum1 - baseline; +} + +/// Finds the corresponding line in a diff. +/// +/// @param buf1 +/// @param lnum1 +/// +/// @return The corresponding line. +linenr_T diff_get_corresponding_line(buf_T *buf1, linenr_T lnum1) +{ + linenr_T lnum = diff_get_corresponding_line_int(buf1, lnum1); // don't end up past the end of the file - if (lnum2 > buf2->b_ml.ml_line_count) { - lnum2 = buf2->b_ml.ml_line_count; + if (lnum > curbuf->b_ml.ml_line_count) { + return curbuf->b_ml.ml_line_count; } - - return lnum2; + return lnum; } /// For line "lnum" in the current window find the equivalent lnum in window diff --git a/src/nvim/move.c b/src/nvim/move.c index 81d46a7f17..4d646f5a4b 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -2147,14 +2147,12 @@ void do_check_cursorbind(void) curbuf = curwin->w_buffer; /* skip original window and windows with 'noscrollbind' */ if (curwin != old_curwin && curwin->w_p_crb) { - if (curwin->w_p_diff) - curwin->w_cursor.lnum - = diff_get_corresponding_line(old_curbuf, - line, - curbuf, - curwin->w_cursor.lnum); - else + if (curwin->w_p_diff) { + curwin->w_cursor.lnum = + diff_get_corresponding_line(old_curbuf, line); + } else { curwin->w_cursor.lnum = line; + } curwin->w_cursor.col = col; curwin->w_cursor.coladd = coladd; curwin->w_curswant = curswant; diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim index 5de394de8e..f40e06ff33 100644 --- a/src/nvim/testdir/test_diffmode.vim +++ b/src/nvim/testdir/test_diffmode.vim @@ -218,3 +218,20 @@ func Test_diffoff() bwipe! bwipe! endfunc + +func Test_setting_cursor() + new Xtest1 + put =range(1,90) + wq + new Xtest2 + put =range(1,100) + wq + + tabe Xtest2 + $ + diffsp Xtest1 + tabclose + + call delete('Xtest1') + call delete('Xtest2') +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index f4984864f3..86c87b08ef 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -908,7 +908,7 @@ static const int included_patches[] = { 47, 46, // 45 NA - // 44, + 44, 43, 42, 41, -- cgit From b2967a0320ec327d1271bb75d96156a5ff1c8758 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 5 Aug 2017 23:53:48 +0200 Subject: nvim -h: omit special-case options Group some options, and sort them alphabetically. `nvim -h` should fit on one (smallish) screen. Uncommon options don't need to be here, they live in the :help. --- src/nvim/main.c | 71 ++++++++++++++++++--------------------- src/nvim/testdir/test_startup.vim | 6 ++-- 2 files changed, 35 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index 3f828d7be9..a665ad1de2 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1878,54 +1878,47 @@ static void usage(void) signal_stop(); // kill us with CTRL-C here, if you like mch_msg(_("Usage:\n")); - mch_msg(_(" nvim [arguments] [file ...] Edit specified file(s)\n")); - mch_msg(_(" nvim [arguments] - Read text from stdin\n")); - mch_msg(_(" nvim [arguments] -t Edit file where tag is defined\n")); - mch_msg(_(" nvim [arguments] -q [errorfile] Edit file with first error\n")); - mch_msg(_("\nArguments:\n")); + mch_msg(_(" nvim [options] [file ...] Edit file(s)\n")); + mch_msg(_(" nvim [options] - Read text from stdin\n")); + mch_msg(_(" nvim [options] -t Edit file where tag is defined\n")); + mch_msg(_(" nvim [options] -q [errorfile] Edit file with first error\n")); + mch_msg(_("\nOptions:\n")); mch_msg(_(" -- Only file names after this\n")); -#if !defined(UNIX) - mch_msg(_(" --literal Don't expand wildcards\n")); -#endif - mch_msg(_(" -e Ex mode\n")); - mch_msg(_(" -E Improved Ex mode\n")); - mch_msg(_(" -s Silent (batch) mode (only for ex mode)\n")); + mch_msg(_(" + Start at end of file\n")); + mch_msg(_(" --cmd Execute before any config\n")); + mch_msg(_(" +, -c Execute after config and first file\n")); + mch_msg("\n"); + mch_msg(_(" -b Binary mode\n")); mch_msg(_(" -d Diff mode\n")); - mch_msg(_(" -R Read-only mode\n")); - mch_msg(_(" -Z Restricted mode\n")); + mch_msg(_(" -e, -E Ex mode, Improved Ex mode\n")); + mch_msg(_(" -es Silent (batch) mode\n")); + mch_msg(_(" -h, --help Print this help message\n")); + mch_msg(_(" -i Use this shada file\n")); mch_msg(_(" -m Modifications (writing files) not allowed\n")); mch_msg(_(" -M Modifications in text not allowed\n")); - mch_msg(_(" -b Binary mode\n")); - mch_msg(_(" -l Lisp mode\n")); - mch_msg(_(" -A Arabic mode\n")); - mch_msg(_(" -F Farsi mode\n")); - mch_msg(_(" -H Hebrew mode\n")); - mch_msg(_(" -V[N][file] Be verbose [level N][log messages to file]\n")); - mch_msg(_(" -D Debugging mode\n")); mch_msg(_(" -n No swap file, use memory only\n")); - mch_msg(_(" -r, -L List swap files and exit\n")); - mch_msg(_(" -r Recover crashed session\n")); - mch_msg(_(" -u Use instead of the default\n")); - mch_msg(_(" -i Use instead of the default\n")); - mch_msg(_(" --noplugin Don't load plugin scripts\n")); - mch_msg(_(" -o[N] Open N windows (default: one for each file)\n")); - mch_msg(_(" -O[N] Like -o but split vertically\n")); - mch_msg(_(" -p[N] Open N tab pages (default: one for each file)\n")); - mch_msg(_(" + Start at end of file\n")); - mch_msg(_(" + Start at line \n")); - mch_msg(_(" +/ Start at first occurrence of \n")); - mch_msg(_(" --cmd Execute before loading any vimrc\n")); - mch_msg(_(" -c Execute after loading the first file\n")); + mch_msg(_(" -o[N] Open N windows (default: one per file)\n")); + mch_msg(_(" -O[N] Open N vertical windows (default: one per file)\n")); + mch_msg(_(" -p[N] Open N tab pages (default: one per file)\n")); + mch_msg(_(" -r, -L List swap files\n")); + mch_msg(_(" -r Recover edit state for this file\n")); + mch_msg(_(" -R Read-only mode\n")); mch_msg(_(" -S Source after loading the first file\n")); mch_msg(_(" -s Read Normal mode commands from \n")); - mch_msg(_(" -w Append all typed characters to \n")); - mch_msg(_(" -W Write all typed characters to \n")); - mch_msg(_(" --startuptime Write startup timing messages to \n")); - mch_msg(_(" --api-info Dump API metadata serialized to msgpack and exit\n")); + mch_msg(_(" -u Use this config file\n")); + mch_msg(_(" -v, --version Print version information\n")); + mch_msg(_(" -V[N][file] Verbose [level][file]\n")); + mch_msg(_(" -Z Restricted mode\n")); + mch_msg("\n"); + mch_msg(_(" --api-info Write msgpack-encoded API metadata to stdout\n")); mch_msg(_(" --embed Use stdin/stdout as a msgpack-rpc channel\n")); mch_msg(_(" --headless Don't start a user interface\n")); - mch_msg(_(" -v, --version Print version information and exit\n")); - mch_msg(_(" -h, --help Print this help message and exit\n")); +#if !defined(UNIX) + mch_msg(_(" --literal Don't expand wildcards\n")); +#endif + mch_msg(_(" --noplugin Don't load plugins\n")); + mch_msg(_(" --startuptime Write startup timing messages to \n")); + mch_msg(_("\nSee \":help startup-options\" for all options.\n")); } diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 64f7f31294..5a38178bd5 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -76,11 +76,11 @@ func Test_help_arg() let found = [] for line in lines if line =~ '-R.*Read-only mode' - call add(found, 'Readonly mode') + call add(found, 'Readonly mode') endif " Watch out for a second --version line in the Gnome version. - if line =~ '--version.*Print version information and exit' - call add(found, "--version") + if line =~ '--version.*Print version information' + call add(found, "--version") endif endfor call assert_equal(['Readonly mode', '--version'], found) -- cgit From 6ca6a8134ddf62d3b6abc57185b096fd712cc873 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 17 Aug 2017 00:29:25 +0200 Subject: intro: remove byline #6984 --- src/nvim/version.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index f5b45caefc..e024982faf 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1216,7 +1216,6 @@ void intro_message(int colon) static char *(lines[]) = { N_(NVIM_VERSION_LONG), "", - N_("by al."), N_("Nvim is open source and freely distributable"), N_("https://neovim.io/community"), "", -- cgit From af046a3a81c0d7ebc5219bf20c1463cb5ccd1b9b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 17 Aug 2017 21:23:28 +0200 Subject: version: tweak layout, doc --- src/nvim/version.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index e024982faf..2a3fdbd70d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1089,13 +1089,7 @@ static void list_features(void) msg_putchar('\n'); } } else { - while (msg_col % width) { - int old_msg_col = msg_col; - msg_putchar(' '); - if (old_msg_col == msg_col) { - break; // XXX: Avoid infinite loop. - } - } + msg_putchar(' '); } } else { if (msg_col > 0) { @@ -1103,7 +1097,7 @@ static void list_features(void) } } } - MSG_PUTS("For differences from Vim, see :help vim-differences\n\n"); + MSG_PUTS("See \":help feature-compile\"\n\n"); } void list_version(void) @@ -1144,7 +1138,7 @@ void list_version(void) } #endif // ifdef HAVE_PATHDEF - version_msg(_("\n\nOptional features included (+) or not (-): ")); + version_msg(_("\n\nFeatures: ")); list_features(); -- cgit From b13070ec01844977f10cae38fc6f2a0fd9defad8 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 17 Aug 2017 23:30:28 +0200 Subject: doc/api: nvim_out_write() and friends References #7178 --- src/nvim/api/vim.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 2bc31b2812..cfbe34b848 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -484,7 +484,8 @@ void nvim_set_option(String name, Object value, Error *err) set_option_to(NULL, SREQ_GLOBAL, name, value, err); } -/// Writes a message to vim output buffer +/// Writes a message to the Vim output buffer. Does not append "\n", the +/// message is buffered (won't display) until a linefeed is written. /// /// @param str Message void nvim_out_write(String str) @@ -493,7 +494,8 @@ void nvim_out_write(String str) write_msg(str, false); } -/// Writes a message to vim error buffer +/// Writes a message to the Vim error buffer. Does not append "\n", the +/// message is buffered (won't display) until a linefeed is written. /// /// @param str Message void nvim_err_write(String str) @@ -502,8 +504,8 @@ void nvim_err_write(String str) write_msg(str, true); } -/// Writes a message to vim error buffer. Appends a linefeed to ensure all -/// contents are written. +/// Writes a message to the Vim error buffer. Appends "\n", so the buffer is +/// flushed (and displayed). /// /// @param str Message /// @see nvim_err_write() -- cgit From 9882e25dc44f1165e1edc8b3898356e493b6b3fe Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 20 Aug 2017 02:13:04 +0200 Subject: clipboard: avoid error flood during :redir redir_write(): - This is a "batch" operation which was not yet covered by start_batch_changes() adjust_clipboard_name(): - msg() and friends during :redir will, of course, cause redir_write() to try to capture that message, which causes recursion. - EMSG() here is trouble: if it interrupts :redir it is a mess. Rather than deal with the mess, show a non-error message. closes #7182 closes #7184 closes #7183 ref #6048 ref #7032 --- src/nvim/eval.c | 18 +++++++------- src/nvim/message.c | 2 ++ src/nvim/ops.c | 69 ++++++++++++++++++++++++++++++++---------------------- 3 files changed, 52 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index ac22d75a83..d6ee13857a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -22775,7 +22775,7 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments) bool eval_has_provider(const char *name) { -#define check_provider(name) \ +#define CHECK_PROVIDER(name) \ if (has_##name == -1) { \ has_##name = !!find_func((char_u *)"provider#" #name "#Call"); \ if (!has_##name) { \ @@ -22791,17 +22791,17 @@ bool eval_has_provider(const char *name) static int has_python3 = -1; static int has_ruby = -1; - if (!strcmp(name, "clipboard")) { - check_provider(clipboard); + if (strequal(name, "clipboard")) { + CHECK_PROVIDER(clipboard); return has_clipboard; - } else if (!strcmp(name, "python3")) { - check_provider(python3); + } else if (strequal(name, "python3")) { + CHECK_PROVIDER(python3); return has_python3; - } else if (!strcmp(name, "python")) { - check_provider(python); + } else if (strequal(name, "python")) { + CHECK_PROVIDER(python); return has_python; - } else if (!strcmp(name, "ruby")) { - check_provider(ruby); + } else if (strequal(name, "ruby")) { + CHECK_PROVIDER(ruby); return has_ruby; } diff --git a/src/nvim/message.c b/src/nvim/message.c index b90c475ede..fe4cb65779 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2519,6 +2519,7 @@ static void redir_write(const char *const str, const ptrdiff_t maxlen) if (redirecting()) { /* If the string doesn't start with CR or NL, go to msg_col */ if (*s != '\n' && *s != '\r') { + start_batch_changes(); while (cur_col < msg_col) { if (capture_ga) { ga_concat_len(capture_ga, " ", 1); @@ -2535,6 +2536,7 @@ static void redir_write(const char *const str, const ptrdiff_t maxlen) } cur_col++; } + end_batch_changes(); } size_t len = maxlen == -1 ? STRLEN(s) : (size_t)maxlen; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 5c6f4d0d07..7bbc72b091 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -58,8 +58,8 @@ static yankreg_T *y_previous = NULL; /* ptr to last written yankreg */ static bool clipboard_didwarn_unnamed = false; // for behavior between start_batch_changes() and end_batch_changes()) -static bool clipboard_delay_update = false; // delay clipboard update static int batch_change_count = 0; // inside a script +static bool clipboard_delay_update = false; // delay clipboard update static bool clipboard_needs_update = false; // clipboard was updated /* @@ -5524,7 +5524,7 @@ int get_default_register_name(void) } /// Determine if register `*name` should be used as a clipboard. -/// In an unnammed operation, `*name` is `NUL` and will be adjusted to `'*'/'+'` if +/// In an unnamed operation, `*name` is `NUL` and will be adjusted to */+ if /// `clipboard=unnamed[plus]` is set. /// /// @param name The name of register, or `NUL` if unnamed. @@ -5535,33 +5535,44 @@ int get_default_register_name(void) /// if the register isn't a clipboard or provider isn't available. static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing) { - if (*name == '*' || *name == '+') { - if(!eval_has_provider("clipboard")) { - if (!quiet) { - EMSG("clipboard: No provider. Try \":CheckHealth\" or " - "\":h clipboard\"."); - } - return NULL; - } - return &y_regs[*name == '*' ? STAR_REGISTER : PLUS_REGISTER]; - } else if ((*name == NUL) && (cb_flags & CB_UNNAMEDMASK)) { - if(!eval_has_provider("clipboard")) { - if (!quiet && !clipboard_didwarn_unnamed) { - msg((char_u *)"clipboard: No provider. Try \":CheckHealth\" or " - "\":h clipboard\"."); - clipboard_didwarn_unnamed = true; - } - return NULL; +#define MSG_NO_CLIP "clipboard: No provider. " \ + "Try \":CheckHealth\" or \":h clipboard\"." + + yankreg_T *target = NULL; + bool explicit_cb_reg = (*name == '*' || *name == '+'); + bool implicit_cb_reg = (*name == NUL) && (cb_flags & CB_UNNAMEDMASK); + int save_redir_off = redir_off; + if (!explicit_cb_reg && !implicit_cb_reg) { + goto end; + } + + if (!eval_has_provider("clipboard")) { + if (batch_change_count == 1 && explicit_cb_reg && !quiet) { + redir_off = true; // Avoid recursion from :redir + emsg(). + // Do NOT error (emsg()) here--if it interrupts :redir we get into + // a weird state, stuck in "redirect mode". + msg((char_u *)MSG_NO_CLIP); + } else if (batch_change_count == 1 && implicit_cb_reg + && !quiet && !clipboard_didwarn_unnamed) { + redir_off = true; // Avoid recursion from :redir + emsg(). + msg((char_u *)MSG_NO_CLIP); + clipboard_didwarn_unnamed = true; } + // ... else, be silent (avoid a flood of messages). + goto end; + } + + if (explicit_cb_reg) { + target = &y_regs[*name == '*' ? STAR_REGISTER : PLUS_REGISTER]; + goto end; + } else { // unnamed register: "implicit" clipboard if (writing && clipboard_delay_update) { clipboard_needs_update = true; - return NULL; + goto end; } else if (!writing && clipboard_needs_update) { - // use the internal value - return NULL; + goto end; // use the internal value } - yankreg_T *target; if (cb_flags & CB_UNNAMEDPLUS) { *name = (cb_flags & CB_UNNAMED && writing) ? '"': '+'; target = &y_regs[PLUS_REGISTER]; @@ -5569,10 +5580,12 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing) *name = '*'; target = &y_regs[STAR_REGISTER]; } - return target; // unnamed register + goto end; } - // don't do anything for other register names - return NULL; + +end: + redir_off = save_redir_off; + return target; } static bool get_clipboard(int name, yankreg_T **target, bool quiet) @@ -5740,7 +5753,7 @@ static void set_clipboard(int name, yankreg_T *reg) (void)eval_call_provider("clipboard", "set", args); } -/// Avoid clipboard (slow) during batch operations (i.e., a script). +/// Avoid slow things (clipboard) during batch operations (while/for-loops). void start_batch_changes(void) { if (++batch_change_count > 1) { @@ -5750,7 +5763,7 @@ void start_batch_changes(void) clipboard_needs_update = false; } -/// Update the clipboard after batch changes finished. +/// Counterpart to start_batch_changes(). void end_batch_changes(void) { if (--batch_change_count > 0) { -- cgit From cc7e344f8357d07b1df17df0b322152d5c50739b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 20 Aug 2017 18:53:58 +0200 Subject: clipboard: remove start_batch_changes() in redir_write() start_batch_changes() doesn't avoid invoking the clipboard once-per-line, because the loop is actually in ex_echo(), which calls redir_write() for each message. But we've already entered start_batch_changes() by then, so that was never the problem. redir_write at /home/vagrant/old.neovim/build/../src/nvim/message.c:2523 msg_puts_attr_len at /home/vagrant/old.neovim/build/../src/nvim/message.c:1600 msg_outtrans_len_attr at /home/vagrant/old.neovim/build/../src/nvim/message.c:1221 ex_echo at /home/vagrant/old.neovim/build/../src/nvim/eval.c:19433 do_one_cmd at /home/vagrant/old.neovim/build/../src/nvim/ex_docmd.c:2242 Trying to defer _explicit_ clipboard updates is difficult. :redir @+ | silent echo system('cat foo') | redir END is essentially equivalent to: for l in readfile('foo') let @+ .= l endfor We cannot make judgements about when to ignore a script's bad decisions. start_batch_changes() only works around the case of clipboard=unnamed, i.e. _implicit_ clipboard updates (`:g/foo/d`). Not explicit assignment. --- src/nvim/message.c | 2 -- src/nvim/ops.c | 7 +++++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/message.c b/src/nvim/message.c index fe4cb65779..b90c475ede 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2519,7 +2519,6 @@ static void redir_write(const char *const str, const ptrdiff_t maxlen) if (redirecting()) { /* If the string doesn't start with CR or NL, go to msg_col */ if (*s != '\n' && *s != '\r') { - start_batch_changes(); while (cur_col < msg_col) { if (capture_ga) { ga_concat_len(capture_ga, " ", 1); @@ -2536,7 +2535,6 @@ static void redir_write(const char *const str, const ptrdiff_t maxlen) } cur_col++; } - end_batch_changes(); } size_t len = maxlen == -1 ? STRLEN(s) : (size_t)maxlen; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 7bbc72b091..6c873a96c0 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -5558,7 +5558,7 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing) msg((char_u *)MSG_NO_CLIP); clipboard_didwarn_unnamed = true; } - // ... else, be silent (avoid a flood of messages). + // ... else, be silent (don't flood during :while, :redir, etc.). goto end; } @@ -5567,10 +5567,12 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing) goto end; } else { // unnamed register: "implicit" clipboard if (writing && clipboard_delay_update) { + // For "set" (copy), defer the clipboard call. clipboard_needs_update = true; goto end; } else if (!writing && clipboard_needs_update) { - goto end; // use the internal value + // For "get" (paste), use the internal value. + goto end; } if (cb_flags & CB_UNNAMEDPLUS) { @@ -5772,6 +5774,7 @@ void end_batch_changes(void) } clipboard_delay_update = false; if (clipboard_needs_update) { + // unnamed ("implicit" clipboard) set_clipboard(NUL, y_previous); clipboard_needs_update = false; } -- cgit From e006b1d98d92aead6aff565ed5d8b034772aa16c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 27 Jul 2017 00:30:57 +0200 Subject: log: some DEBUG-level stream logging --- src/nvim/event/process.c | 3 +-- src/nvim/event/rstream.c | 2 +- src/nvim/event/stream.c | 2 ++ src/nvim/event/wstream.c | 1 + src/nvim/msgpack_rpc/channel.c | 16 +++++++++++++--- src/nvim/normal.c | 1 + 6 files changed, 19 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index c936583841..8371d3cd48 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -233,8 +233,7 @@ void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL switch (proc->type) { case kProcessTypeUv: // Close the process's stdin. If the process doesn't close its own - // stdout/stderr, they will be closed when it exits(possibly due to being - // terminated after a timeout) + // stdout/stderr, they will be closed when it exits (voluntarily or not). process_close_in(proc); ILOG("Sending SIGTERM to pid %d", proc->pid); uv_kill(proc->pid, SIGTERM); diff --git a/src/nvim/event/rstream.c b/src/nvim/event/rstream.c index 854af474b2..2c4db08b30 100644 --- a/src/nvim/event/rstream.c +++ b/src/nvim/event/rstream.c @@ -118,7 +118,7 @@ static void read_cb(uv_stream_t *uvstream, ssize_t cnt, const uv_buf_t *buf) // to `alloc_cb` will return the same unused pointer(`rbuffer_produced` // won't be called) && cnt != 0) { - DLOG("Closing Stream (%p): %s (%s)", stream, + DLOG("closing Stream: %p: %s (%s)", stream, uv_err_name((int)cnt), os_strerror((int)cnt)); // Read error or EOF, either way stop the stream and invoke the callback // with eof == true diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c index 60ceff9b24..7c865bfe1e 100644 --- a/src/nvim/event/stream.c +++ b/src/nvim/event/stream.c @@ -7,6 +7,7 @@ #include +#include "nvim/log.h" #include "nvim/rbuffer.h" #include "nvim/macros.h" #include "nvim/event/stream.h" @@ -81,6 +82,7 @@ void stream_close(Stream *stream, stream_close_cb on_stream_close, void *data) FUNC_ATTR_NONNULL_ARG(1) { assert(!stream->closed); + DLOG("closing Stream: %p", stream); stream->closed = true; stream->close_cb = on_stream_close; stream->close_cb_data = data; diff --git a/src/nvim/event/wstream.c b/src/nvim/event/wstream.c index f453e5898d..320006890d 100644 --- a/src/nvim/event/wstream.c +++ b/src/nvim/event/wstream.c @@ -8,6 +8,7 @@ #include +#include "nvim/log.h" #include "nvim/event/loop.h" #include "nvim/event/wstream.h" #include "nvim/vim.h" diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 6fd1af1ba6..789cf1d4a8 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -133,6 +133,9 @@ uint64_t channel_from_process(Process *proc, uint64_t id, char *source) rstream_init(proc->out, 0); rstream_start(proc->out, receive_msgpack, channel); + DLOG("ch %" PRIu64 " in-stream=%p out-stream=%p", channel->id, proc->in, + proc->out); + return channel->id; } @@ -150,6 +153,8 @@ void channel_from_connection(SocketWatcher *watcher) wstream_init(&channel->data.stream, 0); rstream_init(&channel->data.stream, CHANNEL_BUFFER_SIZE); rstream_start(&channel->data.stream, receive_msgpack, channel); + + DLOG("ch %" PRIu64 " in/out-stream=%p", &channel->data.stream); } /// @param source description of source function, rplugin name, TCP addr, etc @@ -344,6 +349,9 @@ void channel_from_stdio(void) rstream_start(&channel->data.std.in, receive_msgpack, channel); // write stream wstream_init_fd(&main_loop, &channel->data.std.out, 1, 0); + + DLOG("ch %" PRIu64 " in-stream=%p out-stream=%p", channel->id, + &channel->data.std.in, &channel->data.std.out); } /// Creates a loopback channel. This is used to avoid deadlock @@ -363,6 +371,7 @@ void channel_process_exit(uint64_t id, int status) decref(channel); } +// rstream.c:read_event() invokes this as stream->read_cb(). static void receive_msgpack(Stream *stream, RBuffer *rbuf, size_t c, void *data, bool eof) { @@ -379,7 +388,8 @@ static void receive_msgpack(Stream *stream, RBuffer *rbuf, size_t c, } size_t count = rbuffer_size(rbuf); - DLOG("parsing %u bytes of msgpack data from Stream(%p)", count, stream); + DLOG("ch %" PRIu64 ": parsing %u bytes from msgpack Stream: %p", + channel->id, count, stream); // Feed the unpacker with data msgpack_unpacker_reserve_buffer(channel->unpacker, count); @@ -565,8 +575,8 @@ static bool channel_write(Channel *channel, WBuffer *buffer) char buf[256]; snprintf(buf, sizeof(buf), - "Before returning from a RPC call, ch %" PRIu64 " was " - "closed due to a failed write", + "ch %" PRIu64 ": stream write failed. " + "RPC canceled; closing channel", channel->id); call_set_error(channel, buf, ERROR_LOG_LEVEL); } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index c1676780d8..238378c474 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -13,6 +13,7 @@ #include #include +#include "nvim/log.h" #include "nvim/vim.h" #include "nvim/ascii.h" #include "nvim/normal.h" -- cgit From af993da4351d579aa24de08d806c8c1b90813106 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 27 Jul 2017 01:08:50 +0200 Subject: rpc: close channel if stream was closed f_jobstop()/f_rpcstop() .. process_stop() .. process_close_in(proc) closes the write-stream of a RPC channel. But there might be a pending RPC notification on the queue, which may get processed just before the channel is closed. To handle that case, check the Stream.closed in channel.c:receive_msgpack(). Before this change, the above scenario could trigger this assert(!stream->closed) in wstream_write(): 0x00007f96e1cd3428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54 0x00007f96e1cd502a in __GI_abort () at abort.c:89 0x00007f96e1ccbbd7 in __assert_fail_base (fmt=, assertion=assertion@entry=0x768f9b "!stream->closed", file=file@entry=0x768f70 "../src/nvim/event/wstream.c", line=line@entry=77, function=function@entry=0x768fb0 <__PRETTY_FUNCTION__.13735> "wstream_write") at assert.c:92 0x00007f96e1ccbc82 in __GI___assert_fail (assertion=0x768f9b "!stream->closed", file=0x768f70 "../src/nvim/event/wstream.c", line=77, function=0x768fb0 <__PRETTY_FUNCTION__.13735> "wstream_write") at assert.c:101 0x00000000004d2c1f in wstream_write (stream=0x7f96e0a35078, buffer=0x7f96e09f9b40) at ../src/nvim/event/wstream.c:77 0x00000000005857b2 in channel_write (channel=0x7f96e0ae5800, buffer=0x7f96e09f9b40) at ../src/nvim/msgpack_rpc/channel.c:551 0x000000000058567d in on_request_event (argv=0x7ffed792efa0) at ../src/nvim/msgpack_rpc/channel.c:523 0x00000000005854c8 in handle_request (channel=0x7f96e0ae5800, request=0x7ffed792f1b8) at ../src/nvim/msgpack_rpc/channel.c:503 0x00000000005850cb in parse_msgpack (channel=0x7f96e0ae5800) at ../src/nvim/msgpack_rpc/channel.c:423 0x0000000000584f90 in receive_msgpack (stream=0x7f96e0a35218, rbuf=0x7f96e0d1d4c0, c=22, data=0x7f96e0ae5800, eof=false) at ../src/nvim/msgpack_rpc/channel.c:389 0x00000000004d0b20 in read_event (argv=0x7ffed792f4a8) at ../src/nvim/event/rstream.c:190 0x00000000004ce462 in multiqueue_process_events (this=0x7f96e18172d0) at ../src/nvim/event/multiqueue.c:150 0x000000000059b630 in nv_event (cap=0x7ffed792f620) at ../src/nvim/normal.c:7908 0x000000000058be69 in normal_execute (state=0x7ffed792f580, key=-25341) at ../src/nvim/normal.c:1137 0x0000000000652463 in state_enter (s=0x7ffed792f580) at ../src/nvim/state.c:61 0x000000000058a1fe in normal_enter (cmdwin=false, noexmode=false) at ../src/nvim/normal.c:467 0x00000000005500c2 in main (argc=2, argv=0x7ffed792f8d8) at ../src/nvim/main.c:554 Alternative approach suggested by bfredl is to use close_cb of the process. My unsuccessful attempt is below. (It seems close_cb is queued too late, which is the similar problem addressed by this commit): commit 75fc12c6ab15711bdb7b18c6d42ec9d157f5145e Author: Justin M. Keyes Date: Fri Aug 18 01:30:41 2017 +0200 rpc: use Stream's close_cb instead of explicit check in receive_msgpack() diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index 8371d3cd482e..e52da23cdc40 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -416,6 +416,10 @@ static void on_process_exit(Process *proc) static void on_process_stream_close(Stream *stream, void *data) { Process *proc = data; + ILOG("on_process_stream_close"); + if (proc->stream_close_cb != NULL) { + proc->stream_close_cb(stream, proc->stream_close_data); + } decref(proc); } diff --git a/src/nvim/event/process.h b/src/nvim/event/process.h index 5c00e8e7ecd5..34a8d54f6f8c 100644 --- a/src/nvim/event/process.h +++ b/src/nvim/event/process.h @@ -26,6 +26,11 @@ struct process { Stream *in, *out, *err; process_exit_cb cb; internal_process_cb internal_exit_cb, internal_close_cb; + + // Called when any of the process streams (in/out/err) closes. + stream_close_cb stream_close_cb; + void *stream_close_data; + bool closed, detach; MultiQueue *events; }; @@ -50,6 +55,8 @@ static inline Process process_init(Loop *loop, ProcessType type, void *data) .closed = false, .internal_close_cb = NULL, .internal_exit_cb = NULL, + .stream_close_cb = NULL, + .stream_close_data = NULL, .detach = false }; } diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c index 7c865bfe1e8c..c8720d1e45d9 100644 --- a/src/nvim/event/stream.c +++ b/src/nvim/event/stream.c @@ -95,7 +95,11 @@ void stream_close(Stream *stream, stream_close_cb on_stream_close, void *data) void stream_close_handle(Stream *stream) FUNC_ATTR_NONNULL_ALL { + ILOG("stream=%d", stream); + // LOG_CALLSTACK(); if (stream->uvstream) { + // problem: this schedules on the queue, but channel.c:receive_msgpack may + // be processed before close_cb is called by libuv. uv_close((uv_handle_t *)stream->uvstream, close_cb); } else { uv_close((uv_handle_t *)&stream->uv.idle, close_cb); @@ -105,6 +109,7 @@ void stream_close_handle(Stream *stream) static void close_cb(uv_handle_t *handle) { Stream *stream = handle->data; + ILOG(">>>>>>>>>>>>>>>>>>>>>>> stream=%p stream->internal_close_cb=%p", stream, stream->internal_close_cb); if (stream->buffer) { rbuffer_free(stream->buffer); } diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 782eabe04e4a..dc2b794e366a 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -128,6 +128,8 @@ uint64_t channel_from_process(Process *proc, uint64_t id, char *source) source); incref(channel); // process channels are only closed by the exit_cb channel->data.proc = proc; + channel->data.proc->stream_close_cb = close_cb2; + channel->data.proc->stream_close_data = channel; wstream_init(proc->in, 0); rstream_init(proc->out, 0); @@ -387,17 +389,6 @@ static void receive_msgpack(Stream *stream, RBuffer *rbuf, size_t c, goto end; } - if ((chan_wstream(channel) != NULL && chan_wstream(channel)->closed) - || (chan_rstream(channel) != NULL && chan_rstream(channel)->closed)) { - char buf[256]; - snprintf(buf, sizeof(buf), - "ch %" PRIu64 ": stream closed unexpectedly. " - "closing channel", - channel->id); - call_set_error(channel, buf, WARN_LOG_LEVEL); - goto end; - } - size_t count = rbuffer_size(rbuf); DLOG("ch %" PRIu64 ": parsing %u bytes from msgpack Stream: %p", channel->id, count, stream); @@ -571,23 +562,6 @@ static Stream *chan_wstream(Channel *chan) abort(); } -/// Returns the Stream that a Channel reads from. -static Stream *chan_rstream(Channel *chan) -{ - switch (chan->type) { - case kChannelTypeSocket: - return &chan->data.stream; - case kChannelTypeProc: - return chan->data.proc->out; - case kChannelTypeStdio: - return &chan->data.std.in; - case kChannelTypeInternal: - return NULL; - } - abort(); -} - - static bool channel_write(Channel *channel, WBuffer *buffer) { bool success = false; @@ -799,6 +773,12 @@ static void close_cb(Stream *stream, void *data) decref(data); } +static void close_cb2(Stream *stream, void *data) +{ + ILOG("close_cb2"); + close_channel(data); +} + /// @param source description of source function, rplugin name, TCP addr, etc static Channel *register_channel(ChannelType type, uint64_t id, MultiQueue *events, char *source) --- src/nvim/log.c | 2 +- src/nvim/log.h | 8 +++--- src/nvim/msgpack_rpc/channel.c | 61 +++++++++++++++++++++++++++++++++++------- src/nvim/msgpack_rpc/helpers.c | 2 +- 4 files changed, 57 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/nvim/log.c b/src/nvim/log.c index 3baf0b2ebd..436a8a4079 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -250,7 +250,7 @@ static bool v_do_log_to_file(FILE *log_file, int log_level, static const char *log_levels[] = { [DEBUG_LOG_LEVEL] = "DEBUG", [INFO_LOG_LEVEL] = "INFO ", - [WARNING_LOG_LEVEL] = "WARN ", + [WARN_LOG_LEVEL] = "WARN ", [ERROR_LOG_LEVEL] = "ERROR", }; assert(log_level >= DEBUG_LOG_LEVEL && log_level <= ERROR_LOG_LEVEL); diff --git a/src/nvim/log.h b/src/nvim/log.h index 5064d9333b..d63bcc366c 100644 --- a/src/nvim/log.h +++ b/src/nvim/log.h @@ -6,7 +6,7 @@ #define DEBUG_LOG_LEVEL 0 #define INFO_LOG_LEVEL 1 -#define WARNING_LOG_LEVEL 2 +#define WARN_LOG_LEVEL 2 #define ERROR_LOG_LEVEL 3 #define DLOG(...) @@ -43,12 +43,12 @@ __VA_ARGS__) #endif -#if MIN_LOG_LEVEL <= WARNING_LOG_LEVEL +#if MIN_LOG_LEVEL <= WARN_LOG_LEVEL # undef WLOG # undef WLOGN -# define WLOG(...) do_log(WARNING_LOG_LEVEL, __func__, __LINE__, true, \ +# define WLOG(...) do_log(WARN_LOG_LEVEL, __func__, __LINE__, true, \ __VA_ARGS__) -# define WLOGN(...) do_log(WARNING_LOG_LEVEL, __func__, __LINE__, false, \ +# define WLOGN(...) do_log(WARN_LOG_LEVEL, __func__, __LINE__, false, \ __VA_ARGS__) #endif diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 789cf1d4a8..ed97f298d9 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -62,7 +62,7 @@ typedef struct { ChannelType type; msgpack_unpacker *unpacker; union { - Stream stream; + Stream stream; // bidirectional (socket) Process *proc; struct { Stream in; @@ -154,7 +154,8 @@ void channel_from_connection(SocketWatcher *watcher) rstream_init(&channel->data.stream, CHANNEL_BUFFER_SIZE); rstream_start(&channel->data.stream, receive_msgpack, channel); - DLOG("ch %" PRIu64 " in/out-stream=%p", &channel->data.stream); + DLOG("ch %" PRIu64 " in/out-stream=%p", channel->id, + &channel->data.stream); } /// @param source description of source function, rplugin name, TCP addr, etc @@ -383,7 +384,18 @@ static void receive_msgpack(Stream *stream, RBuffer *rbuf, size_t c, char buf[256]; snprintf(buf, sizeof(buf), "ch %" PRIu64 " was closed by the client", channel->id); - call_set_error(channel, buf, WARNING_LOG_LEVEL); + call_set_error(channel, buf, WARN_LOG_LEVEL); + goto end; + } + + if ((chan_wstream(channel) != NULL && chan_wstream(channel)->closed) + || (chan_rstream(channel) != NULL && chan_rstream(channel)->closed)) { + char buf[256]; + snprintf(buf, sizeof(buf), + "ch %" PRIu64 ": stream closed unexpectedly. " + "closing channel", + channel->id); + call_set_error(channel, buf, WARN_LOG_LEVEL); goto end; } @@ -445,8 +457,8 @@ static void parse_msgpack(Channel *channel) // causes for this error(search for 'goto _failed') // // A not so uncommon cause for this might be deserializing objects with - // a high nesting level: msgpack will break when it's internal parse stack - // size exceeds MSGPACK_EMBED_STACK_SIZE(defined as 32 by default) + // a high nesting level: msgpack will break when its internal parse stack + // size exceeds MSGPACK_EMBED_STACK_SIZE (defined as 32 by default) send_error(channel, 0, "Invalid msgpack payload. " "This error can also happen when deserializing " "an object with high level of nesting"); @@ -544,6 +556,39 @@ static void on_request_event(void **argv) api_clear_error(&error); } +/// Returns the Stream that a Channel writes to. +static Stream *chan_wstream(Channel *chan) +{ + switch (chan->type) { + case kChannelTypeSocket: + return &chan->data.stream; + case kChannelTypeProc: + return chan->data.proc->in; + case kChannelTypeStdio: + return &chan->data.std.out; + case kChannelTypeInternal: + return NULL; + } + abort(); +} + +/// Returns the Stream that a Channel reads from. +static Stream *chan_rstream(Channel *chan) +{ + switch (chan->type) { + case kChannelTypeSocket: + return &chan->data.stream; + case kChannelTypeProc: + return chan->data.proc->out; + case kChannelTypeStdio: + return &chan->data.std.in; + case kChannelTypeInternal: + return NULL; + } + abort(); +} + + static bool channel_write(Channel *channel, WBuffer *buffer) { bool success = false; @@ -555,13 +600,9 @@ static bool channel_write(Channel *channel, WBuffer *buffer) switch (channel->type) { case kChannelTypeSocket: - success = wstream_write(&channel->data.stream, buffer); - break; case kChannelTypeProc: - success = wstream_write(channel->data.proc->in, buffer); - break; case kChannelTypeStdio: - success = wstream_write(&channel->data.std.out, buffer); + success = wstream_write(chan_wstream(channel), buffer); break; case kChannelTypeInternal: incref(channel); diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index 444c6cc256..98e56dee3b 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -361,7 +361,7 @@ typedef struct { size_t idx; } APIToMPObjectStackItem; -/// Convert type used by Neovim API to msgpack +/// Convert type used by Nvim API to msgpack type. /// /// @param[in] result Object to convert. /// @param[out] res Structure that defines where conversion results are saved. -- cgit From 0f442c328e33a0c742df9283c1944c077d202a77 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 18 Aug 2017 14:13:28 +0200 Subject: channel.c:call_set_error(): fix memory leak --- src/nvim/msgpack_rpc/channel.c | 1 + src/nvim/msgpack_rpc/helpers.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index ed97f298d9..02f3854f47 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -868,6 +868,7 @@ static void call_set_error(Channel *channel, char *msg, int loglevel) ChannelCallFrame *frame = kv_A(channel->call_stack, i); frame->returned = true; frame->errored = true; + api_free_object(frame->result); frame->result = STRING_OBJ(cstr_to_string(msg)); } diff --git a/src/nvim/msgpack_rpc/helpers.c b/src/nvim/msgpack_rpc/helpers.c index 98e56dee3b..fecae11d45 100644 --- a/src/nvim/msgpack_rpc/helpers.c +++ b/src/nvim/msgpack_rpc/helpers.c @@ -88,7 +88,12 @@ bool msgpack_rpc_to_object(const msgpack_object *const obj, Object *const arg) { bool ret = true; kvec_t(MPToAPIObjectStackItem) stack = KV_INITIAL_VALUE; - kv_push(stack, ((MPToAPIObjectStackItem) { obj, arg, false, 0 })); + kv_push(stack, ((MPToAPIObjectStackItem) { + .mobj = obj, + .aobj = arg, + .container = false, + .idx = 0, + })); while (ret && kv_size(stack)) { MPToAPIObjectStackItem cur = kv_last(stack); if (!cur.container) { -- cgit From 7d183e89f7c055c8f5217e91294123a5aa0a5e2d Mon Sep 17 00:00:00 2001 From: Drew Neil Date: Thu, 25 May 2017 10:11:34 +0100 Subject: Use Normal mode as default when opening a new terminal --- src/nvim/ex_docmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 6e7938046a..d1405978b3 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9835,7 +9835,7 @@ static void ex_terminal(exarg_T *eap) if (*eap->arg != NUL) { // Run {cmd} in 'shell'. char *name = (char *)vim_strsave_escaped(eap->arg, (char_u *)"\"\\"); snprintf(ex_cmd, sizeof(ex_cmd), - ":enew%s | call termopen(\"%s\") | startinsert", + ":enew%s | call termopen(\"%s\")", eap->forceit ? "!" : "", name); xfree(name); } else { // No {cmd}: run the job with tokenized 'shell'. @@ -9857,7 +9857,7 @@ static void ex_terminal(exarg_T *eap) shell_free_argv(argv); snprintf(ex_cmd, sizeof(ex_cmd), - ":enew%s | call termopen([%s]) | startinsert", + ":enew%s | call termopen([%s])", eap->forceit ? "!" : "", shell_argv + 1); } -- cgit From d2595ba1c4491a31d18211050e1abe86ea5379d3 Mon Sep 17 00:00:00 2001 From: Lech Lorens Date: Sun, 20 Aug 2017 12:14:27 +0200 Subject: vim-patch:8.0.0092 Problem: C indenting does not support nested namespaces that C++ 17 has. Solution: Add check that passes double colon inside a name. (Pauli, closes vim/vim#1214) https://github.com/vim/vim/commit/ca8b8d6956dd881de6446fc32c38e817a364a6cc --- src/nvim/indent_c.c | 33 ++++++++++++++++++++------------- src/nvim/version.c | 2 +- 2 files changed, 21 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index fd194a4080..4a6393ac36 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -515,34 +515,41 @@ int cin_isscopedecl(char_u *s) /* Maximum number of lines to search back for a "namespace" line. */ #define FIND_NAMESPACE_LIM 20 -/* - * Recognize a "namespace" scope declaration. - */ -static int cin_is_cpp_namespace(char_u *s) +// Recognize a "namespace" scope declaration. +static bool cin_is_cpp_namespace(char_u *s) { - char_u *p; - int has_name = FALSE; + char_u *p; + bool has_name = false; + bool has_name_start = false; s = cin_skipcomment(s); if (STRNCMP(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc(s[9]))) { p = cin_skipcomment(skipwhite(s + 9)); while (*p != NUL) { if (ascii_iswhite(*p)) { - has_name = TRUE; /* found end of a name */ + has_name = true; // found end of a name p = cin_skipcomment(skipwhite(p)); } else if (*p == '{') { break; } else if (vim_iswordc(*p)) { - if (has_name) - return FALSE; /* word character after skipping past name */ - ++p; + has_name_start = true; + if (has_name) { + return false; // word character after skipping past name + } + p++; + } else if (p[0] == ':' && p[1] == ':' && vim_iswordc(p[2])) { + if (!has_name_start || has_name) { + return false; + } + // C++ 17 nested namespace + p += 3; } else { - return FALSE; + return false; } } - return TRUE; + return true; } - return FALSE; + return false; } /* diff --git a/src/nvim/version.c b/src/nvim/version.c index 2a3fdbd70d..68c41cee88 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -860,7 +860,7 @@ static const int included_patches[] = { // 95 NA // 94 NA // 93 NA - // 92, + 92, // 91, 90, // 89 NA -- cgit From a66eca78c2082aca112125f759be2ef3aa7ef832 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 21 Aug 2017 12:10:15 -0400 Subject: vim-patch:8.0.0308 Problem: When using a symbolic link, the package path will not be inserted at the right position in 'runtimepath'. (Dugan Chen, Norio Takagi) Solution: Resolve symbolic links when finding the right position in 'runtimepath'. (Hirohito Higashi) https://github.com/vim/vim/commit/2f9e575583c2ad3978ee3d0f790eeff7df56bd6c --- src/nvim/ex_cmds2.c | 28 +++++++++++++++++----------- src/nvim/version.c | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 33fe30cd5a..f8c470f213 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2498,6 +2498,7 @@ static int APP_BOTH; static void add_pack_plugin(char_u *fname, void *cookie) { char_u *p4, *p3, *p2, *p1, *p; + char_u *buf = NULL; char *const ffname = fix_fname((char *)fname); @@ -2525,26 +2526,30 @@ static void add_pack_plugin(char_u *fname, void *cookie) // Find "ffname" in "p_rtp", ignoring '/' vs '\' differences size_t fname_len = strlen(ffname); const char *insp = (const char *)p_rtp; - for (;;) { - if (path_fnamencmp(insp, ffname, fname_len) == 0) { - break; + buf = try_malloc(MAXPATHL); + if (buf == NULL) { + goto theend; + } + while (*insp != NUL) { + copy_option_part((char_u **)&insp, buf, MAXPATHL, ","); + add_pathsep((char *)buf); + char *const rtp_ffname = fix_fname((char *)buf); + if (rtp_ffname == NULL) { + goto theend; } - insp = strchr(insp, ','); - if (insp == NULL) { + bool match = path_fnamencmp(rtp_ffname, ffname, fname_len) == 0; + xfree(rtp_ffname); + if (match) { break; } - insp++; } - if (insp == NULL) { + if (*insp == NUL) { // not found, append at the end insp = (const char *)p_rtp + STRLEN(p_rtp); } else { // append after the matching directory. - insp += strlen(ffname); - while (*insp != NUL && *insp != ',') { - insp++; - } + insp--; } *p4 = c; @@ -2614,6 +2619,7 @@ static void add_pack_plugin(char_u *fname, void *cookie) } theend: + xfree(buf); xfree(ffname); } diff --git a/src/nvim/version.c b/src/nvim/version.c index 2a3fdbd70d..a190293d8e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -644,7 +644,7 @@ static const int included_patches[] = { 311, // 310, // 309, - // 308, + 308, 307, // 306, // 305, -- cgit From 24a556419627d3369f0a55b95dce07cb5316cf8b Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 21 Aug 2017 12:37:24 -0400 Subject: vim-patch:8.0.0325 Problem: Packadd test does not clean up symlink. Solution: Delete the link. (Hirohito Higashi) https://github.com/vim/vim/commit/913727e56761d57aaba61197c2d3485418dea7eb --- src/nvim/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index a190293d8e..a0c46c0e3d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -627,7 +627,7 @@ static const int included_patches[] = { // 328, // 327, // 326, - // 325, + 325, // 324, // 323, 322, -- cgit From 651c6f9b6ebcd76fbf65045ab877fdf38b9d3db2 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 21 Aug 2017 12:38:24 -0400 Subject: vim-patch:8.0.0326 Problem: Packadd test uses wrong directory name. Solution: Use the variable name value. (Hirohito Higashi) https://github.com/vim/vim/commit/24f8f543d4036c5d2ce4ea6973a174cf2176cb72 --- src/nvim/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index a0c46c0e3d..92c776c1e8 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -626,7 +626,7 @@ static const int included_patches[] = { // 329, // 328, // 327, - // 326, + 326, 325, // 324, // 323, -- cgit From fc7bf1c71d41dae7b8ab7e82b92ec0e8253b5291 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 21 Aug 2017 12:46:07 -0400 Subject: vim-patch:8.0.0437 Problem: The packadd test does not create the symlink correctly and does not test the right thing. Solution: Create the directory and symlink correctly. https://github.com/vim/vim/commit/644df41c44cbdfacdedbba55ef77a6c6031eccd8 --- src/nvim/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 92c776c1e8..d4cbf32009 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -515,7 +515,7 @@ static const int included_patches[] = { // 440, // 439, // 438, - // 437, + 437, // 436, // 435, // 434, -- cgit From 622c3454dff35cae7ec93383bbf49f16621dc778 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 21 Aug 2017 12:47:58 -0400 Subject: vim-patch:8.0.0612 Problem: Package directories are added to 'runtimepath' only after loading non-package plugins. Solution: Split off the code to add package directories to 'runtimepath'. (Ingo Karkat, closes vim/vim#1680) https://github.com/vim/vim/commit/ce876aaa9a250a5a0d0e34b3a2625e51cf9bf5bb --- src/nvim/ex_cmds2.c | 26 +++++++++++++++++--------- src/nvim/globals.h | 3 +++ src/nvim/main.c | 13 ++++++++++++- src/nvim/testdir/test_startup.vim | 32 ++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 5 files changed, 65 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index f8c470f213..df6b575c1c 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2623,23 +2623,31 @@ theend: xfree(ffname); } -static bool did_source_packages = false; +/// Add all packages in the "start" directory to 'runtimepath'. +void add_pack_start_dirs(void) +{ + do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT + add_pack_plugin, &APP_ADD_DIR); +} + +/// Load plugins from all packages in the "start" directory. +void load_start_packages(void) +{ + did_source_packages = true; + do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT + add_pack_plugin, &APP_LOAD); +} // ":packloadall" // Find plugins in the package directories and source them. -// "eap" is NULL when invoked during startup. void ex_packloadall(exarg_T *eap) { - if (!did_source_packages || (eap != NULL && eap->forceit)) { - did_source_packages = true; - + if (!did_source_packages || eap->forceit) { // First do a round to add all directories to 'runtimepath', then load // the plugins. This allows for plugins to use an autoload directory // of another plugin. - do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT - add_pack_plugin, &APP_ADD_DIR); - do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, // NOLINT - add_pack_plugin, &APP_LOAD); + add_pack_start_dirs(); + load_start_packages(); } } diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 13ecafcbe3..2ee72cdb6a 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -407,6 +407,9 @@ EXTERN int garbage_collect_at_exit INIT(= FALSE); /* ID of script being sourced or was sourced to define the current function. */ EXTERN scid_T current_SID INIT(= 0); + +EXTERN bool did_source_packages INIT(= false); + // Scope information for the code that indirectly triggered the current // provider function call EXTERN struct caller_scope { diff --git a/src/nvim/main.c b/src/nvim/main.c index a665ad1de2..6e85fbc130 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1291,10 +1291,21 @@ static void set_window_layout(mparm_T *paramp) static void load_plugins(void) { if (p_lpl) { + // First add all package directories to 'runtimepath', so that their + // autoload directories can be found. Only if not done already with a + // :packloadall command. + if (!did_source_packages) { + add_pack_start_dirs(); + } + source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL | DIP_NOAFTER); // NOLINT TIME_MSG("loading plugins"); - ex_packloadall(NULL); + // Only source "start" packages if not done already with a :packloadall + // command. + if (!did_source_packages) { + load_start_packages(); + } TIME_MSG("loading packages"); source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL | DIP_AFTER); diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 5a38178bd5..2dce7faded 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -62,6 +62,38 @@ func Test_after_comes_later() call delete('Xafter', 'rf') endfunc +func Test_pack_in_rtp_when_plugins_run() + if !has('packages') + return + endif + let before = [ + \ 'set nocp viminfo+=nviminfo', + \ 'set guioptions+=M', + \ 'let $HOME = "/does/not/exist"', + \ 'set loadplugins', + \ 'set rtp=Xhere', + \ 'set packpath=Xhere', + \ 'set nomore', + \ ] + let after = [ + \ 'quit', + \ ] + call mkdir('Xhere/plugin', 'p') + call writefile(['redir! > Xtestout', 'silent set runtimepath?', 'silent! call foo#Trigger()', 'redir END'], 'Xhere/plugin/here.vim') + call mkdir('Xhere/pack/foo/start/foobar/autoload', 'p') + call writefile(['function! foo#Trigger()', 'echo "autoloaded foo"', 'endfunction'], 'Xhere/pack/foo/start/foobar/autoload/foo.vim') + + if RunVim(before, after, '') + + let lines = filter(readfile('Xtestout'), '!empty(v:val)') + call assert_match('Xhere[/\\]pack[/\\]foo[/\\]start[/\\]foobar', get(lines, 0)) + call assert_match('autoloaded foo', get(lines, 1)) + endif + + call delete('Xtestout') + call delete('Xhere', 'rf') +endfunc + func Test_help_arg() if !has('unix') && has('gui') " this doesn't work with gvim on MS-Windows diff --git a/src/nvim/version.c b/src/nvim/version.c index d4cbf32009..3313ffdfa9 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -340,7 +340,7 @@ static const int included_patches[] = { // 615, 614, // 613, - // 612, + 612, // 611, // 610, // 609, -- cgit From 41d180abb4693814be5833b0907e111ce46b3791 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 21 Aug 2017 12:54:22 -0400 Subject: vim-patch:8.0.0680 Problem: Plugins in start packages are sourced twice. (mseplowitz) Solution: Use the unmodified runtime path when loading plugins (test by Ingo Karkat, closes vim/vim#1801) https://github.com/vim/vim/commit/07ecfa64a18609a986f21d6132d04ee8934f3200 --- src/nvim/ex_cmds2.c | 43 +++++++++++++++++++++++++-------------- src/nvim/main.c | 10 ++++++++- src/nvim/testdir/test_startup.vim | 20 +++++++++++++----- src/nvim/version.c | 2 +- 4 files changed, 53 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index df6b575c1c..371f7b3bce 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -2319,16 +2319,6 @@ static void source_callback(char_u *fname, void *cookie) (void)do_source(fname, false, DOSO_NONE); } -/// Source the file "name" from all directories in 'runtimepath'. -/// "name" can contain wildcards. -/// When "flags" has DIP_ALL: source all files, otherwise only the first one. -/// -/// return FAIL when no file could be sourced, OK otherwise. -int source_runtime(char_u *name, int flags) -{ - return do_in_runtimepath(name, flags, source_callback, NULL); -} - /// Find the file "name" in all directories in "path" and invoke /// "callback(fname, cookie)". /// "name" can contain wildcards. @@ -2434,21 +2424,21 @@ int do_in_path(char_u *path, char_u *name, int flags, return did_one ? OK : FAIL; } -/// Find "name" in 'runtimepath'. When found, invoke the callback function for +/// Find "name" in "path". When found, invoke the callback function for /// it: callback(fname, "cookie") /// When "flags" has DIP_ALL repeat for all matches, otherwise only the first /// one is used. /// Returns OK when at least one match found, FAIL otherwise. -/// If "name" is NULL calls callback for each entry in runtimepath. Cookie is +/// If "name" is NULL calls callback for each entry in "path". Cookie is /// passed by reference in this case, setting it to NULL indicates that callback /// has done its job. -int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback, - void *cookie) +int do_in_path_and_pp(char_u *path, char_u *name, int flags, + DoInRuntimepathCB callback, void *cookie) { int done = FAIL; if ((flags & DIP_NORTP) == 0) { - done = do_in_path(p_rtp, name, flags, callback, cookie); + done = do_in_path(path, name, flags, callback, cookie); } if ((done == FAIL || (flags & DIP_ALL)) && (flags & DIP_START)) { @@ -2476,6 +2466,29 @@ int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback, return done; } +/// Just like do_in_path_and_pp(), using 'runtimepath' for "path". +int do_in_runtimepath(char_u *name, int flags, DoInRuntimepathCB callback, + void *cookie) +{ + return do_in_path_and_pp(p_rtp, name, flags, callback, cookie); +} + +/// Source the file "name" from all directories in 'runtimepath'. +/// "name" can contain wildcards. +/// When "flags" has DIP_ALL: source all files, otherwise only the first one. +/// +/// return FAIL when no file could be sourced, OK otherwise. +int source_runtime(char_u *name, int flags) +{ + return source_in_path(p_rtp, name, flags); +} + +/// Just like source_runtime(), but use "path" instead of 'runtimepath'. +int source_in_path(char_u *path, char_u *name, int flags) +{ + return do_in_path_and_pp(path, name, flags, source_callback, NULL); +} + // Expand wildcards in "pat" and invoke do_source() for each match. static void source_all_matches(char_u *pat) { diff --git a/src/nvim/main.c b/src/nvim/main.c index 6e85fbc130..f601fd7ea3 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1291,15 +1291,23 @@ static void set_window_layout(mparm_T *paramp) static void load_plugins(void) { if (p_lpl) { + char_u *rtp_copy = NULL; + // First add all package directories to 'runtimepath', so that their // autoload directories can be found. Only if not done already with a // :packloadall command. + // Make a copy of 'runtimepath', so that source_runtime does not use the + // pack directories. if (!did_source_packages) { + rtp_copy = vim_strsave(p_rtp); add_pack_start_dirs(); } - source_runtime((char_u *)"plugin/**/*.vim", DIP_ALL | DIP_NOAFTER); // NOLINT + source_in_path(rtp_copy == NULL ? p_rtp : rtp_copy, + (char_u *)"plugin/**/*.vim", // NOLINT + DIP_ALL | DIP_NOAFTER); TIME_MSG("loading plugins"); + xfree(rtp_copy); // Only source "start" packages if not done already with a :packloadall // command. diff --git a/src/nvim/testdir/test_startup.vim b/src/nvim/testdir/test_startup.vim index 2dce7faded..11e26d03aa 100644 --- a/src/nvim/testdir/test_startup.vim +++ b/src/nvim/testdir/test_startup.vim @@ -24,28 +24,34 @@ func Test_after_comes_later() \ 'set guioptions+=M', \ 'let $HOME = "/does/not/exist"', \ 'set loadplugins', - \ 'set rtp=Xhere,Xafter', + \ 'set rtp=Xhere,Xafter,Xanother', \ 'set packpath=Xhere,Xafter', \ 'set nomore', + \ 'let g:sequence = ""', \ ] let after = [ \ 'redir! > Xtestout', \ 'scriptnames', \ 'redir END', + \ 'redir! > Xsequence', + \ 'echo g:sequence', + \ 'redir END', \ 'quit', \ ] call mkdir('Xhere/plugin', 'p') - call writefile(['let done = 1'], 'Xhere/plugin/here.vim') + call writefile(['let g:sequence .= "here "'], 'Xhere/plugin/here.vim') + call mkdir('Xanother/plugin', 'p') + call writefile(['let g:sequence .= "another "'], 'Xanother/plugin/another.vim') call mkdir('Xhere/pack/foo/start/foobar/plugin', 'p') - call writefile(['let done = 1'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim') + call writefile(['let g:sequence .= "pack "'], 'Xhere/pack/foo/start/foobar/plugin/foo.vim') call mkdir('Xafter/plugin', 'p') - call writefile(['let done = 1'], 'Xafter/plugin/later.vim') + call writefile(['let g:sequence .= "after "'], 'Xafter/plugin/later.vim') if RunVim(before, after, '') let lines = readfile('Xtestout') - let expected = ['Xbefore.vim', 'here.vim', 'foo.vim', 'later.vim', 'Xafter.vim'] + let expected = ['Xbefore.vim', 'here.vim', 'another.vim', 'foo.vim', 'later.vim', 'Xafter.vim'] let found = [] for line in lines for one in expected @@ -57,8 +63,12 @@ func Test_after_comes_later() call assert_equal(expected, found) endif + call assert_equal('here another pack after', substitute(join(readfile('Xsequence', 1), ''), '\s\+$', '', '')) + call delete('Xtestout') + call delete('Xsequence') call delete('Xhere', 'rf') + call delete('Xanother', 'rf') call delete('Xafter', 'rf') endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 3313ffdfa9..598c3c3778 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -272,7 +272,7 @@ static const int included_patches[] = { // 683, // 682, // 681, - // 680, + 680, 679, 678, // 677, -- cgit From 4d91369fd752bec5a5ffc15dc094c794b09b1f12 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 15 Aug 2017 18:03:06 +0200 Subject: syntax.c: register 'Normal' highlight group - :hi Normal works with -u NONE - Makes HL_TABLE and ATTR_ENTYRY a function instead of a macro so that in can be used in gdb. - Introduces ATTRENTRY_INIT to init attrentry_t --- src/nvim/syntax.c | 44 +++++++++++++++++++++++++++++++------------- src/nvim/syntax_defs.h | 10 ++++++++++ 2 files changed, 41 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index f0171fa525..9d9f794a56 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -81,7 +81,10 @@ struct hl_group { // highlight groups for 'highlight' option static garray_T highlight_ga = GA_EMPTY_INIT_VALUE; -#define HL_TABLE() ((struct hl_group *)((highlight_ga.ga_data))) +static inline struct hl_group * HL_TABLE(void) +{ + return ((struct hl_group *)((highlight_ga.ga_data))); +} #define MAX_HL_ID 20000 /* maximum value for a highlight ID. */ @@ -5958,6 +5961,7 @@ static char *highlight_init_light[] = "Title ctermfg=DarkMagenta gui=bold guifg=Magenta", "Visual guibg=LightGrey", "WarningMsg ctermfg=DarkRed guifg=Red", + "Normal gui=NONE", NULL }; @@ -5991,6 +5995,7 @@ static char *highlight_init_dark[] = "Title ctermfg=LightMagenta gui=bold guifg=Magenta", "Visual guibg=DarkGrey", "WarningMsg ctermfg=LightRed guifg=Red", + "Normal gui=NONE", NULL }; @@ -6707,14 +6712,16 @@ static void highlight_clear(int idx) } -/* - * Table with the specifications for an attribute number. - * Note that this table is used by ALL buffers. This is required because the - * GUI can redraw at any time for any buffer. - */ +/// Table with the specifications for an attribute number. +/// Note that this table is used by ALL buffers. This is required because the +/// GUI can redraw at any time for any buffer. +/// The attributes table static garray_T attr_table = GA_EMPTY_INIT_VALUE; -#define ATTR_ENTRY(idx) ((attrentry_T *)attr_table.ga_data)[idx] +static inline attrentry_T * ATTR_ENTRY(int idx) +{ + return &((attrentry_T *)attr_table.ga_data)[idx]; +} /// Return the attr number for a set of colors and font. @@ -6804,7 +6811,7 @@ int hl_combine_attr(int char_attr, int prim_attr) { attrentry_T *char_aep = NULL; attrentry_T *spell_aep; - attrentry_T new_en; + attrentry_T new_en = ATTRENTRY_INIT; if (char_attr == 0) { return prim_attr; @@ -6852,17 +6859,24 @@ int hl_combine_attr(int char_attr, int prim_attr) return get_attr_entry(&new_en); } +/// \note this function does not apply exclusively to cterm attr contrary +/// to what its name implies attrentry_T *syn_cterm_attr2entry(int attr) { attr -= ATTR_OFF; - if (attr >= attr_table.ga_len) /* did ":syntax clear" */ + if (attr >= attr_table.ga_len) { + // did ":syntax clear" return NULL; - return &(ATTR_ENTRY(attr)); + } + return ATTR_ENTRY(attr); } +/// \addtogroup LIST_XXX +/// @{ #define LIST_ATTR 1 #define LIST_STRING 2 #define LIST_INT 3 +/// @} static void highlight_list_one(int id) { @@ -7095,12 +7109,13 @@ set_hl_attr ( int idx /* index in array */ ) { - attrentry_T at_en; + attrentry_T at_en = ATTRENTRY_INIT; struct hl_group *sgp = HL_TABLE() + idx; - /* The "Normal" group doesn't need an attribute number */ - if (sgp->sg_name_u != NULL && STRCMP(sgp->sg_name_u, "NORMAL") == 0) + // The "Normal" group doesn't need an attribute number + if (sgp->sg_name_u != NULL && STRCMP(sgp->sg_name_u, "NORMAL") == 0) { return; + } at_en.cterm_ae_attr = sgp->sg_cterm; at_en.cterm_fg_color = sgp->sg_cterm_fg; @@ -7237,6 +7252,9 @@ static int syn_add_group(char_u *name) struct hl_group* hlgp = GA_APPEND_VIA_PTR(struct hl_group, &highlight_ga); memset(hlgp, 0, sizeof(*hlgp)); hlgp->sg_name = name; + hlgp->sg_rgb_bg = -1; + hlgp->sg_rgb_fg = -1; + hlgp->sg_rgb_sp = -1; hlgp->sg_name_u = vim_strsave_up(name); return highlight_ga.ga_len; /* ID is index plus one */ diff --git a/src/nvim/syntax_defs.h b/src/nvim/syntax_defs.h index 9f309451b0..56fadbe7f6 100644 --- a/src/nvim/syntax_defs.h +++ b/src/nvim/syntax_defs.h @@ -73,4 +73,14 @@ typedef struct attr_entry { int cterm_fg_color, cterm_bg_color; } attrentry_T; +#define ATTRENTRY_INIT { \ + .rgb_ae_attr = 0, \ + .cterm_ae_attr = 0, \ + .rgb_fg_color = -1, \ + .rgb_bg_color = -1, \ + .rgb_sp_color = -1, \ + .cterm_fg_color = 0, \ + .cterm_bg_color = 0, \ +} + #endif // NVIM_SYNTAX_DEFS_H -- cgit From 5f6ad863c6d28dce377590a1d33bc386d346cc27 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Tue, 15 Aug 2017 18:07:37 +0200 Subject: syntax.c: style Converts some documentation to doxygen format + minor styling improvements. --- src/nvim/syntax.c | 187 +++++++++++++++++++++++++++--------------------------- src/nvim/window.c | 20 +++--- 2 files changed, 105 insertions(+), 102 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 9d9f794a56..65c0e2464a 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -103,10 +103,8 @@ static int include_none = 0; /* when 1 include "nvim/None" */ static int include_default = 0; /* when 1 include "nvim/default" */ static int include_link = 0; /* when 2 include "nvim/link" and "clear" */ -/* - * The "term", "cterm" and "gui" arguments can be any combination of the - * following names, separated by commas (but no spaces!). - */ +/// The "term", "cterm" and "gui" arguments can be any combination of the +/// following names, separated by commas (but no spaces!). static char *(hl_name_table[]) = {"bold", "standout", "underline", "undercurl", "italic", "reverse", "inverse", "NONE"}; @@ -1778,8 +1776,9 @@ syn_current_attr ( cur_si->si_trans_id = CUR_STATE( current_state.ga_len - 2).si_trans_id; } - } else + } else { cur_si->si_attr = syn_id2attr(syn_id); + } cur_si->si_cont_list = NULL; cur_si->si_next_list = next_list; check_keepend(); @@ -5255,12 +5254,10 @@ get_id_list ( /* * Handle full group name. */ - if (vim_strpbrk(name + 1, (char_u *)"\\.*^$~[") == NULL) + if (vim_strpbrk(name + 1, (char_u *)"\\.*^$~[") == NULL) { id = syn_check_group(name + 1, (int)(end - p)); - else { - /* - * Handle match of regexp with group names. - */ + } else { + // Handle match of regexp with group names. *name = '^'; STRCAT(name, "$"); regmatch.regprog = vim_regcomp(name, RE_MAGIC); @@ -5999,20 +5996,21 @@ static char *highlight_init_dark[] = NULL }; -void -init_highlight ( - int both, /* include groups where 'bg' doesn't matter */ - int reset /* clear group first */ -) + +/// Load colors from a file if "g:colors_name" is set, otherwise load builtin +/// colors +/// +/// @param both include groups where 'bg' doesn't matter +/// @param reset clear groups first +void +init_highlight(int both, int reset) { int i; char **pp; static int had_both = FALSE; - /* - * Try finding the color scheme file. Used when a color file was loaded - * and 'background' or 't_Co' is changed. - */ + // Try finding the color scheme file. Used when a color file was loaded + // and 'background' or 't_Co' is changed. char_u *p = get_var_value("g:colors_name"); if (p != NULL) { // Value of g:colors_name could be freed in load_colors() and make @@ -6031,33 +6029,34 @@ init_highlight ( if (both) { had_both = TRUE; pp = highlight_init_both; - for (i = 0; pp[i] != NULL; ++i) - do_highlight((char_u *)pp[i], reset, TRUE); - } else if (!had_both) - /* Don't do anything before the call with both == TRUE from main(). - * Not everything has been setup then, and that call will overrule - * everything anyway. */ + for (i = 0; pp[i] != NULL; i++) { + do_highlight((char_u *)pp[i], reset, true); + } + } else if (!had_both) { + // Don't do anything before the call with both == TRUE from main(). + // Not everything has been setup then, and that call will overrule + // everything anyway. return; + } - if (*p_bg == 'l') - pp = highlight_init_light; - else - pp = highlight_init_dark; - for (i = 0; pp[i] != NULL; ++i) - do_highlight((char_u *)pp[i], reset, TRUE); + pp = (*p_bg == 'l') ? highlight_init_light : highlight_init_dark; + + for (i = 0; pp[i] != NULL; i++) { + do_highlight((char_u *)pp[i], reset, true); + } /* Reverse looks ugly, but grey may not work for 8 colors. Thus let it * depend on the number of colors available. * With 8 colors brown is equal to yellow, need to use black for Search fg * to avoid Statement highlighted text disappears. * Clear the attributes, needed when changing the t_Co value. */ - if (t_colors > 8) + if (t_colors > 8) { do_highlight( (char_u *)(*p_bg == 'l' ? "Visual cterm=NONE ctermbg=LightGrey" - : "Visual cterm=NONE ctermbg=DarkGrey"), FALSE, - TRUE); - else { + : "Visual cterm=NONE ctermbg=DarkGrey"), false, + true); + } else { do_highlight((char_u *)"Visual cterm=reverse ctermbg=NONE", FALSE, TRUE); if (*p_bg == 'l') @@ -6117,12 +6116,7 @@ int load_colors(char_u *name) /// "forceit" and "init" both TRUE. /// @param init TRUE when called for initializing void -do_highlight( - char_u *line, - int forceit, - int init -) -{ +do_highlight(char_u *line, int forceit, int init) { char_u *name_end; char_u *linep; char_u *key_start; @@ -6139,15 +6133,16 @@ do_highlight( int dolink = FALSE; int error = FALSE; int color; - int is_normal_group = FALSE; /* "Normal" group */ + bool is_normal_group = false; // "Normal" group /* * If no argument, list current highlighting. */ if (ends_excmd(*line)) { - for (int i = 1; i <= highlight_ga.ga_len && !got_int; ++i) - /* TODO: only call when the group has attributes set */ + for (int i = 1; i <= highlight_ga.ga_len && !got_int; i++) { + // todo(vim): only call when the group has attributes set highlight_list_one(i); + } return; } @@ -6275,12 +6270,12 @@ do_highlight( return; idx = id - 1; /* index is ID minus one */ - /* Return if "default" was used and the group already has settings. */ - if (dodefault && hl_has_settings(idx, TRUE)) + // Return if "default" was used and the group already has settings + if (dodefault && hl_has_settings(idx, true)) { return; + } - if (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0) - is_normal_group = TRUE; + is_normal_group = (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0); /* Clear the highlighting for ":hi clear {group}" and ":hi clear". */ if (doclear || (forceit && init)) { @@ -6289,7 +6284,7 @@ do_highlight( HL_TABLE()[idx].sg_set = 0; } - if (!doclear) + if (!doclear) { while (!ends_excmd(*linep)) { key_start = linep; if (*linep == '=') { @@ -6395,12 +6390,12 @@ do_highlight( } } } else if (STRCMP(key, "FONT") == 0) { - /* in non-GUI fonts are simply ignored */ - } else if (STRCMP(key, - "CTERMFG") == 0 || STRCMP(key, "CTERMBG") == 0) { + // in non-GUI fonts are simply ignored + } else if (STRCMP(key, "CTERMFG") == 0 || STRCMP(key, "CTERMBG") == 0) { if (!init || !(HL_TABLE()[idx].sg_set & SG_CTERM)) { - if (!init) + if (!init) { HL_TABLE()[idx].sg_set |= SG_CTERM; + } /* When setting the foreground color, and previously the "bold" * flag was set for a light color, reset it now */ @@ -6494,9 +6489,10 @@ do_highlight( * colors (on some terminals, e.g. "linux") */ if (color & 8) { HL_TABLE()[idx].sg_cterm |= HL_BOLD; - HL_TABLE()[idx].sg_cterm_bold = TRUE; - } else + HL_TABLE()[idx].sg_cterm_bold = true; + } else { HL_TABLE()[idx].sg_cterm &= ~HL_BOLD; + } } color &= 7; // truncate to 8 colors } else if (t_colors == 16 || t_colors == 88 || t_colors >= 256) { @@ -6608,21 +6604,23 @@ do_highlight( /* * When highlighting has been given for a group, don't link it. */ - if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK)) + if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK)) { HL_TABLE()[idx].sg_link = 0; + } /* * Continue with next argument. */ linep = skipwhite(linep); } + } /* * If there is an error, and it's a new entry, remove it from the table. */ - if (error && idx == highlight_ga.ga_len) + if (error && idx == highlight_ga.ga_len) { syn_unadd_group(); - else { + } else { if (is_normal_group) { HL_TABLE()[idx].sg_attr = 0; // Need to update all groups, because they might be using "bg" and/or @@ -6630,16 +6628,17 @@ do_highlight( highlight_attr_set_all(); // If the normal group has changed, it is simpler to refresh every UI ui_refresh(); - } else + } else { set_hl_attr(idx); + } HL_TABLE()[idx].sg_scriptID = current_SID; redraw_all_later(NOT_VALID); } xfree(key); xfree(arg); - /* Only call highlight_changed() once, after sourcing a syntax file */ - need_highlight_changed = TRUE; + // Only call highlight_changed() once, after sourcing a syntax file + need_highlight_changed = true; } #if defined(EXITFREE) @@ -6715,7 +6714,6 @@ static void highlight_clear(int idx) /// Table with the specifications for an attribute number. /// Note that this table is used by ALL buffers. This is required because the /// GUI can redraw at any time for any buffer. -/// The attributes table static garray_T attr_table = GA_EMPTY_INIT_VALUE; static inline attrentry_T * ATTR_ENTRY(int idx) @@ -6915,7 +6913,13 @@ static void highlight_list_one(int id) last_set_msg(sgp->sg_scriptID); } -static int highlight_list_arg(int id, int didh, int type, int iarg, char_u *sarg, char *name) +/// Outputs a highlight when doing ":hi MyHighlight" +/// +/// @param type one of \ref LIST_XXX +/// @param iarg integer argument used if \p type == LIST_INT +/// @param sarg string used if \p type == LIST_STRING +static int highlight_list_arg(int id, int didh, int type, int iarg, + char_u *sarg, const char *name) { char_u buf[100]; char_u *ts; @@ -7055,24 +7059,23 @@ const char *highlight_color(const int id, const char *const what, return NULL; } -/* - * Output the syntax list header. - * Return TRUE when started a new line. - */ -static int -syn_list_header ( - int did_header, /* did header already */ - int outlen, /* length of string that comes */ - int id /* highlight group id */ -) +/// Output the syntax list header. +/// +/// @param did_header did header already +/// @param outlen length of string that comes +/// @param id highlight group id +/// @return true when started a new line. +static int +syn_list_header(int did_header, int outlen, int id) { int endcol = 19; int newline = TRUE; if (!did_header) { msg_putchar('\n'); - if (got_int) - return TRUE; + if (got_int) { + return true; + } msg_outtrans(HL_TABLE()[id - 1].sg_name); endcol = 15; } else if (msg_col + outlen + 1 >= Columns) { @@ -7139,10 +7142,10 @@ set_hl_attr ( } } -/* - * Lookup a highlight group name and return it's ID. - * If it is not found, 0 is returned. - */ +/// Lookup a highlight group name and return its ID. +/// +/// @param highlight name e.g. 'Cursor', 'Normal' +/// @return the highlight id, else 0 if \p name does not exist int syn_name2id(const char_u *name) { int i; @@ -7191,7 +7194,7 @@ int syn_namen2id(char_u *linep, int len) return id; } -/// Find highlight group name in the table and return it's ID. +/// Find highlight group name in the table and return its ID. /// If it doesn't exist yet, a new entry is created. /// /// @param pp Highlight group name @@ -7210,11 +7213,11 @@ int syn_check_group(char_u *pp, int len) return id; } -/* - * Add new highlight group and return it's ID. - * "name" must be an allocated string, it will be consumed. - * Return 0 for failure. - */ +/// Add new highlight group and return it's ID. +/// +/// @param name must be an allocated string, it will be consumed. +/// @return 0 for failure, else the allocated group id +/// @see syn_check_group syn_unadd_group static int syn_add_group(char_u *name) { char_u *p; @@ -7260,20 +7263,18 @@ static int syn_add_group(char_u *name) return highlight_ga.ga_len; /* ID is index plus one */ } -/* - * When, just after calling syn_add_group(), an error is discovered, this - * function deletes the new name. - */ +/// When, just after calling syn_add_group(), an error is discovered, this +/// function deletes the new name. static void syn_unadd_group(void) { - --highlight_ga.ga_len; + highlight_ga.ga_len--; xfree(HL_TABLE()[highlight_ga.ga_len].sg_name); xfree(HL_TABLE()[highlight_ga.ga_len].sg_name_u); } -/* - * Translate a group ID to highlight attributes. - */ + +/// Translate a group ID to highlight attributes. +/// @see syn_cterm_attr2entry int syn_id2attr(int hl_id) { struct hl_group *sgp; diff --git a/src/nvim/window.c b/src/nvim/window.c index 081fc98816..c2d0a9b3b1 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5515,11 +5515,14 @@ void restore_buffer(bufref_T *save_curbuf) } -// Add match to the match list of window 'wp'. The pattern 'pat' will be -// highlighted with the group 'grp' with priority 'prio'. -// Optionally, a desired ID 'id' can be specified (greater than or equal to 1). -// If no particular ID is desired, -1 must be specified for 'id'. -// Return ID of added match, -1 on failure. +/// Add match to the match list of window 'wp'. The pattern 'pat' will be +/// highlighted with the group 'grp' with priority 'prio'. +/// Optionally, a desired ID 'id' can be specified (greater than or equal to 1). +/// +/// @param[in] id a desired ID 'id' can be specified +/// (greater than or equal to 1). -1 must be specified if no +/// particular ID is desired +/// @return ID of added match, -1 on failure. int match_add(win_T *wp, const char *const grp, const char *const pat, int prio, int id, list_T *pos_list, const char *const conceal_char) @@ -5697,10 +5700,9 @@ fail: return -1; } -/* - * Delete match with ID 'id' in the match list of window 'wp'. - * Print error messages if 'perr' is TRUE. - */ + +/// Delete match with ID 'id' in the match list of window 'wp'. +/// Print error messages if 'perr' is TRUE. int match_delete(win_T *wp, int id, int perr) { matchitem_T *cur = wp->w_match_head; -- cgit From 85f3084e21e112a34d891d90cfaf37a7de726866 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 22 Aug 2017 20:31:54 +0200 Subject: clipboard: disallow recursion; show hint only once (#7203) - Show hint only once per session. - provider#clipboard#Call(): prevent recursion - provider#clear_stderr(): use has_key(), because :silent! is still captured by :redir. closes #7184 --- src/nvim/ops.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 6c873a96c0..c01840cfd0 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -55,12 +55,11 @@ static yankreg_T y_regs[NUM_REGISTERS]; static yankreg_T *y_previous = NULL; /* ptr to last written yankreg */ -static bool clipboard_didwarn_unnamed = false; - // for behavior between start_batch_changes() and end_batch_changes()) static int batch_change_count = 0; // inside a script static bool clipboard_delay_update = false; // delay clipboard update static bool clipboard_needs_update = false; // clipboard was updated +static bool clipboard_didwarn = false; /* * structure used by block_prep, op_delete and op_yank for blockwise operators @@ -5541,22 +5540,17 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing) yankreg_T *target = NULL; bool explicit_cb_reg = (*name == '*' || *name == '+'); bool implicit_cb_reg = (*name == NUL) && (cb_flags & CB_UNNAMEDMASK); - int save_redir_off = redir_off; if (!explicit_cb_reg && !implicit_cb_reg) { goto end; } if (!eval_has_provider("clipboard")) { - if (batch_change_count == 1 && explicit_cb_reg && !quiet) { - redir_off = true; // Avoid recursion from :redir + emsg(). + if (batch_change_count == 1 && !quiet + && (!clipboard_didwarn || (explicit_cb_reg && !redirecting()))) { + clipboard_didwarn = true; // Do NOT error (emsg()) here--if it interrupts :redir we get into // a weird state, stuck in "redirect mode". msg((char_u *)MSG_NO_CLIP); - } else if (batch_change_count == 1 && implicit_cb_reg - && !quiet && !clipboard_didwarn_unnamed) { - redir_off = true; // Avoid recursion from :redir + emsg(). - msg((char_u *)MSG_NO_CLIP); - clipboard_didwarn_unnamed = true; } // ... else, be silent (don't flood during :while, :redir, etc.). goto end; @@ -5586,7 +5580,6 @@ static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing) } end: - redir_off = save_redir_off; return target; } -- cgit From e5565891af5858965a65366ecb7f791abc988931 Mon Sep 17 00:00:00 2001 From: Yuto Tokunaga Date: Wed, 23 Aug 2017 07:55:00 +0900 Subject: win: wmain(): locale-independent argv (#7180) fix #7060 --- src/nvim/CMakeLists.txt | 5 +++++ src/nvim/main.c | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 688912eda6..e2f1f16635 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -10,6 +10,11 @@ if(USE_GCOV) endif() endif() +if(WIN32) + # tell MinGW compiler to enable wmain + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -municode") +endif() + set(TOUCHES_DIR ${PROJECT_BINARY_DIR}/touches) set(GENERATOR_DIR ${CMAKE_CURRENT_LIST_DIR}/generators) set(GENERATED_DIR ${PROJECT_BINARY_DIR}/src/nvim/auto) diff --git a/src/nvim/main.c b/src/nvim/main.c index f601fd7ea3..af614762ac 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -7,6 +7,11 @@ #include #include +#ifdef WIN32 +# include +# include +#endif + #include #include "nvim/ascii.h" @@ -215,10 +220,28 @@ void early_init(void) #ifdef MAKE_LIB int nvim_main(int argc, char **argv) +#elif defined WIN32 +// don't use codepage encoded arguments. see #7060 +int wmain(int argc, wchar_t **argv_w) #else int main(int argc, char **argv) #endif { +#ifdef WIN32 + char *argv[argc]; + + for (size_t i = 0; i < (size_t)argc; i++) { + // get required buffer size + size_t dest_size = (size_t)WideCharToMultiByte( + CP_UTF8, 0, argv_w[i], -1, NULL, 0, NULL, NULL); + char *buf = (char *)xmallocz(dest_size); + // convert from utf16 (widechar) utf8 (multibyte) + WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, buf, (int)dest_size, + NULL, NULL); + argv[i] = buf; + } +#endif + argv0 = argv[0]; char_u *fname = NULL; // file name from command line -- cgit From 71df5dde6d99da73eaea1989a309ffe2a5c7689d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 23 Aug 2017 01:17:59 +0200 Subject: win: wmain(): use utf16_to_utf8() #7060 --- src/nvim/main.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index af614762ac..53a1342b2a 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -220,24 +220,18 @@ void early_init(void) #ifdef MAKE_LIB int nvim_main(int argc, char **argv) -#elif defined WIN32 -// don't use codepage encoded arguments. see #7060 -int wmain(int argc, wchar_t **argv_w) +#elif defined(WIN32) +int wmain(int argc, wchar_t **argv_w) // multibyte args on Windows. #7060 #else int main(int argc, char **argv) #endif { #ifdef WIN32 char *argv[argc]; - - for (size_t i = 0; i < (size_t)argc; i++) { - // get required buffer size - size_t dest_size = (size_t)WideCharToMultiByte( - CP_UTF8, 0, argv_w[i], -1, NULL, 0, NULL, NULL); - char *buf = (char *)xmallocz(dest_size); - // convert from utf16 (widechar) utf8 (multibyte) - WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, buf, (int)dest_size, - NULL, NULL); + for (int i = 0; i < argc; i++) { + char *buf = NULL; + utf16_to_utf8(argv_w[i], &buf); + assert(buf); argv[i] = buf; } #endif -- cgit From 02e5eafa86c729cee238ed6166a560ed9a555fc8 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 23 Aug 2017 01:30:25 +0200 Subject: win: expect utf8-encoded `argv` when built as a library --- src/nvim/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index 53a1342b2a..024c56dd05 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -226,7 +226,7 @@ int wmain(int argc, wchar_t **argv_w) // multibyte args on Windows. #7060 int main(int argc, char **argv) #endif { -#ifdef WIN32 +#if defined(WIN32) && !defined(MAKE_LIB) char *argv[argc]; for (int i = 0; i < argc; i++) { char *buf = NULL; -- cgit From da84f7dcf9dab28a03b9a776f04d882c36fd77fb Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Tue, 22 Aug 2017 11:49:54 +0200 Subject: tui: always use unibi_add_ext_str with unibi_get_ext_str #7204 When using an index returned by unibi_add_ext_str() we should always use unibi_get_ext_str() and not rely on the index being lower than unibi_string_begin_. Closes #7206 --- src/nvim/tui/tui.c | 62 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index b5af5b0333..e3eab72695 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -234,9 +234,9 @@ static void terminfo_start(UI *ui) unibi_out(ui, unibi_keypad_xmit); unibi_out(ui, unibi_clear_screen); // Enable bracketed paste - unibi_out(ui, data->unibi_ext.enable_bracketed_paste); + unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste); // Enable focus reporting - unibi_out(ui, data->unibi_ext.enable_focus_reporting); + unibi_out_ext(ui, data->unibi_ext.enable_focus_reporting); uv_loop_init(&data->write_loop); if (data->out_isatty) { uv_tty_init(&data->write_loop, &data->output_handle.tty, data->out_fd, 0); @@ -263,9 +263,9 @@ static void terminfo_stop(UI *ui) unibi_out(ui, unibi_keypad_local); unibi_out(ui, unibi_exit_ca_mode); // Disable bracketed paste - unibi_out(ui, data->unibi_ext.disable_bracketed_paste); + unibi_out_ext(ui, data->unibi_ext.disable_bracketed_paste); // Disable focus reporting - unibi_out(ui, data->unibi_ext.disable_focus_reporting); + unibi_out_ext(ui, data->unibi_ext.disable_focus_reporting); flush_buf(ui, true); uv_tty_reset_mode(); uv_close((uv_handle_t *)&data->output_handle, NULL); @@ -426,14 +426,14 @@ static void update_attrs(UI *ui, HlAttrs attrs) data->params[0].i = (fg >> 16) & 0xff; // red data->params[1].i = (fg >> 8) & 0xff; // green data->params[2].i = fg & 0xff; // blue - unibi_out(ui, data->unibi_ext.set_rgb_foreground); + unibi_out_ext(ui, data->unibi_ext.set_rgb_foreground); } if (bg != -1) { data->params[0].i = (bg >> 16) & 0xff; // red data->params[1].i = (bg >> 8) & 0xff; // green data->params[2].i = bg & 0xff; // blue - unibi_out(ui, data->unibi_ext.set_rgb_background); + unibi_out_ext(ui, data->unibi_ext.set_rgb_background); } } else { if (fg != -1) { @@ -679,7 +679,7 @@ static void set_scroll_region(UI *ui) data->params[1].i = grid->bot; unibi_out(ui, unibi_change_scroll_region); if (grid->left != 0 || grid->right != ui->width - 1) { - unibi_out(ui, data->unibi_ext.enable_lr_margin); + unibi_out_ext(ui, data->unibi_ext.enable_lr_margin); if (data->can_set_lr_margin) { data->params[0].i = grid->left; data->params[1].i = grid->right; @@ -700,7 +700,7 @@ static void reset_scroll_region(UI *ui) UGrid *grid = &data->grid; if (0 <= data->unibi_ext.reset_scroll_region) { - unibi_out(ui, data->unibi_ext.reset_scroll_region); + unibi_out_ext(ui, data->unibi_ext.reset_scroll_region); } else { data->params[0].i = 0; data->params[1].i = ui->height - 1; @@ -717,7 +717,7 @@ static void reset_scroll_region(UI *ui) data->params[0].i = ui->width - 1; unibi_out(ui, unibi_set_right_margin_parm); } - unibi_out(ui, data->unibi_ext.disable_lr_margin); + unibi_out_ext(ui, data->unibi_ext.disable_lr_margin); } unibi_goto(ui, grid->row, grid->col); } @@ -730,7 +730,7 @@ static void tui_resize(UI *ui, Integer width, Integer height) if (!got_winch) { // Try to resize the terminal window. data->params[0].i = (int)height; data->params[1].i = (int)width; - unibi_out(ui, data->unibi_ext.resize_screen); + unibi_out_ext(ui, data->unibi_ext.resize_screen); // DECSLPP does not reset the scroll region. if (data->scroll_region_is_full_screen) { reset_scroll_region(ui); @@ -836,7 +836,7 @@ static void tui_mouse_on(UI *ui) { TUIData *data = ui->data; if (!data->mouse_enabled) { - unibi_out(ui, data->unibi_ext.enable_mouse); + unibi_out_ext(ui, data->unibi_ext.enable_mouse); data->mouse_enabled = true; } } @@ -845,7 +845,7 @@ static void tui_mouse_off(UI *ui) { TUIData *data = ui->data; if (data->mouse_enabled) { - unibi_out(ui, data->unibi_ext.disable_mouse); + unibi_out_ext(ui, data->unibi_ext.disable_mouse); data->mouse_enabled = false; } } @@ -864,7 +864,7 @@ static void tui_set_mode(UI *ui, ModeShape mode) if (attr > 0) { attrentry_T *aep = syn_cterm_attr2entry(attr); data->params[0].i = aep->rgb_bg_color; - unibi_out(ui, data->unibi_ext.set_cursor_color); + unibi_out_ext(ui, data->unibi_ext.set_cursor_color); } } @@ -875,7 +875,7 @@ static void tui_set_mode(UI *ui, ModeShape mode) default: WLOG("Unknown shape value %d", shape); break; } data->params[0].i = shape + (int)(c.blinkon == 0); - unibi_out(ui, data->unibi_ext.set_cursor_style); + unibi_out_ext(ui, data->unibi_ext.set_cursor_style); } /// @param mode editor mode @@ -1182,25 +1182,27 @@ static void unibi_goto(UI *ui, int row, int col) unibi_out(ui, unibi_cursor_address); } +#define UNIBI_OUT(fn) \ + do { \ + TUIData *data = ui->data; \ + const char *str = NULL; \ + if (unibi_index >= 0) { \ + str = fn(data->ut, (unsigned)unibi_index); \ + } \ + if (str) { \ + unibi_var_t vars[26 + 26] = { { 0 } }; \ + unibi_format(vars, vars + 26, str, data->params, out, ui, NULL, NULL); \ + } \ + } while (0) static void unibi_out(UI *ui, int unibi_index) { - TUIData *data = ui->data; - - const char *str = NULL; - - if (unibi_index >= 0) { - if (unibi_index < unibi_string_begin_) { - str = unibi_get_ext_str(data->ut, (unsigned)unibi_index); - } else { - str = unibi_get_str(data->ut, (unsigned)unibi_index); - } - } - - if (str) { - unibi_var_t vars[26 + 26] = {{0}}; - unibi_format(vars, vars + 26, str, data->params, out, ui, NULL, NULL); - } + UNIBI_OUT(unibi_get_str); +} +static void unibi_out_ext(UI *ui, int unibi_index) +{ + UNIBI_OUT(unibi_get_ext_str); } +#undef UNIBI_OUT static void out(void *ctx, const char *str, size_t len) { -- cgit From e1628fab0062c96b5211213f3e990cfd6dc4c1d2 Mon Sep 17 00:00:00 2001 From: Leonardo Brondani Schenkel Date: Thu, 24 Aug 2017 12:48:32 +0200 Subject: tui: support new iterm2, iTerm2.app terminfo entries iTerm2 got its own entry in Thomas Dickey's terminfo.src on 2017-08-16. Make sure that the new entry is handled in the same way as the old entry. closes #7209 closes #7214 --- src/nvim/tui/terminfo.c | 4 +++- src/nvim/tui/tui.c | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c index b8fffcb7d6..586fafba97 100644 --- a/src/nvim/tui/terminfo.c +++ b/src/nvim/tui/terminfo.c @@ -104,7 +104,9 @@ unibi_term *load_builtin_terminfo(const char * term) return unibi_from_mem((const char *)interix_8colour_terminfo, sizeof interix_8colour_terminfo); } else if (terminfo_is_term_family(term, "iterm") - || terminfo_is_term_family(term, "iTerm.app")) { + || terminfo_is_term_family(term, "iterm2") + || terminfo_is_term_family(term, "iTerm.app") + || terminfo_is_term_family(term, "iTerm2.app")) { return unibi_from_mem((const char *)iterm_256colour_terminfo, sizeof iterm_256colour_terminfo); } else if (terminfo_is_term_family(term, "st")) { diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index e3eab72695..dd93053dbf 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1263,7 +1263,9 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, bool gnome = terminfo_is_term_family(term, "gnome") || terminfo_is_term_family(term, "vte"); bool iterm = terminfo_is_term_family(term, "iterm") - || terminfo_is_term_family(term, "iTerm.app"); + || terminfo_is_term_family(term, "iterm2") + || terminfo_is_term_family(term, "iTerm.app") + || terminfo_is_term_family(term, "iTerm2.app"); // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; bool konsole_pretending_xterm = xterm && konsole; @@ -1535,7 +1537,9 @@ static void augment_terminfo(TUIData *data, const char *term, bool screen = terminfo_is_term_family(term, "screen"); bool tmux = terminfo_is_term_family(term, "tmux") || !!os_getenv("TMUX"); bool iterm = terminfo_is_term_family(term, "iterm") - || terminfo_is_term_family(term, "iTerm.app"); + || terminfo_is_term_family(term, "iterm2") + || terminfo_is_term_family(term, "iTerm.app") + || terminfo_is_term_family(term, "iTerm2.app"); // None of the following work over SSH; see :help TERM . bool iterm_pretending_xterm = xterm && iterm_env; -- cgit From 0e13b15fde1cc02cd1bb390d161cdc13afb96e39 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Wed, 30 Aug 2017 19:54:14 +0800 Subject: vim-patch:8.0.0209 Problem: When using :substitute with the "c" flag and 'cursorbind' is set the cursor is not updated in other windows. Solution: Call do_check_cursorbind(). (Masanori Misono) https://github.com/vim/vim/commit/41baa7983aa81b0343b053e6a672cf8224a10245 --- src/nvim/ex_cmds.c | 4 ++++ src/nvim/version.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index a555fb77e8..32dbf4cc69 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3500,6 +3500,10 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) setmouse(); /* disable mouse in xterm */ curwin->w_cursor.col = regmatch.startpos[0].col; + if (curwin->w_p_crb) { + do_check_cursorbind(); + } + /* When 'cpoptions' contains "u" don't sync undo when * asking for confirmation. */ if (vim_strchr(p_cpo, CPO_UNDO) != NULL) diff --git a/src/nvim/version.c b/src/nvim/version.c index 53b44f8029..d7ebc26321 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -743,7 +743,7 @@ static const int included_patches[] = { // 212, // 211 NA // 210, - // 209, + 209, 208, // 207, // 206, -- cgit From 11429f94293b95394df436cb09d64a528fa387db Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 3 Sep 2017 16:58:32 +0800 Subject: vim-patch:8.0.0247 (#7232) Problem: Under some circumstances, one needs to type Ctrl-N or Ctrl-P twice to have a menu entry selected. (Lifepillar) Solution: call ins_compl_free(). (Christian Brabandt, closes vim/vim#1411) https://github.com/vim/vim/commit/aed6d0b81a14a81433c0f3c2c65cef935100db33 --- src/nvim/edit.c | 1 + src/nvim/testdir/test_popup.vim | 37 +++++++++++++++++++++++++++++++++---- src/nvim/version.c | 2 +- 3 files changed, 35 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index ca62679fab..17f0b8ef82 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -2406,6 +2406,7 @@ void set_completion(colnr_T startcol, list_T *list) ins_compl_prep(' '); } ins_compl_clear(); + ins_compl_free(); compl_direction = FORWARD; if (startcol > curwin->w_cursor.col) diff --git a/src/nvim/testdir/test_popup.vim b/src/nvim/testdir/test_popup.vim index 519d855cd8..e1ba142d1c 100644 --- a/src/nvim/testdir/test_popup.vim +++ b/src/nvim/testdir/test_popup.vim @@ -7,10 +7,10 @@ func! ListMonths() if g:setting != '' exe ":set" g:setting endif - let mth=copy(g:months) + let mth = copy(g:months) let entered = strcharpart(getline('.'),0,col('.')) if !empty(entered) - let mth=filter(mth, 'v:val=~"^".entered') + let mth = filter(mth, 'v:val=~"^".entered') endif call complete(1, mth) return '' @@ -468,7 +468,7 @@ endfunc " auto-wrap text. func Test_completion_ctrl_e_without_autowrap() new - let tw_save=&tw + let tw_save = &tw set tw=78 let li = [ \ '" zzz', @@ -478,7 +478,7 @@ func Test_completion_ctrl_e_without_autowrap() call feedkeys("A\\\\", "tx") call assert_equal(li, getline(1, '$')) - let &tw=tw_save + let &tw = tw_save q! endfunc @@ -541,4 +541,33 @@ func Test_completion_comment_formatting() bwipe! endfunc +function! DummyCompleteSix() + call complete(1, ['Hello', 'World']) + return '' +endfunction + +" complete() correctly clears the list of autocomplete candidates +func Test_completion_clear_candidate_list() + new + %d + " select first entry from the completion popup + call feedkeys("a xxx\\=DummyCompleteSix()\", "tx") + call assert_equal('Hello', getline(1)) + %d + " select second entry from the completion popup + call feedkeys("a xxx\\=DummyCompleteSix()\\", "tx") + call assert_equal('World', getline(1)) + %d + " select original text + call feedkeys("a xxx\\=DummyCompleteSix()\\\", "tx") + call assert_equal(' xxx', getline(1)) + %d + " back at first entry from completion list + call feedkeys("a xxx\\=DummyCompleteSix()\\\\", "tx") + call assert_equal('Hello', getline(1)) + + bw! +endfunc + + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index d7ebc26321..73ac3fa6ce 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -705,7 +705,7 @@ static const int included_patches[] = { 250, // 249 NA // 248, - // 247, + 247, // 246 NA // 245, // 244, -- cgit From 69a201d6c5504ded687a0603c2a6e88531deb5dc Mon Sep 17 00:00:00 2001 From: Albert Han Date: Sun, 3 Sep 2017 09:23:09 -0400 Subject: vim-patch:8.0.0125 Problem: Not enough testing for entering Ex commands. Solution: Add test for CTRL-\ e {expr}. (Dominique Pelle) https://github.com/vim/vim/commit/eaaa9bbda6ec0a8589a9b23720f95bffe01dc267 --- src/nvim/testdir/test_cmdline.vim | 17 +++++++++++++++++ src/nvim/version.c | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index bab700284f..2facffb067 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -230,9 +230,26 @@ func Test_paste_in_cmdline() call feedkeys("f;:aaa \\ bbb\\"\", 'tx') call assert_equal('"aaa a;b-c*d bbb', @:) + + call feedkeys(":\etoupper(getline(1))\\\"\", 'tx') + call assert_equal('"ASDF.X /TMP/SOME VERYLONGWORD A;B-C*D ', @:) bwipe! endfunc +func Test_remove_char_in_cmdline() + call feedkeys(":abc def\\\\"\", 'tx') + call assert_equal('"abc ef', @:) + + call feedkeys(":abc def\\\\"\", 'tx') + call assert_equal('"abcdef', @:) + + call feedkeys(":abc def ghi\\\\"\", 'tx') + call assert_equal('"abc ghi', @:) + + call feedkeys(":abc def\\\\"\", 'tx') + call assert_equal('"def', @:) +endfunc + func Test_illegal_address() new 2;'( diff --git a/src/nvim/version.c b/src/nvim/version.c index 73ac3fa6ce..6e24e30a09 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -827,7 +827,7 @@ static const int included_patches[] = { 128, 127, 126, - // 125, + 125, 124, // 123 NA // 122 NA -- cgit From 541dde36e3302314e2646415dbfd2b79a6c2a1fc Mon Sep 17 00:00:00 2001 From: Matthew Malcomson Date: Sat, 2 Sep 2017 14:12:32 +0100 Subject: eventloop: K_EVENT should not finish operator normal_finish_command() and normal_prepare() assume that any pending operator needs to be finished after any subsequent key. Set `finish_op = false` in nv_event() to indicate that the pending operator shouldn't be finished in normal_execute(). This is how nv_visual() indicates that 'v' or 'V' in operator-pending mode should not finish the current pending operator. fixes #5398 fixes #6166 (partially; mappings are still interrupted) --- src/nvim/normal.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 238378c474..f9017164af 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -7958,6 +7958,7 @@ static void nv_event(cmdarg_T *cap) may_garbage_collect = false; multiqueue_process_events(main_loop.events); cap->retval |= CA_COMMAND_BUSY; // don't call edit() now + finish_op = false; } /// Trigger FocusGained event. -- cgit From f050aaabbb31b58ebac519a6f7014610f2b119f0 Mon Sep 17 00:00:00 2001 From: "Vadim A. Misbakh-Soloviov" Date: Mon, 4 Sep 2017 23:48:05 +0700 Subject: tui: DECSCUSR workaround for Konsole (#7236) closes #7235 --- src/nvim/tui/tui.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index dd93053dbf..1cbd02dfd9 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1448,7 +1448,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // teminfo entries. See // https://github.com/gnachman/iTerm2/pull/92 for more. // xterm even has an extended version that has a vertical bar. - if (true_xterm // per xterm ctlseqs doco (since version 282) + if (!konsole && (true_xterm // per xterm ctlseqs doco (since version 282) // per MinTTY 0.4.3-1 release notes from 2009 || putty // per https://bugzilla.gnome.org/show_bug.cgi?id=720821 @@ -1463,7 +1463,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // Allows forcing the use of DECSCUSR on linux type terminals, such as // console-terminal-emulator from the nosh toolset, which does indeed // implement the xterm extension: - || (linuxvt && (xterm_version || (vte_version > 0) || colorterm))) { + || (linuxvt && (xterm_version || (vte_version > 0) || colorterm)))) { data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", "\x1b[%p1%d q"); if (-1 == data->unibi_ext.reset_cursor_style) { -- cgit From b6b6e4a96f37ba6a54d194ecbc042d5ef7d595e6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 28 Aug 2017 01:27:57 +0200 Subject: eventloop: FocusGained: schedule event instead of pseudokey closes #4840 closes #6164 --- src/nvim/aucmd.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/nvim/aucmd.h | 9 +++++++++ src/nvim/edit.c | 11 +---------- src/nvim/ex_getln.c | 8 -------- src/nvim/keymap.c | 2 -- src/nvim/keymap.h | 2 -- src/nvim/normal.c | 14 -------------- src/nvim/state.c | 5 +++-- src/nvim/terminal.c | 8 -------- src/nvim/tui/input.c | 13 +++++-------- 10 files changed, 66 insertions(+), 54 deletions(-) create mode 100644 src/nvim/aucmd.c create mode 100644 src/nvim/aucmd.h (limited to 'src') diff --git a/src/nvim/aucmd.c b/src/nvim/aucmd.c new file mode 100644 index 0000000000..8b86d89bf2 --- /dev/null +++ b/src/nvim/aucmd.c @@ -0,0 +1,48 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + +#include "nvim/os/os.h" +#include "nvim/fileio.h" +#include "nvim/vim.h" +#include "nvim/main.h" +#include "nvim/screen.h" +#include "nvim/ui.h" + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "aucmd.c.generated.h" +#endif + +static void focusgained_event(void **argv) +{ + bool *gained = argv[0]; + do_autocmd_focusgained(*gained); + xfree(gained); +} +void aucmd_schedule_focusgained(bool gained) +{ + bool *gainedp = xmalloc(sizeof(*gainedp)); + *gainedp = gained; + loop_schedule(&main_loop, event_create(focusgained_event, 1, gainedp)); +} + +static void do_autocmd_focusgained(bool gained) + FUNC_ATTR_NONNULL_ALL +{ + static bool recursive = false; + + if (recursive) { + return; // disallow recursion + } + recursive = true; + bool has_any = has_event(EVENT_FOCUSGAINED) || has_event(EVENT_FOCUSLOST); + bool did_any = apply_autocmds((gained ? EVENT_FOCUSGAINED : EVENT_FOCUSLOST), + NULL, NULL, false, curbuf); + if (has_any && !did_any) { + // HACK: Reschedule, hoping that the next event-loop tick will pick this up + // during a "regular" state (as opposed to a weird implicit state, e.g. + // early_init()..win_alloc_first() which disables autocommands). + aucmd_schedule_focusgained(gained); + } + recursive = false; +} + diff --git a/src/nvim/aucmd.h b/src/nvim/aucmd.h new file mode 100644 index 0000000000..6570ba7a92 --- /dev/null +++ b/src/nvim/aucmd.h @@ -0,0 +1,9 @@ +#ifndef NVIM_AUCMD_H +#define NVIM_AUCMD_H + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "aucmd.h.generated.h" +#endif + +#endif // NVIM_AUCMD_H + diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 17f0b8ef82..2bafb77fef 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -974,14 +974,6 @@ static int insert_handle_key(InsertState *s) multiqueue_process_events(main_loop.events); break; - case K_FOCUSGAINED: // Neovim has been given focus - apply_autocmds(EVENT_FOCUSGAINED, NULL, NULL, false, curbuf); - break; - - case K_FOCUSLOST: // Neovim has lost focus - apply_autocmds(EVENT_FOCUSLOST, NULL, NULL, false, curbuf); - break; - case K_HOME: // case K_KHOME: case K_S_HOME: @@ -3167,8 +3159,7 @@ static bool ins_compl_prep(int c) /* Ignore end of Select mode mapping and mouse scroll buttons. */ if (c == K_SELECT || c == K_MOUSEDOWN || c == K_MOUSEUP - || c == K_MOUSELEFT || c == K_MOUSERIGHT || c == K_EVENT - || c == K_FOCUSGAINED || c == K_FOCUSLOST) { + || c == K_MOUSELEFT || c == K_MOUSERIGHT || c == K_EVENT) { return retval; } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 5e216925df..fd7ad7a4b5 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1620,14 +1620,6 @@ static int command_line_handle_key(CommandLineState *s) } return command_line_not_changed(s); - case K_FOCUSGAINED: // Neovim has been given focus - apply_autocmds(EVENT_FOCUSGAINED, NULL, NULL, false, curbuf); - return command_line_not_changed(s); - - case K_FOCUSLOST: // Neovim has lost focus - apply_autocmds(EVENT_FOCUSLOST, NULL, NULL, false, curbuf); - return command_line_not_changed(s); - default: // Normal character with no special meaning. Just set mod_mask // to 0x0 so that typing Shift-Space in the GUI doesn't enter diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index 3d7ebb6382..cfe038693a 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -286,8 +286,6 @@ static struct key_name_entry { {K_SNR, (char_u *)"SNR"}, {K_PLUG, (char_u *)"Plug"}, {K_PASTE, (char_u *)"Paste"}, - {K_FOCUSGAINED, (char_u *)"FocusGained"}, - {K_FOCUSLOST, (char_u *)"FocusLost"}, {0, NULL} }; diff --git a/src/nvim/keymap.h b/src/nvim/keymap.h index b8fed77a90..ee64854c98 100644 --- a/src/nvim/keymap.h +++ b/src/nvim/keymap.h @@ -428,8 +428,6 @@ enum key_extra { #define K_CMDWIN TERMCAP2KEY(KS_EXTRA, KE_CMDWIN) #define K_DROP TERMCAP2KEY(KS_EXTRA, KE_DROP) -#define K_FOCUSGAINED TERMCAP2KEY(KS_EXTRA, KE_FOCUSGAINED) -#define K_FOCUSLOST TERMCAP2KEY(KS_EXTRA, KE_FOCUSLOST) #define K_EVENT TERMCAP2KEY(KS_EXTRA, KE_EVENT) #define K_PASTE TERMCAP2KEY(KS_EXTRA, KE_PASTE) diff --git a/src/nvim/normal.c b/src/nvim/normal.c index f9017164af..6415bec846 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -345,8 +345,6 @@ static const struct nv_cmd { { K_F8, farsi_f8, 0, 0 }, { K_F9, farsi_f9, 0, 0 }, { K_EVENT, nv_event, NV_KEEPREG, 0 }, - { K_FOCUSGAINED, nv_focusgained, NV_KEEPREG, 0 }, - { K_FOCUSLOST, nv_focuslost, NV_KEEPREG, 0 }, }; /* Number of commands in nv_cmds[]. */ @@ -7961,18 +7959,6 @@ static void nv_event(cmdarg_T *cap) finish_op = false; } -/// Trigger FocusGained event. -static void nv_focusgained(cmdarg_T *cap) -{ - apply_autocmds(EVENT_FOCUSGAINED, NULL, NULL, false, curbuf); -} - -/// Trigger FocusLost event. -static void nv_focuslost(cmdarg_T *cap) -{ - apply_autocmds(EVENT_FOCUSLOST, NULL, NULL, false, curbuf); -} - /* * Return TRUE when 'mousemodel' is set to "popup" or "popup_setpos". */ diff --git a/src/nvim/state.c b/src/nvim/state.c index eb0b590a9b..24248ec66c 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -26,10 +26,11 @@ void state_enter(VimState *s) int check_result = s->check ? s->check(s) : 1; if (!check_result) { - break; + break; // Terminate this state. } else if (check_result == -1) { - continue; + continue; // check() again. } + // Execute this state. int key; diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index deec930ebd..1c764d302d 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -432,14 +432,6 @@ static int terminal_execute(VimState *state, int key) TerminalState *s = (TerminalState *)state; switch (key) { - case K_FOCUSGAINED: // nvim has been given focus - apply_autocmds(EVENT_FOCUSGAINED, NULL, NULL, false, curbuf); - break; - - case K_FOCUSLOST: // nvim has lost focus - apply_autocmds(EVENT_FOCUSLOST, NULL, NULL, false, curbuf); - break; - // Temporary fix until paste events gets implemented case K_PASTE: break; diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 03587d68f0..8bb5971bd4 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -8,6 +8,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/ascii.h" #include "nvim/main.h" +#include "nvim/aucmd.h" #include "nvim/os/os.h" #include "nvim/os/input.h" #include "nvim/event/rstream.h" @@ -280,9 +281,9 @@ static void timer_cb(TimeWatcher *watcher, void *data) /// Handle focus events. /// -/// If the upcoming sequence of bytes in the input stream matches either the -/// escape code for focus gained `[I` or focus lost `[O` then consume -/// that sequence and push the appropriate event into the input queue +/// If the upcoming sequence of bytes in the input stream matches the termcode +/// for "focus gained" or "focus lost", consume that sequence and schedule an +/// event on the main loop. /// /// @param input the input stream /// @return true iff handle_focus_event consumed some input @@ -294,11 +295,7 @@ static bool handle_focus_event(TermInput *input) // Advance past the sequence bool focus_gained = *rbuffer_get(input->read_stream.buffer, 2) == 'I'; rbuffer_consumed(input->read_stream.buffer, 3); - if (focus_gained) { - enqueue_input(input, FOCUSGAINED_KEY, sizeof(FOCUSGAINED_KEY) - 1); - } else { - enqueue_input(input, FOCUSLOST_KEY, sizeof(FOCUSLOST_KEY) - 1); - } + aucmd_schedule_focusgained(focus_gained); return true; } return false; -- cgit From 46fdacc5b5abb05d49c0f16fe5ffc4ceb7795dee Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 31 Aug 2017 23:20:30 +0200 Subject: doc: eventloop --- src/nvim/event/loop.c | 8 +++++++- src/nvim/event/loop.h | 22 ++++++++++++++++++++-- src/nvim/state.c | 8 +++++--- 3 files changed, 32 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c index 25701a1621..cc9088f776 100644 --- a/src/nvim/event/loop.c +++ b/src/nvim/event/loop.c @@ -59,7 +59,13 @@ void loop_poll_events(Loop *loop, int ms) multiqueue_process_events(loop->fast_events); } -// Schedule an event from another thread +/// Schedules an event from another thread. +/// +/// @note Event is queued into `fast_events`, which is processed outside of the +/// primary `events` queue by loop_poll_events(). For `main_loop`, that +/// means `fast_events` is NOT processed in an "editor mode" +/// (VimState.execute), so redraw and other side-effects are likely to be +/// skipped. void loop_schedule(Loop *loop, Event event) { uv_mutex_lock(&loop->mutex); diff --git a/src/nvim/event/loop.h b/src/nvim/event/loop.h index e7d7bdd483..b0ddc59469 100644 --- a/src/nvim/event/loop.h +++ b/src/nvim/event/loop.h @@ -16,10 +16,28 @@ KLIST_INIT(WatcherPtr, WatcherPtr, _noop) typedef struct loop { uv_loop_t uv; - MultiQueue *events, *fast_events, *thread_events; + MultiQueue *events; + MultiQueue *thread_events; + // Immediate events: + // "Events that should be processed after exiting uv_run() (to avoid + // recursion), but before returning from loop_poll_events()." + // 502aee690c980fcb3cfcb3f211dcfad06103db46 + // Practical consequence: these events are processed by + // state_enter()..os_inchar() + // whereas "regular" (main_loop.events) events are processed by + // state_enter()..VimState.execute() + // But state_enter()..os_inchar() can be "too early" if you want the event + // to trigger UI updates and other user-activity-related side-effects. + MultiQueue *fast_events; + + // used by process/job-control subsystem klist_t(WatcherPtr) *children; uv_signal_t children_watcher; - uv_timer_t children_kill_timer, poll_timer; + uv_timer_t children_kill_timer; + + // generic timer, used by loop_poll_events() + uv_timer_t poll_timer; + size_t children_stop_requests; uv_async_t async; uv_mutex_t mutex; diff --git a/src/nvim/state.c b/src/nvim/state.c index 24248ec66c..4d9032b7a5 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -49,11 +49,13 @@ getkey: ui_flush(); // Call `os_inchar` directly to block for events or user input without // consuming anything from `input_buffer`(os/input.c) or calling the - // mapping engine. If an event was put into the queue, we send K_EVENT - // directly. + // mapping engine. (void)os_inchar(NULL, 0, -1, 0); input_disable_events(); - key = !multiqueue_empty(main_loop.events) ? K_EVENT : safe_vgetc(); + // If an event was put into the queue, we send K_EVENT directly. + key = !multiqueue_empty(main_loop.events) + ? K_EVENT + : safe_vgetc(); } if (key == K_EVENT) { -- cgit From d30abd8857a41f439de01f8c0e6d1075acf124d9 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 2 Sep 2017 11:35:14 +0200 Subject: eventloop: FocusGained: schedule the schedule main_loop.fast_events does not manifest as K_EVENT, because it is processed at a different stage than main_loop.events. In order to queue into main_loop.events, we need to go through the threadsafe loop_schedule(), which queues into main_loop.thread_events and eventually main_loop.fast_events. _Then_ it is safe to directly queue into main_loop.events. This makes it more likely that the event is treated as K_EVENT. --- src/nvim/aucmd.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/aucmd.c b/src/nvim/aucmd.c index 8b86d89bf2..a69881431e 100644 --- a/src/nvim/aucmd.c +++ b/src/nvim/aucmd.c @@ -14,15 +14,20 @@ static void focusgained_event(void **argv) { - bool *gained = argv[0]; - do_autocmd_focusgained(*gained); - xfree(gained); + bool *gainedp = argv[0]; + do_autocmd_focusgained(*gainedp); + xfree(gainedp); +} +static void schedule_event(void **argv) +{ + bool *gainedp = argv[0]; + multiqueue_put(main_loop.events, focusgained_event, 1, gainedp); } void aucmd_schedule_focusgained(bool gained) { bool *gainedp = xmalloc(sizeof(*gainedp)); *gainedp = gained; - loop_schedule(&main_loop, event_create(focusgained_event, 1, gainedp)); + loop_schedule(&main_loop, event_create(schedule_event, 1, gainedp)); } static void do_autocmd_focusgained(bool gained) @@ -34,15 +39,8 @@ static void do_autocmd_focusgained(bool gained) return; // disallow recursion } recursive = true; - bool has_any = has_event(EVENT_FOCUSGAINED) || has_event(EVENT_FOCUSLOST); - bool did_any = apply_autocmds((gained ? EVENT_FOCUSGAINED : EVENT_FOCUSLOST), - NULL, NULL, false, curbuf); - if (has_any && !did_any) { - // HACK: Reschedule, hoping that the next event-loop tick will pick this up - // during a "regular" state (as opposed to a weird implicit state, e.g. - // early_init()..win_alloc_first() which disables autocommands). - aucmd_schedule_focusgained(gained); - } + apply_autocmds((gained ? EVENT_FOCUSGAINED : EVENT_FOCUSLOST), + NULL, NULL, false, curbuf); recursive = false; } -- cgit From d47b538f39e3e9700a18f1cd72e561086f62d7f3 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 2 Sep 2017 11:35:44 +0200 Subject: eventloop: do not redraw in cmdline K_EVENT handler If :echo is done by an timer or event (such as FocusGained/FocusLost), redrawcmdline() clobbers it. --- src/nvim/ex_getln.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index fd7ad7a4b5..9bfa9e22df 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -441,8 +441,7 @@ static int command_line_execute(VimState *state, int key) if (s->c == K_EVENT) { multiqueue_process_events(main_loop.events); - redrawcmdline(); - return 1; + return command_line_not_changed(s); } if (KeyTyped) { -- cgit From 6c53c3ee55991d9b1ea61a8dc443038b478ca92a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 2 Sep 2017 11:35:48 +0200 Subject: eventloop: restore redraw in cmdline K_EVENT handler Restores behavior from commit: 02e86ef04cc1 --- src/nvim/ex_getln.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 9bfa9e22df..fd7ad7a4b5 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -441,7 +441,8 @@ static int command_line_execute(VimState *state, int key) if (s->c == K_EVENT) { multiqueue_process_events(main_loop.events); - return command_line_not_changed(s); + redrawcmdline(); + return 1; } if (KeyTyped) { -- cgit From 63c64705058e96368cbc1dcc3fc4f97fc51c73fe Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 2 Sep 2017 11:35:53 +0200 Subject: log: introduce `context` --- src/nvim/log.c | 40 ++++++++++++++++++++++++++-------------- src/nvim/log.h | 18 +++++++++--------- src/nvim/ui.c | 4 ++-- 3 files changed, 37 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/nvim/log.c b/src/nvim/log.c index 436a8a4079..a8451f7bc4 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -95,8 +95,12 @@ void log_unlock(void) uv_mutex_unlock(&mutex); } -bool do_log(int log_level, const char *func_name, int line_num, bool eol, - const char* fmt, ...) FUNC_ATTR_UNUSED +/// @param context description of a shared context or subsystem +/// @param func_name function name, or NULL +/// @param line_num source line number, or -1 +bool do_log(int log_level, const char *context, const char *func_name, + int line_num, bool eol, const char* fmt, ...) + FUNC_ATTR_UNUSED { if (log_level < MIN_LOG_LEVEL) { return false; @@ -112,8 +116,8 @@ bool do_log(int log_level, const char *func_name, int line_num, bool eol, va_list args; va_start(args, fmt); - ret = v_do_log_to_file(log_file, log_level, func_name, line_num, eol, - fmt, args); + ret = v_do_log_to_file(log_file, log_level, context, func_name, line_num, + eol, fmt, args); va_end(args); if (log_file != stderr && log_file != stdout) { @@ -151,7 +155,7 @@ FILE *open_log_file(void) static bool opening_log_file = false; // check if it's a recursive call if (opening_log_file) { - do_log_to_file(stderr, ERROR_LOG_LEVEL, __func__, __LINE__, true, + do_log_to_file(stderr, ERROR_LOG_LEVEL, NULL, __func__, __LINE__, true, "Cannot LOG() recursively."); return stderr; } @@ -171,7 +175,7 @@ FILE *open_log_file(void) // - LOG() is called before early_init() // - Directory does not exist // - File is not writable - do_log_to_file(stderr, ERROR_LOG_LEVEL, __func__, __LINE__, true, + do_log_to_file(stderr, ERROR_LOG_LEVEL, NULL, __func__, __LINE__, true, "Logging to stderr, failed to open $" LOG_FILE_ENV ": %s", log_file_path); return stderr; @@ -201,7 +205,7 @@ void log_callstack_to_file(FILE *log_file, const char *const func_name, // Now we have a command string like: // addr2line -e /path/to/exe -f -p 0x123 0x456 ... - do_log_to_file(log_file, DEBUG_LOG_LEVEL, func_name, line_num, true, + do_log_to_file(log_file, DEBUG_LOG_LEVEL, NULL, func_name, line_num, true, "trace:"); FILE *fp = popen(cmdbuf, "r"); char linebuf[IOSIZE]; @@ -230,22 +234,23 @@ end: } #endif -static bool do_log_to_file(FILE *log_file, int log_level, +static bool do_log_to_file(FILE *log_file, int log_level, const char *context, const char *func_name, int line_num, bool eol, const char* fmt, ...) { va_list args; va_start(args, fmt); - bool ret = v_do_log_to_file(log_file, log_level, func_name, line_num, eol, - fmt, args); + bool ret = v_do_log_to_file(log_file, log_level, context, func_name, + line_num, eol, fmt, args); va_end(args); return ret; } static bool v_do_log_to_file(FILE *log_file, int log_level, - const char *func_name, int line_num, bool eol, - const char* fmt, va_list args) + const char *context, const char *func_name, + int line_num, bool eol, const char* fmt, + va_list args) { static const char *log_levels[] = { [DEBUG_LOG_LEVEL] = "DEBUG", @@ -268,8 +273,15 @@ static bool v_do_log_to_file(FILE *log_file, int log_level, // print the log message prefixed by the current timestamp and pid int64_t pid = os_get_pid(); - if (fprintf(log_file, "%s %s %" PRId64 "/%s:%d: ", date_time, - log_levels[log_level], pid, func_name, line_num) < 0) { + int rv = (line_num == -1 || func_name == NULL) + ? fprintf(log_file, "%s %s %" PRId64 " %s", date_time, + log_levels[log_level], pid, + (context == NULL ? "?:" : context)) + : fprintf(log_file, "%s %s %" PRId64 " %s%s:%d: ", date_time, + log_levels[log_level], pid, + (context == NULL ? "" : context), + func_name, line_num); + if (rv < 0) { return false; } if (vfprintf(log_file, fmt, args) < 0) { diff --git a/src/nvim/log.h b/src/nvim/log.h index d63bcc366c..f378b92039 100644 --- a/src/nvim/log.h +++ b/src/nvim/log.h @@ -22,42 +22,42 @@ # define MIN_LOG_LEVEL INFO_LOG_LEVEL #endif -#define LOG(level, ...) do_log((level), __func__, __LINE__, true, \ +#define LOG(level, ...) do_log((level), NULL, __func__, __LINE__, true, \ __VA_ARGS__) #if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL # undef DLOG # undef DLOGN -# define DLOG(...) do_log(DEBUG_LOG_LEVEL, __func__, __LINE__, true, \ +# define DLOG(...) do_log(DEBUG_LOG_LEVEL, NULL, __func__, __LINE__, true, \ __VA_ARGS__) -# define DLOGN(...) do_log(DEBUG_LOG_LEVEL, __func__, __LINE__, false, \ +# define DLOGN(...) do_log(DEBUG_LOG_LEVEL, NULL, __func__, __LINE__, false, \ __VA_ARGS__) #endif #if MIN_LOG_LEVEL <= INFO_LOG_LEVEL # undef ILOG # undef ILOGN -# define ILOG(...) do_log(INFO_LOG_LEVEL, __func__, __LINE__, true, \ +# define ILOG(...) do_log(INFO_LOG_LEVEL, NULL, __func__, __LINE__, true, \ __VA_ARGS__) -# define ILOGN(...) do_log(INFO_LOG_LEVEL, __func__, __LINE__, false, \ +# define ILOGN(...) do_log(INFO_LOG_LEVEL, NULL, __func__, __LINE__, false, \ __VA_ARGS__) #endif #if MIN_LOG_LEVEL <= WARN_LOG_LEVEL # undef WLOG # undef WLOGN -# define WLOG(...) do_log(WARN_LOG_LEVEL, __func__, __LINE__, true, \ +# define WLOG(...) do_log(WARN_LOG_LEVEL, NULL, __func__, __LINE__, true, \ __VA_ARGS__) -# define WLOGN(...) do_log(WARN_LOG_LEVEL, __func__, __LINE__, false, \ +# define WLOGN(...) do_log(WARN_LOG_LEVEL, NULL, __func__, __LINE__, false, \ __VA_ARGS__) #endif #if MIN_LOG_LEVEL <= ERROR_LOG_LEVEL # undef ELOG # undef ELOGN -# define ELOG(...) do_log(ERROR_LOG_LEVEL, __func__, __LINE__, true, \ +# define ELOG(...) do_log(ERROR_LOG_LEVEL, NULL, __func__, __LINE__, true, \ __VA_ARGS__) -# define ELOGN(...) do_log(ERROR_LOG_LEVEL, __func__, __LINE__, false, \ +# define ELOGN(...) do_log(ERROR_LOG_LEVEL, NULL, __func__, __LINE__, false, \ __VA_ARGS__) #endif diff --git a/src/nvim/ui.c b/src/nvim/ui.c index b85a01814d..01d3604159 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -71,10 +71,10 @@ static char uilog_last_event[1024] = { 0 }; uilog_seen++; \ } else { \ if (uilog_seen > 0) { \ - do_log(DEBUG_LOG_LEVEL, "ui", 0, true, \ + do_log(DEBUG_LOG_LEVEL, "UI: ", NULL, -1, true, \ "%s (+%zu times...)", uilog_last_event, uilog_seen); \ } \ - DLOG("ui: " STR(funname)); \ + do_log(DEBUG_LOG_LEVEL, "UI: ", NULL, -1, true, STR(funname)); \ uilog_seen = 0; \ xstrlcpy(uilog_last_event, STR(funname), sizeof(uilog_last_event)); \ } \ -- cgit From 8716994cf07e9c9dab4af31a0acf47c858a1b789 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 2 Sep 2017 17:04:42 +0200 Subject: lint --- src/nvim/keymap.c | 292 +++++++++++++++++++++++++++--------------------------- src/nvim/log.c | 4 +- 2 files changed, 148 insertions(+), 148 deletions(-) (limited to 'src') diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index cfe038693a..a75fe793ac 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -140,153 +140,153 @@ static char_u modifier_keys_table[] = }; static struct key_name_entry { - int key; /* Special key code or ascii value */ - char_u *name; /* Name of key */ + int key; // Special key code or ascii value + char *name; // Name of key } key_names_table[] = { - {' ', (char_u *)"Space"}, - {TAB, (char_u *)"Tab"}, - {K_TAB, (char_u *)"Tab"}, - {NL, (char_u *)"NL"}, - {NL, (char_u *)"NewLine"}, /* Alternative name */ - {NL, (char_u *)"LineFeed"}, /* Alternative name */ - {NL, (char_u *)"LF"}, /* Alternative name */ - {CAR, (char_u *)"CR"}, - {CAR, (char_u *)"Return"}, /* Alternative name */ - {CAR, (char_u *)"Enter"}, /* Alternative name */ - {K_BS, (char_u *)"BS"}, - {K_BS, (char_u *)"BackSpace"}, /* Alternative name */ - {ESC, (char_u *)"Esc"}, - {CSI, (char_u *)"CSI"}, - {K_CSI, (char_u *)"xCSI"}, - {'|', (char_u *)"Bar"}, - {'\\', (char_u *)"Bslash"}, - {K_DEL, (char_u *)"Del"}, - {K_DEL, (char_u *)"Delete"}, /* Alternative name */ - {K_KDEL, (char_u *)"kDel"}, - {K_UP, (char_u *)"Up"}, - {K_DOWN, (char_u *)"Down"}, - {K_LEFT, (char_u *)"Left"}, - {K_RIGHT, (char_u *)"Right"}, - {K_XUP, (char_u *)"xUp"}, - {K_XDOWN, (char_u *)"xDown"}, - {K_XLEFT, (char_u *)"xLeft"}, - {K_XRIGHT, (char_u *)"xRight"}, - - {K_F1, (char_u *)"F1"}, - {K_F2, (char_u *)"F2"}, - {K_F3, (char_u *)"F3"}, - {K_F4, (char_u *)"F4"}, - {K_F5, (char_u *)"F5"}, - {K_F6, (char_u *)"F6"}, - {K_F7, (char_u *)"F7"}, - {K_F8, (char_u *)"F8"}, - {K_F9, (char_u *)"F9"}, - {K_F10, (char_u *)"F10"}, - - {K_F11, (char_u *)"F11"}, - {K_F12, (char_u *)"F12"}, - {K_F13, (char_u *)"F13"}, - {K_F14, (char_u *)"F14"}, - {K_F15, (char_u *)"F15"}, - {K_F16, (char_u *)"F16"}, - {K_F17, (char_u *)"F17"}, - {K_F18, (char_u *)"F18"}, - {K_F19, (char_u *)"F19"}, - {K_F20, (char_u *)"F20"}, - - {K_F21, (char_u *)"F21"}, - {K_F22, (char_u *)"F22"}, - {K_F23, (char_u *)"F23"}, - {K_F24, (char_u *)"F24"}, - {K_F25, (char_u *)"F25"}, - {K_F26, (char_u *)"F26"}, - {K_F27, (char_u *)"F27"}, - {K_F28, (char_u *)"F28"}, - {K_F29, (char_u *)"F29"}, - {K_F30, (char_u *)"F30"}, - - {K_F31, (char_u *)"F31"}, - {K_F32, (char_u *)"F32"}, - {K_F33, (char_u *)"F33"}, - {K_F34, (char_u *)"F34"}, - {K_F35, (char_u *)"F35"}, - {K_F36, (char_u *)"F36"}, - {K_F37, (char_u *)"F37"}, - - {K_XF1, (char_u *)"xF1"}, - {K_XF2, (char_u *)"xF2"}, - {K_XF3, (char_u *)"xF3"}, - {K_XF4, (char_u *)"xF4"}, - - {K_HELP, (char_u *)"Help"}, - {K_UNDO, (char_u *)"Undo"}, - {K_INS, (char_u *)"Insert"}, - {K_INS, (char_u *)"Ins"}, /* Alternative name */ - {K_KINS, (char_u *)"kInsert"}, - {K_HOME, (char_u *)"Home"}, - {K_KHOME, (char_u *)"kHome"}, - {K_XHOME, (char_u *)"xHome"}, - {K_ZHOME, (char_u *)"zHome"}, - {K_END, (char_u *)"End"}, - {K_KEND, (char_u *)"kEnd"}, - {K_XEND, (char_u *)"xEnd"}, - {K_ZEND, (char_u *)"zEnd"}, - {K_PAGEUP, (char_u *)"PageUp"}, - {K_PAGEDOWN, (char_u *)"PageDown"}, - {K_KPAGEUP, (char_u *)"kPageUp"}, - {K_KPAGEDOWN, (char_u *)"kPageDown"}, - - {K_KPLUS, (char_u *)"kPlus"}, - {K_KMINUS, (char_u *)"kMinus"}, - {K_KDIVIDE, (char_u *)"kDivide"}, - {K_KMULTIPLY, (char_u *)"kMultiply"}, - {K_KENTER, (char_u *)"kEnter"}, - {K_KPOINT, (char_u *)"kPoint"}, - - {K_K0, (char_u *)"k0"}, - {K_K1, (char_u *)"k1"}, - {K_K2, (char_u *)"k2"}, - {K_K3, (char_u *)"k3"}, - {K_K4, (char_u *)"k4"}, - {K_K5, (char_u *)"k5"}, - {K_K6, (char_u *)"k6"}, - {K_K7, (char_u *)"k7"}, - {K_K8, (char_u *)"k8"}, - {K_K9, (char_u *)"k9"}, - - {'<', (char_u *)"lt"}, - - {K_MOUSE, (char_u *)"Mouse"}, - {K_LEFTMOUSE, (char_u *)"LeftMouse"}, - {K_LEFTMOUSE_NM, (char_u *)"LeftMouseNM"}, - {K_LEFTDRAG, (char_u *)"LeftDrag"}, - {K_LEFTRELEASE, (char_u *)"LeftRelease"}, - {K_LEFTRELEASE_NM, (char_u *)"LeftReleaseNM"}, - {K_MIDDLEMOUSE, (char_u *)"MiddleMouse"}, - {K_MIDDLEDRAG, (char_u *)"MiddleDrag"}, - {K_MIDDLERELEASE, (char_u *)"MiddleRelease"}, - {K_RIGHTMOUSE, (char_u *)"RightMouse"}, - {K_RIGHTDRAG, (char_u *)"RightDrag"}, - {K_RIGHTRELEASE, (char_u *)"RightRelease"}, - {K_MOUSEDOWN, (char_u *)"ScrollWheelUp"}, - {K_MOUSEUP, (char_u *)"ScrollWheelDown"}, - {K_MOUSELEFT, (char_u *)"ScrollWheelRight"}, - {K_MOUSERIGHT, (char_u *)"ScrollWheelLeft"}, - {K_MOUSEDOWN, (char_u *)"MouseDown"}, /* OBSOLETE: Use */ - {K_MOUSEUP, (char_u *)"MouseUp"}, /* ScrollWheelXXX instead */ - {K_X1MOUSE, (char_u *)"X1Mouse"}, - {K_X1DRAG, (char_u *)"X1Drag"}, - {K_X1RELEASE, (char_u *)"X1Release"}, - {K_X2MOUSE, (char_u *)"X2Mouse"}, - {K_X2DRAG, (char_u *)"X2Drag"}, - {K_X2RELEASE, (char_u *)"X2Release"}, - {K_DROP, (char_u *)"Drop"}, - {K_ZERO, (char_u *)"Nul"}, - {K_SNR, (char_u *)"SNR"}, - {K_PLUG, (char_u *)"Plug"}, - {K_PASTE, (char_u *)"Paste"}, - {0, NULL} + { ' ', "Space" }, + { TAB, "Tab" }, + { K_TAB, "Tab" }, + { NL, "NL" }, + { NL, "NewLine" }, // Alternative name + { NL, "LineFeed" }, // Alternative name + { NL, "LF" }, // Alternative name + { CAR, "CR" }, + { CAR, "Return" }, // Alternative name + { CAR, "Enter" }, // Alternative name + { K_BS, "BS" }, + { K_BS, "BackSpace" }, // Alternative name + { ESC, "Esc" }, + { CSI, "CSI" }, + { K_CSI, "xCSI" }, + { '|', "Bar" }, + { '\\', "Bslash" }, + { K_DEL, "Del" }, + { K_DEL, "Delete" }, // Alternative name + { K_KDEL, "kDel" }, + { K_UP, "Up" }, + { K_DOWN, "Down" }, + { K_LEFT, "Left" }, + { K_RIGHT, "Right" }, + { K_XUP, "xUp" }, + { K_XDOWN, "xDown" }, + { K_XLEFT, "xLeft" }, + { K_XRIGHT, "xRight" }, + + { K_F1, "F1" }, + { K_F2, "F2" }, + { K_F3, "F3" }, + { K_F4, "F4" }, + { K_F5, "F5" }, + { K_F6, "F6" }, + { K_F7, "F7" }, + { K_F8, "F8" }, + { K_F9, "F9" }, + { K_F10, "F10" }, + + { K_F11, "F11" }, + { K_F12, "F12" }, + { K_F13, "F13" }, + { K_F14, "F14" }, + { K_F15, "F15" }, + { K_F16, "F16" }, + { K_F17, "F17" }, + { K_F18, "F18" }, + { K_F19, "F19" }, + { K_F20, "F20" }, + + { K_F21, "F21" }, + { K_F22, "F22" }, + { K_F23, "F23" }, + { K_F24, "F24" }, + { K_F25, "F25" }, + { K_F26, "F26" }, + { K_F27, "F27" }, + { K_F28, "F28" }, + { K_F29, "F29" }, + { K_F30, "F30" }, + + { K_F31, "F31" }, + { K_F32, "F32" }, + { K_F33, "F33" }, + { K_F34, "F34" }, + { K_F35, "F35" }, + { K_F36, "F36" }, + { K_F37, "F37" }, + + { K_XF1, "xF1" }, + { K_XF2, "xF2" }, + { K_XF3, "xF3" }, + { K_XF4, "xF4" }, + + { K_HELP, "Help" }, + { K_UNDO, "Undo" }, + { K_INS, "Insert" }, + { K_INS, "Ins" }, // Alternative name + { K_KINS, "kInsert" }, + { K_HOME, "Home" }, + { K_KHOME, "kHome" }, + { K_XHOME, "xHome" }, + { K_ZHOME, "zHome" }, + { K_END, "End" }, + { K_KEND, "kEnd" }, + { K_XEND, "xEnd" }, + { K_ZEND, "zEnd" }, + { K_PAGEUP, "PageUp" }, + { K_PAGEDOWN, "PageDown" }, + { K_KPAGEUP, "kPageUp" }, + { K_KPAGEDOWN, "kPageDown" }, + + { K_KPLUS, "kPlus" }, + { K_KMINUS, "kMinus" }, + { K_KDIVIDE, "kDivide" }, + { K_KMULTIPLY, "kMultiply" }, + { K_KENTER, "kEnter" }, + { K_KPOINT, "kPoint" }, + + { K_K0, "k0" }, + { K_K1, "k1" }, + { K_K2, "k2" }, + { K_K3, "k3" }, + { K_K4, "k4" }, + { K_K5, "k5" }, + { K_K6, "k6" }, + { K_K7, "k7" }, + { K_K8, "k8" }, + { K_K9, "k9" }, + + { '<', "lt" }, + + { K_MOUSE, "Mouse" }, + { K_LEFTMOUSE, "LeftMouse" }, + { K_LEFTMOUSE_NM, "LeftMouseNM" }, + { K_LEFTDRAG, "LeftDrag" }, + { K_LEFTRELEASE, "LeftRelease" }, + { K_LEFTRELEASE_NM, "LeftReleaseNM" }, + { K_MIDDLEMOUSE, "MiddleMouse" }, + { K_MIDDLEDRAG, "MiddleDrag" }, + { K_MIDDLERELEASE, "MiddleRelease" }, + { K_RIGHTMOUSE, "RightMouse" }, + { K_RIGHTDRAG, "RightDrag" }, + { K_RIGHTRELEASE, "RightRelease" }, + { K_MOUSEDOWN, "ScrollWheelUp" }, + { K_MOUSEUP, "ScrollWheelDown" }, + { K_MOUSELEFT, "ScrollWheelRight" }, + { K_MOUSERIGHT, "ScrollWheelLeft" }, + { K_MOUSEDOWN, "MouseDown" }, // OBSOLETE: Use + { K_MOUSEUP, "MouseUp" }, // ScrollWheelXXX instead + { K_X1MOUSE, "X1Mouse" }, + { K_X1DRAG, "X1Drag" }, + { K_X1RELEASE, "X1Release" }, + { K_X2MOUSE, "X2Mouse" }, + { K_X2DRAG, "X2Drag" }, + { K_X2RELEASE, "X2Release" }, + { K_DROP, "Drop" }, + { K_ZERO, "Nul" }, + { K_SNR, "SNR" }, + { K_PLUG, "Plug" }, + { K_PASTE, "Paste" }, + { 0, NULL } }; static struct mousetable { @@ -719,7 +719,7 @@ int find_special_key_in_table(int c) */ int get_special_key_code(const char_u *name) { - char_u *table_name; + char *table_name; int i, j; for (i = 0; key_names_table[i].name != NULL; i++) { diff --git a/src/nvim/log.c b/src/nvim/log.c index a8451f7bc4..7bfe5c4089 100644 --- a/src/nvim/log.c +++ b/src/nvim/log.c @@ -99,7 +99,7 @@ void log_unlock(void) /// @param func_name function name, or NULL /// @param line_num source line number, or -1 bool do_log(int log_level, const char *context, const char *func_name, - int line_num, bool eol, const char* fmt, ...) + int line_num, bool eol, const char *fmt, ...) FUNC_ATTR_UNUSED { if (log_level < MIN_LOG_LEVEL) { @@ -249,7 +249,7 @@ static bool do_log_to_file(FILE *log_file, int log_level, const char *context, static bool v_do_log_to_file(FILE *log_file, int log_level, const char *context, const char *func_name, - int line_num, bool eol, const char* fmt, + int line_num, bool eol, const char *fmt, va_list args) { static const char *log_levels[] = { -- cgit From c00a33ed19c1372bf5880e2f32adf37c9bea165b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 3 Sep 2017 14:31:38 +0200 Subject: eventloop: loop_schedule_deferred() Generalize the "schedule schedule" technique. --- src/nvim/aucmd.c | 9 ++------- src/nvim/event/loop.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/aucmd.c b/src/nvim/aucmd.c index a69881431e..fc421116ea 100644 --- a/src/nvim/aucmd.c +++ b/src/nvim/aucmd.c @@ -5,7 +5,6 @@ #include "nvim/fileio.h" #include "nvim/vim.h" #include "nvim/main.h" -#include "nvim/screen.h" #include "nvim/ui.h" #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -18,16 +17,12 @@ static void focusgained_event(void **argv) do_autocmd_focusgained(*gainedp); xfree(gainedp); } -static void schedule_event(void **argv) -{ - bool *gainedp = argv[0]; - multiqueue_put(main_loop.events, focusgained_event, 1, gainedp); -} void aucmd_schedule_focusgained(bool gained) { bool *gainedp = xmalloc(sizeof(*gainedp)); *gainedp = gained; - loop_schedule(&main_loop, event_create(schedule_event, 1, gainedp)); + loop_schedule_deferred(&main_loop, + event_create(focusgained_event, 1, gainedp)); } static void do_autocmd_focusgained(bool gained) diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c index cc9088f776..570db6dfc3 100644 --- a/src/nvim/event/loop.c +++ b/src/nvim/event/loop.c @@ -74,6 +74,24 @@ void loop_schedule(Loop *loop, Event event) uv_mutex_unlock(&loop->mutex); } +/// Schedules an event from another thread. Unlike loop_schedule(), the event +/// is forwarded to `Loop.events`, instead of being processed immediately. +/// +/// @see loop_schedule +void loop_schedule_deferred(Loop *loop, Event event) +{ + Event *eventp = xmalloc(sizeof(*eventp)); + *eventp = event; + loop_schedule(loop, event_create(loop_deferred_event, 2, loop, eventp)); +} +static void loop_deferred_event(void **argv) +{ + Loop *loop = argv[0]; + Event *eventp = argv[1]; + multiqueue_put_event(loop->events, *eventp); + xfree(eventp); +} + void loop_on_put(MultiQueue *queue, void *data) { Loop *loop = data; -- cgit From cdd9e868efdad1f1eb9febfabb5f8671e75b95b9 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 2 Sep 2017 19:51:49 +0200 Subject: doc: channel, eventloop --- src/nvim/api/ui.c | 1 + src/nvim/api/vim.c | 28 ++++++++-------------------- src/nvim/event/loop.c | 1 + src/nvim/msgpack_rpc/channel.c | 10 ++++------ 4 files changed, 14 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 573be23d8e..bbbd5ab2dc 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -215,6 +215,7 @@ static void ui_set_option(UI *ui, String name, Object value, Error *error) #undef UI_EXT_OPTION } +/// Pushes data into UI.UIData, to be consumed later by remote_ui_flush(). static void push_call(UI *ui, char *name, Array args) { Array call = ARRAY_DICT_INIT; diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index cfbe34b848..ab893a4c0f 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -255,12 +255,11 @@ free_vim_args: return rv; } -/// Execute lua code. Parameters might be passed, they are available inside -/// the chunk as `...`. The chunk can return a value. +/// Execute lua code. Parameters (if any) are available as `...` inside the +/// chunk. The chunk can return a value. /// -/// To evaluate an expression, it must be prefixed with "return ". For -/// instance, to call a lua function with arguments sent in and get its -/// return value back, use the code "return my_function(...)". +/// Only statements are executed. To evaluate an expression, prefix it +/// with `return`: return my_function(...) /// /// @param code lua code to execute /// @param args Arguments to the code @@ -423,29 +422,18 @@ void nvim_del_var(String name, Error *err) dict_set_var(&globvardict, name, NIL, true, false, err); } -/// Sets a global variable -/// /// @deprecated -/// -/// @param name Variable name -/// @param value Variable value -/// @param[out] err Error details, if any +/// @see nvim_set_var /// @return Old value or nil if there was no previous value. -/// -/// @warning It may return nil if there was no previous value -/// or if previous value was `v:null`. +/// @warning May return nil if there was no previous value +/// OR if previous value was `v:null`. Object vim_set_var(String name, Object value, Error *err) { return dict_set_var(&globvardict, name, value, false, true, err); } -/// Removes a global variable -/// /// @deprecated -/// -/// @param name Variable name -/// @param[out] err Error details, if any -/// @return Old value +/// @see nvim_del_var Object vim_del_var(String name, Error *err) { return dict_set_var(&globvardict, name, NIL, true, true, err); diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c index 570db6dfc3..5adf16c0f3 100644 --- a/src/nvim/event/loop.c +++ b/src/nvim/event/loop.c @@ -66,6 +66,7 @@ void loop_poll_events(Loop *loop, int ms) /// means `fast_events` is NOT processed in an "editor mode" /// (VimState.execute), so redraw and other side-effects are likely to be /// skipped. +/// @see loop_schedule_deferred void loop_schedule(Loop *loop, Event event) { uv_mutex_lock(&loop->mutex); diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 02f3854f47..88232a55de 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -188,12 +188,11 @@ uint64_t channel_connect(bool tcp, const char *address, int timeout, return channel->id; } -/// Sends event/arguments to channel +/// Publishes an event to a channel. /// -/// @param id The channel id. If 0, the event will be sent to all -/// channels that have subscribed to the event type -/// @param name The event name, an arbitrary string -/// @param args Array with event arguments +/// @param id Channel id. 0 means "broadcast to all subscribed channels" +/// @param name Event name (application-defined) +/// @param args Array of event arguments /// @return True if the event was sent successfully, false otherwise. bool channel_send_event(uint64_t id, const char *name, Array args) { @@ -215,7 +214,6 @@ bool channel_send_event(uint64_t id, const char *name, Array args) send_event(channel, name, args); } } else { - // TODO(tarruda): Implement event broadcasting in vimscript broadcast_event(name, args); } -- cgit From 82795c2c3a429b2725af882cad4317bed8f1b741 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Wed, 6 Sep 2017 01:04:57 +0800 Subject: vim-patch: 8.0.0{181,182,188} (#7152) vim-patch:8.0.0181 Problem: When 'cursorbind' and 'cursorcolumn' are both on, the column highlignt in non-current windows is wrong. Solution: Add validate_cursor(). (Masanori Misono, closes vim/vim#1372) https://github.com/vim/vim/commit/519d7785f4437762c07b2e04217f83a069a8c663 vim-patch:8.0.0182 Problem: When 'cursorbind' and 'cursorline' are set, but 'cursorcolumn' is not, then the cursor line highlighting is not updated. (Hirohito Higashi) Solution: Call redraw_later() with NOT_VALID. https://github.com/vim/vim/commit/e47683a0913f102b6ae08c8848d5aa675d99b188 vim-patch:8.0.0188 Problem: Using NOT_VALID for redraw_later() to update the cursor line/column highlighting is not efficient. Solution: Call validate_cursor() when 'cul' or 'cuc' is set. https://github.com/vim/vim/commit/9506cad7a1a6e52a613f356de969cbd980815777 --- src/nvim/move.c | 13 +++++++++---- src/nvim/version.c | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/move.c b/src/nvim/move.c index 4d646f5a4b..9693132846 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -2164,16 +2164,21 @@ void do_check_cursorbind(void) int restart_edit_save = restart_edit; restart_edit = true; check_cursor(); + if (curwin->w_p_cul || curwin->w_p_cuc) { + validate_cursor(); + } restart_edit = restart_edit_save; } - /* Correct cursor for multi-byte character. */ - if (has_mbyte) + // Correct cursor for multi-byte character. + if (has_mbyte) { mb_adjust_cursor(); + } redraw_later(VALID); - /* Only scroll when 'scrollbind' hasn't done this. */ - if (!curwin->w_p_scb) + // Only scroll when 'scrollbind' hasn't done this. + if (!curwin->w_p_scb) { update_topline(); + } curwin->w_redr_status = true; } } diff --git a/src/nvim/version.c b/src/nvim/version.c index 6e24e30a09..ce1cc03c1f 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -764,14 +764,14 @@ static const int included_patches[] = { // 191 NA 190, // 189, - // 188, + 188, // 187 NA // 186, // 185, // 184, // 183, - // 182, - // 181, + 182, + 181, // 180, 179, 178, -- cgit From 06f8ad5b2af59f61f053387d1347f6b1eada850e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 9 Sep 2017 13:57:27 +0200 Subject: terminal.c: need maketitle() in terminal-mode normal_redraw() usually takes care of this, but that doesn't happen during terminal-mode. regression by c484323dc67f steps to reproduce: nvim -u NORC --cmd 'execute("set titlestring=" . $NVIM_LISTEN_ADDRESS) | set title | startinsert | !sleep 1' term://sh closes #7248 --- src/nvim/screen.c | 2 +- src/nvim/terminal.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 95973354bc..921ef06c7b 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -5847,7 +5847,7 @@ static void screen_start_highlight(int attr) ui_start_highlight(attr); } -void screen_stop_highlight(void) +static void screen_stop_highlight(void) { ui_stop_highlight(); screen_attr = 0; diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index d4517af3ff..4a9acf2559 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -1259,6 +1259,10 @@ static void redraw(bool restore_cursor) update_screen(0); } + if (need_maketitle) { // Update title in terminal-mode. #7248 + maketitle(); + } + if (restore_cursor) { ui_cursor_goto(save_row, save_col); } else if (term) { -- cgit From 26d08dfd0d9d2f8e3685a4fe083588519bd5dac0 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Mon, 28 Aug 2017 21:33:31 +0200 Subject: inccommand: fix optimization logic #7224 Before this change the preview changes in the buffer viewport were limited to the size of the preview window ('cmdwinheight'). closes #7220 --- src/nvim/ex_cmds.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 32dbf4cc69..4b3e02e5fd 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3332,10 +3332,12 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) sub = regtilde(sub, p_magic); // Check for a match on each line. + // If preview: limit to max('cmdwinheight', viewport). linenr_T line2 = eap->line2; for (linenr_T lnum = eap->line1; - lnum <= line2 && !(got_quit || aborting()) - && (!preview || matched_lines.size <= (size_t)p_cwh); + lnum <= line2 && !got_quit && !aborting() + && (!preview || matched_lines.size < (size_t)p_cwh + || lnum <= curwin->w_botline); lnum++) { long nmatch = vim_regexec_multi(®match, curwin, curbuf, lnum, (colnr_T)0, NULL); -- cgit From 713a957e9c90fc1c57935e33346347807595f946 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 10 Sep 2017 18:21:52 +0800 Subject: vim-patch:8.0.0282 vim-patch:8.0.0291 (#7255) vim-patch:8.0.0291 Problem: Visual block insertion does not insert in all lines. Solution: Don't bail out of insert too early. Add a test. (Christian Brabandt, closes vim/vim#1290) https://github.com/vim/vim/commit/23fa81d2223cd9bb7c51829c48047b2976bc2d11 vim-patch:8.0.0282 Problem: When doing a Visual selection and using "I" to go to insert mode, CTRL-O needs to be used twice to go to Normal mode. (Coacher) Solution: Check for the return value of edit(). (Christian Brabandt, closes #1290) https://github.com/vim/vim/commit/0b5c93a7f266cd8c90ea27bdaf9f7214a95d64d7 --- src/nvim/normal.c | 5 ++++- src/nvim/ops.c | 2 +- src/nvim/testdir/test_visual.vim | 13 +++++++++++++ src/nvim/version.c | 4 ++-- 4 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 6415bec846..c40ed58550 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1942,8 +1942,11 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) * the lines. */ auto_format(false, true); - if (restart_edit == 0) + if (restart_edit == 0) { restart_edit = restart_edit_save; + } else { + cap->retval |= CA_COMMAND_BUSY; + } } break; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index c01840cfd0..99dc4670f1 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2060,7 +2060,7 @@ void op_insert(oparg_T *oap, long count1) } t1 = oap->start; - edit(NUL, false, (linenr_T)count1); + (void)edit(NUL, false, (linenr_T)count1); // When a tab was inserted, and the characters in front of the tab // have been converted to a tab as well, the column of the cursor diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index cf0e535937..74c26e3d66 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -15,3 +15,16 @@ func Test_block_shift_multibyte() call assert_equal(' ヹxxx', getline(2)) q! endfunc + +func Test_Visual_ctrl_o() + new + call setline(1, ['one', 'two', 'three']) + call cursor(1,2) + set noshowmode + set tw=0 + call feedkeys("\jjlIa\\:set tw=88\\", 'tx') + call assert_equal(['oane', 'tawo', 'tahree'], getline(1, 3)) + call assert_equal(88, &tw) + set tw& + bw! +endfu diff --git a/src/nvim/version.c b/src/nvim/version.c index ce1cc03c1f..e7061fff9d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -661,7 +661,7 @@ static const int included_patches[] = { // 294, // 293, // 292, - // 291, + 291, 290, // 289, // 288 NA @@ -670,7 +670,7 @@ static const int included_patches[] = { // 285 NA // 284 NA // 283, - // 282, + 282, // 281 NA 280, // 279 NA -- cgit From ceade2fe53175555c44fdc4b65530f18aeb17591 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 10 Sep 2017 18:52:43 +0800 Subject: vim-patch:8.0.0186 (#7154) Problem: The error message from assert_notequal() is confusing. Solution: Only mention the expected value. https://github.com/vim/vim/commit/5869cf060e60cc09e71b2b3bd85f0576ec78f9f5 --- src/nvim/eval.c | 24 +++++++++++++----------- src/nvim/version.c | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d6ee13857a..5ee91d417a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6747,6 +6747,8 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, } else { if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH) { ga_concat(gap, (char_u *)"Pattern "); + } else if (atype == ASSERT_NOTEQUAL) { + ga_concat(gap, (char_u *)"Expected not equal to "); } else { ga_concat(gap, (char_u *)"Expected "); } @@ -6757,18 +6759,18 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, } else { ga_concat(gap, exp_str); } - tofree = (char_u *)encode_tv2string(got_tv, NULL); - if (atype == ASSERT_MATCH) { - ga_concat(gap, (char_u *)" does not match "); - } else if (atype == ASSERT_NOTMATCH) { - ga_concat(gap, (char_u *)" does match "); - } else if (atype == ASSERT_NOTEQUAL) { - ga_concat(gap, (char_u *)" differs from "); - } else { - ga_concat(gap, (char_u *)" but got "); + if (atype != ASSERT_NOTEQUAL) { + if (atype == ASSERT_MATCH) { + ga_concat(gap, (char_u *)" does not match "); + } else if (atype == ASSERT_NOTMATCH) { + ga_concat(gap, (char_u *)" does match "); + } else { + ga_concat(gap, (char_u *)" but got "); + } + tofree = (char_u *)encode_tv2string(got_tv, NULL); + ga_concat(gap, tofree); + xfree(tofree); } - ga_concat(gap, tofree); - xfree(tofree); } } diff --git a/src/nvim/version.c b/src/nvim/version.c index e7061fff9d..4c0071f248 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -766,7 +766,7 @@ static const int included_patches[] = { // 189, 188, // 187 NA - // 186, + 186, // 185, // 184, // 183, -- cgit From d2cbc311855114b7736919a344a82e303d4a8164 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 11 Sep 2017 22:17:41 +0800 Subject: Vim-patch 8.0.0300 (#7258) vim-patch:8.0.0300 Problem: Cannot stop diffing hidden buffers. (Daniel Hahler) Solution: When using :diffoff! make the whole list if diffed buffers empty. (closes vim/vim#736) https://github.com/vim/vim/commit/25ea0544587dd45088512fec9d7a685e35fea679 --- src/nvim/diff.c | 19 +++++++++++++++++++ src/nvim/testdir/test_diffmode.vim | 37 +++++++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 57 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 17de4284ce..cc0f3b2629 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -135,6 +135,20 @@ void diff_buf_add(buf_T *buf) EMSGN(_("E96: Cannot diff more than %" PRId64 " buffers"), DB_COUNT); } +/// +/// Remove all buffers to make diffs for. +/// +static void diff_buf_clear(void) +{ + for (int i = 0; i < DB_COUNT; i++) { + if (curtab->tp_diffbuf[i] != NULL) { + curtab->tp_diffbuf[i] = NULL; + curtab->tp_diff_invalid = true; + diff_redraw(true); + } + } +} + /// Find buffer "buf" in the list of diff buffers for the current tab page. /// /// @param buf The buffer to find. @@ -1175,6 +1189,11 @@ void ex_diffoff(exarg_T *eap) diffwin |= wp->w_p_diff; } + // Also remove hidden buffers from the list. + if (eap->forceit) { + diff_buf_clear(); + } + // Remove "hor" from from 'scrollopt' if there are no diff windows left. if (!diffwin && (vim_strchr(p_sbo, 'h') != NULL)) { do_cmdline_cmd("set sbo-=hor"); diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim index f40e06ff33..8ee82bd538 100644 --- a/src/nvim/testdir/test_diffmode.vim +++ b/src/nvim/testdir/test_diffmode.vim @@ -212,6 +212,7 @@ func Test_diffoff() call setline(1, ['One', '', 'Two', 'Three']) diffthis redraw + call assert_notequal(normattr, screenattr(1, 1)) diffoff! redraw call assert_equal(normattr, screenattr(1, 1)) @@ -219,6 +220,42 @@ func Test_diffoff() bwipe! endfunc +func Test_diffoff_hidden() + set diffopt=filler,foldcolumn:0 + e! one + call setline(1, ['Two', 'Three']) + let normattr = screenattr(1, 1) + diffthis + botright vert new two + call setline(1, ['One', 'Four']) + diffthis + redraw + call assert_notequal(normattr, screenattr(1, 1)) + set hidden + close + redraw + " diffing with hidden buffer two + call assert_notequal(normattr, screenattr(1, 1)) + diffoff + redraw + call assert_equal(normattr, screenattr(1, 1)) + diffthis + redraw + " still diffing with hidden buffer two + call assert_notequal(normattr, screenattr(1, 1)) + diffoff! + redraw + call assert_equal(normattr, screenattr(1, 1)) + diffthis + redraw + " no longer diffing with hidden buffer two + call assert_equal(normattr, screenattr(1, 1)) + + bwipe! + bwipe! + set hidden& diffopt& +endfunc + func Test_setting_cursor() new Xtest1 put =range(1,90) diff --git a/src/nvim/version.c b/src/nvim/version.c index 4c0071f248..6f38776a60 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -652,7 +652,7 @@ static const int included_patches[] = { // 303, // 302, // 301, - // 300, + 300, // 299, // 298, 297, -- cgit From 6d0f87a0bd9c683f21c20e29145f375ca77c2792 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sat, 9 Sep 2017 11:38:19 +0200 Subject: 'inccommand': fix 'gdefault' lockup #7261 closes #7244 ref #7249 --- src/nvim/ex_cmds.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 4b3e02e5fd..99bf07c3fb 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3665,9 +3665,38 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) * use "\=col("."). */ curwin->w_cursor.col = regmatch.startpos[0].col; + // When the match included the "$" of the last line it may + // go beyond the last line of the buffer. + if (nmatch > curbuf->b_ml.ml_line_count - sub_firstlnum + 1) { + nmatch = curbuf->b_ml.ml_line_count - sub_firstlnum + 1; + skip_match = true; + } + // 3. Substitute the string. During 'inccommand' preview only do this if // there is a replace pattern. - if (!preview || has_second_delim) { + if (preview && !has_second_delim) { + // For a multi-line match, make a copy of the last matched + // line and continue in that one. + if (nmatch > 1) { + sub_firstlnum += nmatch - 1; + xfree(sub_firstline); + sub_firstline = vim_strsave(ml_get(sub_firstlnum)); + // When going beyond the last line, stop substituting. + if (sub_firstlnum <= line2) { + do_again = true; + } else { + subflags.do_all = false; + } + } + + if (skip_match) { + // Already hit end of the buffer, sub_firstlnum is one + // less than what it ought to be. + xfree(sub_firstline); + sub_firstline = vim_strsave((char_u *)""); + copycol = 0; + } + } else if (!preview || has_second_delim) { if (subflags.do_count) { // prevent accidentally changing the buffer by a function save_ma = curbuf->b_p_ma; @@ -3691,13 +3720,6 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) goto skip; } - // When the match included the "$" of the last line it may - // go beyond the last line of the buffer. - if (nmatch > curbuf->b_ml.ml_line_count - sub_firstlnum + 1) { - nmatch = curbuf->b_ml.ml_line_count - sub_firstlnum + 1; - skip_match = true; - } - // Need room for: // - result so far in new_start (not for first sub in line) // - original text up to match -- cgit From 2736f0cb5631dec43064c77f504a7bc160aaeeb1 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 12 Sep 2017 23:45:31 +0200 Subject: ex_cmds.c:do_sub(): macroize duplicate code --- src/nvim/ex_cmds.c | 76 +++++++++++++++++++++++------------------------------- 1 file changed, 32 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 99bf07c3fb..918e7a0c91 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3672,31 +3672,38 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) skip_match = true; } - // 3. Substitute the string. During 'inccommand' preview only do this if - // there is a replace pattern. +#define ADJUST_SUB_FIRSTLNUM() \ + do { \ + /* For a multi-line match, make a copy of the last matched */ \ + /* line and continue in that one. */ \ + if (nmatch > 1) { \ + sub_firstlnum += nmatch - 1; \ + xfree(sub_firstline); \ + sub_firstline = vim_strsave(ml_get(sub_firstlnum)); \ + /* When going beyond the last line, stop substituting. */ \ + if (sub_firstlnum <= line2) { \ + do_again = true; \ + } else { \ + subflags.do_all = false; \ + } \ + } \ + if (skip_match) { \ + /* Already hit end of the buffer, sub_firstlnum is one */ \ + /* less than what it ought to be. */ \ + xfree(sub_firstline); \ + sub_firstline = vim_strsave((char_u *)""); \ + copycol = 0; \ + } \ + } while (0) + if (preview && !has_second_delim) { - // For a multi-line match, make a copy of the last matched - // line and continue in that one. - if (nmatch > 1) { - sub_firstlnum += nmatch - 1; - xfree(sub_firstline); - sub_firstline = vim_strsave(ml_get(sub_firstlnum)); - // When going beyond the last line, stop substituting. - if (sub_firstlnum <= line2) { - do_again = true; - } else { - subflags.do_all = false; - } - } + ADJUST_SUB_FIRSTLNUM(); + goto skip; + } - if (skip_match) { - // Already hit end of the buffer, sub_firstlnum is one - // less than what it ought to be. - xfree(sub_firstline); - sub_firstline = vim_strsave((char_u *)""); - copycol = 0; - } - } else if (!preview || has_second_delim) { + // 3. Substitute the string. During 'inccommand' preview only do this if + // there is a replace pattern. + if (!preview || has_second_delim) { if (subflags.do_count) { // prevent accidentally changing the buffer by a function save_ma = curbuf->b_p_ma; @@ -3750,30 +3757,10 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) // is beyond the end of the line after the substitution. curwin->w_cursor.col = 0; - // For a multi-line match, make a copy of the last matched - // line and continue in that one. - if (nmatch > 1) { - sub_firstlnum += nmatch - 1; - xfree(sub_firstline); - sub_firstline = vim_strsave(ml_get(sub_firstlnum)); - // When going beyond the last line, stop substituting. - if (sub_firstlnum <= line2) { - do_again = true; - } else { - subflags.do_all = false; - } - } - // Remember next character to be copied. copycol = regmatch.endpos[0].col; - if (skip_match) { - // Already hit end of the buffer, sub_firstlnum is one - // less than what it ought to be. - xfree(sub_firstline); - sub_firstline = vim_strsave((char_u *)""); - copycol = 0; - } + ADJUST_SUB_FIRSTLNUM(); // Now the trick is to replace CTRL-M chars with a real line // break. This would make it impossible to insert a CTRL-M in @@ -4030,6 +4017,7 @@ skip: kv_destroy(matched_lines); return preview_buf; +#undef ADJUST_SUB_FIRSTLNUM } // NOLINT(readability/fn_size) /* -- cgit From 47019bb167e2b2d28c8648d39781c66e3ec02c00 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 16 Sep 2017 11:20:26 +0200 Subject: getchar.c: add TERM_FOCUS to MAP_HASH (#7271) vim-patch:8.0.1108 https://github.com/vim/vim/commit/69fbc9e1dab176f345719436cd89d854df0a2abd --- src/nvim/getchar.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index a22b716bb6..f5949333bd 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -92,17 +92,15 @@ static int typeahead_char = 0; /* typeahead char that's not flushed */ */ static int block_redo = FALSE; -/* - * Make a hash value for a mapping. - * "mode" is the lower 4 bits of the State for the mapping. - * "c1" is the first character of the "lhs". - * Returns a value between 0 and 255, index in maphash. - * Put Normal/Visual mode mappings mostly separately from Insert/Cmdline mode. - */ +// Make a hash value for a mapping. +// "mode" is the lower 4 bits of the State for the mapping. +// "c1" is the first character of the "lhs". +// Returns a value between 0 and 255, index in maphash. +// Put Normal/Visual mode mappings mostly separately from Insert/Cmdline mode. #define MAP_HASH(mode, \ c1) (((mode) & \ (NORMAL + VISUAL + SELECTMODE + \ - OP_PENDING)) ? (c1) : ((c1) ^ 0x80)) + OP_PENDING + TERM_FOCUS)) ? (c1) : ((c1) ^ 0x80)) // Each mapping is put in one of the MAX_MAPHASH hash lists, // to speed up finding it. -- cgit From b9cba41106e380556ddf731d8fbfcc9c84f8e225 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 16 Sep 2017 23:13:35 -0400 Subject: tui: Use unibi_var_from_num when available As of unibilium 1.2.1, directly manipulating unibi_var_t is deprecated. ../src/nvim/tui/tui.c: In function 'update_attrs': ../src/nvim/tui/tui.c:321:7: warning: 'i' is deprecated: use unibi_var_from_num or unibi_num_from_var instead [-Wdeprecated-declarations] data->params[0].i = (fg >> 16) & 0xff; // red ^~~~ In file included from ../src/nvim/tui/tui.c:12:0: /usr/include/unibilium.h:632:9: note: declared here int i UNIBI_DEPRECATED("use unibi_var_from_num or unibi_num_from_var instead"); ^ All use should go through unibi_{num,str}_from_var and unibi_var_from_{num,str}. Wrap access of unibi_var_t behind a new UNIBI_SET_NUM_VAR macro which uses the new functions when they're available. --- src/nvim/tui/tui.c | 94 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 1cbd02dfd9..256772489d 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -52,6 +52,15 @@ #define LINUXSET0C "\x1b[?0c" #define LINUXSET1C "\x1b[?1c" +#ifdef NVIM_UNIBI_HAS_VAR_FROM +#define UNIBI_SET_NUM_VAR(var, num) \ + do { \ + (var) = unibi_var_from_num((num)); \ + } while (0) +#else +#define UNIBI_SET_NUM_VAR(var, num) (var).i = (num); +#endif + // Per the commentary in terminfo, only a minus sign is a true suffix // separator. bool terminfo_is_term_family(const char *term, const char *family) @@ -391,15 +400,15 @@ static void update_attrs(UI *ui, HlAttrs attrs) if (unibi_get_str(data->ut, unibi_set_attributes)) { if (attrs.bold || attrs.reverse || attrs.underline || attrs.undercurl) { - data->params[0].i = 0; // standout - data->params[1].i = attrs.underline || attrs.undercurl; - data->params[2].i = attrs.reverse; - data->params[3].i = 0; // blink - data->params[4].i = 0; // dim - data->params[5].i = attrs.bold; - data->params[6].i = 0; // blank - data->params[7].i = 0; // protect - data->params[8].i = 0; // alternate character set + UNIBI_SET_NUM_VAR(data->params[0], 0); // standout + UNIBI_SET_NUM_VAR(data->params[1], attrs.underline || attrs.undercurl); + UNIBI_SET_NUM_VAR(data->params[2], attrs.reverse); + UNIBI_SET_NUM_VAR(data->params[3], 0); // blink + UNIBI_SET_NUM_VAR(data->params[4], 0); // dim + UNIBI_SET_NUM_VAR(data->params[5], attrs.bold); + UNIBI_SET_NUM_VAR(data->params[6], 0); // blank + UNIBI_SET_NUM_VAR(data->params[7], 0); // protect + UNIBI_SET_NUM_VAR(data->params[8], 0); // alternate character set unibi_out(ui, unibi_set_attributes); } else if (!data->default_attr) { unibi_out(ui, unibi_exit_attribute_mode); @@ -423,26 +432,26 @@ static void update_attrs(UI *ui, HlAttrs attrs) } if (ui->rgb) { if (fg != -1) { - data->params[0].i = (fg >> 16) & 0xff; // red - data->params[1].i = (fg >> 8) & 0xff; // green - data->params[2].i = fg & 0xff; // blue + UNIBI_SET_NUM_VAR(data->params[0], (fg >> 16) & 0xff); // red + UNIBI_SET_NUM_VAR(data->params[1], (fg >> 8) & 0xff); // green + UNIBI_SET_NUM_VAR(data->params[2], fg & 0xff); // blue unibi_out_ext(ui, data->unibi_ext.set_rgb_foreground); } if (bg != -1) { - data->params[0].i = (bg >> 16) & 0xff; // red - data->params[1].i = (bg >> 8) & 0xff; // green - data->params[2].i = bg & 0xff; // blue + UNIBI_SET_NUM_VAR(data->params[0], (bg >> 16) & 0xff); // red + UNIBI_SET_NUM_VAR(data->params[1], (bg >> 8) & 0xff); // green + UNIBI_SET_NUM_VAR(data->params[2], bg & 0xff); // blue unibi_out_ext(ui, data->unibi_ext.set_rgb_background); } } else { if (fg != -1) { - data->params[0].i = fg; + UNIBI_SET_NUM_VAR(data->params[0], fg); unibi_out(ui, unibi_set_a_foreground); } if (bg != -1) { - data->params[0].i = bg; + UNIBI_SET_NUM_VAR(data->params[0], bg); unibi_out(ui, unibi_set_a_background); } } @@ -558,7 +567,7 @@ static void cursor_goto(UI *ui, int row, int col) unibi_out(ui, unibi_cursor_left); } } else { - data->params[0].i = n; + UNIBI_SET_NUM_VAR(data->params[0], n); unibi_out(ui, unibi_parm_left_cursor); } ugrid_goto(grid, row, col); @@ -570,7 +579,7 @@ static void cursor_goto(UI *ui, int row, int col) unibi_out(ui, unibi_cursor_right); } } else { - data->params[0].i = n; + UNIBI_SET_NUM_VAR(data->params[0], n); unibi_out(ui, unibi_parm_right_cursor); } ugrid_goto(grid, row, col); @@ -585,7 +594,7 @@ static void cursor_goto(UI *ui, int row, int col) unibi_out(ui, unibi_cursor_down); } } else { - data->params[0].i = n; + UNIBI_SET_NUM_VAR(data->params[0], n); unibi_out(ui, unibi_parm_down_cursor); } ugrid_goto(grid, row, col); @@ -597,7 +606,7 @@ static void cursor_goto(UI *ui, int row, int col) unibi_out(ui, unibi_cursor_up); } } else { - data->params[0].i = n; + UNIBI_SET_NUM_VAR(data->params[0], n); unibi_out(ui, unibi_parm_up_cursor); } ugrid_goto(grid, row, col); @@ -675,19 +684,19 @@ static void set_scroll_region(UI *ui) TUIData *data = ui->data; UGrid *grid = &data->grid; - data->params[0].i = grid->top; - data->params[1].i = grid->bot; + UNIBI_SET_NUM_VAR(data->params[0], grid->top); + UNIBI_SET_NUM_VAR(data->params[1], grid->bot); unibi_out(ui, unibi_change_scroll_region); if (grid->left != 0 || grid->right != ui->width - 1) { unibi_out_ext(ui, data->unibi_ext.enable_lr_margin); if (data->can_set_lr_margin) { - data->params[0].i = grid->left; - data->params[1].i = grid->right; + UNIBI_SET_NUM_VAR(data->params[0], grid->left); + UNIBI_SET_NUM_VAR(data->params[1], grid->right); unibi_out(ui, unibi_set_lr_margin); } else { - data->params[0].i = grid->left; + UNIBI_SET_NUM_VAR(data->params[0], grid->left); unibi_out(ui, unibi_set_left_margin_parm); - data->params[0].i = grid->right; + UNIBI_SET_NUM_VAR(data->params[0], grid->right); unibi_out(ui, unibi_set_right_margin_parm); } } @@ -702,19 +711,19 @@ static void reset_scroll_region(UI *ui) if (0 <= data->unibi_ext.reset_scroll_region) { unibi_out_ext(ui, data->unibi_ext.reset_scroll_region); } else { - data->params[0].i = 0; - data->params[1].i = ui->height - 1; + UNIBI_SET_NUM_VAR(data->params[0], 0); + UNIBI_SET_NUM_VAR(data->params[1], ui->height - 1); unibi_out(ui, unibi_change_scroll_region); } if (grid->left != 0 || grid->right != ui->width - 1) { if (data->can_set_lr_margin) { - data->params[0].i = 0; - data->params[1].i = ui->width - 1; + UNIBI_SET_NUM_VAR(data->params[0], 0); + UNIBI_SET_NUM_VAR(data->params[1], ui->width - 1); unibi_out(ui, unibi_set_lr_margin); } else { - data->params[0].i = 0; + UNIBI_SET_NUM_VAR(data->params[0], 0); unibi_out(ui, unibi_set_left_margin_parm); - data->params[0].i = ui->width - 1; + UNIBI_SET_NUM_VAR(data->params[0], ui->width - 1); unibi_out(ui, unibi_set_right_margin_parm); } unibi_out_ext(ui, data->unibi_ext.disable_lr_margin); @@ -728,8 +737,8 @@ static void tui_resize(UI *ui, Integer width, Integer height) ugrid_resize(&data->grid, (int)width, (int)height); if (!got_winch) { // Try to resize the terminal window. - data->params[0].i = (int)height; - data->params[1].i = (int)width; + UNIBI_SET_NUM_VAR(data->params[0], (int)height); + UNIBI_SET_NUM_VAR(data->params[1], (int)width); unibi_out_ext(ui, data->unibi_ext.resize_screen); // DECSLPP does not reset the scroll region. if (data->scroll_region_is_full_screen) { @@ -863,7 +872,7 @@ static void tui_set_mode(UI *ui, ModeShape mode) int attr = syn_id2attr(c.id); if (attr > 0) { attrentry_T *aep = syn_cterm_attr2entry(attr); - data->params[0].i = aep->rgb_bg_color; + UNIBI_SET_NUM_VAR(data->params[0], aep->rgb_bg_color); unibi_out_ext(ui, data->unibi_ext.set_cursor_color); } } @@ -874,7 +883,7 @@ static void tui_set_mode(UI *ui, ModeShape mode) case SHAPE_VER: shape = 5; break; default: WLOG("Unknown shape value %d", shape); break; } - data->params[0].i = shape + (int)(c.blinkon == 0); + UNIBI_SET_NUM_VAR(data->params[0], shape + (int)(c.blinkon == 0)); unibi_out_ext(ui, data->unibi_ext.set_cursor_style); } @@ -927,14 +936,14 @@ static void tui_scroll(UI *ui, Integer count) if (count == 1) { unibi_out(ui, unibi_delete_line); } else { - data->params[0].i = (int)count; + UNIBI_SET_NUM_VAR(data->params[0], (int)count); unibi_out(ui, unibi_parm_delete_line); } } else { if (count == -1) { unibi_out(ui, unibi_insert_line); } else { - data->params[0].i = -(int)count; + UNIBI_SET_NUM_VAR(data->params[0], -(int)count); unibi_out(ui, unibi_parm_insert_line); } } @@ -1177,8 +1186,8 @@ end: static void unibi_goto(UI *ui, int row, int col) { TUIData *data = ui->data; - data->params[0].i = row; - data->params[1].i = col; + UNIBI_SET_NUM_VAR(data->params[0], row); + UNIBI_SET_NUM_VAR(data->params[1], col); unibi_out(ui, unibi_cursor_address); } @@ -1190,7 +1199,8 @@ static void unibi_goto(UI *ui, int row, int col) str = fn(data->ut, (unsigned)unibi_index); \ } \ if (str) { \ - unibi_var_t vars[26 + 26] = { { 0 } }; \ + unibi_var_t vars[26 + 26]; \ + memset(&vars, 0, sizeof(vars)); \ unibi_format(vars, vars + 26, str, data->params, out, ui, NULL, NULL); \ } \ } while (0) -- cgit From e53af2b1f50c4662698f4a7c42a6008955a73426 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 18 Sep 2017 01:43:45 +0800 Subject: vim-patch:8.0.0305 (#7265) Problem: Invalid memory access when option has duplicate flag. Solution: Correct pointer computation. (Dominique Pelle, closes vim/vim#1442) https://github.com/vim/vim/commit/aaaf57d8a936efe420190c077e4a74041cc6c72e --- src/nvim/option.c | 7 ++++--- src/nvim/testdir/test_options.vim | 6 ++++++ src/nvim/version.c | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 8ba10fd38a..74250e83e6 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1749,7 +1749,7 @@ do_set ( if (flags & P_FLAGLIST) { // Remove flags that appear twice. - for (s = newval; *s; s++) { + for (s = newval; *s;) { // if options have P_FLAGLIST and P_ONECOMMA such as // 'whichwrap' if (flags & P_ONECOMMA) { @@ -1757,15 +1757,16 @@ do_set ( && vim_strchr(s + 2, *s) != NULL) { // Remove the duplicated value and the next comma. STRMOVE(s, s + 2); - s -= 2; + continue; } } else { if ((!(flags & P_COMMA) || *s != ',') && vim_strchr(s + 1, *s) != NULL) { STRMOVE(s, s + 1); - s--; + continue; } } + s++; } } diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index 5ee0919e18..2ffe63787b 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -13,6 +13,12 @@ function! Test_whichwrap() set whichwrap+=h,l call assert_equal('b,s,h,l', &whichwrap) + set whichwrap=h,h + call assert_equal('h', &whichwrap) + + set whichwrap=h,h,h + call assert_equal('h', &whichwrap) + set whichwrap& endfunction diff --git a/src/nvim/version.c b/src/nvim/version.c index 6f38776a60..f5df256d3d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -647,7 +647,7 @@ static const int included_patches[] = { 308, 307, // 306, - // 305, + 305, // 304, // 303, // 302, -- cgit From 009c695f0a6c6da322f89e0f621d59d596e712fa Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 18 Sep 2017 01:56:08 +0800 Subject: vim-patch:8.0.0302 NA (#7264) (NA: Nvim removed the ability to set termcodes directly.) Problem: Cannot set terminal key codes with :let. Solution: Make it work. https://github.com/vim/vim/commit/e353c402e63b9b0a0bc06acf390e352d9e7eeaeb --- src/nvim/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index f5df256d3d..e4142dea98 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -650,7 +650,7 @@ static const int included_patches[] = { 305, // 304, // 303, - // 302, + // 302, NA // 301, 300, // 299, -- cgit From cf59d617bc6d2aabb487c4d6be8082160a633a39 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 18 Sep 2017 02:04:17 +0800 Subject: vim-patch:8.0.0324 (#7279) Problem: Illegal memory access with "1;y". Solution: Call check_cursor() instead of check_cursor_lnum(). (Dominique Pelle, closes vim/vim#1455) https://github.com/vim/vim/commit/f1f6f3f7df2938b3583e341482d96c1d53124c51 --- src/nvim/ex_docmd.c | 4 ++-- src/nvim/testdir/test_cmdline.vim | 14 +++++++++++++- src/nvim/version.c | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index d1405978b3..bef5fd287e 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1668,8 +1668,8 @@ static char_u * do_one_cmd(char_u **cmdlinep, if (*ea.cmd == ';') { if (!ea.skip) { curwin->w_cursor.lnum = ea.line2; - // Don't leave the cursor on an illegal line (caused by ';') - check_cursor_lnum(); + // don't leave the cursor on an illegal line or column + check_cursor(); } } else if (*ea.cmd != ',') { break; diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 2facffb067..c0f04f4730 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -250,9 +250,21 @@ func Test_remove_char_in_cmdline() call assert_equal('"def', @:) endfunc -func Test_illegal_address() +func Test_illegal_address1() new 2;'( 2;') quit endfunc + +func Test_illegal_address2() + call writefile(['c', 'x', ' x', '.', '1;y'], 'Xtest.vim') + new + source Xtest.vim + " Trigger calling validate_cursor() + diffsp Xtest.vim + quit! + bwipe! + call delete('Xtest.vim') +endfunc + diff --git a/src/nvim/version.c b/src/nvim/version.c index e4142dea98..1f040b214b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -628,7 +628,7 @@ static const int included_patches[] = { // 327, 326, 325, - // 324, + 324, // 323, 322, // 321, -- cgit From 12efbf897de28f00523885ceb99fb7cf41ed82e6 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 18 Sep 2017 02:05:22 +0800 Subject: vim-patch:8.0.0327 (#7281) Problem: The E11 error message in the command line window is not translated. Solution: use _(). (Hirohito Higashi) https://github.com/vim/vim/commit/75c19464ed7fb6024af64747379e61abc4e4a483 --- src/nvim/ex_docmd.c | 2 +- src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index bef5fd287e..f9442a4cf6 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1813,7 +1813,7 @@ static char_u * do_one_cmd(char_u **cmdlinep, if (text_locked() && !(ea.argt & CMDWIN) && !IS_USER_CMDIDX(ea.cmdidx)) { // Command not allowed when editing the command line. - errormsg = get_text_locked_msg(); + errormsg = (char_u *)_(get_text_locked_msg()); goto doend; } /* Disallow editing another buffer when "curbuf_lock" is set. diff --git a/src/nvim/version.c b/src/nvim/version.c index 1f040b214b..675ebb17b0 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -625,7 +625,7 @@ static const int included_patches[] = { // 330, // 329, // 328, - // 327, + 327, 326, 325, 324, -- cgit From f8dcd319d9338cccc66ae481d5865e8816794306 Mon Sep 17 00:00:00 2001 From: Michael Schupikov Date: Sat, 23 Sep 2017 08:32:29 +0200 Subject: vim-patch:8.0.0294 (#7305) Problem: Argument list is not stored correctly in a session file. (lgpasquale) Solution: Use "$argadd" instead of "argadd". (closes vim/vim#1434) https://github.com/vim/vim/commit/79da563cf9220b9abb83455a68d995684133ea56 Signed-off-by: Michael Schupikov --- src/nvim/ex_docmd.c | 2 +- src/nvim/testdir/Makefile | 1 + src/nvim/testdir/test_mksession.vim | 15 +++++++++++++++ src/nvim/version.c | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 src/nvim/testdir/test_mksession.vim (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index f9442a4cf6..47e23b6e80 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9378,7 +9378,7 @@ ses_arglist ( (void)vim_FullName((char *)s, (char *)buf, MAXPATHL, FALSE); s = buf; } - if (fputs("argadd ", fd) < 0 || ses_put_fname(fd, s, flagp) == FAIL + if (fputs("$argadd ", fd) < 0 || ses_put_fname(fd, s, flagp) == FAIL || put_eol(fd) == FAIL) { xfree(buf); return FAIL; diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 96de7224c5..9133bfc0a2 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -58,6 +58,7 @@ NEW_TESTS ?= \ test_match.res \ test_matchadd_conceal.res \ test_matchadd_conceal_utf8.res \ + test_mksession.res \ test_nested_function.res \ test_normal.res \ test_quickfix.res \ diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim new file mode 100644 index 0000000000..2238213850 --- /dev/null +++ b/src/nvim/testdir/test_mksession.vim @@ -0,0 +1,15 @@ +" Tests for sessions + +" Verify that arglist is stored correctly to the session file. +func Test_mksession_arglist() + argdel * + next file1 file2 file3 file4 + mksession! Xtest_mks.out + source Xtest_mks.out + call assert_equal(['file1', 'file2', 'file3', 'file4'], argv()) + + call delete('Xtest_mks.out') + argdel * +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index 675ebb17b0..d4f9c0232f 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -658,7 +658,7 @@ static const int included_patches[] = { 297, // 296, // 295, - // 294, + 294, // 293, // 292, 291, -- cgit From 094bc39d017df34796bf92f50f5261d6ac33e83d Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 22 Sep 2017 10:07:35 -0400 Subject: Move definition of cstrchr above the functions which call it Functions with FUNC_ATTR_ALWAYS_INLINE need to be defined before they are called to work around bugs with some compiler versions. When the body is after the use of the function, compilation will fail with /home/niko/build/neovim/src/nvim/regexp.c: In function 'regmatch': /home/niko/build/neovim/build/src/nvim/auto/regexp.c.generated.h:77: sorry, unimplemented: inlining failed in call to 'cstrchr': function body not available /home/niko/build/neovim/src/nvim/regexp.c:4193: sorry, unimplemented: called from here --- src/nvim/regexp.c | 77 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index 847b2f273e..ae611a0005 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -3316,6 +3316,47 @@ bt_regexec_nl ( return (int)r; } +/// Wrapper around strchr which accounts for case-insensitive searches and +/// non-ASCII characters. +/// +/// This function is used a lot for simple searches, keep it fast! +/// +/// @param s string to search +/// @param c character to find in @a s +/// +/// @return NULL if no match, otherwise pointer to the position in @a s +static inline char_u *cstrchr(const char_u *const s, const int c) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL + FUNC_ATTR_ALWAYS_INLINE +{ + if (!rex.reg_ic) { + return vim_strchr(s, c); + } + + // Use folded case for UTF-8, slow! For ASCII use libc strpbrk which is + // expected to be highly optimized. + if (c > 0x80) { + const int folded_c = utf_fold(c); + for (const char_u *p = s; *p != NUL; p += utfc_ptr2len(p)) { + if (utf_fold(utf_ptr2char(p)) == folded_c) { + return (char_u *)p; + } + } + return NULL; + } + + int cc; + if (ASCII_ISUPPER(c)) { + cc = TOLOWER_ASC(c); + } else if (ASCII_ISLOWER(c)) { + cc = TOUPPER_ASC(c); + } else { + return vim_strchr(s, c); + } + + char tofind[] = { (char)c, (char)cc, NUL }; + return (char_u *)strpbrk((const char *)s, tofind); +} /// Matches a regexp against multiple lines. /// "rmp->regprog" is a compiled regexp as returned by vim_regcomp(). @@ -6320,42 +6361,6 @@ static int cstrncmp(char_u *s1, char_u *s2, int *n) return result; } -/* - * cstrchr: This function is used a lot for simple searches, keep it fast! - */ -static inline char_u *cstrchr(const char_u *const s, const int c) - FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL - FUNC_ATTR_ALWAYS_INLINE -{ - if (!rex.reg_ic) { - return vim_strchr(s, c); - } - - // Use folded case for UTF-8, slow! For ASCII use libc strpbrk which is - // expected to be highly optimized. - if (c > 0x80) { - const int folded_c = utf_fold(c); - for (const char_u *p = s; *p != NUL; p += utfc_ptr2len(p)) { - if (utf_fold(utf_ptr2char(p)) == folded_c) { - return (char_u *)p; - } - } - return NULL; - } - - int cc; - if (ASCII_ISUPPER(c)) { - cc = TOLOWER_ASC(c); - } else if (ASCII_ISLOWER(c)) { - cc = TOUPPER_ASC(c); - } else { - return vim_strchr(s, c); - } - - char tofind[] = { (char)c, (char)cc, NUL }; - return (char_u *)strpbrk((const char *)s, tofind); -} - /*************************************************************** * regsub stuff * ***************************************************************/ -- cgit From 3ab6a519fca63d1fcb5eeb98437697a7abaca7b0 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 24 Sep 2017 09:29:08 +0800 Subject: vim-patch:8.0.0328 Problem: The "zero count" error doesn't have a number. (Hirohito Higashi) Solution: Give it a number and be more specific about the error. https://github.com/vim/vim/commit/23a5558cfd860401aa694f0302d621887440f031 --- src/nvim/globals.h | 5 +++-- src/nvim/version.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 2ee72cdb6a..300e506854 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1146,8 +1146,9 @@ EXTERN char_u e_winheight[] INIT(= N_( EXTERN char_u e_winwidth[] INIT(= N_( "E592: 'winwidth' cannot be smaller than 'winminwidth'")); EXTERN char_u e_write[] INIT(= N_("E80: Error while writing")); -EXTERN char_u e_zerocount[] INIT(= N_("Zero count")); -EXTERN char_u e_usingsid[] INIT(= N_("E81: Using not in a script context")); +EXTERN char_u e_zerocount[] INIT(= N_("E939: Positive count required")); +EXTERN char_u e_usingsid[] INIT(= N_( + "E81: Using not in a script context")); EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s")); EXTERN char_u e_maxmempat[] INIT(= N_( "E363: pattern uses more memory than 'maxmempattern'")); diff --git a/src/nvim/version.c b/src/nvim/version.c index d4f9c0232f..09a62a3b0e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -624,7 +624,7 @@ static const int included_patches[] = { 331, // 330, // 329, - // 328, + 328, 327, 326, 325, -- cgit From 006425b8b683711cfb4f89074034ec1fe2085d40 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 24 Sep 2017 09:48:52 +0800 Subject: vim-patch:8.0.0330 Problem: Illegal memory access after "vapo". (Dominique Pelle) Solution: Fix the cursor column. https://github.com/vim/vim/commit/84b2a381451e9068b09ef6d85f5e8cf1598e7355 --- src/nvim/search.c | 12 ++++++++---- src/nvim/testdir/test_visual.vim | 7 +++++++ src/nvim/version.c | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/search.c b/src/nvim/search.c index 1bf2317d2a..387614fd09 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -3557,11 +3557,15 @@ extend: --start_lnum; if (VIsual_active) { - /* Problem: when doing "Vipipip" nothing happens in a single white - * line, we get stuck there. Trap this here. */ - if (VIsual_mode == 'V' && start_lnum == curwin->w_cursor.lnum) + // Problem: when doing "Vipipip" nothing happens in a single white + // line, we get stuck there. Trap this here. + if (VIsual_mode == 'V' && start_lnum == curwin->w_cursor.lnum) { goto extend; - VIsual.lnum = start_lnum; + } + if (VIsual.lnum != start_lnum) { + VIsual.lnum = start_lnum; + VIsual.col = 0; + } VIsual_mode = 'V'; redraw_curbuf_later(INVERTED); /* update the inversion */ showmode(); diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 74c26e3d66..8cb59ca32a 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -28,3 +28,10 @@ func Test_Visual_ctrl_o() set tw& bw! endfu + +func Test_Visual_vapo() + new + normal oxx + normal vapo + bwipe! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index d4f9c0232f..b642777d8a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -622,7 +622,7 @@ static const int included_patches[] = { // 333, // 332, 331, - // 330, + 330, // 329, // 328, 327, -- cgit From 2b53a565b991fc329ab7af683ec50e9cfcac557f Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 24 Sep 2017 10:05:53 +0800 Subject: vim-patch:8.0.0333 Problem: Illegal memory access when 'complete' ends in a backslash. Solution: Check for trailing backslash. (Dominique Pelle, closes vim/vim#1478) https://github.com/vim/vim/commit/226c53429109f24e31c17016aedfd7fbf7a9aa50 --- src/nvim/option.c | 7 ++++--- src/nvim/testdir/test_options.vim | 10 ++++++++++ src/nvim/version.c | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 74250e83e6..13aadb71bb 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2997,9 +2997,10 @@ did_set_string_option ( if (s[-1] == 'k' || s[-1] == 's') { /* skip optional filename after 'k' and 's' */ while (*s && *s != ',' && *s != ' ') { - if (*s == '\\') - ++s; - ++s; + if (*s == '\\' && s[1] != NUL) { + s++; + } + s++; } } else { if (errbuf != NULL) { diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index 2ffe63787b..8a9d793a2e 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -103,3 +103,13 @@ func Test_keymap_valid() call assert_fails(":set kmp=trunc\x00name", "E544:") call assert_fails(":set kmp=trunc\x00name", "trunc") endfunc + +func Test_complete() + " Trailing single backslash used to cause invalid memory access. + set complete=s\ + new + call feedkeys("i\\", 'xt') + bwipe! + set complete& +endfun + diff --git a/src/nvim/version.c b/src/nvim/version.c index d4f9c0232f..7470b07655 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -619,7 +619,7 @@ static const int included_patches[] = { // 336, // 335, // 334, - // 333, + 333, // 332, 331, // 330, -- cgit From 583b68f5a94f362c44ff29c62909969e6908438b Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 24 Sep 2017 11:06:16 +0800 Subject: vim-patch:8.0.0101 Problem: Some options are not strictly checked. Solution: Add flags for strickter checks. https://github.com/vim/vim/commit/031cb743ae154cfb727a9b7787bdcb61202ff1c8 --- src/nvim/option.c | 13 +++++++------ src/nvim/options.lua | 2 ++ src/nvim/version.c | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 74250e83e6..ae1a2b1b24 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3172,17 +3172,18 @@ did_set_string_option ( } else { // Options that are a list of flags. p = NULL; - if (varp == &p_ww) + if (varp == &p_ww) { // 'whichwrap' p = (char_u *)WW_ALL; - if (varp == &p_shm) + } + if (varp == &p_shm) { // 'shortmess' p = (char_u *)SHM_ALL; - else if (varp == &(p_cpo)) + } else if (varp == &(p_cpo)) { // 'cpoptions' p = (char_u *)CPO_VI; - else if (varp == &(curbuf->b_p_fo)) + } else if (varp == &(curbuf->b_p_fo)) { // 'formatoptions' p = (char_u *)FO_ALL; - else if (varp == &curwin->w_p_cocu) + } else if (varp == &curwin->w_p_cocu) { // 'concealcursor' p = (char_u *)COCU_ALL; - else if (varp == &p_mouse) { + } else if (varp == &p_mouse) { // 'mouse' p = (char_u *)MOUSE_ALL; } if (p != NULL) { diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 103227f6b5..757fac9465 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -575,6 +575,7 @@ return { full_name='dictionary', abbreviation='dict', type='string', list='onecomma', scope={'global', 'buffer'}, deny_duplicates=true, + normal_fname_chars=true, vi_def=true, expand=true, varname='p_dict', @@ -1750,6 +1751,7 @@ return { { full_name='printexpr', abbreviation='pexpr', type='string', scope={'global'}, + secure=true, vi_def=true, varname='p_pexpr', defaults={if_true={vi=""}} diff --git a/src/nvim/version.c b/src/nvim/version.c index d4f9c0232f..feb69cae52 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -851,7 +851,7 @@ static const int included_patches[] = { // 104, // 103 NA // 102, - // 101, + 101, 100, 99, // 98 NA -- cgit From d2eba872fb80ec9ace3a244aa706e55c82a48e83 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 24 Sep 2017 11:06:16 +0800 Subject: vim-patch:8.0.0101 Problem: Some options are not strictly checked. Solution: Add flags for strickter checks. https://github.com/vim/vim/commit/031cb743ae154cfb727a9b7787bdcb61202ff1c8 --- src/nvim/option.c | 13 +++++++------ src/nvim/options.lua | 2 ++ src/nvim/version.c | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 74250e83e6..ae1a2b1b24 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -3172,17 +3172,18 @@ did_set_string_option ( } else { // Options that are a list of flags. p = NULL; - if (varp == &p_ww) + if (varp == &p_ww) { // 'whichwrap' p = (char_u *)WW_ALL; - if (varp == &p_shm) + } + if (varp == &p_shm) { // 'shortmess' p = (char_u *)SHM_ALL; - else if (varp == &(p_cpo)) + } else if (varp == &(p_cpo)) { // 'cpoptions' p = (char_u *)CPO_VI; - else if (varp == &(curbuf->b_p_fo)) + } else if (varp == &(curbuf->b_p_fo)) { // 'formatoptions' p = (char_u *)FO_ALL; - else if (varp == &curwin->w_p_cocu) + } else if (varp == &curwin->w_p_cocu) { // 'concealcursor' p = (char_u *)COCU_ALL; - else if (varp == &p_mouse) { + } else if (varp == &p_mouse) { // 'mouse' p = (char_u *)MOUSE_ALL; } if (p != NULL) { diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 103227f6b5..757fac9465 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -575,6 +575,7 @@ return { full_name='dictionary', abbreviation='dict', type='string', list='onecomma', scope={'global', 'buffer'}, deny_duplicates=true, + normal_fname_chars=true, vi_def=true, expand=true, varname='p_dict', @@ -1750,6 +1751,7 @@ return { { full_name='printexpr', abbreviation='pexpr', type='string', scope={'global'}, + secure=true, vi_def=true, varname='p_pexpr', defaults={if_true={vi=""}} diff --git a/src/nvim/version.c b/src/nvim/version.c index d4f9c0232f..feb69cae52 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -851,7 +851,7 @@ static const int included_patches[] = { // 104, // 103 NA // 102, - // 101, + 101, 100, 99, // 98 NA -- cgit From cd13c24427a3191c7383b76a0bf9467bee2736e3 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 24 Sep 2017 11:54:40 +0800 Subject: vim-patch:8.0.0102 Problem: Cannot set 'dictionary' to a path. Solution: Allow for slash and backslash. Add a test (partly by Daisuke Suzuki, closes vim/vim#1279, closes vim/vim#1284) https://github.com/vim/vim/commit/7554da4033498c4da0af3cde542c3e87e9097b73 --- src/nvim/generators/gen_options.lua | 1 + src/nvim/option.c | 13 ++++++++----- src/nvim/options.lua | 4 ++-- src/nvim/testdir/test_options.vim | 15 +++++++++++++++ src/nvim/version.c | 2 +- 5 files changed, 27 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index ca0134043c..36562c0be9 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -74,6 +74,7 @@ local get_flags = function(o) {'gettext'}, {'noglob'}, {'normal_fname_chars', 'P_NFNAME'}, + {'normal_dname_chars', 'P_NDNAME'}, {'pri_mkrc'}, {'deny_in_modelines', 'P_NO_ML'}, {'deny_duplicates', 'P_NODUP'}, diff --git a/src/nvim/option.c b/src/nvim/option.c index ae1a2b1b24..6ed4989a4c 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -242,6 +242,7 @@ typedef struct vimoption { #define P_NO_DEF_EXP 0x8000000U ///< Do not expand default value. #define P_RWINONLY 0x10000000U ///< only redraw current window +#define P_NDNAME 0x20000000U ///< only normal dir name chars allowed #define HIGHLIGHT_INIT \ "8:SpecialKey,~:EndOfBuffer,z:TermCursor,Z:TermCursorNC,@:NonText," \ @@ -2454,11 +2455,13 @@ did_set_string_option ( if ((secure || sandbox != 0) && (options[opt_idx].flags & P_SECURE)) { errmsg = e_secure; - } else if ((options[opt_idx].flags & P_NFNAME) - && vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL) { - // Check for a "normal" file name in some options. Disallow a path - // separator (slash and/or backslash), wildcards and characters that are - // often illegal in a file name. + } else if ((((options[opt_idx].flags & P_NFNAME) + && vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL)) + || ((options[opt_idx].flags & P_NDNAME) + && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL)) { + // Check for a "normal" directory or file name in some options. Disallow a + // path separator (slash and/or backslash), wildcards and characters that + // are often illegal in a file name. errmsg = e_invarg; } /* 'backupcopy' */ diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 757fac9465..cce9e10409 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -7,7 +7,7 @@ -- enable_if=nil, -- defaults={condition=nil, if_true={vi=224, vim=0}, if_false=nil}, -- secure=nil, gettext=nil, noglob=nil, normal_fname_chars=nil, --- pri_mkrc=nil, deny_in_modelines=nil, +-- pri_mkrc=nil, deny_in_modelines=nil, normal_dname_chars=nil, -- expand=nil, nodefault=nil, no_mkrc=nil, vi_def=true, vim=true, -- alloced=nil, -- save_pv_indir=nil, @@ -575,7 +575,7 @@ return { full_name='dictionary', abbreviation='dict', type='string', list='onecomma', scope={'global', 'buffer'}, deny_duplicates=true, - normal_fname_chars=true, + normal_dname_chars=true, vi_def=true, expand=true, varname='p_dict', diff --git a/src/nvim/testdir/test_options.vim b/src/nvim/testdir/test_options.vim index 2ffe63787b..ea020d9ca0 100644 --- a/src/nvim/testdir/test_options.vim +++ b/src/nvim/testdir/test_options.vim @@ -103,3 +103,18 @@ func Test_keymap_valid() call assert_fails(":set kmp=trunc\x00name", "E544:") call assert_fails(":set kmp=trunc\x00name", "trunc") endfunc + +func Test_dictionary() + " Check that it's possible to set the option. + set dictionary=/usr/share/dict/words + call assert_equal('/usr/share/dict/words', &dictionary) + set dictionary=/usr/share/dict/words,/and/there + call assert_equal('/usr/share/dict/words,/and/there', &dictionary) + set dictionary=/usr/share/dict\ words + call assert_equal('/usr/share/dict words', &dictionary) + + " Check rejecting weird characters. + call assert_fails("set dictionary=/not&there", "E474:") + call assert_fails("set dictionary=/not>there", "E474:") + call assert_fails("set dictionary=/not.*there", "E474:") +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index feb69cae52..890587b307 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -850,7 +850,7 @@ static const int included_patches[] = { // 105 NA // 104, // 103 NA - // 102, + 102, 101, 100, 99, -- cgit From 3a1c33a6c3ad5074bfc442507282a438726f1b58 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 24 Sep 2017 13:21:07 +0800 Subject: vim-patch:8.0.0106 Problem: Cannot use a semicolon in 'backupext'. (Jeff) Solution: Allow for a few more characters when "secure" isn't set. https://github.com/vim/vim/commit/0945eaface83e78138fbd40f95cc590bab0e8c86 --- src/nvim/option.c | 7 ++++--- src/nvim/version.c | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 6ed4989a4c..e989f700ae 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2455,13 +2455,14 @@ did_set_string_option ( if ((secure || sandbox != 0) && (options[opt_idx].flags & P_SECURE)) { errmsg = e_secure; - } else if ((((options[opt_idx].flags & P_NFNAME) - && vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL)) + } else if (((options[opt_idx].flags & P_NFNAME) + && vim_strpbrk(*varp, (char_u *)(secure + ? "/\\*?[|;&<>\r\n" : "/\\*?[<>\r\n")) != NULL) || ((options[opt_idx].flags & P_NDNAME) && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL)) { // Check for a "normal" directory or file name in some options. Disallow a // path separator (slash and/or backslash), wildcards and characters that - // are often illegal in a file name. + // are often illegal in a file name. Be more permissive if "secure" is off. errmsg = e_invarg; } /* 'backupcopy' */ diff --git a/src/nvim/version.c b/src/nvim/version.c index 06482bf490..f6a9418dbf 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -846,7 +846,7 @@ static const int included_patches[] = { // 109 NA // 108 NA // 107 NA - // 106, + 106, // 105 NA 104, // 103 NA -- cgit From 2b4a52f901bf4cc9a88c45eea39c303028091dd3 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 24 Sep 2017 23:20:45 +0800 Subject: vim-patch:8.0.0091 (#7312) Problem: Test_help_complete sometimes fails in MS-Windows console. Solution: Use getcompletion() instead of feedkeys() and command line completion. (Hirohito Higashi) https://github.com/vim/vim/commit/9f0e423c2818c0cacd0810f9c3c67cbb6b80963d --- src/nvim/testdir/test_help_tagjump.vim | 57 ++++++++++++++-------------------- src/nvim/version.c | 2 +- 2 files changed, 25 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_help_tagjump.vim b/src/nvim/testdir/test_help_tagjump.vim index 1ca0f722cf..65d99c644c 100644 --- a/src/nvim/testdir/test_help_tagjump.vim +++ b/src/nvim/testdir/test_help_tagjump.vim @@ -89,17 +89,8 @@ func s:doc_config_teardown() endif endfunc -func s:get_cmd_compl_list(cmd) - let list = [] - let str = '' - for cnt in range(1, 999) - call feedkeys(a:cmd . repeat("\", cnt) . "'\let str='\", 'tx') - if str ==# a:cmd[1:] - break - endif - call add(list, str) - endfor - return list +func s:get_help_compl_list(cmd) + return getcompletion(a:cmd, 'help') endfunc func Test_help_complete() @@ -111,49 +102,49 @@ func Test_help_complete() if has('multi_lang') set helplang= endif - let list = s:get_cmd_compl_list(":h test") - call assert_equal(['h test-col', 'h test-char'], list) + let list = s:get_help_compl_list("test") + call assert_equal(['test-col', 'test-char'], list) if has('multi_lang') " 'helplang=ab' and help file lang is 'en' set helplang=ab - let list = s:get_cmd_compl_list(":h test") - call assert_equal(['h test-col', 'h test-char'], list) + let list = s:get_help_compl_list("test") + call assert_equal(['test-col', 'test-char'], list) " 'helplang=' and help file lang is 'en' and 'ab' set rtp+=Xdir1/doc-ab set helplang= - let list = s:get_cmd_compl_list(":h test") - call assert_equal(sort(['h test-col@en', 'h test-col@ab', - \ 'h test-char@en', 'h test-char@ab']), sort(list)) + let list = s:get_help_compl_list("test") + call assert_equal(sort(['test-col@en', 'test-col@ab', + \ 'test-char@en', 'test-char@ab']), sort(list)) " 'helplang=ab' and help file lang is 'en' and 'ab' set helplang=ab - let list = s:get_cmd_compl_list(":h test") - call assert_equal(sort(['h test-col', 'h test-col@en', - \ 'h test-char', 'h test-char@en']), sort(list)) + let list = s:get_help_compl_list("test") + call assert_equal(sort(['test-col', 'test-col@en', + \ 'test-char', 'test-char@en']), sort(list)) " 'helplang=' and help file lang is 'en', 'ab' and 'ja' set rtp+=Xdir1/doc-ja set helplang= - let list = s:get_cmd_compl_list(":h test") - call assert_equal(sort(['h test-col@en', 'h test-col@ab', - \ 'h test-col@ja', 'h test-char@en', - \ 'h test-char@ab', 'h test-char@ja']), sort(list)) + let list = s:get_help_compl_list("test") + call assert_equal(sort(['test-col@en', 'test-col@ab', + \ 'test-col@ja', 'test-char@en', + \ 'test-char@ab', 'test-char@ja']), sort(list)) " 'helplang=ab' and help file lang is 'en', 'ab' and 'ja' set helplang=ab - let list = s:get_cmd_compl_list(":h test") - call assert_equal(sort(['h test-col', 'h test-col@en', - \ 'h test-col@ja', 'h test-char', - \ 'h test-char@en', 'h test-char@ja']), sort(list)) + let list = s:get_help_compl_list("test") + call assert_equal(sort(['test-col', 'test-col@en', + \ 'test-col@ja', 'test-char', + \ 'test-char@en', 'test-char@ja']), sort(list)) " 'helplang=ab,ja' and help file lang is 'en', 'ab' and 'ja' set helplang=ab,ja - let list = s:get_cmd_compl_list(":h test") - call assert_equal(sort(['h test-col', 'h test-col@ja', - \ 'h test-col@en', 'h test-char', - \ 'h test-char@ja', 'h test-char@en']), sort(list)) + let list = s:get_help_compl_list("test") + call assert_equal(sort(['test-col', 'test-col@ja', + \ 'test-col@en', 'test-char', + \ 'test-char@ja', 'test-char@en']), sort(list)) endif catch call assert_exception('X') diff --git a/src/nvim/version.c b/src/nvim/version.c index d4f9c0232f..16523380cc 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -861,7 +861,7 @@ static const int included_patches[] = { // 94 NA // 93 NA 92, - // 91, + 91, 90, // 89 NA 88, -- cgit From 1c7f396f0cba3e87c4c1cae041489e28d59d1306 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Sep 2017 15:32:31 -0400 Subject: vim-patch:8.0.0112 Problem: Tests 92 and 93 are old style. Solution: Make test92 and test93 new style. (Hirohito Higashi, closes vim/vim#1289) https://github.com/vim/vim/commit/eca626fcdb73d480660c78b9f84cc043fa561922 --- src/nvim/testdir/test_mksession.vim | 102 +++++++++++++++++++++++++++++- src/nvim/testdir/test_mksession_utf8.vim | 104 +++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 src/nvim/testdir/test_mksession_utf8.vim (limited to 'src') diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 2238213850..928f065efb 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -1,4 +1,104 @@ -" Tests for sessions +" Test for :mksession, :mkview and :loadview in latin1 encoding + +scriptencoding latin1 + +if !has('multi_byte') || !has('mksession') + finish +endif + +func Test_mksession() + tabnew + let wrap_save = &wrap + set sessionoptions=buffers splitbelow fileencoding=latin1 + call setline(1, [ + \ 'start:', + \ 'no multibyte chAracter', + \ ' one leaDing tab', + \ ' four leadinG spaces', + \ 'two consecutive tabs', + \ 'two tabs in one line', + \ 'one ä multibyteCharacter', + \ 'aä Ä two multiByte characters', + \ 'Aäöü three mulTibyte characters' + \ ]) + let tmpfile = tempname() + exec 'w! ' . tmpfile + /^start: + set wrap + vsplit + norm! j16| + split + norm! j16| + split + norm! j16| + split + norm! j8| + split + norm! j8| + split + norm! j16| + split + norm! j16| + split + norm! j16| + wincmd l + + set nowrap + /^start: + norm! j16|3zl + split + norm! j016|3zl + split + norm! j016|3zl + split + norm! j08|3zl + split + norm! j08|3zl + split + norm! j016|3zl + split + norm! j016|3zl + split + norm! j016|3zl + split + call wincol() + mksession! test_mks.out + let li = filter(readfile('test_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"') + let expected = [ + \ 'normal! 016|', + \ 'normal! 016|', + \ 'normal! 016|', + \ 'normal! 08|', + \ 'normal! 08|', + \ 'normal! 016|', + \ 'normal! 016|', + \ 'normal! 016|', + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 8 . '|'", + \ " normal! 08|", + \ " exe 'normal! ' . s:c . '|zs' . 8 . '|'", + \ " normal! 08|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|" + \ ] + call assert_equal(expected, li) + tabclose! + + call delete('test_mks.out') + call delete(tmpfile) + let &wrap = wrap_save +endfunc " Verify that arglist is stored correctly to the session file. func Test_mksession_arglist() diff --git a/src/nvim/testdir/test_mksession_utf8.vim b/src/nvim/testdir/test_mksession_utf8.vim new file mode 100644 index 0000000000..c05a1d3b6d --- /dev/null +++ b/src/nvim/testdir/test_mksession_utf8.vim @@ -0,0 +1,104 @@ +" Test for :mksession, :mkview and :loadview in utf-8 encoding + +set encoding=utf-8 +scriptencoding utf-8 + +if !has('multi_byte') || !has('mksession') + finish +endif + +func Test_mksession_utf8() + tabnew + let wrap_save = &wrap + set sessionoptions=buffers splitbelow fileencoding=utf-8 + call setline(1, [ + \ 'start:', + \ 'no multibyte chAracter', + \ ' one leaDing tab', + \ ' four leadinG spaces', + \ 'two consecutive tabs', + \ 'two tabs in one line', + \ 'one … multibyteCharacter', + \ 'a “b†two multiByte characters', + \ '“câ€1€ three mulTibyte characters' + \ ]) + let tmpfile = tempname() + exec 'w! ' . tmpfile + /^start: + set wrap + vsplit + norm! j16| + split + norm! j16| + split + norm! j16| + split + norm! j8| + split + norm! j8| + split + norm! j16| + split + norm! j16| + split + norm! j16| + wincmd l + + set nowrap + /^start: + norm! j16|3zl + split + norm! j016|3zl + split + norm! j016|3zl + split + norm! j08|3zl + split + norm! j08|3zl + split + norm! j016|3zl + split + norm! j016|3zl + split + norm! j016|3zl + split + call wincol() + mksession! test_mks.out + let li = filter(readfile('test_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"') + let expected = [ + \ 'normal! 016|', + \ 'normal! 016|', + \ 'normal! 016|', + \ 'normal! 08|', + \ 'normal! 08|', + \ 'normal! 016|', + \ 'normal! 016|', + \ 'normal! 016|', + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 8 . '|'", + \ " normal! 08|", + \ " exe 'normal! ' . s:c . '|zs' . 8 . '|'", + \ " normal! 08|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|", + \ " exe 'normal! ' . s:c . '|zs' . 16 . '|'", + \ " normal! 016|" + \ ] + call assert_equal(expected, li) + tabclose! + + call delete('test_mks.out') + call delete(tmpfile) + let &wrap = wrap_save +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index a060b4a74f..80018f6eab 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -840,7 +840,7 @@ static const int included_patches[] = { // 115 NA // 114 NA // 113 NA - // 112, + 112, 111, 110, // 109 NA -- cgit From 5bb2a19417e33ef573411b2069ab3d8095f7a9fa Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Sep 2017 15:39:41 -0400 Subject: vim-patch:8.0.0253 Problem: When creating a session when winminheight is 2 or larger and loading that session gives an error. Solution: Also set winminheight before setting winheight to 1. (Rafael Bodill, neovim vim/vim#5717) https://github.com/vim/vim/commit/36ae89c550a4f0a380606c3fb4a054957ad698f0 --- src/nvim/ex_docmd.c | 2 ++ src/nvim/testdir/test_mksession.vim | 9 +++++++++ src/nvim/version.c | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 47e23b6e80..5145c65bc7 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -8933,6 +8933,8 @@ makeopens ( // resized when moving between windows. // Do this before restoring the view, so that the topline and the // cursor can be set. This is done again below. + // winminheight and winminwidth need to be set to avoid an error if the + // user has set winheight or winwidth. if (put_line(fd, "set winminheight=1 winminwidth=1 winheight=1 winwidth=1") == FAIL) { return FAIL; diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 928f065efb..284bafab75 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -100,6 +100,15 @@ func Test_mksession() let &wrap = wrap_save endfunc +func Test_mksession_winheight() + new + set winheight=10 winminheight=2 + mksession! test_mks.out + source test_mks.out + + " call delete('test_mks.out') +endfunc + " Verify that arglist is stored correctly to the session file. func Test_mksession_arglist() argdel * diff --git a/src/nvim/version.c b/src/nvim/version.c index 80018f6eab..f2686eacec 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -699,7 +699,7 @@ static const int included_patches[] = { // 256, // 255, // 254, - // 253, + 253, // 252, // 251, 250, -- cgit From 43da7ea27b3391a9e74c658b90a5ed1cae926d40 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Sep 2017 15:50:09 -0400 Subject: vim-patch:8.0.0258 Problem: mksession test leaves file behind. Solution: Delete the file. Rename files to start with "X". https://github.com/vim/vim/commit/c9b56b2ceb4662f87c39ea07ba5090a073fd6286 --- src/nvim/testdir/test_mksession.vim | 14 +++++++------- src/nvim/version.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 284bafab75..7158b31a14 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -21,7 +21,7 @@ func Test_mksession() \ 'aä Ä two multiByte characters', \ 'Aäöü three mulTibyte characters' \ ]) - let tmpfile = tempname() + let tmpfile = 'Xtemp' exec 'w! ' . tmpfile /^start: set wrap @@ -62,8 +62,8 @@ func Test_mksession() norm! j016|3zl split call wincol() - mksession! test_mks.out - let li = filter(readfile('test_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"') + mksession! Xtest_mks.out + let li = filter(readfile('Xtest_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"') let expected = [ \ 'normal! 016|', \ 'normal! 016|', @@ -95,7 +95,7 @@ func Test_mksession() call assert_equal(expected, li) tabclose! - call delete('test_mks.out') + call delete('Xtest_mks.out') call delete(tmpfile) let &wrap = wrap_save endfunc @@ -103,10 +103,10 @@ endfunc func Test_mksession_winheight() new set winheight=10 winminheight=2 - mksession! test_mks.out - source test_mks.out + mksession! Xtest_mks.out + source Xtest_mks.out - " call delete('test_mks.out') + call delete('Xtest_mks.out') endfunc " Verify that arglist is stored correctly to the session file. diff --git a/src/nvim/version.c b/src/nvim/version.c index f2686eacec..580ed592ca 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -694,7 +694,7 @@ static const int included_patches[] = { // 261, // 260 NA 259, - // 258, + 258, // 257 NA // 256, // 255, -- cgit From 25d4cd7e2830265505b0f6f88e6d08b4954af6eb Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Sep 2017 15:52:21 -0400 Subject: vim-patch:8.0.1024 Problem: Manual folds are lost when a session file has the same buffer in two windows. (Jeansen) Solution: Use ":edit" only once. (Christian Brabandt, closes vim/vim#1958) https://github.com/vim/vim/commit/4bebc9a0565670b853d227f81a9a31eafdb47eed --- src/nvim/ex_docmd.c | 43 ++++++---- src/nvim/testdir/test_mksession.vim | 32 ++++++++ src/nvim/version.c | 151 ++++++++++++++++++++++++++++++++++++ 3 files changed, 209 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 5145c65bc7..87d9e10619 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -8813,7 +8813,7 @@ makeopens ( buf->b_wininfo == NULL ? (int64_t)1L : (int64_t)buf->b_wininfo->wi_fpos.lnum) < 0 - || ses_fname(fd, buf, &ssop_flags) == FAIL) + || ses_fname(fd, buf, &ssop_flags, true) == FAIL) return FAIL; } } @@ -8885,7 +8885,7 @@ makeopens ( && !bt_nofile(wp->w_buffer) ) { if (fputs(need_tabnew ? "tabedit " : "edit ", fd) < 0 - || ses_fname(fd, wp->w_buffer, &ssop_flags) == FAIL) + || ses_fname(fd, wp->w_buffer, &ssop_flags, true) == FAIL) return FAIL; need_tabnew = FALSE; if (!wp->w_arg_idx_invalid) @@ -9223,21 +9223,30 @@ put_view ( if (wp->w_buffer->b_ffname != NULL && (!bt_nofile(wp->w_buffer) || wp->w_buffer->terminal) ) { - /* - * Editing a file in this buffer: use ":edit file". - * This may have side effects! (e.g., compressed or network file). - */ - if (fputs("edit ", fd) < 0 - || ses_fname(fd, wp->w_buffer, flagp) == FAIL) + // Editing a file in this buffer: use ":edit file". + // This may have side effects! (e.g., compressed or network file). + // + // Note, if a buffer for that file already exists, use :badd to + // edit that buffer, to not lose folding information (:edit resets + // folds in other buffers) + if (fputs("if bufexists('", fd) < 0 + || ses_fname(fd, wp->w_buffer, flagp, false) == FAIL + || fputs("') | buffer ", fd) < 0 + || ses_fname(fd, wp->w_buffer, flagp, false) == FAIL + || fputs(" | else | edit ", fd) < 0 + || ses_fname(fd, wp->w_buffer, flagp, false) == FAIL + || fputs(" | endif", fd) < 0 + || put_eol(fd) == FAIL) { return FAIL; + } } else { /* No file in this buffer, just make it empty. */ if (put_line(fd, "enew") == FAIL) return FAIL; if (wp->w_buffer->b_ffname != NULL) { - /* The buffer does have a name, but it's not a file name. */ + // The buffer does have a name, but it's not a file name. if (fputs("file ", fd) < 0 - || ses_fname(fd, wp->w_buffer, flagp) == FAIL) + || ses_fname(fd, wp->w_buffer, flagp, true) == FAIL) return FAIL; } do_cursor = FALSE; @@ -9391,12 +9400,10 @@ ses_arglist ( return OK; } -/* - * Write a buffer name to the session file. - * Also ends the line. - * Returns FAIL if writing fails. - */ -static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp) +/// Write a buffer name to the session file. +/// Also ends the line, if "add_eol" is true. +/// Returns FAIL if writing fails. +static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp, bool add_eol) { char_u *name; @@ -9413,8 +9420,10 @@ static int ses_fname(FILE *fd, buf_T *buf, unsigned *flagp) name = buf->b_sfname; else name = buf->b_ffname; - if (ses_put_fname(fd, name, flagp) == FAIL || put_eol(fd) == FAIL) + if (ses_put_fname(fd, name, flagp) == FAIL + || (add_eol && put_eol(fd) == FAIL)) { return FAIL; + } return OK; } diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 7158b31a14..13fb07c7e0 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -121,4 +121,36 @@ func Test_mksession_arglist() argdel * endfunc + +func Test_mksession_one_buffer_two_windows() + edit Xtest1 + new Xtest2 + split + mksession! Xtest_mks.out + let lines = readfile('Xtest_mks.out') + let count1 = 0 + let count2 = 0 + let count2buf = 0 + for line in lines + if line =~ 'edit \f*Xtest1$' + let count1 += 1 + endif + if line =~ 'edit \f\{-}Xtest2' + let count2 += 1 + endif + if line =~ 'buffer \f\{-}Xtest2' + let count2buf += 1 + endif + endfor + call assert_equal(1, count1, 'Xtest1 count') + call assert_equal(2, count2, 'Xtest2 count') + call assert_equal(2, count2buf, 'Xtest2 buffer count') + + close + bwipe! + !cp Xtest_mks.out /tmp + call delete('Xtest_mks.out') +endfunc + + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/version.c b/src/nvim/version.c index 580ed592ca..9f75f75d4f 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -77,6 +77,157 @@ static char *features[] = { // clang-format off static const int included_patches[] = { + // 1026, + // 1025, + 1024, + // 1023, + // 1022, + // 1021, + // 1020, + // 1019, + // 1018, + // 1017, + // 1016, + // 1015, + // 1014, + // 1013, + // 1012, + // 1011, + // 1010, + // 1009, + // 1008, + // 1007, + // 1006, + // 1005, + // 1004, + // 1003, + // 1002, + // 1001, + // 1000, + // 999, + // 998, + // 997, + // 996, + // 995, + // 994, + // 993, + // 992, + // 991, + // 990, + // 989, + // 988, + // 987, + // 986, + // 985, + // 984, + // 983, + // 982, + // 981, + // 980, + // 979, + // 978, + // 977, + // 976, + // 975, + // 974, + // 973, + // 972, + // 971, + // 970, + // 969, + // 968, + // 967, + // 966, + // 965, + // 964, + // 963, + // 962, + // 961, + // 960, + // 959, + // 958, + // 957, + // 956, + // 955, + // 954, + // 953, + // 952, + // 951, + // 950, + // 949, + // 948, + // 947, + // 946, + // 945, + // 944, + // 943, + // 942, + // 941, + // 940, + // 939, + // 938, + // 937, + // 936, + // 935, + // 934, + // 933, + // 932, + // 931, + // 930, + // 929, + // 928, + // 927, + // 926, + // 925, + // 924, + // 923, + // 922, + // 921, + // 920, + // 919, + // 918, + // 917, + // 916, + // 915, + // 914, + // 913, + // 912, + // 911, + // 910, + // 909, + // 908, + // 907, + // 906, + // 905, + // 904, + // 903, + // 902, + // 901, + // 900, + // 899, + // 898, + // 897, + // 896, + // 895, + // 894, + // 893, + // 892, + // 891, + // 890, + // 889, + // 888, + // 887, + // 886, + // 885, + // 884, + // 883, + // 882, + // 881, + // 880, + // 879, + // 878, + // 877, + // 876, // 875, // 874, // 873, -- cgit From e0197a4d76420e611e9da2f437f01cb31d65cdb0 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Sep 2017 16:04:01 -0400 Subject: vim-patch:8.0.1025 Problem: Stray copy command in test. Solution: Remove the copy command. https://github.com/vim/vim/commit/4e83961985abb78757b135f29ac4ffde675247af --- src/nvim/testdir/test_mksession.vim | 1 - src/nvim/version.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_mksession.vim b/src/nvim/testdir/test_mksession.vim index 13fb07c7e0..4774cf4af5 100644 --- a/src/nvim/testdir/test_mksession.vim +++ b/src/nvim/testdir/test_mksession.vim @@ -148,7 +148,6 @@ func Test_mksession_one_buffer_two_windows() close bwipe! - !cp Xtest_mks.out /tmp call delete('Xtest_mks.out') endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 9f75f75d4f..fa8b495703 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -78,7 +78,7 @@ static char *features[] = { // clang-format off static const int included_patches[] = { // 1026, - // 1025, + 1025, 1024, // 1023, // 1022, -- cgit From f66307475db14858310f103600b42f23ff7ce48e Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 26 Sep 2017 16:08:15 -0400 Subject: lint --- src/nvim/ex_docmd.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 87d9e10619..3130747e08 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -8810,11 +8810,12 @@ makeopens ( && buf->b_fname != NULL && buf->b_p_bl) { if (fprintf(fd, "badd +%" PRId64 " ", - buf->b_wininfo == NULL ? - (int64_t)1L : - (int64_t)buf->b_wininfo->wi_fpos.lnum) < 0 - || ses_fname(fd, buf, &ssop_flags, true) == FAIL) + buf->b_wininfo == NULL + ? (int64_t)1L + : (int64_t)buf->b_wininfo->wi_fpos.lnum) < 0 + || ses_fname(fd, buf, &ssop_flags, true) == FAIL) { return FAIL; + } } } @@ -8885,11 +8886,13 @@ makeopens ( && !bt_nofile(wp->w_buffer) ) { if (fputs(need_tabnew ? "tabedit " : "edit ", fd) < 0 - || ses_fname(fd, wp->w_buffer, &ssop_flags, true) == FAIL) + || ses_fname(fd, wp->w_buffer, &ssop_flags, true) == FAIL) { return FAIL; - need_tabnew = FALSE; - if (!wp->w_arg_idx_invalid) + } + need_tabnew = false; + if (!wp->w_arg_idx_invalid) { edited_win = wp; + } break; } } @@ -9240,16 +9243,18 @@ put_view ( return FAIL; } } else { - /* No file in this buffer, just make it empty. */ - if (put_line(fd, "enew") == FAIL) + // No file in this buffer, just make it empty. + if (put_line(fd, "enew") == FAIL) { return FAIL; + } if (wp->w_buffer->b_ffname != NULL) { // The buffer does have a name, but it's not a file name. if (fputs("file ", fd) < 0 - || ses_fname(fd, wp->w_buffer, flagp, true) == FAIL) + || ses_fname(fd, wp->w_buffer, flagp, true) == FAIL) { return FAIL; + } } - do_cursor = FALSE; + do_cursor = false; } } -- cgit From 36f13ceb0ab384f0cad9813ae02792a1cf13021a Mon Sep 17 00:00:00 2001 From: ckelsel Date: Wed, 27 Sep 2017 20:05:17 +0800 Subject: vim-patch:8.0.0131 Problem: Not enough test coverage for syntax commands. Solution: Add more tests. (Dominique Pelle) https://github.com/vim/vim/commit/73b484c4da00011317dc68ada4f5dfc6515ad263 --- src/nvim/testdir/test_syntax.vim | 78 +++++++++++++++++++++++++++++++++++++++- src/nvim/version.c | 2 +- 2 files changed, 78 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index af2cbbfe8e..584b6f024a 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -50,7 +50,7 @@ func Test_syn_iskeyword() setlocal isk-=_ call assert_equal('DLTD_BY', GetSyntaxItem('DLTD')) /\/:norm! ygn - let b2=@0 + let b2 = @0 call assert_equal('DLTD', @0) syn iskeyword clear @@ -76,3 +76,79 @@ func Test_syntax_after_reload() call assert_true(exists('g:gotit')) call delete('Xsomefile') endfunc + +func Test_syntime() + if !has('profile') + finish + endif + + syntax on + syntime on + let a = execute('syntime report') + call assert_equal("\nNo Syntax items defined for this buffer", a) + + view ../memfile_test.c + setfiletype cpp + redraw + let a = execute('syntime report') + call assert_match('^ TOTAL *COUNT *MATCH *SLOWEST *AVERAGE *NAME *PATTERN', a) + call assert_match(' \d*\.\d* \+[^0]\d* .* cppRawString ', a) + call assert_match(' \d*\.\d* \+[^0]\d* .* cppNumber ', a) + + syntime off + syntime clear + let a = execute('syntime report') + call assert_match('^ TOTAL *COUNT *MATCH *SLOWEST *AVERAGE *NAME *PATTERN', a) + call assert_notmatch('.* cppRawString *', a) + call assert_notmatch('.* cppNumber*', a) + call assert_notmatch('[1-9]', a) + + call assert_fails('syntime abc', 'E475') + + syntax clear + let a = execute('syntime report') + call assert_equal("\nNo Syntax items defined for this buffer", a) + + bd +endfunc + +func Test_syntax_list() + syntax on + let a = execute('syntax list') + call assert_equal("\nNo Syntax items defined for this buffer", a) + + view ../memfile_test.c + setfiletype c + + let a = execute('syntax list') + call assert_match('cInclude*', a) + call assert_match('cDefine', a) + + let a = execute('syntax list cDefine') + call assert_notmatch('cInclude*', a) + call assert_match('cDefine', a) + call assert_match(' links to Macro$', a) + + call assert_fails('syntax list ABCD', 'E28:') + call assert_fails('syntax list @ABCD', 'E392:') + + syntax clear + let a = execute('syntax list') + call assert_equal("\nNo Syntax items defined for this buffer", a) + + bd +endfunc + +func Test_syntax_completion() + call feedkeys(":syn \\\"\", 'tx') + call assert_equal('"syn case clear cluster conceal enable include iskeyword keyword list manual match off on region reset spell sync', @:) + + call feedkeys(":syn case \\\"\", 'tx') + call assert_equal('"syn case ignore match', @:) + + call feedkeys(":syn list \\\"\", 'tx') + call assert_match('^"syn list Boolean Character ', @:) + + call feedkeys(":syn match \\\"\", 'tx') + call assert_match('^"syn match Boolean Character ', @:) +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index b0d4e194fa..bf53f16e8d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -972,7 +972,7 @@ static const int included_patches[] = { 134, 133, // 132, - // 131, + 131, // 130 NA // 129 NA 128, -- cgit From 65c97961ecdcfa89bb0ce9ff88f1e84e4d926f21 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Wed, 27 Sep 2017 20:06:35 +0800 Subject: vim-patch:8.0.0132 Problem: Test fails because of using :finish. Solution: Change to return. https://github.com/vim/vim/commit/4c8980b717f73042f1d625ee255fa74eddb989ba --- src/nvim/testdir/test_syntax.vim | 2 +- src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 584b6f024a..73594f0f55 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -79,7 +79,7 @@ endfunc func Test_syntime() if !has('profile') - finish + return endif syntax on diff --git a/src/nvim/version.c b/src/nvim/version.c index bf53f16e8d..6b57185b50 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -971,7 +971,7 @@ static const int included_patches[] = { 135, 134, 133, - // 132, + 132, 131, // 130 NA // 129 NA -- cgit From f1242c2a26f51c53c6f248666023a919f93d72fa Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 27 Sep 2017 08:27:31 -0400 Subject: oldtest: Run test_mksession_utf8 tests --- src/nvim/testdir/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 9133bfc0a2..38caa8815d 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -59,6 +59,7 @@ NEW_TESTS ?= \ test_matchadd_conceal.res \ test_matchadd_conceal_utf8.res \ test_mksession.res \ + test_mksession_utf8.res \ test_nested_function.res \ test_normal.res \ test_quickfix.res \ -- cgit From f97ca6b3339ca04477296c834a159d40d2201ccd Mon Sep 17 00:00:00 2001 From: ckelsel Date: Thu, 28 Sep 2017 11:47:26 +0800 Subject: vim-patch:8.0.0155 Problem: When sorting zero elements a NULL pointer is passed to qsort(), which ubsan warns for. Solution: Don't call qsort() if there are no elements. (Dominique Pelle) https://github.com/vim/vim/commit/a216255a4faa91a15e7005ac319f2f62294f3f9e --- src/nvim/syntax.c | 9 ++++++--- src/nvim/version.c | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 65c0e2464a..5781424d2b 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5845,9 +5845,12 @@ static void syntime_report(void) } } - /* sort on total time */ - qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T), - syn_compare_syntime); + // Sort on total time. Skip if there are no items to avoid passing NULL + // pointer to qsort(). + if (ga.ga_len > 1) { + qsort(ga.ga_data, (size_t)ga.ga_len, sizeof(time_entry_T), + syn_compare_syntime); + } MSG_PUTS_TITLE(_( " TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN")); diff --git a/src/nvim/version.c b/src/nvim/version.c index 6b57185b50..1432a92998 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -948,7 +948,7 @@ static const int included_patches[] = { 158, // 157, 156, - // 155, + 155, // 154, // 153, // 152 NA -- cgit From e479f3b944614f28c42ec597ec473652f3ac9912 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Sep 2017 21:38:43 +0300 Subject: kvec: Add kv_drop() which is to be used like `(void)kv_pop(kvec)` --- src/nvim/lib/kvec.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/nvim/lib/kvec.h b/src/nvim/lib/kvec.h index 584282d773..4e5fb0d794 100644 --- a/src/nvim/lib/kvec.h +++ b/src/nvim/lib/kvec.h @@ -64,6 +64,14 @@ #define kv_max(v) ((v).capacity) #define kv_last(v) kv_A(v, kv_size(v) - 1) +/// Drop last n items from kvec without resizing +/// +/// Previously spelled as `(void)kv_pop(v)`, repeated n times. +/// +/// @param[out] v Kvec to drop items from. +/// @param[in] n Number of elements to drop. +#define kv_drop(v, n) ((v).size -= (n)) + #define kv_resize(v, s) \ ((v).capacity = (s), \ (v).items = xrealloc((v).items, sizeof((v).items[0]) * (v).capacity)) -- cgit From ba7277cfb4e2556f246446d06b53f3427f28130f Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Wed, 26 Jul 2017 23:28:26 +0200 Subject: Adds nvim_get_hl_by_name/by_id ...in order to retrieve highlights. Added test/functional/api/highlight_spec.lua HL_NORMAL is not really a good name, since it's more like an empty attribute than the normal's one. If one pays attention, syn_cterm_attr2entry is never called with attr=0 because it's always special cased before. I suggest in subsequent PRs we remove the ATTR_OFF and just insert an EMPTY ATTR/RESET_ATTR/UNINITIALIZED for id 0. --- src/nvim/api/ui.c | 34 +----------- src/nvim/api/vim.c | 37 +++++++++++++ src/nvim/syntax.c | 22 +++----- src/nvim/tui/tui.c | 6 +-- src/nvim/ugrid.c | 4 +- src/nvim/ugrid.h | 2 - src/nvim/ui.c | 149 ++++++++++++++++++++++++++++++++++++++++------------- src/nvim/ui.h | 3 ++ 8 files changed, 166 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index bbbd5ab2dc..afbee09c1c 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -242,39 +242,7 @@ static void push_call(UI *ui, char *name, Array args) static void remote_ui_highlight_set(UI *ui, HlAttrs attrs) { Array args = ARRAY_DICT_INIT; - Dictionary hl = ARRAY_DICT_INIT; - - if (attrs.bold) { - PUT(hl, "bold", BOOLEAN_OBJ(true)); - } - - if (attrs.underline) { - PUT(hl, "underline", BOOLEAN_OBJ(true)); - } - - if (attrs.undercurl) { - PUT(hl, "undercurl", BOOLEAN_OBJ(true)); - } - - if (attrs.italic) { - PUT(hl, "italic", BOOLEAN_OBJ(true)); - } - - if (attrs.reverse) { - PUT(hl, "reverse", BOOLEAN_OBJ(true)); - } - - if (attrs.foreground != -1) { - PUT(hl, "foreground", INTEGER_OBJ(attrs.foreground)); - } - - if (attrs.background != -1) { - PUT(hl, "background", INTEGER_OBJ(attrs.background)); - } - - if (attrs.special != -1) { - PUT(hl, "special", INTEGER_OBJ(attrs.special)); - } + Dictionary hl = hlattrs2dict(attrs); ADD(args, DICTIONARY_OBJ(hl)); push_call(ui, "highlight_set", args); diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index ab893a4c0f..0459d9235d 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -33,6 +33,7 @@ #include "nvim/syntax.h" #include "nvim/getchar.h" #include "nvim/os/input.h" +#include "nvim/ui.h" #define LINE_BUFFER_SIZE 4096 @@ -55,6 +56,42 @@ void nvim_command(String command, Error *err) try_end(err); } +/// Retrieves highlight description from its name +/// +/// @param name Highlight group name +/// @return a highlight description e.g. {'bold': true, 'bg': 123, 'fg': 42} +/// @see nvim_get_hl_by_id +Dictionary nvim_get_hl_by_name(String name, Error *err) + FUNC_API_SINCE(3) +{ + Dictionary result = ARRAY_DICT_INIT; + int id = syn_name2id((const char_u *)name.data); + + if (id == 0) { + api_set_error(err, kErrorTypeException, "Invalid highlight name %s", + name.data); + return result; + } + result = nvim_get_hl_by_id(id, err); + return result; +} + +/// Retrieves highlight description from its id +/// +/// @param hl_id highlight id as returned by hlID() +/// @see nvim_get_hl_by_name +Dictionary nvim_get_hl_by_id(Integer hl_id, Error *err) + FUNC_API_SINCE(3) +{ + Dictionary dic = ARRAY_DICT_INIT; + if (syn_get_final_id((int)hl_id) == 0) { + api_set_error(err, kErrorTypeException, "Invalid highlight id %d", hl_id); + return dic; + } + int attrcode = syn_id2attr((int)hl_id); + return get_attr_by_id(attrcode, err); +} + /// Passes input keys to Nvim. /// On VimL error: Does not fail, but updates v:errmsg. /// diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 65c0e2464a..fdb7196fc4 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -42,6 +42,7 @@ #include "nvim/ui.h" #include "nvim/os/os.h" #include "nvim/os/time.h" +#include "nvim/api/private/helpers.h" static bool did_syntax_onoff = false; @@ -6622,7 +6623,6 @@ do_highlight(char_u *line, int forceit, int init) { syn_unadd_group(); } else { if (is_normal_group) { - HL_TABLE()[idx].sg_attr = 0; // Need to update all groups, because they might be using "bg" and/or // "fg", which have been changed now. highlight_attr_set_all(); @@ -6826,7 +6826,7 @@ int hl_combine_attr(int char_attr, int prim_attr) // Copy all attributes from char_aep to the new entry new_en = *char_aep; } else { - memset(&new_en, 0, sizeof(new_en)); + new_en = (attrentry_T)ATTRENTRY_INIT; } spell_aep = syn_cterm_attr2entry(prim_attr); @@ -6859,6 +6859,7 @@ int hl_combine_attr(int char_attr, int prim_attr) /// \note this function does not apply exclusively to cterm attr contrary /// to what its name implies +/// \warn don't call it with attr 0 (i.e., the null attribute) attrentry_T *syn_cterm_attr2entry(int attr) { attr -= ATTR_OFF; @@ -7103,22 +7104,15 @@ syn_list_header(int did_header, int outlen, int id) return newline; } -/* - * Set the attribute numbers for a highlight group. - * Called after one of the attributes has changed. - */ -static void -set_hl_attr ( - int idx /* index in array */ -) +/// Set the attribute numbers for a highlight group. +/// Called after one of the attributes has changed. +/// @param idx corrected highlight index +static void +set_hl_attr(int idx) { attrentry_T at_en = ATTRENTRY_INIT; struct hl_group *sgp = HL_TABLE() + idx; - // The "Normal" group doesn't need an attribute number - if (sgp->sg_name_u != NULL && STRCMP(sgp->sg_name_u, "NORMAL") == 0) { - return; - } at_en.cterm_ae_attr = sgp->sg_cterm; at_en.cterm_fg_color = sgp->sg_cterm_fg; diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 256772489d..8e0e905bcd 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -288,7 +288,7 @@ static void terminfo_stop(UI *ui) static void tui_terminal_start(UI *ui) { TUIData *data = ui->data; - data->print_attrs = EMPTY_ATTRS; + data->print_attrs = HLATTRS_INIT; ugrid_init(&data->grid); terminfo_start(ui); update_size(ui); @@ -628,7 +628,7 @@ static void clear_region(UI *ui, int top, int bot, int left, int right) if (grid->bg == -1 && right == ui->width -1) { // Background is set to the default color and the right edge matches the // screen end, try to use terminal codes for clearing the requested area. - HlAttrs clear_attrs = EMPTY_ATTRS; + HlAttrs clear_attrs = HLATTRS_INIT; clear_attrs.foreground = grid->fg; clear_attrs.background = grid->bg; update_attrs(ui, clear_attrs); @@ -926,7 +926,7 @@ static void tui_scroll(UI *ui, Integer count) cursor_goto(ui, grid->top, grid->left); // also set default color attributes or some terminals can become funny if (scroll_clears_to_current_colour) { - HlAttrs clear_attrs = EMPTY_ATTRS; + HlAttrs clear_attrs = HLATTRS_INIT; clear_attrs.foreground = grid->fg; clear_attrs.background = grid->bg; update_attrs(ui, clear_attrs); diff --git a/src/nvim/ugrid.c b/src/nvim/ugrid.c index 7a0a16687e..2b5e96ee60 100644 --- a/src/nvim/ugrid.c +++ b/src/nvim/ugrid.c @@ -16,7 +16,7 @@ void ugrid_init(UGrid *grid) { - grid->attrs = EMPTY_ATTRS; + grid->attrs = HLATTRS_INIT; grid->fg = grid->bg = -1; grid->cells = NULL; } @@ -118,7 +118,7 @@ UCell *ugrid_put(UGrid *grid, uint8_t *text, size_t size) static void clear_region(UGrid *grid, int top, int bot, int left, int right) { - HlAttrs clear_attrs = EMPTY_ATTRS; + HlAttrs clear_attrs = HLATTRS_INIT; clear_attrs.foreground = grid->fg; clear_attrs.background = grid->bg; UGRID_FOREACH_CELL(grid, top, bot, left, right, { diff --git a/src/nvim/ugrid.h b/src/nvim/ugrid.h index 268362bf1b..1cf047502d 100644 --- a/src/nvim/ugrid.h +++ b/src/nvim/ugrid.h @@ -21,8 +21,6 @@ struct ugrid { UCell **cells; }; -#define EMPTY_ATTRS ((HlAttrs){ false, false, false, false, false, -1, -1, -1 }) - #define UGRID_FOREACH_CELL(grid, top, bot, left, right, code) \ do { \ for (int row = top; row <= bot; row++) { \ diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 01d3604159..184ae56cf2 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -166,6 +166,115 @@ void ui_event(char *name, Array args) } } +/// Retrieves attribute description from its id +/// +/// @param attr_id attribute id +Dictionary get_attr_by_id(Integer attr_id, Error *err) +{ + HlAttrs attrs = HLATTRS_INIT; + Dictionary dic = ARRAY_DICT_INIT; + + if (attr_id == 0) { + goto end; + } + + attrentry_T *aep = syn_cterm_attr2entry((int)attr_id); + if (!aep) { + api_set_error(err, kErrorTypeException, + "Invalid attribute id %d", attr_id); + return dic; + } + + attrs = attrentry2hlattrs(aep, p_tgc); + +end: + return hlattrs2dict(attrs); +} + + +/// Converts an attrentry_T into an HlAttrs +/// +/// @param[in] aep data to convert +/// @param use_rgb use 'gui*' settings if true, else resorts to 'cterm*' +HlAttrs attrentry2hlattrs(const attrentry_T *aep, bool use_rgb) +{ + assert(aep); + + HlAttrs attrs = HLATTRS_INIT; + int mask = 0; + + mask = use_rgb ? aep->rgb_ae_attr : aep->cterm_ae_attr; + + attrs.bold = mask & HL_BOLD; + attrs.underline = mask & HL_UNDERLINE; + attrs.undercurl = mask & HL_UNDERCURL; + attrs.italic = mask & HL_ITALIC; + attrs.reverse = mask & (HL_INVERSE | HL_STANDOUT); + + if (use_rgb) { + if (aep->rgb_fg_color != -1) { + attrs.foreground = aep->rgb_fg_color; + } + + if (aep->rgb_bg_color != -1) { + attrs.background = aep->rgb_bg_color; + } + + if (aep->rgb_sp_color != -1) { + attrs.special = aep->rgb_sp_color; + } + } else { + if (cterm_normal_fg_color != aep->cterm_fg_color) { + attrs.foreground = aep->cterm_fg_color - 1; + } + + if (cterm_normal_bg_color != aep->cterm_bg_color) { + attrs.background = aep->cterm_bg_color - 1; + } + } + + return attrs; +} + +Dictionary hlattrs2dict(HlAttrs attrs) +{ + Dictionary hl = ARRAY_DICT_INIT; + + if (attrs.bold) { + PUT(hl, "bold", BOOLEAN_OBJ(true)); + } + + if (attrs.underline) { + PUT(hl, "underline", BOOLEAN_OBJ(true)); + } + + if (attrs.undercurl) { + PUT(hl, "undercurl", BOOLEAN_OBJ(true)); + } + + if (attrs.italic) { + PUT(hl, "italic", BOOLEAN_OBJ(true)); + } + + if (attrs.reverse) { + PUT(hl, "reverse", BOOLEAN_OBJ(true)); + } + + if (attrs.foreground != -1) { + PUT(hl, "foreground", INTEGER_OBJ(attrs.foreground)); + } + + if (attrs.background != -1) { + PUT(hl, "background", INTEGER_OBJ(attrs.background)); + } + + if (attrs.special != -1) { + PUT(hl, "special", INTEGER_OBJ(attrs.special)); + } + + return hl; +} + void ui_refresh(void) { if (!ui_active()) { @@ -405,54 +514,20 @@ void ui_flush(void) static void set_highlight_args(int attr_code) { - HlAttrs rgb_attrs = { false, false, false, false, false, -1, -1, -1 }; + HlAttrs rgb_attrs = HLATTRS_INIT; HlAttrs cterm_attrs = rgb_attrs; if (attr_code == HL_NORMAL) { goto end; } - - int rgb_mask = 0; - int cterm_mask = 0; attrentry_T *aep = syn_cterm_attr2entry(attr_code); if (!aep) { goto end; } - rgb_mask = aep->rgb_ae_attr; - cterm_mask = aep->cterm_ae_attr; - - rgb_attrs.bold = rgb_mask & HL_BOLD; - rgb_attrs.underline = rgb_mask & HL_UNDERLINE; - rgb_attrs.undercurl = rgb_mask & HL_UNDERCURL; - rgb_attrs.italic = rgb_mask & HL_ITALIC; - rgb_attrs.reverse = rgb_mask & (HL_INVERSE | HL_STANDOUT); - cterm_attrs.bold = cterm_mask & HL_BOLD; - cterm_attrs.underline = cterm_mask & HL_UNDERLINE; - cterm_attrs.undercurl = cterm_mask & HL_UNDERCURL; - cterm_attrs.italic = cterm_mask & HL_ITALIC; - cterm_attrs.reverse = cterm_mask & (HL_INVERSE | HL_STANDOUT); - - if (aep->rgb_fg_color != normal_fg) { - rgb_attrs.foreground = aep->rgb_fg_color; - } - - if (aep->rgb_bg_color != normal_bg) { - rgb_attrs.background = aep->rgb_bg_color; - } - - if (aep->rgb_sp_color != normal_sp) { - rgb_attrs.special = aep->rgb_sp_color; - } - - if (cterm_normal_fg_color != aep->cterm_fg_color) { - cterm_attrs.foreground = aep->cterm_fg_color - 1; - } - - if (cterm_normal_bg_color != aep->cterm_bg_color) { - cterm_attrs.background = aep->cterm_bg_color - 1; - } + rgb_attrs = attrentry2hlattrs(aep, true); + cterm_attrs = attrentry2hlattrs(aep, false); end: UI_CALL(highlight_set, (ui->rgb ? rgb_attrs : cterm_attrs)); diff --git a/src/nvim/ui.h b/src/nvim/ui.h index 064f77fee1..f1ea0716e6 100644 --- a/src/nvim/ui.h +++ b/src/nvim/ui.h @@ -21,6 +21,9 @@ typedef struct { int foreground, background, special; } HlAttrs; +#define HLATTRS_INIT \ + ((HlAttrs){ false, false, false, false, false, -1, -1, -1 }) + typedef struct ui_t UI; struct ui_t { -- cgit From e3a2cca3878f44252eccdc1918cc8854145de860 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sun, 27 Aug 2017 00:33:36 +0200 Subject: Increased test coverage for RGB and cterm --- src/nvim/api/vim.c | 4 ++-- src/nvim/syntax.c | 26 ++++++++++++++++++++++++++ src/nvim/ui.c | 25 ------------------------- 3 files changed, 28 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 0459d9235d..bf3e4bc6a0 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -78,7 +78,7 @@ Dictionary nvim_get_hl_by_name(String name, Error *err) /// Retrieves highlight description from its id /// -/// @param hl_id highlight id as returned by hlID() +/// @param hl_id highlight id as returned by |hlID()| /// @see nvim_get_hl_by_name Dictionary nvim_get_hl_by_id(Integer hl_id, Error *err) FUNC_API_SINCE(3) @@ -89,7 +89,7 @@ Dictionary nvim_get_hl_by_id(Integer hl_id, Error *err) return dic; } int attrcode = syn_id2attr((int)hl_id); - return get_attr_by_id(attrcode, err); + return hl_get_attr_by_id(attrcode, err); } /// Passes input keys to Nvim. diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index fdb7196fc4..2f48cc8757 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -8221,6 +8221,32 @@ RgbValue name_to_color(const uint8_t *name) return -1; } +/// Retrieves attribute description from its id +/// +/// @param attr_id attribute id +Dictionary hl_get_attr_by_id(Integer attr_id, Error *err) +{ + HlAttrs attrs = HLATTRS_INIT; + Dictionary dic = ARRAY_DICT_INIT; + + if (attr_id == 0) { + goto end; + } + + attrentry_T *aep = syn_cterm_attr2entry((int)attr_id); + if (!aep) { + api_set_error(err, kErrorTypeException, + "Invalid attribute id %d", attr_id); + return dic; + } + + attrs = attrentry2hlattrs(aep, p_tgc); + +end: + return hlattrs2dict(attrs); +} + + /************************************** * End of Highlighting stuff * **************************************/ diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 184ae56cf2..afe7a51d43 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -166,31 +166,6 @@ void ui_event(char *name, Array args) } } -/// Retrieves attribute description from its id -/// -/// @param attr_id attribute id -Dictionary get_attr_by_id(Integer attr_id, Error *err) -{ - HlAttrs attrs = HLATTRS_INIT; - Dictionary dic = ARRAY_DICT_INIT; - - if (attr_id == 0) { - goto end; - } - - attrentry_T *aep = syn_cterm_attr2entry((int)attr_id); - if (!aep) { - api_set_error(err, kErrorTypeException, - "Invalid attribute id %d", attr_id); - return dic; - } - - attrs = attrentry2hlattrs(aep, p_tgc); - -end: - return hlattrs2dict(attrs); -} - /// Converts an attrentry_T into an HlAttrs /// -- cgit From 3a006486397d611234abd9b429bce0b44d6b7747 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sun, 3 Sep 2017 05:25:57 +0200 Subject: Changed prototypes to accept a boolean "rgb" --- src/nvim/api/vim.c | 10 ++++++---- src/nvim/syntax.c | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index bf3e4bc6a0..0c3c497533 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -59,9 +59,10 @@ void nvim_command(String command, Error *err) /// Retrieves highlight description from its name /// /// @param name Highlight group name +/// @param rgb True to export GUI values /// @return a highlight description e.g. {'bold': true, 'bg': 123, 'fg': 42} /// @see nvim_get_hl_by_id -Dictionary nvim_get_hl_by_name(String name, Error *err) +Dictionary nvim_get_hl_by_name(String name, Boolean rgb, Error *err) FUNC_API_SINCE(3) { Dictionary result = ARRAY_DICT_INIT; @@ -72,15 +73,16 @@ Dictionary nvim_get_hl_by_name(String name, Error *err) name.data); return result; } - result = nvim_get_hl_by_id(id, err); + result = nvim_get_hl_by_id(id, rgb, err); return result; } /// Retrieves highlight description from its id /// /// @param hl_id highlight id as returned by |hlID()| +/// @param rgb True to export GUI values /// @see nvim_get_hl_by_name -Dictionary nvim_get_hl_by_id(Integer hl_id, Error *err) +Dictionary nvim_get_hl_by_id(Integer hl_id, Boolean rgb, Error *err) FUNC_API_SINCE(3) { Dictionary dic = ARRAY_DICT_INIT; @@ -89,7 +91,7 @@ Dictionary nvim_get_hl_by_id(Integer hl_id, Error *err) return dic; } int attrcode = syn_id2attr((int)hl_id); - return hl_get_attr_by_id(attrcode, err); + return hl_get_attr_by_id(attrcode, rgb, err); } /// Passes input keys to Nvim. diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 2f48cc8757..32567a63de 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -8224,7 +8224,7 @@ RgbValue name_to_color(const uint8_t *name) /// Retrieves attribute description from its id /// /// @param attr_id attribute id -Dictionary hl_get_attr_by_id(Integer attr_id, Error *err) +Dictionary hl_get_attr_by_id(Integer attr_id, Boolean rgb, Error *err) { HlAttrs attrs = HLATTRS_INIT; Dictionary dic = ARRAY_DICT_INIT; @@ -8240,7 +8240,7 @@ Dictionary hl_get_attr_by_id(Integer attr_id, Error *err) return dic; } - attrs = attrentry2hlattrs(aep, p_tgc); + attrs = attrentry2hlattrs(aep, rgb); end: return hlattrs2dict(attrs); -- cgit From 481e40cc8ca061f5c3a68f56f30ee96e9086da4d Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sat, 30 Sep 2017 11:44:50 +0900 Subject: Remove duplicate ATTRENTRY_INIT --- src/nvim/syntax.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 32567a63de..933baad901 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6825,8 +6825,6 @@ int hl_combine_attr(int char_attr, int prim_attr) if (char_aep != NULL) { // Copy all attributes from char_aep to the new entry new_en = *char_aep; - } else { - new_en = (attrentry_T)ATTRENTRY_INIT; } spell_aep = syn_cterm_attr2entry(prim_attr); -- cgit From 4543fc1612183da659a9ca10f826ae59e2186f22 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sat, 30 Sep 2017 22:20:47 +0200 Subject: menu_get: prettyprint special chars --- src/nvim/menu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 0db250d111..69700e34fd 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -698,7 +698,9 @@ static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes) if (*menu->strings[bit] == NUL) { tv_dict_add_str(impl, S_LEN("rhs"), (char *)""); } else { - tv_dict_add_str(impl, S_LEN("rhs"), (char *)menu->strings[bit]); + tv_dict_add_allocated_str(impl, S_LEN("rhs"), + str2special_save((char *)menu->strings[bit], + false, false)); } tv_dict_add_nr(impl, S_LEN("silent"), menu->silent[bit]); tv_dict_add_nr(impl, S_LEN("enabled"), -- cgit From 2b133101cf67b523c2503ef715dfb9ebfa732da2 Mon Sep 17 00:00:00 2001 From: Ignas Anikevicius Date: Mon, 18 Sep 2017 21:06:55 +0300 Subject: win: vim_FullName(): force backslashes #7287 - Replace obvious cases of '/' literal with PATHSEP. (There are still some remaining cases that need closer inspection.) - Fixup tests: ui/screen_basic closes #7117 ref https://github.com/neovim/neovim/issues/2471#issuecomment-271193714 --- src/nvim/path.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/path.c b/src/nvim/path.c index f2339c8046..51adcfb135 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -1690,6 +1690,9 @@ int vim_FullName(const char *fname, char *buf, size_t len, bool force) if (strlen(fname) > (len - 1)) { xstrlcpy(buf, fname, len); // truncate +#ifdef WIN32 + slash_adjust(buf); +#endif return FAIL; } @@ -1702,6 +1705,9 @@ int vim_FullName(const char *fname, char *buf, size_t len, bool force) if (rv == FAIL) { xstrlcpy(buf, fname, len); // something failed; use the filename } +#ifdef WIN32 + slash_adjust(buf); +#endif return rv; } @@ -2196,11 +2202,11 @@ static int path_get_absolute_path(const char_u *fname, char_u *buf, // expand it if forced or not an absolute path if (force || !path_is_absolute_path(fname)) { - if ((p = vim_strrchr(fname, '/')) != NULL) { + if ((p = vim_strrchr(fname, PATHSEP)) != NULL) { // relative to root if (p == fname) { // only one path component - relative_directory[0] = '/'; + relative_directory[0] = PATHSEP; relative_directory[1] = NUL; } else { assert(p >= fname); -- cgit From 41f624a85b95d54ce038637cbe53530ad1b99f53 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Mon, 2 Oct 2017 14:55:19 +0200 Subject: Deal with NOP, add actext to output --- src/nvim/menu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 69700e34fd..88d968704b 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -682,6 +682,10 @@ static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes) tv_dict_add_str(dict, S_LEN("shortcut"), buf); } + if (menu->actext) { + tv_dict_add_str(dict, S_LEN("actext"), (char *)menu->actext); + } + if (menu->modes & MENU_TIP_MODE && menu->strings[MENU_INDEX_TIP]) { tv_dict_add_str(dict, S_LEN("tooltip"), (char *)menu->strings[MENU_INDEX_TIP]); @@ -695,13 +699,9 @@ static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes) for (int bit = 0; bit < MENU_MODES; bit++) { if ((menu->modes & modes & (1 << bit)) != 0) { dict_T *impl = tv_dict_alloc(); - if (*menu->strings[bit] == NUL) { - tv_dict_add_str(impl, S_LEN("rhs"), (char *)""); - } else { - tv_dict_add_allocated_str(impl, S_LEN("rhs"), - str2special_save((char *)menu->strings[bit], - false, false)); - } + tv_dict_add_allocated_str(impl, S_LEN("rhs"), + str2special_save((char *)menu->strings[bit], + false, false)); tv_dict_add_nr(impl, S_LEN("silent"), menu->silent[bit]); tv_dict_add_nr(impl, S_LEN("enabled"), (menu->enabled & (1 << bit)) ? 1 : 0); -- cgit From 235fda5f86d80b1aa7d7cbcb41e3399c556b7455 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 3 Oct 2017 14:53:11 -0400 Subject: Stub ngettext when libintl isn't available This should have been included in #6547 as part of vim-patch:7.4.2152. Closes #7352 --- src/nvim/gettext.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/gettext.h b/src/nvim/gettext.h index aa0e97233e..60317b8484 100644 --- a/src/nvim/gettext.h +++ b/src/nvim/gettext.h @@ -13,6 +13,7 @@ #else # define _(x) ((char *)(x)) # define N_(x) x +# define ngettext(x, xs, n) ((n) == 1 ? (x) : (xs)) # define bindtextdomain(x, y) // empty # define bind_textdomain_codeset(x, y) // empty # define textdomain(x) // empty -- cgit From 5f4d2edeeea4d05761811d652dee8067fdbbae2a Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 19 Aug 2017 18:33:14 -0700 Subject: 'titleold': set UI title on exit #7191 closes #7129 ref #4063 --- src/nvim/buffer.c | 13 ++++++++++--- src/nvim/globals.h | 1 + src/nvim/option.c | 1 + src/nvim/os_unix.c | 7 +++++++ 4 files changed, 19 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 724a8578ac..950010b13b 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3069,9 +3069,16 @@ static bool ti_change(char_u *str, char_u **last) /// Set current window title void resettitle(void) { - ui_call_set_title(cstr_as_string((char *)lasttitle)); - ui_call_set_icon(cstr_as_string((char *)lasticon)); - ui_flush(); + // if icon change, should the title be reset too? + if (p_icon) { + ui_call_set_title(cstr_as_string((char *)lasttitle)); + ui_call_set_icon(cstr_as_string((char *)lasticon)); + } else if (p_title) { + ui_call_set_title(cstr_as_string((char *)lasttitle)); + } + if (p_title || p_icon) { + ui_flush(); + } } # if defined(EXITFREE) diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 300e506854..62bb817c4c 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -279,6 +279,7 @@ EXTERN int need_wait_return INIT(= 0); /* need to wait for return later */ EXTERN int did_wait_return INIT(= FALSE); /* wait_return() was used and nothing written since then */ EXTERN int need_maketitle INIT(= TRUE); /* call maketitle() soon */ +EXTERN int did_enable_title INIT(= FALSE); /* did set title */ EXTERN int quit_more INIT(= FALSE); /* 'q' hit at "--more--" msg */ #if defined(UNIX) || defined(MACOS_X) diff --git a/src/nvim/option.c b/src/nvim/option.c index 13aadb71bb..3a7499f195 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1953,6 +1953,7 @@ did_set_title ( if (starting != NO_SCREEN) { maketitle(); resettitle(); + did_enable_title = true; } } diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c index 692bcc97f4..5855a874c4 100644 --- a/src/nvim/os_unix.c +++ b/src/nvim/os_unix.c @@ -15,6 +15,7 @@ #include #include "nvim/api/private/handle.h" +#include "nvim/api/private/helpers.h" #include "nvim/vim.h" #include "nvim/ascii.h" #include "nvim/os_unix.h" @@ -137,6 +138,12 @@ void mch_exit(int r) FUNC_ATTR_NORETURN { exiting = true; + if ((p_title + || (did_enable_title + && (p_titlestring == NULL || STRLEN(p_titlestring) == 0))) + && p_titleold != NULL) { + ui_call_set_title(cstr_as_string((char *)p_titleold)); + } ui_builtin_stop(); ui_flush(); ml_close_all(true); // remove all memfiles -- cgit From 70e84a7c4c7bfad9b3a0ec18fd219f51205c03f8 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 5 Oct 2017 09:14:18 +0200 Subject: 'titleold': simplify behavior - default 'titleold' to empty - set title on exit if 'title' is enabled and 'titleold' is non-empty - update docs --- src/nvim/buffer.c | 5 +---- src/nvim/globals.h | 1 - src/nvim/option.c | 1 - src/nvim/options.lua | 2 +- src/nvim/os_unix.c | 5 +---- 5 files changed, 3 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 950010b13b..fbfb4e02ea 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3069,14 +3069,11 @@ static bool ti_change(char_u *str, char_u **last) /// Set current window title void resettitle(void) { - // if icon change, should the title be reset too? if (p_icon) { - ui_call_set_title(cstr_as_string((char *)lasttitle)); ui_call_set_icon(cstr_as_string((char *)lasticon)); - } else if (p_title) { - ui_call_set_title(cstr_as_string((char *)lasttitle)); } if (p_title || p_icon) { + ui_call_set_title(cstr_as_string((char *)lasttitle)); ui_flush(); } } diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 62bb817c4c..300e506854 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -279,7 +279,6 @@ EXTERN int need_wait_return INIT(= 0); /* need to wait for return later */ EXTERN int did_wait_return INIT(= FALSE); /* wait_return() was used and nothing written since then */ EXTERN int need_maketitle INIT(= TRUE); /* call maketitle() soon */ -EXTERN int did_enable_title INIT(= FALSE); /* did set title */ EXTERN int quit_more INIT(= FALSE); /* 'q' hit at "--more--" msg */ #if defined(UNIX) || defined(MACOS_X) diff --git a/src/nvim/option.c b/src/nvim/option.c index 3a7499f195..13aadb71bb 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1953,7 +1953,6 @@ did_set_title ( if (starting != NO_SCREEN) { maketitle(); resettitle(); - did_enable_title = true; } } diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 103227f6b5..84ccb2e28d 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -2498,7 +2498,7 @@ return { no_mkrc=true, vi_def=true, varname='p_titleold', - defaults={if_true={vi=N_("Thanks for flying Vim")}} + defaults={if_true={vi=N_("")}} }, { full_name='titlestring', diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c index 5855a874c4..2748de7329 100644 --- a/src/nvim/os_unix.c +++ b/src/nvim/os_unix.c @@ -138,10 +138,7 @@ void mch_exit(int r) FUNC_ATTR_NORETURN { exiting = true; - if ((p_title - || (did_enable_title - && (p_titlestring == NULL || STRLEN(p_titlestring) == 0))) - && p_titleold != NULL) { + if (p_title && *p_titleold != NUL) { ui_call_set_title(cstr_as_string((char *)p_titleold)); } ui_builtin_stop(); -- cgit From 73b50de925c10aaf0db2ffed47ec8459b0730cd1 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 5 Oct 2017 09:49:17 +0200 Subject: 'titleold': move logic to getout() --- src/nvim/main.c | 5 +++++ src/nvim/os_unix.c | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index 024c56dd05..ea7a58bda3 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -649,6 +649,11 @@ void getout(int exitval) /* Position the cursor again, the autocommands may have moved it */ ui_cursor_goto((int)Rows - 1, 0); + // Apply 'titleold'. + if (p_title && *p_titleold != NUL) { + ui_call_set_title(cstr_as_string((char *)p_titleold)); + } + #if defined(USE_ICONV) && defined(DYNAMIC_ICONV) iconv_end(); #endif diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c index 2748de7329..692bcc97f4 100644 --- a/src/nvim/os_unix.c +++ b/src/nvim/os_unix.c @@ -15,7 +15,6 @@ #include #include "nvim/api/private/handle.h" -#include "nvim/api/private/helpers.h" #include "nvim/vim.h" #include "nvim/ascii.h" #include "nvim/os_unix.h" @@ -138,9 +137,6 @@ void mch_exit(int r) FUNC_ATTR_NORETURN { exiting = true; - if (p_title && *p_titleold != NUL) { - ui_call_set_title(cstr_as_string((char *)p_titleold)); - } ui_builtin_stop(); ui_flush(); ml_close_all(true); // remove all memfiles -- cgit From a4019bc9f6478941fe75879e81d37bd628bc94c5 Mon Sep 17 00:00:00 2001 From: Andrew Ferreira Date: Sat, 7 Oct 2017 06:45:23 -0400 Subject: eval.c: ga_concat_esc() #7357 vim-patch:2368917d8f0c0a997eac7a51ddfaa748dc528392 closes #7256 --- src/nvim/eval.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 5ee91d417a..86b99c2783 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6733,6 +6733,39 @@ static void prepare_assert_error(garray_T *gap) } } +// Append "str" to "gap", escaping unprintable characters. +// Changes NL to \n, CR to \r, etc. +static void ga_concat_esc(garray_T *gap, char_u *str) +{ + char_u *p; + char_u buf[NUMBUFLEN]; + + if (str == NULL) { + ga_concat(gap, (char_u *)"NULL"); + return; + } + + for (p = str; *p != NUL; p++) { + switch (*p) { + case BS: ga_concat(gap, (char_u *)"\\b"); break; + case ESC: ga_concat(gap, (char_u *)"\\e"); break; + case FF: ga_concat(gap, (char_u *)"\\f"); break; + case NL: ga_concat(gap, (char_u *)"\\n"); break; + case TAB: ga_concat(gap, (char_u *)"\\t"); break; + case CAR: ga_concat(gap, (char_u *)"\\r"); break; + case '\\': ga_concat(gap, (char_u *)"\\\\"); break; + default: + if (*p < ' ') { + vim_snprintf((char *)buf, NUMBUFLEN, "\\x%02x", *p); + ga_concat(gap, buf); + } else { + ga_append(gap, *p); + } + break; + } + } +} + // Fill "gap" with information about an assert error. static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, char_u *exp_str, typval_T *exp_tv, @@ -6753,11 +6786,11 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, ga_concat(gap, (char_u *)"Expected "); } if (exp_str == NULL) { - tofree = (char_u *) encode_tv2string(exp_tv, NULL); - ga_concat(gap, tofree); + tofree = (char_u *)encode_tv2string(exp_tv, NULL); + ga_concat_esc(gap, tofree); xfree(tofree); } else { - ga_concat(gap, exp_str); + ga_concat_esc(gap, exp_str); } if (atype != ASSERT_NOTEQUAL) { if (atype == ASSERT_MATCH) { @@ -6768,7 +6801,7 @@ static void fill_assert_error(garray_T *gap, typval_T *opt_msg_tv, ga_concat(gap, (char_u *)" but got "); } tofree = (char_u *)encode_tv2string(got_tv, NULL); - ga_concat(gap, tofree); + ga_concat_esc(gap, tofree); xfree(tofree); } } -- cgit From 9ad7529f705c883e13fba9a014696fb37318145f Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sat, 7 Oct 2017 20:32:37 +0800 Subject: vim-patch:8.0.0157 (#7362) Problem: No command line completion for ":syntax spell" and ":syntax sync". Solution: Implement the completion. (Dominique Pelle) https://github.com/vim/vim/commit/2d02839050a2557bf36dab37ccd9f92168a757d1 --- src/nvim/syntax.c | 36 +++++++++++++++++++++++++++++------- src/nvim/testdir/test_syntax.vim | 8 ++++++++ src/nvim/version.c | 2 +- 3 files changed, 38 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 65c0e2464a..ddc3f5c27b 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5567,8 +5567,10 @@ bool syntax_present(win_T *win) static enum { - EXP_SUBCMD, /* expand ":syn" sub-commands */ - EXP_CASE /* expand ":syn case" arguments */ + EXP_SUBCMD, // expand ":syn" sub-commands + EXP_CASE, // expand ":syn case" arguments + EXP_SPELL, // expand ":syn spell" arguments + EXP_SYNC // expand ":syn sync" arguments } expand_what; /* @@ -5612,6 +5614,10 @@ void set_context_in_syntax_cmd(expand_T *xp, const char *arg) xp->xp_context = EXPAND_NOTHING; } else if (STRNICMP(arg, "case", p - arg) == 0) { expand_what = EXP_CASE; + } else if (STRNICMP(arg, "spell", p - arg) == 0) { + expand_what = EXP_SPELL; + } else if (STRNICMP(arg, "sync", p - arg) == 0) { + expand_what = EXP_SYNC; } else if (STRNICMP(arg, "keyword", p - arg) == 0 || STRNICMP(arg, "region", p - arg) == 0 || STRNICMP(arg, "match", p - arg) == 0 @@ -5624,17 +5630,33 @@ void set_context_in_syntax_cmd(expand_T *xp, const char *arg) } } -static char *(case_args[]) = {"match", "ignore", NULL}; - /* * Function given to ExpandGeneric() to obtain the list syntax names for * expansion. */ char_u *get_syntax_name(expand_T *xp, int idx) { - if (expand_what == EXP_SUBCMD) - return (char_u *)subcommands[idx].name; - return (char_u *)case_args[idx]; + switch (expand_what) { + case EXP_SUBCMD: + return (char_u *)subcommands[idx].name; + case EXP_CASE: { + static char *case_args[] = { "match", "ignore", NULL }; + return (char_u *)case_args[idx]; + } + case EXP_SPELL: { + static char *spell_args[] = + { "toplevel", "notoplevel", "default", NULL }; + return (char_u *)spell_args[idx]; + } + case EXP_SYNC: { + static char *sync_args[] = + { "ccomment", "clear", "fromstart", + "linebreaks=", "linecont", "lines=", "match", + "maxlines=", "minlines=", "region", NULL }; + return (char_u *)sync_args[idx]; + } + } + return NULL; } diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index af2cbbfe8e..05e930d984 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -76,3 +76,11 @@ func Test_syntax_after_reload() call assert_true(exists('g:gotit')) call delete('Xsomefile') endfunc + +func Test_syntax_completion() + call feedkeys(":syn spell \\\"\", 'tx') + call assert_equal('"syn spell default notoplevel toplevel', @:) + + call feedkeys(":syn sync \\\"\", 'tx') + call assert_equal('"syn sync ccomment clear fromstart linebreaks= linecont lines= match maxlines= minlines= region', @:) +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index b0d4e194fa..76897088a1 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -946,7 +946,7 @@ static const int included_patches[] = { // 160, 159, 158, - // 157, + 157, 156, // 155, // 154, -- cgit From 7a832c312f13bd6be9350952cdac3bd30613a824 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 7 Oct 2017 15:55:25 +0200 Subject: syntax: 'cursorcolumn', 'colorcolumn': low priority #6380 --- src/nvim/screen.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 921ef06c7b..a6418a6f27 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2201,16 +2201,16 @@ win_line ( int change_end = -1; /* last col of changed area */ colnr_T trailcol = MAXCOL; /* start of trailing spaces */ int need_showbreak = false; // overlong line, skip first x chars - int line_attr = 0; /* attribute for the whole line */ - matchitem_T *cur; /* points to the match list */ - match_T *shl; /* points to search_hl or a match */ - int shl_flag; /* flag to indicate whether search_hl - has been processed or not */ - int prevcol_hl_flag; /* flag to indicate whether prevcol - equals startcol of search_hl or one - of the matches */ - int prev_c = 0; /* previous Arabic character */ - int prev_c1 = 0; /* first composing char for prev_c */ + int line_attr = 0; // attribute for the whole line + matchitem_T *cur; // points to the match list + match_T *shl; // points to search_hl or a match + int shl_flag; // flag to indicate whether search_hl + // has been processed or not + int prevcol_hl_flag; // flag to indicate whether prevcol + // equals startcol of search_hl or one + // of the matches + int prev_c = 0; // previous Arabic character + int prev_c1 = 0; // first composing char for prev_c int did_line_attr = 0; bool search_attr_from_match = false; // if search_attr is from :match @@ -3594,15 +3594,13 @@ win_line ( && lcs_eol_one > 0) { // Display a '$' after the line or highlight an extra // character if the line break is included. - // For a diff line the highlighting continues after the - // "$". + // For a diff line the highlighting continues after the "$". if (diff_hlf == (hlf_T)0 && line_attr == 0) { - /* In virtualedit, visual selections may extend - * beyond end of line. */ + // In virtualedit, visual selections may extend beyond end of line. if (area_highlighting && virtual_active() - && tocol != MAXCOL && vcol < tocol) + && tocol != MAXCOL && vcol < tocol) { n_extra = 0; - else { + } else { p_extra = at_end_str; n_extra = 1; c_extra = NUL; @@ -4035,10 +4033,10 @@ win_line ( if (wp->w_p_cuc && VCOL_HLC == (long)wp->w_virtcol && lnum != wp->w_cursor.lnum) { vcol_save_attr = char_attr; - char_attr = hl_combine_attr(char_attr, win_hl_attr(wp, HLF_CUC)); + char_attr = hl_combine_attr(win_hl_attr(wp, HLF_CUC), char_attr); } else if (draw_color_col && VCOL_HLC == *color_cols) { vcol_save_attr = char_attr; - char_attr = hl_combine_attr(char_attr, win_hl_attr(wp, HLF_MC)); + char_attr = hl_combine_attr(win_hl_attr(wp, HLF_MC), char_attr); } } -- cgit From d1874ab2821d076397290cc154d87ec2dc352c79 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 7 Oct 2017 16:06:46 +0200 Subject: syntax: 'cursorline': low priority #6380 --- src/nvim/screen.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index a6418a6f27..5659f30f64 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2202,6 +2202,7 @@ win_line ( colnr_T trailcol = MAXCOL; /* start of trailing spaces */ int need_showbreak = false; // overlong line, skip first x chars int line_attr = 0; // attribute for the whole line + int line_attr_low_priority = 0; // current line, lowest priority matchitem_T *cur; // points to the match list match_T *shl; // points to search_hl or a match int shl_flag; // flag to indicate whether search_hl @@ -2427,10 +2428,17 @@ win_line ( filler_lines = wp->w_topfill; filler_todo = filler_lines; - /* If this line has a sign with line highlighting set line_attr. */ + // 'cursorline' highlighting for the current window. Not when Visual mode is + // active, because it's not clear what is selected then. + if (wp->w_p_cul && lnum == wp->w_cursor.lnum + && !(wp == curwin && VIsual_active)) { + line_attr_low_priority = win_hl_attr(wp, HLF_CUL); + } + v = buf_getsigntype(wp->w_buffer, lnum, SIGN_LINEHL); - if (v != 0) - line_attr = sign_get_attr((int)v, TRUE); + if (v != 0) { + line_attr = sign_get_attr((int)v, true); + } // Highlight the current line in the quickfix window. if (bt_quickfix(wp->w_buffer) && qf_current_entry(wp) == lnum) { @@ -2441,7 +2449,7 @@ win_line ( line_attr = hl_combine_attr(wp->w_hl_attr_normal, line_attr); } - if (line_attr != 0) { + if (line_attr_low_priority || line_attr) { area_highlighting = true; } @@ -2663,20 +2671,6 @@ win_line ( cur = cur->next; } - /* Cursor line highlighting for 'cursorline' in the current window. Not - * when Visual mode is active, because it's not clear what is selected - * then. */ - if (wp->w_p_cul && lnum == wp->w_cursor.lnum - && !(wp == curwin && VIsual_active)) { - if (line_attr != 0 && !(State & INSERT) && bt_quickfix(wp->w_buffer) - && qf_current_entry(wp) == lnum) { - line_attr = hl_combine_attr(win_hl_attr(wp, HLF_CUL), line_attr); - } else { - line_attr = win_hl_attr(wp, HLF_CUL); - } - area_highlighting = true; - } - off = (unsigned)(current_ScreenLine - ScreenLines); col = 0; if (wp->w_p_rl) { @@ -3595,7 +3589,9 @@ win_line ( // Display a '$' after the line or highlight an extra // character if the line break is included. // For a diff line the highlighting continues after the "$". - if (diff_hlf == (hlf_T)0 && line_attr == 0) { + if (diff_hlf == (hlf_T)0 + && line_attr == 0 + && line_attr_low_priority == 0) { // In virtualedit, visual selections may extend beyond end of line. if (area_highlighting && virtual_active() && tocol != MAXCOL && vcol < tocol) { @@ -3659,7 +3655,7 @@ win_line ( (col < wp->w_width))) { c = ' '; ptr--; // put it back at the NUL - } else if ((diff_hlf != (hlf_T)0 || line_attr != 0) + } else if ((diff_hlf != (hlf_T)0 || line_attr_low_priority || line_attr) && (wp->w_p_rl ? (col >= 0) : (col - boguscols < wp->w_width))) { @@ -3671,7 +3667,8 @@ win_line ( did_line_attr++; // don't do search HL for the rest of the line - if (line_attr != 0 && char_attr == search_attr && col > 0) { + if ((line_attr_low_priority || line_attr) + && char_attr == search_attr && col > 0) { char_attr = line_attr; } if (diff_hlf == HLF_TXD) { @@ -4040,6 +4037,9 @@ win_line ( } } + // Apply `line_attr_low_priority` now, so that everthing can override it. + char_attr = hl_combine_attr(line_attr_low_priority, char_attr); + /* * Store character to be displayed. * Skip characters that are left of the screen for 'nowrap'. -- cgit From c0e45d97b0cbc700cd6f2b9733c15875339262df Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sat, 30 Sep 2017 21:43:03 +0800 Subject: vim-patch:8.0.0148 #7344 Problem: When a C preprocessor statement has two line continuations the following line does not have the right indent. (Ken Takata) Solution: Add the indent of the previous continuation line. (Hirohito Higashi) https://github.com/vim/vim/commit/c6aa475a27e3ed1645446b014c32ebf68d005d49 --- src/nvim/indent_c.c | 82 +++++++++++++++++++++++++++++++---------------------- src/nvim/version.c | 2 +- 2 files changed, 49 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 4a6393ac36..279d45bb0a 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -734,16 +734,20 @@ static int cin_ispreproc(char_u *s) return FALSE; } -/* - * Return TRUE if line "*pp" at "*lnump" is a preprocessor statement or a - * continuation line of a preprocessor statement. Decrease "*lnump" to the - * start and return the line in "*pp". - */ -static int cin_ispreproc_cont(char_u **pp, linenr_T *lnump) +/// Return TRUE if line "*pp" at "*lnump" is a preprocessor statement or a +/// continuation line of a preprocessor statement. Decrease "*lnump" to the +/// start and return the line in "*pp". +/// Put the amount of indent in "*amount". +static int cin_ispreproc_cont(char_u **pp, linenr_T *lnump, int *amount) { char_u *line = *pp; linenr_T lnum = *lnump; - int retval = FALSE; + int retval = false; + int candidate_amount = *amount; + + if (*line != NUL && line[STRLEN(line) - 1] == '\\') { + candidate_amount = get_indent_lnum(lnum); + } for (;; ) { if (cin_ispreproc(line)) { @@ -758,8 +762,12 @@ static int cin_ispreproc_cont(char_u **pp, linenr_T *lnump) break; } - if (lnum != *lnump) + if (lnum != *lnump) { *pp = ml_get(*lnump); + } + if (retval) { + *amount = candidate_amount; + } return retval; } @@ -1994,10 +2002,12 @@ int get_c_indent(void) amount = -1; for (lnum = cur_curpos.lnum - 1; lnum > our_paren_pos.lnum; --lnum) { l = skipwhite(ml_get(lnum)); - if (cin_nocode(l)) /* skip comment lines */ + if (cin_nocode(l)) { // skip comment lines continue; - if (cin_ispreproc_cont(&l, &lnum)) - continue; /* ignore #define, #if, etc. */ + } + if (cin_ispreproc_cont(&l, &lnum, &amount)) { + continue; // ignore #define, #if, etc. + } curwin->w_cursor.lnum = lnum; /* Skip a comment or raw string. XXX */ @@ -2353,15 +2363,14 @@ int get_c_indent(void) * up with it. */ if (curwin->w_cursor.lnum <= ourscope) { - /* we reached end of scope: - * if looking for an enum or structure initialization - * go further back: - * if it is an initializer (enum xxx or xxx =), then - * don't add ind_continuation, otherwise it is a variable - * declaration: - * int x, - * here; <-- add ind_continuation - */ + // We reached end of scope: + // If looking for a enum or structure initialization + // go further back: + // If it is an initializer (enum xxx or xxx =), then + // don't add ind_continuation, otherwise it is a variable + // declaration: + // int x, + // here; <-- add ind_continuation if (lookfor == LOOKFOR_ENUM_OR_INIT) { if (curwin->w_cursor.lnum == 0 || curwin->w_cursor.lnum @@ -2389,11 +2398,12 @@ int get_c_indent(void) continue; } - /* - * Skip preprocessor directives and blank lines. - */ - if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum)) + // + // Skip preprocessor directives and blank lines. + // + if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)) { continue; + } if (cin_nocode(l)) continue; @@ -2497,9 +2507,10 @@ int get_c_indent(void) continue; } - /* Skip preprocessor directives and blank lines. */ - if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum)) + // Skip preprocessor directives and blank lines. + if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)) { continue; + } /* Finally the actual check for "namespace". */ if (cin_is_cpp_namespace(l)) { @@ -2662,9 +2673,10 @@ int get_c_indent(void) * unlocked it) */ l = get_cursor_line_ptr(); - if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum) - || cin_nocode(l)) + if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount) + || cin_nocode(l)) { continue; + } /* * Are we at the start of a cpp base class declaration or @@ -3309,11 +3321,12 @@ term_again: break; } - /* - * Skip preprocessor directives and blank lines. - */ - if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum)) + // + // Skip preprocessor directives and blank lines. + // + if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)) { continue; + } if (cin_nocode(l)) continue; @@ -3405,9 +3418,10 @@ term_again: while (curwin->w_cursor.lnum > 1) { look = ml_get(--curwin->w_cursor.lnum); - if (!(cin_nocode(look) || cin_ispreproc_cont( - &look, &curwin->w_cursor.lnum))) + if (!(cin_nocode(look) + || cin_ispreproc_cont(&look, &curwin->w_cursor.lnum, &amount))) { break; + } } if (curwin->w_cursor.lnum > 0 && cin_ends_in(look, (char_u *)"}", NULL)) diff --git a/src/nvim/version.c b/src/nvim/version.c index 76897088a1..8bcf8c7a59 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -955,7 +955,7 @@ static const int included_patches[] = { // 151, 150, 149, - // 148, + 148, 147, 146, // 145 NA -- cgit From e3ca1e604630d930ddc49fccb9a1541d381b1915 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sat, 7 Oct 2017 23:20:34 +0800 Subject: vim-patch:8.0.0142 (#7335) see also #7082 Problem: Normal colors are wrong with 'termguicolors'. Solution: Initialize to INVALCOLOR instead of zero. (Ben Jackson, closes vim/vim#1344) https://github.com/vim/vim/commit/0cdb72aa38c4a0140c94d56bf8bc17cb30260ebf --- src/nvim/syntax.c | 2 -- src/nvim/version.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index ddc3f5c27b..8de81f02df 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6847,8 +6847,6 @@ int hl_combine_attr(int char_attr, int prim_attr) if (char_aep != NULL) { // Copy all attributes from char_aep to the new entry new_en = *char_aep; - } else { - memset(&new_en, 0, sizeof(new_en)); } spell_aep = syn_cterm_attr2entry(prim_attr); diff --git a/src/nvim/version.c b/src/nvim/version.c index 8bcf8c7a59..8015d7520d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -961,7 +961,7 @@ static const int included_patches[] = { // 145 NA // 144 NA 143, - // 142, + 142, // 141, // 140, // 139 NA -- cgit From d916ea107a243768ff5b272a0bf2522e42f51b65 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 7 Oct 2017 18:05:02 +0200 Subject: resettitle(): remove conditions (#7360) These conditions were added in #7358 for no apparent reason. ref https://github.com/neovim/neovim/pull/7358#discussion_r143064448 --- src/nvim/buffer.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index fbfb4e02ea..fc5bb90973 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3069,13 +3069,9 @@ static bool ti_change(char_u *str, char_u **last) /// Set current window title void resettitle(void) { - if (p_icon) { - ui_call_set_icon(cstr_as_string((char *)lasticon)); - } - if (p_title || p_icon) { - ui_call_set_title(cstr_as_string((char *)lasttitle)); - ui_flush(); - } + ui_call_set_icon(cstr_as_string((char *)lasticon)); + ui_call_set_title(cstr_as_string((char *)lasttitle)); + ui_flush(); } # if defined(EXITFREE) -- cgit From 1663599bebd7bd360f116b003b9f572b01d7a8d8 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 9 Oct 2017 00:52:57 +0800 Subject: vim-patch:8.0.0164 (#7368) Problem: Outdated and misplaced comments. Solution: Fix the comments. https://github.com/vim/vim/commit/caa55b65c204946d160c1b743c5f8f3b506dc4d3 --- src/nvim/charset.c | 2 +- src/nvim/eval.c | 2 +- src/nvim/getchar.c | 25 ++++++++++--------------- src/nvim/version.c | 2 +- 4 files changed, 13 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 403ef65c4f..577fc13a31 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -762,7 +762,7 @@ bool vim_isIDc(int c) } /// Check that "c" is a keyword character: -/// Letters and characters from 'iskeyword' option for current buffer. +/// Letters and characters from 'iskeyword' option for the current buffer. /// For multi-byte characters mb_get_class() is used (builtin rules). /// /// @param c character to check diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 86b99c2783..b2a0d9a767 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -17528,7 +17528,7 @@ static void f_winsaveview(typval_T *argvars, typval_T *rettv, FunPtr fptr) tv_dict_add_nr(dict, S_LEN("skipcol"), (varnumber_T)curwin->w_skipcol); } -/// Writes list of strings to file +/// Write "list" of strings to file "fd". /// /// @param fp File to write to. /// @param[in] list List to write. diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index f5949333bd..4f8a8528a0 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -868,20 +868,15 @@ int ins_typebuf(char_u *str, int noremap, int offset, int nottyped, bool silent) addlen = (int)STRLEN(str); - /* - * Easy case: there is room in front of typebuf.tb_buf[typebuf.tb_off] - */ if (offset == 0 && addlen <= typebuf.tb_off) { + // Easy case: there is room in front of typebuf.tb_buf[typebuf.tb_off] typebuf.tb_off -= addlen; memmove(typebuf.tb_buf + typebuf.tb_off, str, (size_t)addlen); - } - /* - * Need to allocate a new buffer. - * In typebuf.tb_buf there must always be room for 3 * MAXMAPLEN + 4 - * characters. We add some extra room to avoid having to allocate too - * often. - */ - else { + } else { + // Need to allocate a new buffer. + // In typebuf.tb_buf there must always be room for 3 * MAXMAPLEN + 4 + // characters. We add some extra room to avoid having to allocate too + // often. newoff = MAXMAPLEN + 4; newlen = typebuf.tb_len + addlen + newoff + 4 * (MAXMAPLEN + 4); if (newlen < 0) { /* string is getting too long */ @@ -1663,10 +1658,10 @@ static int vgetorpeek(int advance) } if (c != NUL && !got_int) { if (advance) { - /* KeyTyped = FALSE; When the command that stuffed something - * was typed, behave like the stuffed command was typed. - * needed for CTRL-W CTRl-] to open a fold, for example. */ - KeyStuffed = TRUE; + // KeyTyped = FALSE; When the command that stuffed something + // was typed, behave like the stuffed command was typed. + // needed for CTRL-W CTRL-] to open a fold, for example. + KeyStuffed = true; } if (typebuf.tb_no_abbr_cnt == 0) typebuf.tb_no_abbr_cnt = 1; /* no abbreviations now */ diff --git a/src/nvim/version.c b/src/nvim/version.c index 8015d7520d..11ae3f11b6 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -939,7 +939,7 @@ static const int included_patches[] = { 167, // 166, 165, - // 164, + 164, // 163 NA // 162 NA // 161 NA -- cgit From ad58e50b45ddb73f0582590b9e96da49f34174d0 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 8 Oct 2017 22:09:12 +0300 Subject: kvec: Add kv_Z which is like kv_A, but zero is the last value --- src/nvim/lib/kvec.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/lib/kvec.h b/src/nvim/lib/kvec.h index 4e5fb0d794..ee1b890cb9 100644 --- a/src/nvim/lib/kvec.h +++ b/src/nvim/lib/kvec.h @@ -62,7 +62,8 @@ #define kv_pop(v) ((v).items[--(v).size]) #define kv_size(v) ((v).size) #define kv_max(v) ((v).capacity) -#define kv_last(v) kv_A(v, kv_size(v) - 1) +#define kv_Z(v, i) kv_A(v, kv_size(v) - (i) - 1) +#define kv_last(v) kv_Z(v, 0) /// Drop last n items from kvec without resizing /// -- cgit From 0300c4d10991fb6ce218d45c4fe6d71a73f07d62 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 20 Aug 2017 18:40:22 +0300 Subject: viml/expressions: Add lexer with some basic tests --- src/nvim/CMakeLists.txt | 2 + src/nvim/viml/parser/expressions.c | 367 +++++++++++++++++++++++++++++++++++++ src/nvim/viml/parser/expressions.h | 118 ++++++++++++ src/nvim/viml/parser/parser.h | 129 +++++++++++++ 4 files changed, 616 insertions(+) create mode 100644 src/nvim/viml/parser/expressions.c create mode 100644 src/nvim/viml/parser/expressions.h create mode 100644 src/nvim/viml/parser/parser.h (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 688912eda6..77e4721853 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -81,6 +81,8 @@ foreach(subdir event eval lua + viml + viml/parser ) if(${subdir} MATCHES "tui" AND NOT FEAT_TUI) continue() diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c new file mode 100644 index 0000000000..0164de3a14 --- /dev/null +++ b/src/nvim/viml/parser/expressions.c @@ -0,0 +1,367 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + +/// VimL expression parser + +#include +#include +#include +#include + +#include "nvim/vim.h" +#include "nvim/memory.h" +#include "nvim/types.h" +#include "nvim/charset.h" +#include "nvim/ascii.h" + +#include "nvim/viml/parser/expressions.h" +#include "nvim/viml/parser/parser.h" + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "viml/parser/expressions.c.generated.h" +#endif + +/// Character used as a separator in autoload function/variable names. +#define AUTOLOAD_CHAR '#' + +/// Get next token for the VimL expression input +LexExprToken viml_pexpr_next_token(ParserState *const pstate) + FUNC_ATTR_WARN_UNUSED_RESULT +{ + LexExprToken ret = { + .type = kExprLexInvalid, + .start = pstate->pos, + }; + ParserLine pline; + if (!viml_parser_get_remaining_line(pstate, &pline)) { + ret.type = kExprLexEOC; + return ret; + } + if (pline.size <= 0) { + ret.len = 0; + ret.type = kExprLexEOC; + goto viml_pexpr_next_token_adv_return; + } + ret.len = 1; + const uint8_t schar = (uint8_t)pline.data[0]; +#define GET_CCS(ret, pline) \ + do { \ + if (ret.len < pline.size \ + && strchr("?#", pline.data[ret.len]) != NULL) { \ + ret.data.cmp.ccs = \ + (CaseCompareStrategy)pline.data[ret.len]; \ + ret.len++; \ + } else { \ + ret.data.cmp.ccs = kCCStrategyUseOption; \ + } \ + } while (0) + switch (schar) { + // Paired brackets. +#define BRACKET(typ, opning, clsing) \ + case opning: \ + case clsing: { \ + ret.type = typ; \ + ret.data.brc.closing = (schar == clsing); \ + break; \ + } + BRACKET(kExprLexParenthesis, '(', ')') + BRACKET(kExprLexBracket, '[', ']') + BRACKET(kExprLexFigureBrace, '{', '}') +#undef BRACKET + + // Single character tokens without data. +#define CHAR(typ, ch) \ + case ch: { \ + ret.type = typ; \ + break; \ + } + CHAR(kExprLexQuestion, '?') + CHAR(kExprLexColon, ':') + CHAR(kExprLexDot, '.') + CHAR(kExprLexPlus, '+') + CHAR(kExprLexComma, ',') +#undef CHAR + + // Multiplication/division/modulo. +#define MUL(mul_type, ch) \ + case ch: { \ + ret.type = kExprLexMultiplication; \ + ret.data.mul.type = mul_type; \ + break; \ + } + MUL(kExprLexMulMul, '*') + MUL(kExprLexMulDiv, '/') + MUL(kExprLexMulMod, '%') +#undef MUL + +#define CHARREG(typ, cond) \ + do { \ + ret.type = typ; \ + for (; (ret.len < pline.size \ + && cond(pline.data[ret.len])) \ + ; ret.len++) { \ + } \ + } while (0) + + // Whitespace. + case ' ': + case TAB: { + CHARREG(kExprLexSpacing, ascii_iswhite); + break; + } + + // Control character, except for NUL, NL and TAB. + case Ctrl_A: case Ctrl_B: case Ctrl_C: case Ctrl_D: case Ctrl_E: + case Ctrl_F: case Ctrl_G: case Ctrl_H: + + case Ctrl_K: case Ctrl_L: case Ctrl_M: case Ctrl_N: case Ctrl_O: + case Ctrl_P: case Ctrl_Q: case Ctrl_R: case Ctrl_S: case Ctrl_T: + case Ctrl_U: case Ctrl_V: case Ctrl_W: case Ctrl_X: case Ctrl_Y: + case Ctrl_Z: { +#define ISCTRL(schar) (schar < ' ') + CHARREG(kExprLexInvalid, ISCTRL); + ret.data.err.type = kExprLexSpacing; + ret.data.err.msg = + _("E15: Invalid control character present in input: %.*s"); + break; +#undef ISCTRL + } + + // Number. + // Note: determining whether dot is (not) a part of a float needs more + // context, so lexer does not do this. + // FIXME: Resolve ambiguity by additional argument. + case '0': case '1': case '2': case '3': case '4': case '5': case '6': + case '7': case '8': case '9': { + CHARREG(kExprLexNumber, ascii_isdigit); + break; + } + + // Environment variable. + case '$': { + CHARREG(kExprLexEnv, vim_isIDc); + break; + } + + // Normal variable/function name. + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': + case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': + case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': + case 'v': case 'w': case 'x': case 'y': case 'z': + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': + case 'H': case 'I': case 'J': case 'K': case 'L': case 'M': case 'N': + case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': + case 'V': case 'W': case 'X': case 'Y': case 'Z': + case '_': { +#define ISWORD_OR_AUTOLOAD(x) \ + (ASCII_ISALNUM(x) || (x) == AUTOLOAD_CHAR || (x) == '_') +#define ISWORD(x) \ + (ASCII_ISALNUM(x) || (x) == '_') + ret.data.var.scope = 0; + ret.data.var.autoload = false; + CHARREG(kExprLexPlainIdentifier, ISWORD); + // "is" and "isnot" operators. + if ((ret.len == 2 && memcmp(pline.data, "is", 2) == 0) + || (ret.len == 5 && memcmp(pline.data, "isnot", 5) == 0)) { + ret.type = kExprLexComparison; + ret.data.cmp.type = kExprLexCmpIdentical; + ret.data.cmp.inv = (ret.len == 5); + GET_CCS(ret, pline); + // Scope: `s:`, etc. + } else if (ret.len == 1 + && pline.size > 1 + && strchr("sgvbwtla", schar) != NULL + && pline.data[ret.len] == ':') { + ret.len++; + ret.data.var.scope = schar; + CHARREG(kExprLexPlainIdentifier, ISWORD_OR_AUTOLOAD); + ret.data.var.autoload = ( + memchr(pline.data + 2, AUTOLOAD_CHAR, ret.len - 2) + != NULL); + // Previous CHARREG stopped at autoload character in order to make it + // possible to detect `is#`. Continue now with autoload characters + // included. + // + // Warning: there is ambiguity for the lexer: `is#Foo(1)` is a call of + // function `is#Foo()`, `1is#Foo(1)` is a comparison `1 is# Foo(1)`. This + // needs to be resolved on the higher level where context is available. + } else if (pline.size > ret.len + && pline.data[ret.len] == AUTOLOAD_CHAR) { + ret.data.var.autoload = true; + CHARREG(kExprLexPlainIdentifier, ISWORD_OR_AUTOLOAD); + } + break; +#undef ISWORD_OR_AUTOLOAD +#undef ISWORD + } +#undef CHARREG + + // Option. + case '&': { +#define OPTNAMEMISS(ret) \ + do { \ + ret.type = kExprLexInvalid; \ + ret.data.err.type = kExprLexOption; \ + ret.data.err.msg = _("E112: Option name missing: %.*s"); \ + } while (0) + if (pline.size > 1 && pline.data[1] == '&') { + ret.type = kExprLexAnd; + ret.len++; + break; + } + if (pline.size == 1 || !ASCII_ISALPHA(pline.data[1])) { + OPTNAMEMISS(ret); + break; + } + ret.type = kExprLexOption; + if (pline.size > 2 + && pline.data[2] == ':' + && strchr("gl", pline.data[1]) != NULL) { + ret.len += 2; + ret.data.opt.scope = (pline.data[1] == 'g' + ? kExprLexOptGlobal + : kExprLexOptLocal); + ret.data.opt.name = pline.data + 3; + } else { + ret.data.opt.scope = kExprLexOptUnspecified; + ret.data.opt.name = pline.data + 1; + } + const char *p = ret.data.opt.name; + const char *const e = pline.data + pline.size; + if (e - p >= 4 && p[0] == 't' && p[1] == '_') { + ret.data.opt.len = 4; + ret.len += 4; + } else { + for (; p < e && ASCII_ISALPHA(*p); p++) { + } + ret.data.opt.len = (size_t)(p - ret.data.opt.name); + if (ret.data.opt.len == 0) { + OPTNAMEMISS(ret); + } else { + ret.len += ret.data.opt.len; + } + } + break; +#undef OPTNAMEMISS + } + + // Register. + case '@': { + ret.type = kExprLexRegister; + if (pline.size > 1) { + ret.len++; + ret.data.reg.name = (uint8_t)pline.data[1]; + } else { + ret.data.reg.name = -1; + } + break; + } + + // Single quoted string. + case '\'': { + ret.type = kExprLexSingleQuotedString; + ret.data.str.closed = false; + for (; ret.len < pline.size && !ret.data.str.closed; ret.len++) { + if (pline.data[ret.len] == '\'') { + if (ret.len + 1 < pline.size && pline.data[ret.len + 1] == '\'') { + ret.len++; + } else { + ret.data.str.closed = true; + } + } + } + break; + } + + // Double quoted string. + case '"': { + ret.type = kExprLexDoubleQuotedString; + ret.data.str.closed = false; + for (; ret.len < pline.size && !ret.data.str.closed; ret.len++) { + if (pline.data[ret.len] == '\\') { + if (ret.len + 1 < pline.size) { + ret.len++; + } + } else if (pline.data[ret.len] == '"') { + ret.data.str.closed = true; + } + } + break; + } + + // Unary not, (un)equality and regex (not) match comparison operators. + case '!': + case '=': { + if (pline.size == 1) { +viml_pexpr_next_token_invalid_comparison: + ret.type = (schar == '!' ? kExprLexNot : kExprLexInvalid); + if (ret.type == kExprLexInvalid) { + ret.data.err.msg = _("E15: Expected == or =~: %.*s"); + ret.data.err.type = kExprLexComparison; + } + break; + } + ret.type = kExprLexComparison; + ret.data.cmp.inv = (schar == '!'); + if (pline.data[1] == '=') { + ret.data.cmp.type = kExprLexCmpEqual; + ret.len++; + } else if (pline.data[1] == '~') { + ret.data.cmp.type = kExprLexCmpMatches; + ret.len++; + } else { + goto viml_pexpr_next_token_invalid_comparison; + } + GET_CCS(ret, pline); + break; + } + + // Less/greater [or equal to] comparison operators. + case '>': + case '<': { + ret.type = kExprLexComparison; + const bool haseqsign = (pline.size > 1 && pline.data[1] == '='); + if (haseqsign) { + ret.len++; + } + GET_CCS(ret, pline); + ret.data.cmp.inv = (schar == '<'); + ret.data.cmp.type = ((ret.data.cmp.inv ^ haseqsign) + ? kExprLexCmpGreaterOrEqual + : kExprLexCmpGreater); + break; + } + + // Minus sign or arrow from lambdas. + case '-': { + if (pline.size > 1 && pline.data[1] == '>') { + ret.len++; + ret.type = kExprLexArrow; + } else { + ret.type = kExprLexMinus; + } + break; + } + + // Expression end because Ex command ended. + case NUL: + case NL: { + ret.type = kExprLexEOC; + break; + } + + // Everything else is not valid. + default: { + ret.len = (size_t)utfc_ptr2len_len((const char_u *)pline.data, + (int)pline.size); + ret.type = kExprLexInvalid; + ret.data.err.type = kExprLexPlainIdentifier; + ret.data.err.msg = _("E15: Unidentified character: %.*s"); + break; + } + } +#undef GET_CCS +viml_pexpr_next_token_adv_return: + viml_parser_advance(pstate, ret.len); + return ret; +} diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h new file mode 100644 index 0000000000..52354760a5 --- /dev/null +++ b/src/nvim/viml/parser/expressions.h @@ -0,0 +1,118 @@ +#ifndef NVIM_VIML_PARSER_EXPRESSIONS_H +#define NVIM_VIML_PARSER_EXPRESSIONS_H + +#include +#include + +#include "nvim/types.h" +#include "nvim/viml/parser/parser.h" + +// Defines whether to ignore case: +// == kCCStrategyUseOption +// ==# kCCStrategyMatchCase +// ==? kCCStrategyIgnoreCase +typedef enum { + kCCStrategyUseOption = 0, // 0 for xcalloc + kCCStrategyMatchCase = '#', + kCCStrategyIgnoreCase = '?', +} CaseCompareStrategy; + +/// Lexer token type +typedef enum { + kExprLexInvalid = 0, ///< Invalid token, indicaten an error. + kExprLexMissing, ///< Missing token, for use in parser. + kExprLexSpacing, ///< Spaces, tabs, newlines, etc. + kExprLexEOC, ///< End of command character: NL, |, just end of stream. + + kExprLexQuestion, ///< Question mark, for use in ternary. + kExprLexColon, ///< Colon, for use in ternary. + kExprLexOr, ///< Logical or operator. + kExprLexAnd, ///< Logical and operator. + kExprLexComparison, ///< One of the comparison operators. + kExprLexPlus, ///< Plus sign. + kExprLexMinus, ///< Minus sign. + kExprLexDot, ///< Dot: either concat or subscript, also part of the float. + kExprLexMultiplication, ///< Multiplication, division or modulo operator. + + kExprLexNot, ///< Not: !. + + kExprLexNumber, ///< Integer number literal, or part of a float. + kExprLexSingleQuotedString, ///< Single quoted string literal. + kExprLexDoubleQuotedString, ///< Double quoted string literal. + kExprLexOption, ///< &optionname option value. + kExprLexRegister, ///< @r register value. + kExprLexEnv, ///< Environment $variable value. + kExprLexPlainIdentifier, ///< Identifier without scope: `abc`, `foo#bar`. + + kExprLexBracket, ///< Bracket, either opening or closing. + kExprLexFigureBrace, ///< Figure brace, either opening or closing. + kExprLexParenthesis, ///< Parenthesis, either opening or closing. + kExprLexComma, ///< Comma. + kExprLexArrow, ///< Arrow, like from lambda expressions. +} LexExprTokenType; + +/// Lexer token +typedef struct { + ParserPosition start; + size_t len; + LexExprTokenType type; + union { + struct { + enum { + kExprLexCmpEqual, ///< Equality, unequality. + kExprLexCmpMatches, ///< Matches regex, not matches regex. + kExprLexCmpGreater, ///< `>` or `<=` + kExprLexCmpGreaterOrEqual, ///< `>=` or `<`. + kExprLexCmpIdentical, ///< `is` or `isnot` + } type; ///< Comparison type. + CaseCompareStrategy ccs; ///< Case comparison strategy. + bool inv; ///< True if comparison is to be inverted. + } cmp; ///< For kExprLexComparison. + + struct { + enum { + kExprLexMulMul, ///< Real multiplication. + kExprLexMulDiv, ///< Division. + kExprLexMulMod, ///< Modulo. + } type; ///< Multiplication type. + } mul; ///< For kExprLexMultiplication. + + struct { + bool closing; ///< True if bracket/etc is a closing one. + } brc; ///< For brackets/braces/parenthesis. + + struct { + int name; ///< Register name, may be -1 if name not present. + } reg; ///< For kExprLexRegister. + + struct { + bool closed; ///< True if quote was closed. + } str; ///< For kExprLexSingleQuotedString and kExprLexDoubleQuotedString. + + struct { + const char *name; ///< Option name start. + size_t len; ///< Option name length. + enum { + kExprLexOptUnspecified = 0, + kExprLexOptGlobal = 1, + kExprLexOptLocal = 2, + } scope; ///< Option scope: &l:, &g: or not specified. + } opt; ///< Option properties. + + struct { + int scope; ///< Scope character or 0 if not present. + bool autoload; ///< Has autoload characters. + } var; ///< For kExprLexPlainIdentifier + + struct { + LexExprTokenType type; ///< Suggested type for parsing incorrect code. + const char *msg; ///< Error message. + } err; ///< For kExprLexInvalid + } data; ///< Additional data, if needed. +} LexExprToken; + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "viml/parser/expressions.h.generated.h" +#endif + +#endif // NVIM_VIML_PARSER_EXPRESSIONS_H diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h new file mode 100644 index 0000000000..ec582294e1 --- /dev/null +++ b/src/nvim/viml/parser/parser.h @@ -0,0 +1,129 @@ +#ifndef NVIM_VIML_PARSER_PARSER_H +#define NVIM_VIML_PARSER_PARSER_H + +#include +#include +#include + +#include "nvim/lib/kvec.h" +#include "nvim/func_attr.h" + +/// One parsed line +typedef struct { + const char *data; ///< Parsed line pointer + size_t size; ///< Parsed line size +} ParserLine; + +/// Line getter type for parser +/// +/// Line getter must return {NULL, 0} for EOF. +typedef void (*ParserLineGetter)(void *cookie, ParserLine *ret_pline); + +/// Parser position in the input +typedef struct { + size_t line; ///< Line index in ParserInputReader.lines. + size_t col; ///< Byte index in the line. +} ParserPosition; + +/// Parser state item. +typedef struct { + enum { + kPTopStateParsingCommand = 0, + kPTopStateParsingExpression, + } type; + union { + struct { + enum { + kExprUnknown = 0, + } type; + } expr; + } data; +} ParserStateItem; + +/// Structure defining input reader +typedef struct { + /// Function used to get next line. + ParserLineGetter get_line; + /// Data for get_line function. + void *cookie; + /// All lines obtained by get_line. + kvec_withinit_t(ParserLine, 4) lines; +} ParserInputReader; + +/// Highlighted region definition +/// +/// Note: one chunk may highlight only one line. +typedef struct { + ParserPosition start; ///< Start of the highlight: line and column. + size_t end_col; ///< End column, points to the start of the next character. + const char *group; ///< Highlight group. +} ParserHighlightChunk; + +/// Highlighting defined by a parser +typedef kvec_withinit_t(ParserHighlightChunk, 16) ParserHighlight; + +/// Structure defining parser state +typedef struct { + /// Line reader. + ParserInputReader reader; + /// Position up to which input was parsed. + ParserPosition pos; + /// Parser state stack. + kvec_withinit_t(ParserStateItem, 16) stack; + /// Highlighting support. + ParserHighlight *colors; + /// True if line continuation can be used. + bool can_continuate; +} ParserState; + +static inline bool viml_parser_get_remaining_line(ParserState *const pstate, + ParserLine *const ret_pline) + REAL_FATTR_ALWAYS_INLINE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_NONNULL_ALL; + +/// Get currently parsed line, shifted to pstate->pos.col +/// +/// @param pstate Parser state to operate on. +/// +/// @return True if there is a line, false in case of EOF. +static inline bool viml_parser_get_remaining_line(ParserState *const pstate, + ParserLine *const ret_pline) +{ + const size_t num_lines = kv_size(pstate->reader.lines); + if (pstate->pos.line == num_lines) { + pstate->reader.get_line(pstate->reader.cookie, ret_pline); + kvi_push(pstate->reader.lines, *ret_pline); + } else { + *ret_pline = kv_last(pstate->reader.lines); + } + assert(pstate->pos.line == kv_size(pstate->reader.lines) - 1); + if (ret_pline->data != NULL) { + ret_pline->data += pstate->pos.col; + ret_pline->size -= pstate->pos.col; + } + return ret_pline->data != NULL; +} + +static inline void viml_parser_advance(ParserState *const pstate, + const size_t len) + REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL; + +/// Advance position by a given number of bytes +/// +/// At maximum advances to the next line. +/// +/// @param pstate Parser state to advance. +/// @param[in] len Number of bytes to advance. +static inline void viml_parser_advance(ParserState *const pstate, + const size_t len) +{ + assert(pstate->pos.line == kv_size(pstate->reader.lines) - 1); + const ParserLine pline = kv_last(pstate->reader.lines); + if (pstate->pos.col + len >= pline.size) { + pstate->pos.line++; + pstate->pos.col = 0; + } else { + pstate->pos.col += len; + } +} + +#endif // NVIM_VIML_PARSER_PARSER_H -- cgit From 2d8b9937deae3731143f4ea44e5c41715fe1363a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 20 Aug 2017 20:40:59 +0300 Subject: viml/parser: Handle encoding conversions --- src/nvim/viml/parser/expressions.c | 13 ++++++++++--- src/nvim/viml/parser/parser.h | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 0164de3a14..c29fac9cb4 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -25,8 +25,13 @@ #define AUTOLOAD_CHAR '#' /// Get next token for the VimL expression input -LexExprToken viml_pexpr_next_token(ParserState *const pstate) - FUNC_ATTR_WARN_UNUSED_RESULT +/// +/// @param pstate Parser state. +/// @param[in] peek If true, do not advance pstate cursor. +/// +/// @return Next token. +LexExprToken viml_pexpr_next_token(ParserState *const pstate, const bool peek) + FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { LexExprToken ret = { .type = kExprLexInvalid, @@ -362,6 +367,8 @@ viml_pexpr_next_token_invalid_comparison: } #undef GET_CCS viml_pexpr_next_token_adv_return: - viml_parser_advance(pstate, ret.len); + if (!peek) { + viml_parser_advance(pstate, ret.len); + } return ret; } diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h index ec582294e1..231e43b4c7 100644 --- a/src/nvim/viml/parser/parser.h +++ b/src/nvim/viml/parser/parser.h @@ -7,11 +7,13 @@ #include "nvim/lib/kvec.h" #include "nvim/func_attr.h" +#include "nvim/mbyte.h" /// One parsed line typedef struct { const char *data; ///< Parsed line pointer size_t size; ///< Parsed line size + bool allocated; ///< True if line may be freed. } ParserLine; /// Line getter type for parser @@ -48,6 +50,8 @@ typedef struct { void *cookie; /// All lines obtained by get_line. kvec_withinit_t(ParserLine, 4) lines; + /// Conversion, for :scriptencoding. + vimconv_T conv; } ParserInputReader; /// Highlighted region definition @@ -76,6 +80,33 @@ typedef struct { bool can_continuate; } ParserState; +static inline void viml_preader_get_line(ParserInputReader *const preader, + ParserLine *const ret_pline) + REAL_FATTR_NONNULL_ALL; + +/// Get one line from ParserInputReader +static inline void viml_preader_get_line(ParserInputReader *const preader, + ParserLine *const ret_pline) +{ + ParserLine pline; + preader->get_line(preader->cookie, &pline); + if (preader->conv.vc_type != CONV_NONE && pline.size) { + ParserLine cpline = { + .allocated = true, + .size = pline.size, + }; + cpline.data = (char *)string_convert(&preader->conv, + (char_u *)pline.data, + &cpline.size); + if (pline.allocated) { + xfree((void *)pline.data); + } + pline = cpline; + } + kvi_push(preader->lines, pline); + *ret_pline = pline; +} + static inline bool viml_parser_get_remaining_line(ParserState *const pstate, ParserLine *const ret_pline) REAL_FATTR_ALWAYS_INLINE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_NONNULL_ALL; @@ -90,8 +121,7 @@ static inline bool viml_parser_get_remaining_line(ParserState *const pstate, { const size_t num_lines = kv_size(pstate->reader.lines); if (pstate->pos.line == num_lines) { - pstate->reader.get_line(pstate->reader.cookie, ret_pline); - kvi_push(pstate->reader.lines, *ret_pline); + viml_preader_get_line(&pstate->reader, ret_pline); } else { *ret_pline = kv_last(pstate->reader.lines); } -- cgit From 1265da028882d9877a5ebbd3f3f52cb4b52a4b94 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 3 Sep 2017 19:53:41 +0300 Subject: viml/parser: Add helper functions for highlighting --- src/nvim/viml/parser/parser.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src') diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h index 231e43b4c7..a17edac403 100644 --- a/src/nvim/viml/parser/parser.h +++ b/src/nvim/viml/parser/parser.h @@ -156,4 +156,33 @@ static inline void viml_parser_advance(ParserState *const pstate, } } +static inline void viml_parser_highlight(ParserState *const pstate, + const ParserPosition start, + const size_t end_col, + const char *const group) + REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL; + +/// Record highlighting of some region of text +/// +/// @param pstate Parser state to work with. +/// @param[in] start Start position of the highlight. +/// @param[in] len Highlighting chunk length. +/// @param[in] group Highlight group. +static inline void viml_parser_highlight(ParserState *const pstate, + const ParserPosition start, + const size_t len, + const char *const group) +{ + if (pstate->colors == NULL) { + return; + } + // TODO(ZyX-I): May do some assert() sanitizing here. + // TODO(ZyX-I): May join chunks. + kvi_push(*pstate->colors, ((ParserHighlightChunk) { + .start = start, + .end_col = start.col + len, + .group = group, + })); +} + #endif // NVIM_VIML_PARSER_PARSER_H -- cgit From 52517321d1859c31fef14aa75d784615693fcecb Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 8 Oct 2017 20:23:11 +0200 Subject: test: nvim_get_hl_by_name/by_id #7082 - test all properties - test failure modes --- src/nvim/api/vim.c | 1 - src/nvim/syntax.c | 9 +++------ 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index bc89ffefe6..98f4410347 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -33,7 +33,6 @@ #include "nvim/syntax.h" #include "nvim/getchar.h" #include "nvim/os/input.h" -#include "nvim/ui.h" #define LINE_BUFFER_SIZE 4096 diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index f59495f660..0224b28c2a 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -7127,8 +7127,7 @@ syn_list_header(int did_header, int outlen, int id) /// Set the attribute numbers for a highlight group. /// Called after one of the attributes has changed. /// @param idx corrected highlight index -static void -set_hl_attr(int idx) +static void set_hl_attr(int idx) { attrentry_T at_en = ATTRENTRY_INIT; struct hl_group *sgp = HL_TABLE() + idx; @@ -8241,9 +8240,7 @@ RgbValue name_to_color(const uint8_t *name) return -1; } -/// Retrieves attribute description from its id -/// -/// @param attr_id attribute id +/// Gets highlight description for id `attr_id` as a map. Dictionary hl_get_attr_by_id(Integer attr_id, Boolean rgb, Error *err) { HlAttrs attrs = HLATTRS_INIT; @@ -8256,7 +8253,7 @@ Dictionary hl_get_attr_by_id(Integer attr_id, Boolean rgb, Error *err) attrentry_T *aep = syn_cterm_attr2entry((int)attr_id); if (!aep) { api_set_error(err, kErrorTypeException, - "Invalid attribute id %d", attr_id); + "Invalid attribute id: %d", attr_id); return dic; } -- cgit From 430e516d3ac1235c1ee3009a8a36089bf278440e Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 3 Sep 2017 21:58:16 +0300 Subject: viml/parser/expressions: Start creating expressions parser Currently supported nodes: - Register as it is one of the simplest value nodes (even numbers are not that simple with that dot handling). - Plus, both unary and binary. - Parenthesis, both nesting and calling. Note regarding unit tests: it stores data for AST in highlighting in strings in place of tables because luassert fails to do a good job at representing big tables. Squashing a bunch of data into a single string simply yields more readable result. --- src/nvim/viml/parser/expressions.c | 625 +++++++++++++++++++++++++++++++++++++ src/nvim/viml/parser/expressions.h | 74 +++++ 2 files changed, 699 insertions(+) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index c29fac9cb4..b54f2eb237 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -13,10 +13,18 @@ #include "nvim/types.h" #include "nvim/charset.h" #include "nvim/ascii.h" +#include "nvim/lib/kvec.h" #include "nvim/viml/parser/expressions.h" #include "nvim/viml/parser/parser.h" +typedef kvec_withinit_t(ExprASTNode **, 16) ExprASTStack; + +typedef enum { + kELvlOperator, ///< Operators: function call, subscripts, binary operators, … + kELvlValue, ///< Actual value: literals, variables, nested expressions. +} ExprASTLevel; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "viml/parser/expressions.c.generated.h" #endif @@ -144,6 +152,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const bool peek) // Environment variable. case '$': { + // FIXME: Parser function can’t be thread-safe with vim_isIDc. CHARREG(kExprLexEnv, vim_isIDc); break; } @@ -183,6 +192,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const bool peek) ret.data.var.autoload = ( memchr(pline.data + 2, AUTOLOAD_CHAR, ret.len - 2) != NULL); + // FIXME: Resolve ambiguity with an argument to the lexer function. // Previous CHARREG stopped at autoload character in order to make it // possible to detect `is#`. Continue now with autoload characters // included. @@ -372,3 +382,618 @@ viml_pexpr_next_token_adv_return: } return ret; } + +// start = s ternary_expr s EOC +// ternary_expr = binop_expr +// ( s Question s ternary_expr s Colon s ternary_expr s )? +// binop_expr = unaryop_expr ( binop unaryop_expr )? +// unaryop_expr = ( unaryop )? subscript_expr +// subscript_expr = subscript_expr subscript +// | value_expr +// subscript = Bracket('[') s ternary_expr s Bracket(']') +// | s Parenthesis('(') call_args Parenthesis(')') +// | Dot ( PlainIdentifier | Number )+ +// # Note: `s` before Parenthesis('(') is only valid if preceding subscript_expr +// # is PlainIdentifier +// value_expr = ( float | Number +// | DoubleQuotedString | SingleQuotedString +// | paren_expr +// | list_literal +// | lambda_literal +// | dict_literal +// | Environment +// | Option +// | Register +// | var ) +// float = Number Dot Number ( PlainIdentifier('e') ( Plus | Minus )? Number )? +// # Note: `1.2.3` is concat and not float. `"abc".2.3` is also concat without +// # floats. +// paren_expr = Parenthesis('(') s ternary_expr s Parenthesis(')') +// list_literal = Bracket('[') s +// ( ternary_expr s Comma s )* +// ternary_expr? s +// Bracket(']') +// dict_literal = FigureBrace('{') s +// ( ternary_expr s Colon s ternary_expr s Comma s )* +// ( ternary_expr s Colon s ternary_expr s )? +// FigureBrace('}') +// lambda_literal = FigureBrace('{') s +// ( PlainIdentifier s Comma s )* +// PlainIdentifier s +// Arrow s +// ternary_expr s +// FigureBrace('}') +// var = varchunk+ +// varchunk = PlainIdentifier +// | Comparison("is" | "is#" | "isnot" | "isnot#") +// | FigureBrace('{') s ternary_expr s FigureBrace('}') +// call_args = ( s ternary_expr s Comma s )* s ternary_expr? s +// binop = s ( Plus | Minus | Dot +// | Comparison +// | Multiplication +// | Or +// | And ) s +// unaryop = s ( Not | Plus | Minus ) s +// s = Spacing? +// +// Binary operator precedence and associativity: +// +// Operator | Precedence | Associativity +// ---------+------------+----------------- +// || | 2 | left +// && | 3 | left +// cmp* | 4 | not associative +// + - . | 5 | left +// * / % | 6 | left +// +// * comparison operators: +// +// == ==# ==? != !=# !=? +// =~ =~# =~? !~ !~# !~? +// > ># >? <= <=# <=? +// < <# = >=# >=? +// is is# is? isnot isnot# isnot? +// +// Used highlighting groups and assumed linkage: +// +// NVimInvalid -> Error +// NVimInvalidValue -> NVimInvalid +// NVimInvalidOperator -> NVimInvalid +// NVimInvalidDelimiter -> NVimInvalid +// +// NVimOperator -> Operator +// NVimUnaryOperator -> NVimOperator +// NVimBinaryOperator -> NVimOperator +// NVimComparisonOperator -> NVimOperator +// NVimTernaryOperator -> NVimOperator +// +// NVimParenthesis -> Delimiter +// +// NVimInvalidSpacing -> NVimInvalid +// NVimInvalidTernaryOperator -> NVimInvalidOperator +// NVimInvalidRegister -> NVimInvalidValue +// NVimInvalidClosingBracket -> NVimInvalidDelimiter +// NVimInvalidSpacing -> NVimInvalid +// +// NVimUnaryPlus -> NVimUnaryOperator +// NVimBinaryPlus -> NVimBinaryOperator +// NVimRegister -> SpecialChar +// NVimNestingParenthesis -> NVimParenthesis +// NVimCallingParenthesis -> NVimParenthesis + +/// Allocate a new node and set some of the values +/// +/// @param[in] type Node type to allocate. +/// @param[in] level Node level to allocate +static inline ExprASTNode *viml_pexpr_new_node(const ExprASTNodeType type) + FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_MALLOC +{ + ExprASTNode *ret = xmalloc(sizeof(*ret)); + ret->type = type; + ret->children = NULL; + ret->next = NULL; + return ret; +} + +typedef enum { + kEOpLvlInvalid = 0, + kEOpLvlParens, + kEOpLvlTernary, + kEOpLvlOr, + kEOpLvlAnd, + kEOpLvlComparison, + kEOpLvlAddition, ///< Addition, subtraction and concatenation. + kEOpLvlMultiplication, ///< Multiplication, division and modulo. + kEOpLvlUnary, ///< Unary operations: not, minus, plus. + kEOpLvlSubscript, ///< Subscripts. + kEOpLvlValue, ///< Values: literals, variables, nested expressions, … +} ExprOpLvl; + +typedef enum { + kEOpAssNo= 'n', ///< Not associative / not applicable. + kEOpAssLeft = 'l', ///< Left associativity. + kEOpAssRight = 'r', ///< Right associativity. +} ExprOpAssociativity; + +static const ExprOpLvl node_type_to_op_lvl[] = { + [kExprNodeMissing] = kEOpLvlInvalid, + [kExprNodeOpMissing] = kEOpLvlMultiplication, + + [kExprNodeNested] = kEOpLvlParens, + [kExprNodeComplexIdentifier] = kEOpLvlParens, + + [kExprNodeTernary] = kEOpLvlTernary, + + [kExprNodeBinaryPlus] = kEOpLvlAddition, + + [kExprNodeUnaryPlus] = kEOpLvlUnary, + + [kExprNodeSubscript] = kEOpLvlSubscript, + [kExprNodeCall] = kEOpLvlSubscript, + + [kExprNodeRegister] = kEOpLvlValue, + [kExprNodeListLiteral] = kEOpLvlValue, + [kExprNodePlainIdentifier] = kEOpLvlValue, +}; + +static const ExprOpAssociativity node_type_to_op_ass[] = { + [kExprNodeMissing] = kEOpAssNo, + [kExprNodeOpMissing] = kEOpAssNo, + + [kExprNodeNested] = kEOpAssNo, + [kExprNodeComplexIdentifier] = kEOpAssLeft, + + [kExprNodeTernary] = kEOpAssNo, + + [kExprNodeBinaryPlus] = kEOpAssLeft, + + [kExprNodeUnaryPlus] = kEOpAssNo, + + [kExprNodeSubscript] = kEOpAssLeft, + [kExprNodeCall] = kEOpAssLeft, + + [kExprNodeRegister] = kEOpAssNo, + [kExprNodeListLiteral] = kEOpAssNo, + [kExprNodePlainIdentifier] = kEOpAssNo, +}; + +#ifdef UNIT_TESTING +#include +REAL_FATTR_UNUSED +static inline void viml_pexpr_debug_print_ast_stack( + const ExprASTStack *const ast_stack, + const char *const msg) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE +{ + fprintf(stderr, "\n%sstack: %zu:\n", msg, kv_size(*ast_stack)); + for (size_t i = 0; i < kv_size(*ast_stack); i++) { + const ExprASTNode *const *const eastnode_p = ( + (const ExprASTNode *const *)kv_A(*ast_stack, i)); + if (*eastnode_p == NULL) { + fprintf(stderr, "- %p : NULL\n", (void *)eastnode_p); + } else { + fprintf(stderr, "- %p : %p : %c : %zu:%zu:%zu\n", + (void *)eastnode_p, (void *)(*eastnode_p), (*eastnode_p)->type, + (*eastnode_p)->start.line, (*eastnode_p)->start.col, + (*eastnode_p)->len); + } + } +} +#define PSTACK(msg) \ + viml_pexpr_debug_print_ast_stack(&ast_stack, #msg) +#define PSTACK_P(msg) \ + viml_pexpr_debug_print_ast_stack(ast_stack, #msg) +#endif + +/// Handle binary operator +/// +/// This function is responsible for handling priority levels as well. +static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, + ExprASTNode *const bop_node, + ExprASTLevel *const want_level_p) + FUNC_ATTR_NONNULL_ALL +{ + ExprASTNode **top_node_p = NULL; + ExprASTNode *top_node; + ExprOpLvl top_node_lvl; + ExprOpAssociativity top_node_ass; + assert(kv_size(*ast_stack)); + const ExprOpLvl bop_node_lvl = node_type_to_op_lvl[bop_node->type]; + do { + ExprASTNode **new_top_node_p = kv_last(*ast_stack); + ExprASTNode *new_top_node = *new_top_node_p; + assert(new_top_node != NULL); + const ExprOpLvl new_top_node_lvl = node_type_to_op_lvl[new_top_node->type]; + const ExprOpAssociativity new_top_node_ass = ( + node_type_to_op_ass[new_top_node->type]); + if (top_node_p != NULL + && ((bop_node_lvl > new_top_node_lvl + || (bop_node_lvl == new_top_node_lvl + && new_top_node_ass == kEOpAssNo)))) { + break; + } + kv_drop(*ast_stack, 1); + top_node_p = new_top_node_p; + top_node = new_top_node; + top_node_lvl = new_top_node_lvl; + top_node_ass = new_top_node_ass; + } while (kv_size(*ast_stack)); + // FIXME Handle right and no associativity correctly + *top_node_p = bop_node; + bop_node->children = top_node; + assert(bop_node->children->next == NULL); + kvi_push(*ast_stack, top_node_p); + kvi_push(*ast_stack, &bop_node->children->next); + *want_level_p = kELvlValue; +} + +/// Get highlight group name +#define HL(g) (is_invalid ? "NVimInvalid" #g : "NVim" #g) + +/// Highlight current token with the given group +#define HL_CUR_TOKEN(g) \ + viml_parser_highlight(pstate, cur_token.start, cur_token.len, \ + HL(g)) + +/// Allocate new node, saving some values +#define NEW_NODE(type) \ + viml_pexpr_new_node(type) + +/// Set position of the given node to position from the given token +/// +/// @param cur_node Node to modify. +/// @param cur_token Token to set position from. +#define POS_FROM_TOKEN(cur_node, cur_token) \ + do { \ + cur_node->start = cur_token.start; \ + cur_node->len = cur_token.len; \ + } while (0) + +/// Allocate new node and set its position from the current token +/// +/// If previous token happened to contain spacing then it will be included. +/// +/// @param cur_node Variable to save allocated node to. +/// @param typ Node type. +#define NEW_NODE_WITH_CUR_POS(cur_node, typ) \ + do { \ + cur_node = NEW_NODE(typ); \ + POS_FROM_TOKEN(cur_node, cur_token); \ + if (prev_token.type == kExprLexSpacing) { \ + cur_node->start = prev_token.start; \ + cur_node->len += prev_token.len; \ + } \ + } while (0) + +// TODO(ZyX-I): actual condition +/// Check whether it is possible to have next expression after current +/// +/// For :echo: `:echo @a @a` is a valid expression. `:echo (@a @a)` is not. +#define MAY_HAVE_NEXT_EXPR \ + (kv_size(ast_stack) == 1) + +/// Record missing operator: for things like +/// +/// :echo @a @a +/// +/// (allowed) or +/// +/// :echo (@a @a) +/// +/// (parsed as OpMissing(@a, @a)). +#define OP_MISSING \ + do { \ + if (flags & kExprFlagsMulti && MAY_HAVE_NEXT_EXPR) { \ + /* Multiple expressions allowed, return without calling */ \ + /* viml_parser_advance(). */ \ + goto viml_pexpr_parse_end; \ + } else { \ + assert(*top_node_p != NULL); \ + ERROR_FROM_TOKEN_AND_MSG(cur_token, _("E15: Missing operator: %.*s")); \ + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeOpMissing); \ + cur_node->len = 0; \ + viml_pexpr_handle_bop(&ast_stack, cur_node, &want_level); \ + is_invalid = true; \ + goto viml_pexpr_parse_process_token; \ + } \ + } while (0) + +/// Set AST error, unless AST already is not correct +/// +/// @param[out] ret_ast AST to set error in. +/// @param[in] pstate Parser state, used to get error message argument. +/// @param[in] msg Error message, assumed to be already translated and +/// containing a single %token "%.*s". +/// @param[in] start Position at which error occurred. +static inline void east_set_error(ExprAST *const ret_ast, + const ParserState *const pstate, + const char *const msg, + const ParserPosition start) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE +{ + if (!ret_ast->correct) { + return; + } + const ParserLine pline = pstate->reader.lines.items[start.line]; + ret_ast->correct = false; + ret_ast->err.msg = msg; + ret_ast->err.arg_len = (int)(pline.size - start.col); + ret_ast->err.arg = pline.data + start.col; +} + +/// Set error from the given kExprLexInvalid token and given message +#define ERROR_FROM_TOKEN_AND_MSG(cur_token, msg) \ + east_set_error(&ast, pstate, msg, cur_token.start) + +/// Set error from the given kExprLexInvalid token +#define ERROR_FROM_TOKEN(cur_token) \ + ERROR_FROM_TOKEN_AND_MSG(cur_token, cur_token.data.err.msg) + +/// Parse one VimL expression +/// +/// @param pstate Parser state. +/// @param[in] flags Additional flags, see ExprParserFlags +/// +/// @return Parsed AST. +ExprAST viml_pexpr_parse(ParserState *const pstate, const int flags) + FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL +{ + ExprAST ast = { + .correct = true, + .err = { + .msg = NULL, + .arg_len = 0, + .arg = NULL, + }, + .root = NULL, + }; + ExprASTStack ast_stack; + kvi_init(ast_stack); + kvi_push(ast_stack, &ast.root); + // Expressions stack: + // 1. *last is NULL if want_level is kExprLexValue. Indicates where expression + // is to be put. + // 2. *last is not NULL otherwise, indicates current expression to be used as + // an operator argument. + ExprASTLevel want_level = kELvlValue; + LexExprToken prev_token = { .type = kExprLexMissing }; + bool highlighted_prev_spacing = false; + do { + LexExprToken cur_token = viml_pexpr_next_token(pstate, true); + if (cur_token.type == kExprLexEOC) { + if (flags & kExprFlagsDisallowEOC) { + if (cur_token.len == 0) { + // It is end of string, break. + break; + } else { + // It is NL, NUL or bar. + // + // Note: `=1 | 2` actually yields 1 in Vim without any + // errors. This will be changed here. + cur_token.type = kExprLexInvalid; + cur_token.data.err.msg = _("E15: Unexpected EOC character: %.*s"); + const ParserLine pline = ( + pstate->reader.lines.items[cur_token.start.line]); + const char eoc_char = pline.data[cur_token.start.col]; + cur_token.data.err.type = ((eoc_char == NUL || eoc_char == NL) + ? kExprLexSpacing + : kExprLexOr); + } + } else { + break; + } + } + LexExprTokenType tok_type = cur_token.type; + const bool token_invalid = (tok_type == kExprLexInvalid); + bool is_invalid = token_invalid; +viml_pexpr_parse_process_token: + if (tok_type == kExprLexSpacing) { + if (is_invalid) { + viml_parser_highlight(pstate, cur_token.start, cur_token.len, + HL(Spacing)); + } else { + // Do not do anything: let regular spacing be highlighted as normal. + // This also allows later to highlight spacing as invalid. + } + goto viml_pexpr_parse_cycle_end; + } else if (is_invalid && prev_token.type == kExprLexSpacing + && !highlighted_prev_spacing) { + viml_parser_highlight(pstate, prev_token.start, prev_token.len, + HL(Spacing)); + is_invalid = false; + highlighted_prev_spacing = true; + } + ExprASTNode **const top_node_p = kv_last(ast_stack); + ExprASTNode *cur_node = NULL; + // Keep these two asserts separate for debugging purposes. + assert(want_level == kELvlValue || *top_node_p != NULL); + assert(want_level != kELvlValue || *top_node_p == NULL); + switch (tok_type) { + case kExprLexEOC: { + assert(false); + } + case kExprLexInvalid: { + ERROR_FROM_TOKEN(cur_token); + tok_type = cur_token.data.err.type; + goto viml_pexpr_parse_process_token; + } + case kExprLexRegister: { + if (want_level == kELvlValue) { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeRegister); + cur_node->data.reg.name = cur_token.data.reg.name; + *top_node_p = cur_node; + want_level = kELvlOperator; + viml_parser_highlight(pstate, cur_token.start, cur_token.len, + HL(Register)); + } else { + // Register in operator position: e.g. @a @a + OP_MISSING; + } + break; + } + case kExprLexPlus: { + if (want_level == kELvlValue) { + // Value level: assume unary plus + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeUnaryPlus); + *top_node_p = cur_node; + kvi_push(ast_stack, &cur_node->children); + HL_CUR_TOKEN(UnaryPlus); + } else if (want_level < kELvlValue) { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeBinaryPlus); + viml_pexpr_handle_bop(&ast_stack, cur_node, &want_level); + HL_CUR_TOKEN(BinaryPlus); + } + want_level = kELvlValue; + break; + } + case kExprLexParenthesis: { + if (cur_token.data.brc.closing) { + if (want_level == kELvlValue) { + if (kv_size(ast_stack) > 1) { + const ExprASTNode *const prev_top_node = *kv_Z(ast_stack, 1); + if (prev_top_node->type == kExprNodeCall) { + // Function call without arguments, this is not an error. + // But further code does not expect NULL nodes. + kv_drop(ast_stack, 1); + goto viml_pexpr_parse_no_paren_closing_error; + } + } + is_invalid = true; + ERROR_FROM_TOKEN_AND_MSG(cur_token, _("E15: Expected value: %.*s")); + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeMissing); + cur_node->len = 0; + *top_node_p = cur_node; + } else { + // Always drop the topmost value: when want_level != kELvlValue + // topmost item on stack is a *finished* left operand, which may as + // well be "(@a)" which needs not be finished. + kv_drop(ast_stack, 1); + } +viml_pexpr_parse_no_paren_closing_error: {} + ExprASTNode **new_top_node_p = NULL; + while (kv_size(ast_stack) + && (new_top_node_p == NULL + || ((*new_top_node_p)->type != kExprNodeNested + && (*new_top_node_p)->type != kExprNodeCall))) { + new_top_node_p = kv_pop(ast_stack); + } + if (new_top_node_p != NULL + && ((*new_top_node_p)->type == kExprNodeNested + || (*new_top_node_p)->type == kExprNodeCall)) { + if ((*new_top_node_p)->type == kExprNodeNested) { + HL_CUR_TOKEN(NestingParenthesis); + } else { + HL_CUR_TOKEN(CallingParenthesis); + } + } else { + // “Always drop the topmost value†branch has got rid of the single + // value stack had, so there is nothing known to enclose. Correct + // this. + if (new_top_node_p == NULL) { + new_top_node_p = top_node_p; + } + is_invalid = true; + HL_CUR_TOKEN(NestingParenthesis); + ERROR_FROM_TOKEN_AND_MSG( + cur_token, _("E15: Unexpected closing parenthesis: %.*s")); + cur_node = NEW_NODE(kExprNodeNested); + cur_node->start = cur_token.start; + cur_node->len = 0; + // Unexpected closing parenthesis, assume that it was wanted to + // enclose everything in (). + cur_node->children = *new_top_node_p; + *new_top_node_p = cur_node; + assert(cur_node->next == NULL); + } + kvi_push(ast_stack, new_top_node_p); + want_level = kELvlOperator; + } else { + if (want_level == kELvlValue) { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeNested); + *top_node_p = cur_node; + kvi_push(ast_stack, &cur_node->children); + HL_CUR_TOKEN(NestingParenthesis); + } else if (want_level == kELvlOperator) { + if (prev_token.type == kExprLexSpacing) { + // For some reason "function (args)" is a function call, but + // "(funcref) (args)" is not. AFAIR this somehow involves + // compatibility and Bram was commenting that this is + // intentionally inconsistent and he is not very happy with the + // situation himself. + if ((*top_node_p)->type != kExprNodePlainIdentifier + && (*top_node_p)->type != kExprNodeComplexIdentifier) { + OP_MISSING; + } + } + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeCall); + viml_pexpr_handle_bop(&ast_stack, cur_node, &want_level); + HL_CUR_TOKEN(CallingParenthesis); + } else { + // Currently it is impossible to reach this. + assert(false); + } + want_level = kELvlValue; + } + break; + } + } +viml_pexpr_parse_cycle_end: + prev_token = cur_token; + highlighted_prev_spacing = false; + viml_parser_advance(pstate, cur_token.len); + } while (true); +viml_pexpr_parse_end: + if (want_level == kELvlValue) { + east_set_error(&ast, pstate, _("E15: Expected value: %.*s"), pstate->pos); + } else if (kv_size(ast_stack) != 1) { + // Something may be wrong, check whether it really is. + + // Pointer to ast.root must never be dropped, so “!= 1†is expected to be + // the same as “> 1â€. + assert(kv_size(ast_stack)); + // Topmost stack item must be a *finished* value, so it must not be + // analyzed. E.g. it may contain an already finished nested expression. + kv_drop(ast_stack, 1); + while (ast.correct && kv_size(ast_stack)) { + const ExprASTNode *const cur_node = (*kv_pop(ast_stack)); + // This should only happen when want_level == kELvlValue. + assert(cur_node != NULL); + switch (cur_node->type) { + case kExprNodeOpMissing: + case kExprNodeMissing: { + // Error should’ve been already reported. + break; + } + case kExprNodeCall: { + // TODO(ZyX-I): Rehighlight as invalid? + east_set_error( + &ast, pstate, + _("E116: Missing closing parenthesis for function call: %.*s"), + cur_node->start); + break; + } + case kExprNodeNested: { + // TODO(ZyX-I): Rehighlight as invalid? + east_set_error( + &ast, pstate, + _("E110: Missing closing parenthesis for nested expression" + ": %.*s"), + cur_node->start); + break; + } + case kExprNodeBinaryPlus: + case kExprNodeUnaryPlus: + case kExprNodeRegister: { + // It is OK to see these in the stack. + break; + } + // TODO(ZyX-I): handle other values + } + } + } + kvi_destroy(ast_stack); + return ast; +} + +#undef NEW_NODE +#undef HL diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 52354760a5..13888562df 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -111,6 +111,80 @@ typedef struct { } data; ///< Additional data, if needed. } LexExprToken; +/// Expression AST node type +typedef enum { + kExprNodeMissing = 'X', + kExprNodeOpMissing = '_', + kExprNodeTernary = '?', ///< Ternary operator, valid one has three children. + kExprNodeRegister = '@', ///< Register, no children. + kExprNodeSubscript = 's', ///< Subscript, should have two or three children. + kExprNodeListLiteral = 'l', ///< List literal, any number of children. + kExprNodeUnaryPlus = 'p', + kExprNodeBinaryPlus = '+', + kExprNodeNested = 'e', ///< Nested parenthesised expression. + kExprNodeCall = 'c', ///< Function call. + /// Plain identifier: simple variable/function name + /// + /// Looks like "string", "g:Foo", etc: consists from a single + /// kExprLexPlainIdentifier token. + kExprNodePlainIdentifier = 'i', + /// Complex identifier: variable/function name with curly braces + kExprNodeComplexIdentifier = 'I', +} ExprASTNodeType; + +typedef struct expr_ast_node ExprASTNode; + +/// Structure representing one AST node +struct expr_ast_node { + ExprASTNodeType type; ///< Node type. + /// Node children: e.g. for 1 + 2 nodes 1 and 2 will be children of +. + ExprASTNode *children; + /// Next node: e.g. for 1 + 2 child nodes 1 and 2 are put into a single-linked + /// list: `(+)->children` references only node 1, node 2 is in + /// `(+)->children->next`. + ExprASTNode *next; + ParserPosition start; + size_t len; + union { + struct { + int name; ///< Register name, may be -1 if name not present. + } reg; ///< For kExprNodeRegister. + } data; +}; + +enum { + /// Allow multiple expressions in a row: e.g. for :echo + /// + /// Parser will still parse only one of them though. + kExprFlagsMulti = (1 << 0), + /// Allow NL, NUL and bar to be EOC + /// + /// When parsing expressions input by user bar is assumed to be a binary + /// operator and other two are spacings. + kExprFlagsDisallowEOC = (1 << 1), + /// Print errors when encountered + /// + /// Without the flag they are only taken into account when parsing. + kExprFlagsPrintError = (1 << 2), +} ExprParserFlags; + +/// Structure representing complety AST for one expression +typedef struct { + /// True if represented AST is correct and can be executed. Incorrect ones may + /// still be used for completion, or in linters. + bool correct; + /// When AST is not correct this message will be printed. + /// + /// Uses `emsgf(msg, arg_len, arg);`, `msg` is assumed to contain only `%.*s`. + struct { + const char *msg; + int arg_len; + const char *arg; + } err; + /// Root node of the AST. + ExprASTNode *root; +} ExprAST; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "viml/parser/expressions.h.generated.h" #endif -- cgit From 7c97f783935ec122fbf0d7d070c00804738abd6a Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 11 Sep 2017 01:27:46 +0300 Subject: klee: Start preparing for klee tests First stage: something compiling without klee, but with a buch of dirty hacks - done. Second stage: something running under klee, able to emit useful results, but still using dirty hacks - done. Third stage: make CMake care about clang argumnets - not done, may be omitted if proves to be too hard. Not that klee can be run on CI in any case. --- src/nvim/lib/ringbuf.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src') diff --git a/src/nvim/lib/ringbuf.h b/src/nvim/lib/ringbuf.h index 12b75ec65a..e63eae70b0 100644 --- a/src/nvim/lib/ringbuf.h +++ b/src/nvim/lib/ringbuf.h @@ -15,6 +15,7 @@ #ifndef NVIM_LIB_RINGBUF_H #define NVIM_LIB_RINGBUF_H +#include #include #include #include @@ -73,6 +74,32 @@ typedef struct { \ RBType *buf_end; \ } TypeName##RingBuffer; +/// Dummy item free macros, for use in RINGBUF_INIT +/// +/// This macros actually does nothing. +/// +/// @param[in] item Item to be freed. +#define RINGBUF_DUMMY_FREE(item) + +/// Static ring buffer +/// +/// @warning Ring buffers created with this macros must neither be freed nor +/// deallocated. +/// +/// @param scope Ring buffer scope. +/// @param TypeName Ring buffer type name. +/// @param RBType Type of the single ring buffer element. +/// @param varname Variable name. +/// @param rbsize Ring buffer size. +#define RINGBUF_STATIC(scope, TypeName, RBType, varname, rbsize) \ +static RBType _##varname##_buf[rbsize]; \ +scope TypeName##RingBuffer varname = { \ + .buf = _##varname##_buf, \ + .next = _##varname##_buf, \ + .first = NULL, \ + .buf_end = _##varname##_buf + rbsize - 1, \ +}; + /// Initialize a new ring buffer /// /// @param TypeName Ring buffer type name. Actual type name will be -- cgit From 7980614650f0aedb39bf88466e5bd3ce90429cc1 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 17 Sep 2017 17:33:03 +0300 Subject: viml/parser/expressions: Add support for figure braces (three kinds) --- src/nvim/viml/parser/expressions.c | 644 +++++++++++++++++++++++++++++++++---- src/nvim/viml/parser/expressions.h | 35 ++ 2 files changed, 620 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index b54f2eb237..f4cfed3113 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -20,10 +20,22 @@ typedef kvec_withinit_t(ExprASTNode **, 16) ExprASTStack; +/// Which nodes may be wanted typedef enum { - kELvlOperator, ///< Operators: function call, subscripts, binary operators, … - kELvlValue, ///< Actual value: literals, variables, nested expressions. -} ExprASTLevel; + /// Operators: function call, subscripts, binary operators, … + /// + /// For unrestricted expressions. + kENodeOperator, + /// Values: literals, variables, nested expressions, unary operators. + /// + /// For unrestricted expressions as well, implies that top item in AST stack + /// points to NULL. + kENodeValue, + /// Argument: only allows simple argument names. + kENodeArgument, + /// Argument separator: only allows commas. + kENodeArgumentSeparator, +} ExprASTWantedNode; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "viml/parser/expressions.c.generated.h" @@ -456,6 +468,8 @@ viml_pexpr_next_token_adv_return: // // Used highlighting groups and assumed linkage: // +// NVimInternalError -> highlight as fg:red/bg:red +// // NVimInvalid -> Error // NVimInvalidValue -> NVimInvalid // NVimInvalidOperator -> NVimInvalid @@ -469,11 +483,33 @@ viml_pexpr_next_token_adv_return: // // NVimParenthesis -> Delimiter // +// NVimComma -> Delimiter +// NVimArrow -> Delimiter +// +// NVimLambda -> Delimiter +// NVimDict -> Delimiter +// NVimCurly -> Delimiter +// +// NVimIdentifier -> Identifier +// NVimIdentifierScope -> NVimIdentifier +// NVimIdentifierScopeDelimiter -> NVimIdentifier +// +// NVimFigureBrace -> NVimInternalError +// +// NVimInvalidComma -> NVimInvalidDelimiter // NVimInvalidSpacing -> NVimInvalid // NVimInvalidTernaryOperator -> NVimInvalidOperator // NVimInvalidRegister -> NVimInvalidValue // NVimInvalidClosingBracket -> NVimInvalidDelimiter // NVimInvalidSpacing -> NVimInvalid +// NVimInvalidArrow -> NVimInvalidDelimiter +// NVimInvalidLambda -> NVimInvalidDelimiter +// NVimInvalidDict -> NVimInvalidDelimiter +// NVimInvalidCurly -> NVimInvalidDelimiter +// NVimInvalidFigureBrace -> NVimInvalidDelimiter +// NVimInvalidIdentifier -> NVimInvalidValue +// NVimInvalidIdentifierScope -> NVimInvalidValue +// NVimInvalidIdentifierScopeDelimiter -> NVimInvalidValue // // NVimUnaryPlus -> NVimUnaryOperator // NVimBinaryPlus -> NVimBinaryOperator @@ -498,6 +534,9 @@ static inline ExprASTNode *viml_pexpr_new_node(const ExprASTNodeType type) typedef enum { kEOpLvlInvalid = 0, kEOpLvlParens, + kEOpLvlArrow, + kEOpLvlComma, + kEOpLvlColon, kEOpLvlTernary, kEOpLvlOr, kEOpLvlAnd, @@ -506,6 +545,7 @@ typedef enum { kEOpLvlMultiplication, ///< Multiplication, division and modulo. kEOpLvlUnary, ///< Unary operations: not, minus, plus. kEOpLvlSubscript, ///< Subscripts. + kEOpLvlComplexIdentifier, ///< Plain identifier, curly braces name. kEOpLvlValue, ///< Values: literals, variables, nested expressions, … } ExprOpLvl; @@ -520,7 +560,16 @@ static const ExprOpLvl node_type_to_op_lvl[] = { [kExprNodeOpMissing] = kEOpLvlMultiplication, [kExprNodeNested] = kEOpLvlParens, - [kExprNodeComplexIdentifier] = kEOpLvlParens, + + [kExprNodeUnknownFigure] = kEOpLvlParens, + [kExprNodeLambda] = kEOpLvlParens, + [kExprNodeDictLiteral] = kEOpLvlParens, + + [kExprNodeArrow] = kEOpLvlArrow, + + [kExprNodeComma] = kEOpLvlComma, + + [kExprNodeColon] = kEOpLvlColon, [kExprNodeTernary] = kEOpLvlTernary, @@ -531,9 +580,12 @@ static const ExprOpLvl node_type_to_op_lvl[] = { [kExprNodeSubscript] = kEOpLvlSubscript, [kExprNodeCall] = kEOpLvlSubscript, + [kExprNodeComplexIdentifier] = kEOpLvlComplexIdentifier, + [kExprNodePlainIdentifier] = kEOpLvlComplexIdentifier, + [kExprNodeCurlyBracesIdentifier] = kEOpLvlComplexIdentifier, + [kExprNodeRegister] = kEOpLvlValue, [kExprNodeListLiteral] = kEOpLvlValue, - [kExprNodePlainIdentifier] = kEOpLvlValue, }; static const ExprOpAssociativity node_type_to_op_ass[] = { @@ -541,7 +593,24 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { [kExprNodeOpMissing] = kEOpAssNo, [kExprNodeNested] = kEOpAssNo, - [kExprNodeComplexIdentifier] = kEOpAssLeft, + + [kExprNodeUnknownFigure] = kEOpAssLeft, + [kExprNodeLambda] = kEOpAssNo, + [kExprNodeDictLiteral] = kEOpAssNo, + + // Does not really matter. + [kExprNodeArrow] = kEOpAssNo, + + [kExprNodeColon] = kEOpAssNo, + + // Right associativity for comma because this means easier access to arguments + // list, etc: for "[a, b, c, d]" you can access "a" in one step if it is + // represented as "list(comma(a, comma(b, comma(c, d))))" then if it is + // "list(comma(comma(comma(a, b), c), d))" in which case you will need to + // traverse all three comma() structures. And with comma operator (including + // actual comma operator from C which is not present in VimL) nobody cares + // about associativity, only about order of execution. + [kExprNodeComma] = kEOpAssRight, [kExprNodeTernary] = kEOpAssNo, @@ -552,14 +621,31 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { [kExprNodeSubscript] = kEOpAssLeft, [kExprNodeCall] = kEOpAssLeft, + [kExprNodePlainIdentifier] = kEOpAssLeft, + [kExprNodeComplexIdentifier] = kEOpAssLeft, + [kExprNodeCurlyBracesIdentifier] = kEOpAssLeft, + [kExprNodeRegister] = kEOpAssNo, [kExprNodeListLiteral] = kEOpAssNo, - [kExprNodePlainIdentifier] = kEOpAssNo, }; #ifdef UNIT_TESTING #include REAL_FATTR_UNUSED +static inline void viml_pexpr_debug_print_ast_node( + const ExprASTNode *const *const eastnode_p, + const char *const prefix) +{ + if (*eastnode_p == NULL) { + fprintf(stderr, "%s %p : NULL\n", prefix, (void *)eastnode_p); + } else { + fprintf(stderr, "%s %p : %p : %c : %zu:%zu:%zu\n", + prefix, (void *)eastnode_p, (void *)(*eastnode_p), + (*eastnode_p)->type, (*eastnode_p)->start.line, + (*eastnode_p)->start.col, (*eastnode_p)->len); + } +} +REAL_FATTR_UNUSED static inline void viml_pexpr_debug_print_ast_stack( const ExprASTStack *const ast_stack, const char *const msg) @@ -567,22 +653,17 @@ static inline void viml_pexpr_debug_print_ast_stack( { fprintf(stderr, "\n%sstack: %zu:\n", msg, kv_size(*ast_stack)); for (size_t i = 0; i < kv_size(*ast_stack); i++) { - const ExprASTNode *const *const eastnode_p = ( - (const ExprASTNode *const *)kv_A(*ast_stack, i)); - if (*eastnode_p == NULL) { - fprintf(stderr, "- %p : NULL\n", (void *)eastnode_p); - } else { - fprintf(stderr, "- %p : %p : %c : %zu:%zu:%zu\n", - (void *)eastnode_p, (void *)(*eastnode_p), (*eastnode_p)->type, - (*eastnode_p)->start.line, (*eastnode_p)->start.col, - (*eastnode_p)->len); - } + viml_pexpr_debug_print_ast_node( + (const ExprASTNode *const *)kv_A(*ast_stack, i), + "-"); } } #define PSTACK(msg) \ viml_pexpr_debug_print_ast_stack(&ast_stack, #msg) #define PSTACK_P(msg) \ viml_pexpr_debug_print_ast_stack(ast_stack, #msg) +#define PNODE_P(eastnode_p, msg) \ + viml_pexpr_debug_print_ast_node((const ExprASTNode *const *)ast_stack, #msg) #endif /// Handle binary operator @@ -590,7 +671,7 @@ static inline void viml_pexpr_debug_print_ast_stack( /// This function is responsible for handling priority levels as well. static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, ExprASTNode *const bop_node, - ExprASTLevel *const want_level_p) + ExprASTWantedNode *const want_node_p) FUNC_ATTR_NONNULL_ALL { ExprASTNode **top_node_p = NULL; @@ -599,6 +680,9 @@ static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, ExprOpAssociativity top_node_ass; assert(kv_size(*ast_stack)); const ExprOpLvl bop_node_lvl = node_type_to_op_lvl[bop_node->type]; +#ifndef NDEBUG + const ExprOpAssociativity bop_node_ass = node_type_to_op_ass[bop_node->type]; +#endif do { ExprASTNode **new_top_node_p = kv_last(*ast_stack); ExprASTNode *new_top_node = *new_top_node_p; @@ -606,6 +690,8 @@ static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, const ExprOpLvl new_top_node_lvl = node_type_to_op_lvl[new_top_node->type]; const ExprOpAssociativity new_top_node_ass = ( node_type_to_op_ass[new_top_node->type]); + assert(bop_node_lvl != new_top_node_lvl + || bop_node_ass == new_top_node_ass); if (top_node_p != NULL && ((bop_node_lvl > new_top_node_lvl || (bop_node_lvl == new_top_node_lvl @@ -617,14 +703,60 @@ static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, top_node = new_top_node; top_node_lvl = new_top_node_lvl; top_node_ass = new_top_node_ass; + if (bop_node_lvl == top_node_lvl && top_node_ass == kEOpAssRight) { + break; + } } while (kv_size(*ast_stack)); - // FIXME Handle right and no associativity correctly - *top_node_p = bop_node; - bop_node->children = top_node; - assert(bop_node->children->next == NULL); - kvi_push(*ast_stack, top_node_p); - kvi_push(*ast_stack, &bop_node->children->next); - *want_level_p = kELvlValue; + // FIXME: Handle no associativity + if (top_node_ass == kEOpAssLeft || top_node_lvl != bop_node_lvl) { + // outer(op(x,y)) -> outer(new_op(op(x,y),*)) + // + // Before: top_node_p = outer(*), points to op(x,y) + // Other stack elements unknown + // + // After: top_node_p = outer(*), points to new_op(op(x,y)) + // &bop_node->children->next = new_op(op(x,y),*), points to NULL + *top_node_p = bop_node; + bop_node->children = top_node; + assert(bop_node->children->next == NULL); + kvi_push(*ast_stack, top_node_p); + kvi_push(*ast_stack, &bop_node->children->next); + } else { + assert(top_node_lvl == bop_node_lvl && top_node_ass == kEOpAssRight); + assert(top_node->children != NULL && top_node->children->next != NULL); + // outer(op(x,y)) -> outer(op(x,new_op(y,*))) + // + // Before: top_node_p = outer(*), points to op(x,y) + // Other stack elements unknown + // + // After: top_node_p = outer(*), points to op(x,new_op(y)) + // &top_node->children->next = op(x,*), points to new_op(y) + // &bop_node->children->next = new_op(y,*), points to NULL + bop_node->children = top_node->children->next; + top_node->children->next = bop_node; + assert(bop_node->children->next == NULL); + kvi_push(*ast_stack, top_node_p); + kvi_push(*ast_stack, &top_node->children->next); + kvi_push(*ast_stack, &bop_node->children->next); + } + *want_node_p = (*want_node_p == kENodeArgumentSeparator + ? kENodeArgument + : kENodeValue); +} + +/// ParserPosition literal based on ParserPosition pos with columns shifted +/// +/// Function does not check whether remaining position is valid. +/// +/// @param[in] pos Position to shift. +/// @param[in] shift Number of bytes to shift. +/// +/// @return Shifted position. +static inline ParserPosition shifted_pos(const ParserPosition pos, + const size_t shift) + FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_WARN_UNUSED_RESULT +{ + return (ParserPosition) { .line = pos.line, .col = pos.col + shift }; } /// Get highlight group name @@ -692,12 +824,25 @@ static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, ERROR_FROM_TOKEN_AND_MSG(cur_token, _("E15: Missing operator: %.*s")); \ NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeOpMissing); \ cur_node->len = 0; \ - viml_pexpr_handle_bop(&ast_stack, cur_node, &want_level); \ - is_invalid = true; \ + viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); \ goto viml_pexpr_parse_process_token; \ } \ } while (0) +/// Record missing value: for things like "* 5" +/// +/// @param[in] msg Error message. +#define ADD_VALUE_IF_MISSING(msg) \ + do { \ + if (want_node == kENodeValue) { \ + ERROR_FROM_TOKEN_AND_MSG(cur_token, (msg)); \ + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeMissing); \ + cur_node->len = 0; \ + *top_node_p = cur_node; \ + want_node = kENodeOperator; \ + } \ + } while (0) + /// Set AST error, unless AST already is not correct /// /// @param[out] ret_ast AST to set error in. @@ -721,14 +866,42 @@ static inline void east_set_error(ExprAST *const ret_ast, ret_ast->err.arg = pline.data + start.col; } -/// Set error from the given kExprLexInvalid token and given message +/// Set error from the given token and given message #define ERROR_FROM_TOKEN_AND_MSG(cur_token, msg) \ - east_set_error(&ast, pstate, msg, cur_token.start) + do { \ + is_invalid = true; \ + east_set_error(&ast, pstate, msg, cur_token.start); \ + } while (0) + +/// Like #ERROR_FROM_TOKEN_AND_MSG, but gets position from a node +#define ERROR_FROM_NODE_AND_MSG(node, msg) \ + do { \ + is_invalid = true; \ + east_set_error(&ast, pstate, msg, node->start); \ + } while (0) /// Set error from the given kExprLexInvalid token #define ERROR_FROM_TOKEN(cur_token) \ ERROR_FROM_TOKEN_AND_MSG(cur_token, cur_token.data.err.msg) +/// Select figure brace type, altering highlighting as well if needed +/// +/// @param[out] node Node to modify type. +/// @param[in] new_type New type, one of ExprASTNodeType values without +/// kExprNode prefix. +/// @param[in] hl Corresponding highlighting, passed as an argument to #HL. +#define SELECT_FIGURE_BRACE_TYPE(node, new_type, hl) \ + do { \ + ExprASTNode *const node_ = (node); \ + assert(node_->type == kExprNodeUnknownFigure \ + || node_->type == kExprNode##new_type); \ + node_->type = kExprNode##new_type; \ + if (pstate->colors) { \ + kv_A(*pstate->colors, node_->data.fig.opening_hl_idx).group = \ + HL(hl); \ + } \ + } while (0) + /// Parse one VimL expression /// /// @param pstate Parser state. @@ -751,13 +924,15 @@ ExprAST viml_pexpr_parse(ParserState *const pstate, const int flags) kvi_init(ast_stack); kvi_push(ast_stack, &ast.root); // Expressions stack: - // 1. *last is NULL if want_level is kExprLexValue. Indicates where expression + // 1. *last is NULL if want_node is kExprLexValue. Indicates where expression // is to be put. // 2. *last is not NULL otherwise, indicates current expression to be used as // an operator argument. - ExprASTLevel want_level = kELvlValue; + ExprASTWantedNode want_node = kENodeValue; LexExprToken prev_token = { .type = kExprLexMissing }; bool highlighted_prev_spacing = false; + // Lambda node, valid when parsing lambda arguments only. + ExprASTNode *lambda_node = NULL; do { LexExprToken cur_token = viml_pexpr_next_token(pstate, true); if (cur_token.type == kExprLexEOC) { @@ -789,8 +964,7 @@ ExprAST viml_pexpr_parse(ParserState *const pstate, const int flags) viml_pexpr_parse_process_token: if (tok_type == kExprLexSpacing) { if (is_invalid) { - viml_parser_highlight(pstate, cur_token.start, cur_token.len, - HL(Spacing)); + HL_CUR_TOKEN(Spacing); } else { // Do not do anything: let regular spacing be highlighted as normal. // This also allows later to highlight spacing as invalid. @@ -803,11 +977,44 @@ viml_pexpr_parse_process_token: is_invalid = false; highlighted_prev_spacing = true; } + const ParserLine pline = pstate->reader.lines.items[cur_token.start.line]; ExprASTNode **const top_node_p = kv_last(ast_stack); ExprASTNode *cur_node = NULL; - // Keep these two asserts separate for debugging purposes. - assert(want_level == kELvlValue || *top_node_p != NULL); - assert(want_level != kELvlValue || *top_node_p == NULL); + assert((want_node == kENodeValue || want_node == kENodeArgument) + == (*top_node_p == NULL)); + if ((want_node == kENodeArgumentSeparator + && tok_type != kExprLexComma + && tok_type != kExprLexArrow) + || (want_node == kENodeArgument + && !(tok_type == kExprLexPlainIdentifier + && cur_token.data.var.scope == 0 + && !cur_token.data.var.autoload) + && tok_type != kExprLexArrow)) { + lambda_node->data.fig.type_guesses.allow_lambda = false; + if (lambda_node->children != NULL + && lambda_node->children->type == kExprNodeComma) { + // If lambda has comma child this means that parser has already seen at + // least "{arg1,", so node cannot possibly be anything, but lambda. + + // Vim may give E121 or E720 in this case, but it does not look right to + // have either because both are results of reevaluation possibly-lambda + // node as a dictionary and here this is not going to happen. + ERROR_FROM_TOKEN_AND_MSG( + cur_token, _("E15: Expected lambda arguments list or arrow: %.*s")); + } else { + // Else it may appear that possibly-lambda node is actually a dictionary + // or curly-braces-name identifier. + lambda_node = NULL; + if (want_node == kENodeArgumentSeparator) { + want_node = kENodeOperator; + } else { + want_node = kENodeValue; + } + } + } + assert(lambda_node == NULL + || want_node == kENodeArgumentSeparator + || want_node == kENodeArgument); switch (tok_type) { case kExprLexEOC: { assert(false); @@ -818,13 +1025,12 @@ viml_pexpr_parse_process_token: goto viml_pexpr_parse_process_token; } case kExprLexRegister: { - if (want_level == kELvlValue) { + if (want_node == kENodeValue) { NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeRegister); cur_node->data.reg.name = cur_token.data.reg.name; *top_node_p = cur_node; - want_level = kELvlOperator; - viml_parser_highlight(pstate, cur_token.start, cur_token.len, - HL(Register)); + want_node = kENodeOperator; + HL_CUR_TOKEN(Register); } else { // Register in operator position: e.g. @a @a OP_MISSING; @@ -832,23 +1038,343 @@ viml_pexpr_parse_process_token: break; } case kExprLexPlus: { - if (want_level == kELvlValue) { + if (want_node == kENodeValue) { // Value level: assume unary plus NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeUnaryPlus); *top_node_p = cur_node; kvi_push(ast_stack, &cur_node->children); HL_CUR_TOKEN(UnaryPlus); - } else if (want_level < kELvlValue) { + } else { NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeBinaryPlus); - viml_pexpr_handle_bop(&ast_stack, cur_node, &want_level); + viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); HL_CUR_TOKEN(BinaryPlus); } - want_level = kELvlValue; + want_node = kENodeValue; + break; + } + case kExprLexComma: { + assert(want_node != kENodeArgument); + if (want_node == kENodeValue) { + // Value level: comma appearing here is not valid. + // Note: in Vim string(,x) will give E116, this is not the case here. + ERROR_FROM_TOKEN_AND_MSG( + cur_token, _("E15: Expected value, got comma: %.*s")); + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeMissing); + cur_node->len = 0; + *top_node_p = cur_node; + want_node = (want_node == kENodeArgument + ? kENodeArgumentSeparator + : kENodeOperator); + } + if (want_node == kENodeArgumentSeparator) { + assert(lambda_node->data.fig.type_guesses.allow_lambda); + assert(lambda_node != NULL); + SELECT_FIGURE_BRACE_TYPE(lambda_node, Lambda, Lambda); + } + if (kv_size(ast_stack) < 2) { + goto viml_pexpr_parse_invalid_comma; + } + for (size_t i = 1; i < kv_size(ast_stack); i++) { + const ExprASTNode *const *const eastnode_p = + (const ExprASTNode *const *)kv_Z(ast_stack, i); + if (!((*eastnode_p)->type == kExprNodeComma + || ((*eastnode_p)->type == kExprNodeColon + && i == 1)) + || i == kv_size(ast_stack) - 1) { + switch ((*eastnode_p)->type) { + case kExprNodeLambda: { + assert(want_node == kENodeArgumentSeparator); + break; + } + case kExprNodeDictLiteral: + case kExprNodeListLiteral: + case kExprNodeCall: { + break; + } + default: { +viml_pexpr_parse_invalid_comma: + ERROR_FROM_TOKEN_AND_MSG( + cur_token, + _("E15: Comma outside of call, lambda or literal: %.*s")); + break; + } + } + break; + } + } + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeComma); + viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); + HL_CUR_TOKEN(Comma); + break; + } + case kExprLexColon: { + ADD_VALUE_IF_MISSING(_("E15: Expected value, got colon: %.*s")); + if (kv_size(ast_stack) < 2) { + goto viml_pexpr_parse_invalid_colon; + } + for (size_t i = 1; i < kv_size(ast_stack); i++) { + ExprASTNode *const *const eastnode_p = + (ExprASTNode *const *)kv_Z(ast_stack, i); + if ((*eastnode_p)->type != kExprNodeColon + || i == kv_size(ast_stack) - 1) { + switch ((*eastnode_p)->type) { + case kExprNodeUnknownFigure: { + SELECT_FIGURE_BRACE_TYPE((*eastnode_p), DictLiteral, Dict); + break; + } + case kExprNodeComma: + case kExprNodeDictLiteral: + case kExprNodeTernary: { + break; + } + default: { +viml_pexpr_parse_invalid_colon: + ERROR_FROM_TOKEN_AND_MSG( + cur_token, + _("E15: Colon outside of dictionary or ternary operator: " + "%.*s")); + break; + } + } + break; + } + } + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeColon); + viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); + // FIXME: Handle ternary operator. + HL_CUR_TOKEN(Colon); + want_node = kENodeValue; + break; + } + case kExprLexFigureBrace: { + if (cur_token.data.brc.closing) { + ExprASTNode **new_top_node_p = NULL; + // Always drop the topmost value: + // + // 1. When want_node != kENodeValue topmost item on stack is + // a *finished* left operand, which may as well be "{@a}" which + // needs not be finished again. + // 2. Otherwise it is pointing to NULL what nobody wants. + kv_drop(ast_stack, 1); + if (!kv_size(ast_stack)) { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeUnknownFigure); + cur_node->data.fig.type_guesses.allow_lambda = false; + cur_node->data.fig.type_guesses.allow_dict = false; + cur_node->data.fig.type_guesses.allow_ident = false; + cur_node->len = 0; + if (want_node != kENodeValue) { + cur_node->children = *top_node_p; + } + *top_node_p = cur_node; + goto viml_pexpr_parse_figure_brace_closing_error; + } + if (want_node == kENodeValue) { + if ((*kv_last(ast_stack))->type != kExprNodeUnknownFigure + && (*kv_last(ast_stack))->type != kExprNodeComma) { + // kv_last being UnknownFigure may occur for empty dictionary + // literal, while Comma is expected in case of non-empty one. + ERROR_FROM_TOKEN_AND_MSG( + cur_token, + _("E15: Expected value, got closing figure brace: %.*s")); + } + } else { + if (!kv_size(ast_stack)) { + new_top_node_p = top_node_p; + goto viml_pexpr_parse_figure_brace_closing_error; + } + } + do { + new_top_node_p = kv_pop(ast_stack); + } while (kv_size(ast_stack) + && (new_top_node_p == NULL + || ((*new_top_node_p)->type != kExprNodeUnknownFigure + && (*new_top_node_p)->type != kExprNodeDictLiteral + && ((*new_top_node_p)->type + != kExprNodeCurlyBracesIdentifier) + && (*new_top_node_p)->type != kExprNodeLambda))); + ExprASTNode *new_top_node = *new_top_node_p; + switch (new_top_node->type) { + case kExprNodeUnknownFigure: { + if (new_top_node->children == NULL) { + // No children of curly braces node indicates empty dictionary. + + // Should actually be kENodeArgument, but that was changed + // earlier. + assert(want_node == kENodeValue); + assert(new_top_node->data.fig.type_guesses.allow_dict); + SELECT_FIGURE_BRACE_TYPE(new_top_node, DictLiteral, Dict); + HL_CUR_TOKEN(Dict); + } else if (new_top_node->data.fig.type_guesses.allow_ident) { + SELECT_FIGURE_BRACE_TYPE(new_top_node, CurlyBracesIdentifier, + Curly); + HL_CUR_TOKEN(Curly); + } else { + // If by this time type of the node has not already been + // guessed, but it definitely is not a curly braces name then + // it is invalid for sure. + ERROR_FROM_NODE_AND_MSG( + new_top_node, + _("E15: Don't know what figure brace means: %.*s")); + if (pstate->colors) { + // Will reset to NVimInvalidFigureBrace. + kv_A(*pstate->colors, + new_top_node->data.fig.opening_hl_idx).group = ( + HL(FigureBrace)); + } + HL_CUR_TOKEN(FigureBrace); + } + break; + } + case kExprNodeDictLiteral: { + HL_CUR_TOKEN(Dict); + break; + } + case kExprNodeCurlyBracesIdentifier: { + HL_CUR_TOKEN(Curly); + break; + } + case kExprNodeLambda: { + HL_CUR_TOKEN(Lambda); + break; + } + default: { +viml_pexpr_parse_figure_brace_closing_error: + assert(!kv_size(ast_stack)); + ERROR_FROM_TOKEN_AND_MSG( + cur_token, _("E15: Unexpected closing figure brace: %.*s")); + HL_CUR_TOKEN(FigureBrace); + break; + } + } + kvi_push(ast_stack, new_top_node_p); + want_node = kENodeOperator; + } else { + if (want_node == kENodeValue) { + HL_CUR_TOKEN(FigureBrace); + // Value: may be any of lambda, dictionary literal and curly braces + // name. + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeUnknownFigure); + cur_node->data.fig.type_guesses.allow_lambda = true; + cur_node->data.fig.type_guesses.allow_dict = true; + cur_node->data.fig.type_guesses.allow_ident = true; + if (pstate->colors) { + cur_node->data.fig.opening_hl_idx = kv_size(*pstate->colors) - 1; + } + *top_node_p = cur_node; + kvi_push(ast_stack, &cur_node->children); + want_node = kENodeArgument; + lambda_node = cur_node; + } else { + // Operator: may only be curly braces name, but only under certain + // conditions. + + // First condition is that there is no space before {. + if (prev_token.type == kExprLexSpacing) { + OP_MISSING; + } + switch ((*top_node_p)->type) { + // Second is that previous node is one of the identifiers: + // complex, plain, curly braces. + + // TODO(ZyX-I): Extend syntax to allow ${expr}. This is needed to + // handle environment variables like those bash uses for + // `export -f`: their names consist not only of alphanumeric + // characetrs. + case kExprNodeComplexIdentifier: + case kExprNodePlainIdentifier: + case kExprNodeCurlyBracesIdentifier: { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeComplexIdentifier); + cur_node->len = 0; + viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); + ExprASTNode *const new_top_node = *kv_last(ast_stack); + assert(new_top_node->next == NULL); + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeCurlyBracesIdentifier); + new_top_node->next = cur_node; + kvi_push(ast_stack, &cur_node->children); + HL_CUR_TOKEN(Curly); + break; + } + default: { + OP_MISSING; + break; + } + } + } + } + break; + } + case kExprLexArrow: { + if (want_node == kENodeArgumentSeparator + || want_node == kENodeArgument) { + if (want_node == kENodeArgument) { + kv_drop(ast_stack, 1); + } + assert(kv_size(ast_stack) >= 1); + while ((*kv_last(ast_stack))->type != kExprNodeLambda + && (*kv_last(ast_stack))->type != kExprNodeUnknownFigure) { + kv_drop(ast_stack, 1); + } + assert((*kv_last(ast_stack)) == lambda_node); + SELECT_FIGURE_BRACE_TYPE(lambda_node, Lambda, Lambda); + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeArrow); + if (lambda_node->children == NULL) { + assert(want_node == kENodeArgument); + lambda_node->children = cur_node; + kvi_push(ast_stack, &lambda_node->children); + } else { + assert(lambda_node->children->next == NULL); + lambda_node->children->next = cur_node; + kvi_push(ast_stack, &lambda_node->children->next); + } + kvi_push(ast_stack, &cur_node->children); + lambda_node = NULL; + } else { + // Only first branch is valid. + is_invalid = true; + ADD_VALUE_IF_MISSING(_("E15: Unexpected arrow: %.*s")); + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeArrow); + viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); + } + want_node = kENodeValue; + HL_CUR_TOKEN(Arrow); + break; + } + case kExprLexPlainIdentifier: { + if (want_node == kENodeValue || want_node == kENodeArgument) { + want_node = (want_node == kENodeArgument + ? kENodeArgumentSeparator + : kENodeOperator); + // FIXME: It is not valid to have scope inside complex identifier, + // check that. + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodePlainIdentifier); + cur_node->data.var.scope = cur_token.data.var.scope; + const size_t scope_shift = (cur_token.data.var.scope == 0 + ? 0 + : 2); + cur_node->data.var.ident = (pline.data + cur_token.start.col + + scope_shift); + cur_node->data.var.ident_len = cur_token.len - scope_shift; + *top_node_p = cur_node; + if (scope_shift) { + viml_parser_highlight(pstate, cur_token.start, 1, + HL(IdentifierScope)); + viml_parser_highlight(pstate, shifted_pos(cur_token.start, 1), 1, + HL(IdentifierScopeDelimiter)); + } + if (scope_shift < cur_token.len) { + viml_parser_highlight(pstate, shifted_pos(cur_token.start, + scope_shift), + cur_token.len - scope_shift, + HL(Identifier)); + } + } else { + OP_MISSING; + } break; } case kExprLexParenthesis: { if (cur_token.data.brc.closing) { - if (want_level == kELvlValue) { + if (want_node == kENodeValue) { if (kv_size(ast_stack) > 1) { const ExprASTNode *const prev_top_node = *kv_Z(ast_stack, 1); if (prev_top_node->type == kExprNodeCall) { @@ -858,15 +1384,15 @@ viml_pexpr_parse_process_token: goto viml_pexpr_parse_no_paren_closing_error; } } - is_invalid = true; - ERROR_FROM_TOKEN_AND_MSG(cur_token, _("E15: Expected value: %.*s")); + ERROR_FROM_TOKEN_AND_MSG( + cur_token, _("E15: Expected value, got parenthesis: %.*s")); NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeMissing); cur_node->len = 0; *top_node_p = cur_node; } else { - // Always drop the topmost value: when want_level != kELvlValue + // Always drop the topmost value: when want_node != kENodeValue // topmost item on stack is a *finished* left operand, which may as - // well be "(@a)" which needs not be finished. + // well be "(@a)" which needs not be finished again. kv_drop(ast_stack, 1); } viml_pexpr_parse_no_paren_closing_error: {} @@ -892,10 +1418,9 @@ viml_pexpr_parse_no_paren_closing_error: {} if (new_top_node_p == NULL) { new_top_node_p = top_node_p; } - is_invalid = true; - HL_CUR_TOKEN(NestingParenthesis); ERROR_FROM_TOKEN_AND_MSG( cur_token, _("E15: Unexpected closing parenthesis: %.*s")); + HL_CUR_TOKEN(NestingParenthesis); cur_node = NEW_NODE(kExprNodeNested); cur_node->start = cur_token.start; cur_node->len = 0; @@ -906,14 +1431,14 @@ viml_pexpr_parse_no_paren_closing_error: {} assert(cur_node->next == NULL); } kvi_push(ast_stack, new_top_node_p); - want_level = kELvlOperator; + want_node = kENodeOperator; } else { - if (want_level == kELvlValue) { + if (want_node == kENodeValue) { NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeNested); *top_node_p = cur_node; kvi_push(ast_stack, &cur_node->children); HL_CUR_TOKEN(NestingParenthesis); - } else if (want_level == kELvlOperator) { + } else if (want_node == kENodeOperator) { if (prev_token.type == kExprLexSpacing) { // For some reason "function (args)" is a function call, but // "(funcref) (args)" is not. AFAIR this somehow involves @@ -926,13 +1451,13 @@ viml_pexpr_parse_no_paren_closing_error: {} } } NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeCall); - viml_pexpr_handle_bop(&ast_stack, cur_node, &want_level); + viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); HL_CUR_TOKEN(CallingParenthesis); } else { // Currently it is impossible to reach this. assert(false); } - want_level = kELvlValue; + want_node = kENodeValue; } break; } @@ -943,8 +1468,9 @@ viml_pexpr_parse_cycle_end: viml_parser_advance(pstate, cur_token.len); } while (true); viml_pexpr_parse_end: - if (want_level == kELvlValue) { - east_set_error(&ast, pstate, _("E15: Expected value: %.*s"), pstate->pos); + if (want_node == kENodeValue) { + east_set_error(&ast, pstate, _("E15: Expected value, got EOC: %.*s"), + pstate->pos); } else if (kv_size(ast_stack) != 1) { // Something may be wrong, check whether it really is. @@ -956,7 +1482,7 @@ viml_pexpr_parse_end: kv_drop(ast_stack, 1); while (ast.correct && kv_size(ast_stack)) { const ExprASTNode *const cur_node = (*kv_pop(ast_stack)); - // This should only happen when want_level == kELvlValue. + // This should only happen when want_node == kENodeValue. assert(cur_node != NULL); switch (cur_node->type) { case kExprNodeOpMissing: diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 13888562df..13640ec137 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -2,6 +2,7 @@ #define NVIM_VIML_PARSER_EXPRESSIONS_H #include +#include #include #include "nvim/types.h" @@ -130,6 +131,17 @@ typedef enum { kExprNodePlainIdentifier = 'i', /// Complex identifier: variable/function name with curly braces kExprNodeComplexIdentifier = 'I', + /// Figure brace expression which is not yet known + /// + /// May resolve to any of kExprNodeDictLiteral, kExprNodeLambda or + /// kExprNodeCurlyBracesIdentifier. + kExprNodeUnknownFigure = '{', + kExprNodeLambda = '\\', ///< Lambda. + kExprNodeDictLiteral = 'd', ///< Dictionary literal. + kExprNodeCurlyBracesIdentifier= '}', ///< Part of the curly braces name. + kExprNodeComma = ',', ///< Comma “operatorâ€. + kExprNodeColon = ':', ///< Colon “operatorâ€. + kExprNodeArrow = '>', ///< Arrow “operatorâ€. } ExprASTNodeType; typedef struct expr_ast_node ExprASTNode; @@ -149,6 +161,27 @@ struct expr_ast_node { struct { int name; ///< Register name, may be -1 if name not present. } reg; ///< For kExprNodeRegister. + struct { + /// Which nodes UnknownFigure can’t possibly represent. + struct { + /// True if UnknownFigure may actually represent dictionary literal. + bool allow_dict; + /// True if UnknownFigure may actually represent lambda. + bool allow_lambda; + /// True if UnknownFigure may actually be part of curly braces name. + bool allow_ident; + } type_guesses; + /// Highlight chunk index, used for rehighlighting if needed + size_t opening_hl_idx; + } fig; ///< For kExprNodeUnknownFigure. + struct { + int scope; ///< Scope character or 0 if not present. + /// Actual identifier without scope. + /// + /// Points to inside parser reader state. + const char *ident; + size_t ident_len; ///< Actual identifier length. + } var; } data; }; @@ -166,6 +199,8 @@ enum { /// /// Without the flag they are only taken into account when parsing. kExprFlagsPrintError = (1 << 2), + // WARNING: whenever you add a new flag, alter klee_assume() statement in + // viml_expressions_parser.c. } ExprParserFlags; /// Structure representing complety AST for one expression -- cgit From d4782fb1ca05e76095086bdcbc8dcea47f532d00 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 26 Sep 2017 00:28:34 +0300 Subject: viml/parser/expressions: Make commas actually work when calling --- src/nvim/viml/parser/expressions.c | 99 +++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index f4cfed3113..b9abf4a067 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -395,6 +395,43 @@ viml_pexpr_next_token_adv_return: return ret; } +#ifdef UNIT_TESTING +#include +REAL_FATTR_UNUSED +static inline void viml_pexpr_debug_print_ast_node( + const ExprASTNode *const *const eastnode_p, + const char *const prefix) +{ + if (*eastnode_p == NULL) { + fprintf(stderr, "%s %p : NULL\n", prefix, (void *)eastnode_p); + } else { + fprintf(stderr, "%s %p : %p : %c : %zu:%zu:%zu\n", + prefix, (void *)eastnode_p, (void *)(*eastnode_p), + (*eastnode_p)->type, (*eastnode_p)->start.line, + (*eastnode_p)->start.col, (*eastnode_p)->len); + } +} +REAL_FATTR_UNUSED +static inline void viml_pexpr_debug_print_ast_stack( + const ExprASTStack *const ast_stack, + const char *const msg) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE +{ + fprintf(stderr, "\n%sstack: %zu:\n", msg, kv_size(*ast_stack)); + for (size_t i = 0; i < kv_size(*ast_stack); i++) { + viml_pexpr_debug_print_ast_node( + (const ExprASTNode *const *)kv_A(*ast_stack, i), + "-"); + } +} +#define PSTACK(msg) \ + viml_pexpr_debug_print_ast_stack(&ast_stack, #msg) +#define PSTACK_P(msg) \ + viml_pexpr_debug_print_ast_stack(ast_stack, #msg) +#define PNODE_P(eastnode_p, msg) \ + viml_pexpr_debug_print_ast_node((const ExprASTNode *const *)ast_stack, #msg) +#endif + // start = s ternary_expr s EOC // ternary_expr = binop_expr // ( s Question s ternary_expr s Colon s ternary_expr s )? @@ -560,6 +597,9 @@ static const ExprOpLvl node_type_to_op_lvl[] = { [kExprNodeOpMissing] = kEOpLvlMultiplication, [kExprNodeNested] = kEOpLvlParens, + // Note: it is kEOpLvlSubscript for “binary operator†itself, but + // kEOpLvlParens when it comes to inside the parenthesis. + [kExprNodeCall] = kEOpLvlParens, [kExprNodeUnknownFigure] = kEOpLvlParens, [kExprNodeLambda] = kEOpLvlParens, @@ -578,7 +618,6 @@ static const ExprOpLvl node_type_to_op_lvl[] = { [kExprNodeUnaryPlus] = kEOpLvlUnary, [kExprNodeSubscript] = kEOpLvlSubscript, - [kExprNodeCall] = kEOpLvlSubscript, [kExprNodeComplexIdentifier] = kEOpLvlComplexIdentifier, [kExprNodePlainIdentifier] = kEOpLvlComplexIdentifier, @@ -593,6 +632,7 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { [kExprNodeOpMissing] = kEOpAssNo, [kExprNodeNested] = kEOpAssNo, + [kExprNodeCall] = kEOpAssNo, [kExprNodeUnknownFigure] = kEOpAssLeft, [kExprNodeLambda] = kEOpAssNo, @@ -619,7 +659,6 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { [kExprNodeUnaryPlus] = kEOpAssNo, [kExprNodeSubscript] = kEOpAssLeft, - [kExprNodeCall] = kEOpAssLeft, [kExprNodePlainIdentifier] = kEOpAssLeft, [kExprNodeComplexIdentifier] = kEOpAssLeft, @@ -629,43 +668,6 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { [kExprNodeListLiteral] = kEOpAssNo, }; -#ifdef UNIT_TESTING -#include -REAL_FATTR_UNUSED -static inline void viml_pexpr_debug_print_ast_node( - const ExprASTNode *const *const eastnode_p, - const char *const prefix) -{ - if (*eastnode_p == NULL) { - fprintf(stderr, "%s %p : NULL\n", prefix, (void *)eastnode_p); - } else { - fprintf(stderr, "%s %p : %p : %c : %zu:%zu:%zu\n", - prefix, (void *)eastnode_p, (void *)(*eastnode_p), - (*eastnode_p)->type, (*eastnode_p)->start.line, - (*eastnode_p)->start.col, (*eastnode_p)->len); - } -} -REAL_FATTR_UNUSED -static inline void viml_pexpr_debug_print_ast_stack( - const ExprASTStack *const ast_stack, - const char *const msg) - FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE -{ - fprintf(stderr, "\n%sstack: %zu:\n", msg, kv_size(*ast_stack)); - for (size_t i = 0; i < kv_size(*ast_stack); i++) { - viml_pexpr_debug_print_ast_node( - (const ExprASTNode *const *)kv_A(*ast_stack, i), - "-"); - } -} -#define PSTACK(msg) \ - viml_pexpr_debug_print_ast_stack(&ast_stack, #msg) -#define PSTACK_P(msg) \ - viml_pexpr_debug_print_ast_stack(ast_stack, #msg) -#define PNODE_P(eastnode_p, msg) \ - viml_pexpr_debug_print_ast_node((const ExprASTNode *const *)ast_stack, #msg) -#endif - /// Handle binary operator /// /// This function is responsible for handling priority levels as well. @@ -679,17 +681,24 @@ static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, ExprOpLvl top_node_lvl; ExprOpAssociativity top_node_ass; assert(kv_size(*ast_stack)); - const ExprOpLvl bop_node_lvl = node_type_to_op_lvl[bop_node->type]; +#define NODE_LVL(typ) \ + (bop_node->type == kExprNodeCall && typ == kExprNodeCall \ + ? kEOpLvlSubscript \ + : node_type_to_op_lvl[typ]) +#define NODE_ASS(typ) \ + (bop_node->type == kExprNodeCall && typ == kExprNodeCall \ + ? kEOpAssLeft \ + : node_type_to_op_ass[typ]) + const ExprOpLvl bop_node_lvl = NODE_LVL(bop_node->type); #ifndef NDEBUG - const ExprOpAssociativity bop_node_ass = node_type_to_op_ass[bop_node->type]; + const ExprOpAssociativity bop_node_ass = NODE_ASS(bop_node->type); #endif do { ExprASTNode **new_top_node_p = kv_last(*ast_stack); ExprASTNode *new_top_node = *new_top_node_p; assert(new_top_node != NULL); - const ExprOpLvl new_top_node_lvl = node_type_to_op_lvl[new_top_node->type]; - const ExprOpAssociativity new_top_node_ass = ( - node_type_to_op_ass[new_top_node->type]); + const ExprOpLvl new_top_node_lvl = NODE_LVL(new_top_node->type); + const ExprOpAssociativity new_top_node_ass = NODE_ASS(new_top_node->type); assert(bop_node_lvl != new_top_node_lvl || bop_node_ass == new_top_node_ass); if (top_node_p != NULL @@ -742,6 +751,8 @@ static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, *want_node_p = (*want_node_p == kENodeArgumentSeparator ? kENodeArgument : kENodeValue); +#undef NODE_ASS +#undef NODE_LVL } /// ParserPosition literal based on ParserPosition pos with columns shifted -- cgit From 3cc65ac054976ef7520f0247b430ebef2f9537b7 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 26 Sep 2017 00:52:40 +0300 Subject: viml/parser/expressions: Make commas actually work when calling --- src/nvim/viml/parser/expressions.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index b9abf4a067..7bee779c49 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -681,24 +681,22 @@ static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, ExprOpLvl top_node_lvl; ExprOpAssociativity top_node_ass; assert(kv_size(*ast_stack)); -#define NODE_LVL(typ) \ - (bop_node->type == kExprNodeCall && typ == kExprNodeCall \ - ? kEOpLvlSubscript \ - : node_type_to_op_lvl[typ]) -#define NODE_ASS(typ) \ - (bop_node->type == kExprNodeCall && typ == kExprNodeCall \ - ? kEOpAssLeft \ - : node_type_to_op_ass[typ]) - const ExprOpLvl bop_node_lvl = NODE_LVL(bop_node->type); + const ExprOpLvl bop_node_lvl = (bop_node->type == kExprNodeCall + ? kEOpLvlSubscript + : node_type_to_op_lvl[bop_node->type]); #ifndef NDEBUG - const ExprOpAssociativity bop_node_ass = NODE_ASS(bop_node->type); + const ExprOpAssociativity bop_node_ass = ( + bop_node->type == kExprNodeCall + ? kEOpAssLeft + : node_type_to_op_ass[bop_node->type]); #endif do { ExprASTNode **new_top_node_p = kv_last(*ast_stack); ExprASTNode *new_top_node = *new_top_node_p; assert(new_top_node != NULL); - const ExprOpLvl new_top_node_lvl = NODE_LVL(new_top_node->type); - const ExprOpAssociativity new_top_node_ass = NODE_ASS(new_top_node->type); + const ExprOpLvl new_top_node_lvl = node_type_to_op_lvl[new_top_node->type]; + const ExprOpAssociativity new_top_node_ass = ( + node_type_to_op_ass[new_top_node->type]); assert(bop_node_lvl != new_top_node_lvl || bop_node_ass == new_top_node_ass); if (top_node_p != NULL @@ -751,8 +749,6 @@ static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, *want_node_p = (*want_node_p == kENodeArgumentSeparator ? kENodeArgument : kENodeValue); -#undef NODE_ASS -#undef NODE_LVL } /// ParserPosition literal based on ParserPosition pos with columns shifted -- cgit From 0987d3b10f36202e9f0289b50298e69aaf2fa4d2 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 26 Sep 2017 01:22:13 +0300 Subject: viml/parser/expressions: Make curly braces name actually work --- src/nvim/viml/parser/expressions.c | 116 +++++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 38 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 7bee779c49..cabf2dac58 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -909,6 +909,55 @@ static inline void east_set_error(ExprAST *const ret_ast, } \ } while (0) +/// Add identifier which should constitute complex identifier node +/// +/// This one is to be called only in case want_node is kENodeOperator. +/// +/// @param new_ident_node_code Code used to create a new identifier node and +/// update want_node and ast_stack, without +/// a trailing semicolon. +/// @param hl Highlighting name to use, passed as an argument to #HL. +#define ADD_IDENT(new_ident_node_code, hl) \ + do { \ + assert(want_node == kENodeOperator); \ + /* Operator: may only be curly braces name, but only under certain */ \ + /* conditions. */ \ +\ + /* First condition is that there is no space before a part of complex */ \ + /* identifier. */ \ + if (prev_token.type == kExprLexSpacing) { \ + OP_MISSING; \ + } \ + switch ((*top_node_p)->type) { \ + /* Second is that previous node is one of the identifiers: */ \ + /* complex, plain, curly braces. */ \ +\ + /* TODO(ZyX-I): Extend syntax to allow ${expr}. This is needed to */ \ + /* handle environment variables like those bash uses for */ \ + /* `export -f`: their names consist not only of alphanumeric */ \ + /* characetrs. */ \ + case kExprNodeComplexIdentifier: \ + case kExprNodePlainIdentifier: \ + case kExprNodeCurlyBracesIdentifier: { \ + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeComplexIdentifier); \ + cur_node->len = 0; \ + cur_node->children = *top_node_p; \ + *top_node_p = cur_node; \ + kvi_push(ast_stack, &cur_node->children->next); \ + ExprASTNode **const new_top_node_p = kv_last(ast_stack); \ + assert(*new_top_node_p == NULL); \ + new_ident_node_code; \ + *new_top_node_p = cur_node; \ + HL_CUR_TOKEN(hl); \ + break; \ + } \ + default: { \ + OP_MISSING; \ + break; \ + } \ + } \ + } while (0) + /// Parse one VimL expression /// /// @param pstate Parser state. @@ -1272,40 +1321,18 @@ viml_pexpr_parse_figure_brace_closing_error: want_node = kENodeArgument; lambda_node = cur_node; } else { - // Operator: may only be curly braces name, but only under certain - // conditions. - - // First condition is that there is no space before {. - if (prev_token.type == kExprLexSpacing) { - OP_MISSING; - } - switch ((*top_node_p)->type) { - // Second is that previous node is one of the identifiers: - // complex, plain, curly braces. - - // TODO(ZyX-I): Extend syntax to allow ${expr}. This is needed to - // handle environment variables like those bash uses for - // `export -f`: their names consist not only of alphanumeric - // characetrs. - case kExprNodeComplexIdentifier: - case kExprNodePlainIdentifier: - case kExprNodeCurlyBracesIdentifier: { - NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeComplexIdentifier); - cur_node->len = 0; - viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); - ExprASTNode *const new_top_node = *kv_last(ast_stack); - assert(new_top_node->next == NULL); - NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeCurlyBracesIdentifier); - new_top_node->next = cur_node; - kvi_push(ast_stack, &cur_node->children); - HL_CUR_TOKEN(Curly); - break; - } - default: { - OP_MISSING; - break; - } - } + ADD_IDENT( + do { + NEW_NODE_WITH_CUR_POS(cur_node, + kExprNodeCurlyBracesIdentifier); + cur_node->data.fig.opening_hl_idx = kv_size(*pstate->colors); + cur_node->data.fig.type_guesses.allow_lambda = false; + cur_node->data.fig.type_guesses.allow_dict = false; + cur_node->data.fig.type_guesses.allow_ident = true; + kvi_push(ast_stack, &cur_node->children); + want_node = kENodeValue; + } while (0), + Curly); } } break; @@ -1351,8 +1378,6 @@ viml_pexpr_parse_figure_brace_closing_error: want_node = (want_node == kENodeArgument ? kENodeArgumentSeparator : kENodeOperator); - // FIXME: It is not valid to have scope inside complex identifier, - // check that. NEW_NODE_WITH_CUR_POS(cur_node, kExprNodePlainIdentifier); cur_node->data.var.scope = cur_token.data.var.scope; const size_t scope_shift = (cur_token.data.var.scope == 0 @@ -1374,8 +1399,22 @@ viml_pexpr_parse_figure_brace_closing_error: cur_token.len - scope_shift, HL(Identifier)); } + // FIXME: Actually, g{foo}g:foo is valid: "1?g{foo}g:foo" is like + // "g{foo}g" and not an error. } else { - OP_MISSING; + if (cur_token.data.var.scope == 0) { + ADD_IDENT( + do { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodePlainIdentifier); + cur_node->data.var.scope = cur_token.data.var.scope; + cur_node->data.var.ident = pline.data + cur_token.start.col; + cur_node->data.var.ident_len = cur_token.len; + want_node = kENodeOperator; + } while (0), + Identifier); + } else { + OP_MISSING; + } } break; } @@ -1453,7 +1492,8 @@ viml_pexpr_parse_no_paren_closing_error: {} // intentionally inconsistent and he is not very happy with the // situation himself. if ((*top_node_p)->type != kExprNodePlainIdentifier - && (*top_node_p)->type != kExprNodeComplexIdentifier) { + && (*top_node_p)->type != kExprNodeComplexIdentifier + && (*top_node_p)->type != kExprNodeCurlyBracesIdentifier) { OP_MISSING; } } -- cgit From 9fa8f7fc0a24371f7956450d840bdae8a2fc9a51 Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 28 Sep 2017 00:40:25 +0300 Subject: viml/parser/expressions: Add a way to adjust lexer It also adds support for kExprLexOr which for some reason was forgotten. It was only made sure that KLEE test compiles in non-KLEE mode, not that something works or that KLEE is able to run tests. --- src/nvim/viml/parser/expressions.c | 105 +++++++++++++++++++++++++------------ src/nvim/viml/parser/expressions.h | 28 ++++++++++ 2 files changed, 100 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index cabf2dac58..3027c0046b 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -47,10 +47,10 @@ typedef enum { /// Get next token for the VimL expression input /// /// @param pstate Parser state. -/// @param[in] peek If true, do not advance pstate cursor. +/// @param[in] flags Flags, @see LexExprFlags. /// /// @return Next token. -LexExprToken viml_pexpr_next_token(ParserState *const pstate, const bool peek) +LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { LexExprToken ret = { @@ -153,12 +153,33 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const bool peek) } // Number. - // Note: determining whether dot is (not) a part of a float needs more - // context, so lexer does not do this. - // FIXME: Resolve ambiguity by additional argument. case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { + ret.data.num.is_float = false; CHARREG(kExprLexNumber, ascii_isdigit); + if (flags & kELFlagAllowFloat) { + if (pline.size > ret.len + 1 + && pline.data[ret.len] == '.' + && ascii_isdigit(pline.data[ret.len + 1])) { + ret.len++; + ret.data.num.is_float = true; + CHARREG(kExprLexNumber, ascii_isdigit); + if (pline.size > ret.len + 1 + && (pline.data[ret.len] == 'e' + || pline.data[ret.len] == 'E') + && ((pline.size > ret.len + 2 + && (pline.data[ret.len + 1] == '+' + || pline.data[ret.len + 1] == '-') + && ascii_isdigit(pline.data[ret.len + 2])) + || ascii_isdigit(pline.data[ret.len + 1]))) { + ret.len++; + if (pline.data[ret.len] == '+' || pline.data[ret.len] == '-') { + ret.len++; + } + CHARREG(kExprLexNumber, ascii_isdigit); + } + } + } break; } @@ -187,8 +208,9 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const bool peek) ret.data.var.autoload = false; CHARREG(kExprLexPlainIdentifier, ISWORD); // "is" and "isnot" operators. - if ((ret.len == 2 && memcmp(pline.data, "is", 2) == 0) - || (ret.len == 5 && memcmp(pline.data, "isnot", 5) == 0)) { + if (!(flags & kELFlagIsNotCmp) + && ((ret.len == 2 && memcmp(pline.data, "is", 2) == 0) + || (ret.len == 5 && memcmp(pline.data, "isnot", 5) == 0))) { ret.type = kExprLexComparison; ret.data.cmp.type = kExprLexCmpIdentical; ret.data.cmp.inv = (ret.len == 5); @@ -197,14 +219,14 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const bool peek) } else if (ret.len == 1 && pline.size > 1 && strchr("sgvbwtla", schar) != NULL - && pline.data[ret.len] == ':') { + && pline.data[ret.len] == ':' + && !(flags & kELFlagForbidScope)) { ret.len++; ret.data.var.scope = schar; CHARREG(kExprLexPlainIdentifier, ISWORD_OR_AUTOLOAD); ret.data.var.autoload = ( memchr(pline.data + 2, AUTOLOAD_CHAR, ret.len - 2) != NULL); - // FIXME: Resolve ambiguity with an argument to the lexer function. // Previous CHARREG stopped at autoload character in order to make it // possible to detect `is#`. Continue now with autoload characters // included. @@ -373,7 +395,30 @@ viml_pexpr_next_token_invalid_comparison: // Expression end because Ex command ended. case NUL: case NL: { - ret.type = kExprLexEOC; + if (flags & kELFlagForbidEOC) { + ret.type = kExprLexInvalid; + ret.data.err.msg = _("E15: Unexpected EOC character: %.*s"); + ret.data.err.type = kExprLexSpacing; + } else { + ret.type = kExprLexEOC; + } + break; + } + + case '|': { + if (pline.size >= 2 && pline.data[ret.len] == '|') { + // "||" is or. + ret.len++; + ret.type = kExprLexOr; + } else if (flags & kELFlagForbidEOC) { + // Note: `=1 | 2` actually yields 1 in Vim without any + // errors. This will be changed here. + ret.type = kExprLexInvalid; + ret.data.err.msg = _("E15: Unexpected EOC character: %.*s"); + ret.data.err.type = kExprLexOr; + } else { + ret.type = kExprLexEOC; + } break; } @@ -389,7 +434,7 @@ viml_pexpr_next_token_invalid_comparison: } #undef GET_CCS viml_pexpr_next_token_adv_return: - if (!peek) { + if (!(flags & kELFlagPeek)) { viml_parser_advance(pstate, ret.len); } return ret; @@ -990,34 +1035,28 @@ ExprAST viml_pexpr_parse(ParserState *const pstate, const int flags) // Lambda node, valid when parsing lambda arguments only. ExprASTNode *lambda_node = NULL; do { - LexExprToken cur_token = viml_pexpr_next_token(pstate, true); + const int want_node_to_lexer_flags[] = { + [kENodeValue] = kELFlagIsNotCmp, + [kENodeOperator] = kELFlagForbidScope, + [kENodeArgument] = kELFlagIsNotCmp, + [kENodeArgumentSeparator] = kELFlagForbidScope, + }; + // FIXME Determine when (not) to allow floating-point numbers. + const int lexer_additional_flags = ( + kELFlagPeek + | ((flags & kExprFlagsDisallowEOC) ? kELFlagForbidEOC : 0)); + LexExprToken cur_token = viml_pexpr_next_token( + pstate, want_node_to_lexer_flags[want_node] | lexer_additional_flags); if (cur_token.type == kExprLexEOC) { - if (flags & kExprFlagsDisallowEOC) { - if (cur_token.len == 0) { - // It is end of string, break. - break; - } else { - // It is NL, NUL or bar. - // - // Note: `=1 | 2` actually yields 1 in Vim without any - // errors. This will be changed here. - cur_token.type = kExprLexInvalid; - cur_token.data.err.msg = _("E15: Unexpected EOC character: %.*s"); - const ParserLine pline = ( - pstate->reader.lines.items[cur_token.start.line]); - const char eoc_char = pline.data[cur_token.start.col]; - cur_token.data.err.type = ((eoc_char == NUL || eoc_char == NL) - ? kExprLexSpacing - : kExprLexOr); - } - } else { - break; - } + break; } LexExprTokenType tok_type = cur_token.type; const bool token_invalid = (tok_type == kExprLexInvalid); bool is_invalid = token_invalid; viml_pexpr_parse_process_token: + // May use different flags this time. + cur_token = viml_pexpr_next_token( + pstate, want_node_to_lexer_flags[want_node] | lexer_additional_flags); if (tok_type == kExprLexSpacing) { if (is_invalid) { HL_CUR_TOKEN(Spacing); diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 13640ec137..64abab9e41 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -109,9 +109,37 @@ typedef struct { LexExprTokenType type; ///< Suggested type for parsing incorrect code. const char *msg; ///< Error message. } err; ///< For kExprLexInvalid + + struct { + bool is_float; ///< True if number is a floating-point. + } num; ///< For kExprLexNumber } data; ///< Additional data, if needed. } LexExprToken; +typedef enum { + /// If set, “pointer†to the current byte in pstate will not be shifted + kELFlagPeek = (1 << 0), + /// Determines whether scope is allowed to come before the identifier + kELFlagForbidScope = (1 << 1), + /// Determines whether floating-point numbers are allowed + /// + /// I.e. whether dot is a decimal point separator or is not a part of + /// a number at all. + kELFlagAllowFloat = (1 << 2), + /// Determines whether `is` and `isnot` are seen as comparison operators + /// + /// If set they are supposed to be just regular identifiers. + kELFlagIsNotCmp = (1 << 3), + /// Determines whether EOC tokens are allowed + /// + /// If set then it will yield Invalid token with E15 in place of EOC one if + /// “EOC†is something like "|". It is fine with emitting EOC at the end of + /// string still, with or without this flag set. + kELFlagForbidEOC = (1 << 4), + // WARNING: whenever you add a new flag, alter klee_assume() statement in + // viml_expressions_lexer.c. +} LexExprFlags; + /// Expression AST node type typedef enum { kExprNodeMissing = 'X', -- cgit From 97dc1350f0d4f8509ebad2beb7da8847b81bbf4b Mon Sep 17 00:00:00 2001 From: ckelsel Date: Tue, 10 Oct 2017 14:53:27 +0800 Subject: vim-patch:8.0.0183 NA Problem: Ubsan warns for using a pointer that is not aligned. Solution: First copy the address. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/7173b47958a238bb07f80b8f26fb232b0ea69b4a --- src/nvim/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 7e59f3327a..cb66dcd6fe 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -920,7 +920,7 @@ static const int included_patches[] = { 186, // 185, // 184, - // 183, + // 183 NA 182, 181, // 180, -- cgit From dc513f761897f0ea09a511d19254f5c10b68e7fa Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 12 Oct 2017 00:49:47 -0400 Subject: getcmdline_prompt: Temporarily disable msg_silent so prompt is displayed vim-patch:7.4.1636 Closes #7378 --- src/nvim/ex_getln.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index fd7ad7a4b5..80f9b47340 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1863,9 +1863,13 @@ char *getcmdline_prompt(const char firstc, const char *const prompt, ccline.input_fn = (firstc == '@'); ccline.highlight_callback = highlight_callback; + int msg_silent_saved = msg_silent; + msg_silent = 0; + char *const ret = (char *)getcmdline(firstc, 1L, 0); restore_cmdline(&save_ccline); + msg_silent = msg_silent_saved; // Restore msg_col, the prompt from input() may have changed it. // But only if called recursively and the commandline is therefore being // restored to an old one; if not, the input() prompt stays on the screen, -- cgit From 4b3e51d4ee3018cf59d81578e2320b79fb614652 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 10 Oct 2017 18:42:01 +0200 Subject: ops: save and restore clipboard batch status when entering cmdline window --- src/nvim/ex_getln.c | 2 ++ src/nvim/ops.c | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 80f9b47340..54e5bcb9ff 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -5718,6 +5718,7 @@ static int ex_window(void) i = RedrawingDisabled; RedrawingDisabled = 0; + int save_count = save_batch_count(); /* * Call the main loop until or CTRL-C is typed. @@ -5726,6 +5727,7 @@ static int ex_window(void) normal_enter(true, false); RedrawingDisabled = i; + restore_batch_count(save_count); int save_KeyTyped = KeyTyped; diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 99dc4670f1..e7bc20698b 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -5755,7 +5755,6 @@ void start_batch_changes(void) return; } clipboard_delay_update = true; - clipboard_needs_update = false; } /// Counterpart to start_batch_changes(). @@ -5767,12 +5766,37 @@ void end_batch_changes(void) } clipboard_delay_update = false; if (clipboard_needs_update) { + // must be before, as set_clipboard will invoke + // start/end_batch_changes recursively + clipboard_needs_update = false; // unnamed ("implicit" clipboard) set_clipboard(NUL, y_previous); + } +} + +int save_batch_count(void) +{ + int save_count = batch_change_count; + batch_change_count = 0; + clipboard_delay_update = false; + if (clipboard_needs_update) { clipboard_needs_update = false; + // unnamed ("implicit" clipboard) + set_clipboard(NUL, y_previous); } + return save_count; } +void restore_batch_count(int save_count) +{ + assert(batch_change_count == 0); + batch_change_count = save_count; + if (batch_change_count > 0) { + clipboard_delay_update = true; + } +} + + /// Check whether register is empty static inline bool reg_empty(const yankreg_T *const reg) FUNC_ATTR_PURE -- cgit From f33543377e39fc62ab063ca57c716984fb07aea1 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 30 Sep 2017 21:34:34 +0300 Subject: viml/parser/expressions: Add a way to represent tokens from C code --- src/nvim/viml/parser/expressions.c | 179 +++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 3027c0046b..fc64fee140 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -440,6 +440,176 @@ viml_pexpr_next_token_adv_return: return ret; } +#ifdef UNIT_TESTING +static const char *const eltkn_type_tab[] = { + [kExprLexInvalid] = "Invalid", + [kExprLexMissing] = "Missing", + [kExprLexSpacing] = "Spacing", + [kExprLexEOC] = "EOC", + + [kExprLexQuestion] = "Question", + [kExprLexColon] = "Colon", + [kExprLexOr] = "Or", + [kExprLexAnd] = "And", + [kExprLexComparison] = "Comparison", + [kExprLexPlus] = "Plus", + [kExprLexMinus] = "Minus", + [kExprLexDot] = "Dot", + [kExprLexMultiplication] = "Multiplication", + + [kExprLexNot] = "Not", + + [kExprLexNumber] = "Number", + [kExprLexSingleQuotedString] = "SingleQuotedString", + [kExprLexDoubleQuotedString] = "DoubleQuotedString", + [kExprLexOption] = "Option", + [kExprLexRegister] = "Register", + [kExprLexEnv] = "Env", + [kExprLexPlainIdentifier] = "PlainIdentifier", + + [kExprLexBracket] = "Bracket", + [kExprLexFigureBrace] = "FigureBrace", + [kExprLexParenthesis] = "Parenthesis", + [kExprLexComma] = "Comma", + [kExprLexArrow] = "Arrow", +}; + +static const char *const eltkn_cmp_type_tab[] = { + [kExprLexCmpEqual] = "Equal", + [kExprLexCmpMatches] = "Matches", + [kExprLexCmpGreater] = "Greater", + [kExprLexCmpGreaterOrEqual] = "GreaterOrEqual", + [kExprLexCmpIdentical] = "Identical", +}; + +static const char *const ccs_tab[] = { + [kCCStrategyUseOption] = "UseOption", + [kCCStrategyMatchCase] = "MatchCase", + [kCCStrategyIgnoreCase] = "IgnoreCase", +}; + +static const char *const eltkn_mul_type_tab[] = { + [kExprLexMulMul] = "Mul", + [kExprLexMulDiv] = "Div", + [kExprLexMulMod] = "Mod", +}; + +static const char *const eltkn_opt_scope_tab[] = { + [kExprLexOptUnspecified] = "Unspecified", + [kExprLexOptGlobal] = "Global", + [kExprLexOptLocal] = "Local", +}; + +/// Represent `int` character as a string +/// +/// Converts +/// - ASCII digits into '{digit}' +/// - ASCII printable characters into a single-character strings +/// - everything else to numbers. +/// +/// @param[in] ch Character to convert. +/// +/// @return Converted string, stored in a static buffer (overriden after each +/// call). +static const char *intchar2str(const int ch) + FUNC_ATTR_WARN_UNUSED_RESULT +{ + static char buf[sizeof(int) * 3 + 1]; + if (' ' <= ch && ch < 0x7f) { + if (ascii_isdigit(ch)) { + buf[0] = '\''; + buf[1] = (char)ch; + buf[2] = '\''; + buf[3] = NUL; + } else { + buf[0] = (char)ch; + buf[1] = NUL; + } + } else { + snprintf(buf, sizeof(buf), "%i", ch); + } + return buf; +} + +/// Represent token as a string +/// +/// Intended for testing and debugging purposes. +/// +/// @param[in] pstate Parser state, needed to get token string from it. May be +/// NULL, in which case in place of obtaining part of the +/// string represented by token only token length is +/// returned. +/// @param[in] token Token to represent. +/// @param[out] ret_size Return string size, for cases like NULs inside +/// a string. May be NULL. +/// +/// @return Token represented in a string form, in a static buffer (overwritten +/// on each call). +const char *viml_pexpr_repr_token(const ParserState *const pstate, + const LexExprToken token, + size_t *const ret_size) + FUNC_ATTR_WARN_UNUSED_RESULT +{ + static char ret[1024]; + char *p = ret; + const char *const e = &ret[1024] - 1; +#define ADDSTR(...) \ + do { \ + p += snprintf(p, (size_t)(sizeof(ret) - (size_t)(p - ret)), __VA_ARGS__); \ + if (p >= e) { \ + goto viml_pexpr_repr_token_end; \ + } \ + } while (0) + ADDSTR("%zu:%zu:%s", token.start.line, token.start.col, + eltkn_type_tab[token.type]); + switch (token.type) { +#define TKNARGS(tkn_type, ...) \ + case tkn_type: { \ + ADDSTR(__VA_ARGS__); \ + break; \ + } + TKNARGS(kExprLexComparison, "(type=%s,ccs=%s,inv=%i)", + eltkn_cmp_type_tab[token.data.cmp.type], + ccs_tab[token.data.cmp.ccs], + (int)token.data.cmp.inv) + TKNARGS(kExprLexMultiplication, "(type=%s)", + eltkn_mul_type_tab[token.data.mul.type]) + TKNARGS(kExprLexRegister, "(name=%s)", intchar2str(token.data.reg.name)) + case kExprLexDoubleQuotedString: + TKNARGS(kExprLexSingleQuotedString, "(closed=%i)", + (int)token.data.str.closed) + TKNARGS(kExprLexOption, "(scope=%s,name=%.*s)", + eltkn_opt_scope_tab[token.data.opt.scope], + (int)token.data.opt.len, token.data.opt.name) + TKNARGS(kExprLexPlainIdentifier, "(scope=%s,autoload=%i)", + intchar2str(token.data.var.scope), (int)token.data.var.autoload) + TKNARGS(kExprLexNumber, "(is_float=%i)", (int)token.data.num.is_float) + TKNARGS(kExprLexInvalid, "(msg=%s)", token.data.err.msg) + default: { + // No additional arguments. + break; + } +#undef TKNARGS + } + if (pstate == NULL) { + ADDSTR("::%zu", token.len); + } else { + *p++ = ':'; + memmove( + p, &pstate->reader.lines.items[token.start.line].data[token.start.col], + token.len); + p += token.len; + *p = NUL; + } +#undef ADDSTR +viml_pexpr_repr_token_end: + if (ret_size != NULL) { + *ret_size = (size_t)(p - ret); + } + return ret; +} +#endif + #ifdef UNIT_TESTING #include REAL_FATTR_UNUSED @@ -469,12 +639,21 @@ static inline void viml_pexpr_debug_print_ast_stack( "-"); } } + +static inline void viml_pexpr_debug_print_token( + const ParserState *const pstate, const LexExprToken token) + FUNC_ATTR_ALWAYS_INLINE +{ + fprintf(stderr, "\ntkn: %s\n", viml_pexpr_repr_token(pstate, token, NULL)); +} #define PSTACK(msg) \ viml_pexpr_debug_print_ast_stack(&ast_stack, #msg) #define PSTACK_P(msg) \ viml_pexpr_debug_print_ast_stack(ast_stack, #msg) #define PNODE_P(eastnode_p, msg) \ viml_pexpr_debug_print_ast_node((const ExprASTNode *const *)ast_stack, #msg) +#define PTOKEN(tkn) \ + viml_pexpr_debug_print_token(pstate, tkn) #endif // start = s ternary_expr s EOC -- cgit From 3735537a508c5690c4622ebe450e6f3f15706670 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 1 Oct 2017 15:54:46 +0300 Subject: viml/parser/expressions: Fix call inside nested parenthesis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It may have incorrectly tried to call everything because of essentially “value†nodes being treated as not such. --- src/nvim/viml/parser/expressions.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index fc64fee140..1713d0c89f 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -612,6 +612,7 @@ viml_pexpr_repr_token_end: #ifdef UNIT_TESTING #include + REAL_FATTR_UNUSED static inline void viml_pexpr_debug_print_ast_node( const ExprASTNode *const *const eastnode_p, @@ -626,6 +627,7 @@ static inline void viml_pexpr_debug_print_ast_node( (*eastnode_p)->start.col, (*eastnode_p)->len); } } + REAL_FATTR_UNUSED static inline void viml_pexpr_debug_print_ast_stack( const ExprASTStack *const ast_stack, @@ -640,6 +642,7 @@ static inline void viml_pexpr_debug_print_ast_stack( } } +REAL_FATTR_UNUSED static inline void viml_pexpr_debug_print_token( const ParserState *const pstate, const LexExprToken token) FUNC_ATTR_ALWAYS_INLINE @@ -794,6 +797,7 @@ static inline ExprASTNode *viml_pexpr_new_node(const ExprASTNodeType type) typedef enum { kEOpLvlInvalid = 0, + kEOpLvlComplexIdentifier, kEOpLvlParens, kEOpLvlArrow, kEOpLvlComma, @@ -806,7 +810,6 @@ typedef enum { kEOpLvlMultiplication, ///< Multiplication, division and modulo. kEOpLvlUnary, ///< Unary operations: not, minus, plus. kEOpLvlSubscript, ///< Subscripts. - kEOpLvlComplexIdentifier, ///< Plain identifier, curly braces name. kEOpLvlValue, ///< Values: literals, variables, nested expressions, … } ExprOpLvl; @@ -843,10 +846,10 @@ static const ExprOpLvl node_type_to_op_lvl[] = { [kExprNodeSubscript] = kEOpLvlSubscript, - [kExprNodeComplexIdentifier] = kEOpLvlComplexIdentifier, - [kExprNodePlainIdentifier] = kEOpLvlComplexIdentifier, [kExprNodeCurlyBracesIdentifier] = kEOpLvlComplexIdentifier, + [kExprNodeComplexIdentifier] = kEOpLvlValue, + [kExprNodePlainIdentifier] = kEOpLvlValue, [kExprNodeRegister] = kEOpLvlValue, [kExprNodeListLiteral] = kEOpLvlValue, }; @@ -884,10 +887,10 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { [kExprNodeSubscript] = kEOpAssLeft, - [kExprNodePlainIdentifier] = kEOpAssLeft, - [kExprNodeComplexIdentifier] = kEOpAssLeft, [kExprNodeCurlyBracesIdentifier] = kEOpAssLeft, + [kExprNodeComplexIdentifier] = kEOpAssLeft, + [kExprNodePlainIdentifier] = kEOpAssNo, [kExprNodeRegister] = kEOpAssNo, [kExprNodeListLiteral] = kEOpAssNo, }; -- cgit From 9e721031d597bfa435da03597939191970f7a918 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 1 Oct 2017 16:50:46 +0300 Subject: viml/parser/expressions: Fix determining invalid commas/colons --- src/nvim/viml/parser/expressions.c | 163 +++++++++++++++++++++++++------------ src/nvim/viml/parser/expressions.h | 8 +- 2 files changed, 117 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 1713d0c89f..c283241cb4 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -13,6 +13,7 @@ #include "nvim/types.h" #include "nvim/charset.h" #include "nvim/ascii.h" +#include "nvim/assert.h" #include "nvim/lib/kvec.h" #include "nvim/viml/parser/expressions.h" @@ -37,6 +38,32 @@ typedef enum { kENodeArgumentSeparator, } ExprASTWantedNode; +/// Operator priority level +typedef enum { + kEOpLvlInvalid = 0, + kEOpLvlComplexIdentifier, + kEOpLvlParens, + kEOpLvlArrow, + kEOpLvlComma, + kEOpLvlColon, + kEOpLvlTernary, + kEOpLvlOr, + kEOpLvlAnd, + kEOpLvlComparison, + kEOpLvlAddition, ///< Addition, subtraction and concatenation. + kEOpLvlMultiplication, ///< Multiplication, division and modulo. + kEOpLvlUnary, ///< Unary operations: not, minus, plus. + kEOpLvlSubscript, ///< Subscripts. + kEOpLvlValue, ///< Values: literals, variables, nested expressions, … +} ExprOpLvl; + +/// Operator associativity +typedef enum { + kEOpAssNo= 'n', ///< Not associative / not applicable. + kEOpAssLeft = 'l', ///< Left associativity. + kEOpAssRight = 'r', ///< Right associativity. +} ExprOpAssociativity; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "viml/parser/expressions.c.generated.h" #endif @@ -747,6 +774,7 @@ static inline void viml_pexpr_debug_print_token( // // NVimParenthesis -> Delimiter // +// NVimColon -> Delimiter // NVimComma -> Delimiter // NVimArrow -> Delimiter // @@ -895,6 +923,32 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { [kExprNodeListLiteral] = kEOpAssNo, }; +/// Get AST node priority level +/// +/// Used primary to reduce line length, so keep the name short. +/// +/// @param[in] node Node to get priority for. +/// +/// @return Node priority level. +static inline ExprOpLvl node_lvl(const ExprASTNode node) + FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST FUNC_ATTR_WARN_UNUSED_RESULT +{ + return node_type_to_op_lvl[node.type]; +} + +/// Get AST node associativity, to be used for operator nodes primary +/// +/// Used primary to reduce line length, so keep the name short. +/// +/// @param[in] node Node to get priority for. +/// +/// @return Node associativity. +static inline ExprOpAssociativity node_ass(const ExprASTNode node) + FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST FUNC_ATTR_WARN_UNUSED_RESULT +{ + return node_type_to_op_ass[node.type]; +} + /// Handle binary operator /// /// This function is responsible for handling priority levels as well. @@ -910,20 +964,19 @@ static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, assert(kv_size(*ast_stack)); const ExprOpLvl bop_node_lvl = (bop_node->type == kExprNodeCall ? kEOpLvlSubscript - : node_type_to_op_lvl[bop_node->type]); + : node_lvl(*bop_node)); #ifndef NDEBUG const ExprOpAssociativity bop_node_ass = ( bop_node->type == kExprNodeCall ? kEOpAssLeft - : node_type_to_op_ass[bop_node->type]); + : node_ass(*bop_node)); #endif do { ExprASTNode **new_top_node_p = kv_last(*ast_stack); ExprASTNode *new_top_node = *new_top_node_p; assert(new_top_node != NULL); - const ExprOpLvl new_top_node_lvl = node_type_to_op_lvl[new_top_node->type]; - const ExprOpAssociativity new_top_node_ass = ( - node_type_to_op_ass[new_top_node->type]); + const ExprOpLvl new_top_node_lvl = node_lvl(*new_top_node); + const ExprOpAssociativity new_top_node_ass = node_ass(*new_top_node); assert(bop_node_lvl != new_top_node_lvl || bop_node_ass == new_top_node_ass); if (top_node_p != NULL @@ -1352,32 +1405,31 @@ viml_pexpr_parse_process_token: goto viml_pexpr_parse_invalid_comma; } for (size_t i = 1; i < kv_size(ast_stack); i++) { - const ExprASTNode *const *const eastnode_p = - (const ExprASTNode *const *)kv_Z(ast_stack, i); - if (!((*eastnode_p)->type == kExprNodeComma - || ((*eastnode_p)->type == kExprNodeColon - && i == 1)) - || i == kv_size(ast_stack) - 1) { - switch ((*eastnode_p)->type) { - case kExprNodeLambda: { - assert(want_node == kENodeArgumentSeparator); - break; - } - case kExprNodeDictLiteral: - case kExprNodeListLiteral: - case kExprNodeCall: { - break; - } - default: { + ExprASTNode *const *const eastnode_p = + (ExprASTNode *const *)kv_Z(ast_stack, i); + const ExprASTNodeType eastnode_type = (*eastnode_p)->type; + const ExprOpLvl eastnode_lvl = node_lvl(**eastnode_p); + if (eastnode_type == kExprNodeLambda) { + assert(want_node == kENodeArgumentSeparator); + break; + } else if (eastnode_type == kExprNodeDictLiteral + || eastnode_type == kExprNodeListLiteral + || eastnode_type == kExprNodeCall) { + break; + } else if (eastnode_type == kExprNodeComma + || eastnode_type == kExprNodeColon + || eastnode_lvl > kEOpLvlComma) { + // Do nothing + } else { viml_pexpr_parse_invalid_comma: - ERROR_FROM_TOKEN_AND_MSG( - cur_token, - _("E15: Comma outside of call, lambda or literal: %.*s")); - break; - } - } + ERROR_FROM_TOKEN_AND_MSG( + cur_token, + _("E15: Comma outside of call, lambda or literal: %.*s")); break; } + if (i == kv_size(ast_stack) - 1) { + goto viml_pexpr_parse_invalid_comma; + } } NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeComma); viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); @@ -1389,37 +1441,48 @@ viml_pexpr_parse_invalid_comma: if (kv_size(ast_stack) < 2) { goto viml_pexpr_parse_invalid_colon; } + bool is_ternary = false; + bool can_be_ternary = true; for (size_t i = 1; i < kv_size(ast_stack); i++) { ExprASTNode *const *const eastnode_p = (ExprASTNode *const *)kv_Z(ast_stack, i); - if ((*eastnode_p)->type != kExprNodeColon - || i == kv_size(ast_stack) - 1) { - switch ((*eastnode_p)->type) { - case kExprNodeUnknownFigure: { - SELECT_FIGURE_BRACE_TYPE((*eastnode_p), DictLiteral, Dict); - break; - } - case kExprNodeComma: - case kExprNodeDictLiteral: - case kExprNodeTernary: { - break; - } - default: { + const ExprASTNodeType eastnode_type = (*eastnode_p)->type; + const ExprOpLvl eastnode_lvl = node_lvl(**eastnode_p); + STATIC_ASSERT(kEOpLvlTernary > kEOpLvlComma, + "Unexpected operator priorities"); + if (can_be_ternary && eastnode_lvl == kEOpLvlTernary) { + assert(eastnode_type == kExprNodeTernary); + is_ternary = true; + break; + } else if (eastnode_type == kExprNodeUnknownFigure) { + SELECT_FIGURE_BRACE_TYPE(*eastnode_p, DictLiteral, Dict); + break; + } else if (eastnode_type == kExprNodeDictLiteral + || eastnode_type == kExprNodeComma) { + break; + } else if (eastnode_lvl > kEOpLvlTernary) { + // Do nothing + } else if (eastnode_lvl > kEOpLvlComma) { + can_be_ternary = false; + } else { viml_pexpr_parse_invalid_colon: - ERROR_FROM_TOKEN_AND_MSG( - cur_token, - _("E15: Colon outside of dictionary or ternary operator: " - "%.*s")); - break; - } - } + ERROR_FROM_TOKEN_AND_MSG( + cur_token, + _("E15: Colon outside of dictionary or ternary operator: " + "%.*s")); break; } + if (i == kv_size(ast_stack) - 1) { + goto viml_pexpr_parse_invalid_colon; + } } NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeColon); viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); - // FIXME: Handle ternary operator. - HL_CUR_TOKEN(Colon); + if (is_ternary) { + HL_CUR_TOKEN(TernaryColon); + } else { + HL_CUR_TOKEN(Colon); + } want_node = kENodeValue; break; } diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 64abab9e41..01a51e4eda 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -144,10 +144,10 @@ typedef enum { typedef enum { kExprNodeMissing = 'X', kExprNodeOpMissing = '_', - kExprNodeTernary = '?', ///< Ternary operator, valid one has three children. - kExprNodeRegister = '@', ///< Register, no children. - kExprNodeSubscript = 's', ///< Subscript, should have two or three children. - kExprNodeListLiteral = 'l', ///< List literal, any number of children. + kExprNodeTernary = '?', ///< Ternary operator. + kExprNodeRegister = '@', ///< Register. + kExprNodeSubscript = 's', ///< Subscript. + kExprNodeListLiteral = 'l', ///< List literal. kExprNodeUnaryPlus = 'p', kExprNodeBinaryPlus = '+', kExprNodeNested = 'e', ///< Nested parenthesised expression. -- cgit From 6144e26eb920a90b0db22bd7afcac0b9e0734ed6 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 1 Oct 2017 22:35:41 +0300 Subject: viml/parser/expressions: Add support for ternary operator --- src/nvim/viml/parser/expressions.c | 87 ++++++++++++++++++++++---------------- src/nvim/viml/parser/expressions.h | 6 ++- 2 files changed, 56 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index c283241cb4..41c77c5c88 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -46,6 +46,7 @@ typedef enum { kEOpLvlArrow, kEOpLvlComma, kEOpLvlColon, + kEOpLvlTernaryValue, kEOpLvlTernary, kEOpLvlOr, kEOpLvlAnd, @@ -770,7 +771,8 @@ static inline void viml_pexpr_debug_print_token( // NVimUnaryOperator -> NVimOperator // NVimBinaryOperator -> NVimOperator // NVimComparisonOperator -> NVimOperator -// NVimTernaryOperator -> NVimOperator +// NVimTernary -> NVimOperator +// NVimTernaryColon -> NVimTernary // // NVimParenthesis -> Delimiter // @@ -790,7 +792,8 @@ static inline void viml_pexpr_debug_print_token( // // NVimInvalidComma -> NVimInvalidDelimiter // NVimInvalidSpacing -> NVimInvalid -// NVimInvalidTernaryOperator -> NVimInvalidOperator +// NVimInvalidTernary -> NVimInvalidOperator +// NVimInvalidTernaryColon -> NVimInvalidTernary // NVimInvalidRegister -> NVimInvalidValue // NVimInvalidClosingBracket -> NVimInvalidDelimiter // NVimInvalidSpacing -> NVimInvalid @@ -823,30 +826,6 @@ static inline ExprASTNode *viml_pexpr_new_node(const ExprASTNodeType type) return ret; } -typedef enum { - kEOpLvlInvalid = 0, - kEOpLvlComplexIdentifier, - kEOpLvlParens, - kEOpLvlArrow, - kEOpLvlComma, - kEOpLvlColon, - kEOpLvlTernary, - kEOpLvlOr, - kEOpLvlAnd, - kEOpLvlComparison, - kEOpLvlAddition, ///< Addition, subtraction and concatenation. - kEOpLvlMultiplication, ///< Multiplication, division and modulo. - kEOpLvlUnary, ///< Unary operations: not, minus, plus. - kEOpLvlSubscript, ///< Subscripts. - kEOpLvlValue, ///< Values: literals, variables, nested expressions, … -} ExprOpLvl; - -typedef enum { - kEOpAssNo= 'n', ///< Not associative / not applicable. - kEOpAssLeft = 'l', ///< Left associativity. - kEOpAssRight = 'r', ///< Right associativity. -} ExprOpAssociativity; - static const ExprOpLvl node_type_to_op_lvl[] = { [kExprNodeMissing] = kEOpLvlInvalid, [kExprNodeOpMissing] = kEOpLvlMultiplication, @@ -868,6 +847,8 @@ static const ExprOpLvl node_type_to_op_lvl[] = { [kExprNodeTernary] = kEOpLvlTernary, + [kExprNodeTernaryValue] = kEOpLvlTernaryValue, + [kExprNodeBinaryPlus] = kEOpLvlAddition, [kExprNodeUnaryPlus] = kEOpLvlUnary, @@ -907,7 +888,9 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { // about associativity, only about order of execution. [kExprNodeComma] = kEOpAssRight, - [kExprNodeTernary] = kEOpAssNo, + [kExprNodeTernary] = kEOpAssRight, + + [kExprNodeTernaryValue] = kEOpAssRight, [kExprNodeBinaryPlus] = kEOpAssLeft, @@ -1450,9 +1433,20 @@ viml_pexpr_parse_invalid_comma: const ExprOpLvl eastnode_lvl = node_lvl(**eastnode_p); STATIC_ASSERT(kEOpLvlTernary > kEOpLvlComma, "Unexpected operator priorities"); - if (can_be_ternary && eastnode_lvl == kEOpLvlTernary) { - assert(eastnode_type == kExprNodeTernary); + if (can_be_ternary && eastnode_type == kExprNodeTernaryValue + && !(*eastnode_p)->data.ter.got_colon) { + kv_drop(ast_stack, i); + (*eastnode_p)->start = cur_token.start; + (*eastnode_p)->len = cur_token.len; + if (prev_token.type == kExprLexSpacing) { + (*eastnode_p)->start = prev_token.start; + (*eastnode_p)->len += prev_token.len; + } is_ternary = true; + (*eastnode_p)->data.ter.got_colon = true; + assert((*eastnode_p)->children != NULL); + assert((*eastnode_p)->children->next == NULL); + kvi_push(ast_stack, &(*eastnode_p)->children->next); break; } else if (eastnode_type == kExprNodeUnknownFigure) { SELECT_FIGURE_BRACE_TYPE(*eastnode_p, DictLiteral, Dict); @@ -1460,7 +1454,7 @@ viml_pexpr_parse_invalid_comma: } else if (eastnode_type == kExprNodeDictLiteral || eastnode_type == kExprNodeComma) { break; - } else if (eastnode_lvl > kEOpLvlTernary) { + } else if (eastnode_lvl >= kEOpLvlTernaryValue) { // Do nothing } else if (eastnode_lvl > kEOpLvlComma) { can_be_ternary = false; @@ -1476,11 +1470,11 @@ viml_pexpr_parse_invalid_colon: goto viml_pexpr_parse_invalid_colon; } } - NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeColon); - viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); if (is_ternary) { HL_CUR_TOKEN(TernaryColon); } else { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeColon); + viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); HL_CUR_TOKEN(Colon); } want_node = kENodeValue; @@ -1683,8 +1677,6 @@ viml_pexpr_parse_figure_brace_closing_error: cur_token.len - scope_shift, HL(Identifier)); } - // FIXME: Actually, g{foo}g:foo is valid: "1?g{foo}g:foo" is like - // "g{foo}g" and not an error. } else { if (cur_token.data.var.scope == 0) { ADD_IDENT( @@ -1792,6 +1784,21 @@ viml_pexpr_parse_no_paren_closing_error: {} } break; } + case kExprLexQuestion: { + ADD_VALUE_IF_MISSING(_("E15: Expected value, got question mark: %.*s")); + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeTernary); + viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); + HL_CUR_TOKEN(Ternary); + ExprASTNode *ter_val_node; + NEW_NODE_WITH_CUR_POS(ter_val_node, kExprNodeTernaryValue); + ter_val_node->data.ter.got_colon = false; + assert(cur_node->children != NULL); + assert(cur_node->children->next == NULL); + assert(kv_last(ast_stack) == &cur_node->children->next); + *kv_last(ast_stack) = ter_val_node; + kvi_push(ast_stack, &ter_val_node->children); + break; + } } viml_pexpr_parse_cycle_end: prev_token = cur_token; @@ -1815,6 +1822,7 @@ viml_pexpr_parse_end: const ExprASTNode *const cur_node = (*kv_pop(ast_stack)); // This should only happen when want_node == kENodeValue. assert(cur_node != NULL); + // TODO(ZyX-I): Rehighlight as invalid? switch (cur_node->type) { case kExprNodeOpMissing: case kExprNodeMissing: { @@ -1822,7 +1830,6 @@ viml_pexpr_parse_end: break; } case kExprNodeCall: { - // TODO(ZyX-I): Rehighlight as invalid? east_set_error( &ast, pstate, _("E116: Missing closing parenthesis for function call: %.*s"), @@ -1830,7 +1837,6 @@ viml_pexpr_parse_end: break; } case kExprNodeNested: { - // TODO(ZyX-I): Rehighlight as invalid? east_set_error( &ast, pstate, _("E110: Missing closing parenthesis for nested expression" @@ -1844,6 +1850,15 @@ viml_pexpr_parse_end: // It is OK to see these in the stack. break; } + case kExprNodeTernaryValue: { + if (!cur_node->data.ter.got_colon) { + // Actually Vim throws E109 in more cases. + east_set_error( + &ast, pstate, _("E109: Missing ':' after '?': %.*s"), + cur_node->start); + } + break; + } // TODO(ZyX-I): handle other values } } diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 01a51e4eda..cf0907850a 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -145,6 +145,7 @@ typedef enum { kExprNodeMissing = 'X', kExprNodeOpMissing = '_', kExprNodeTernary = '?', ///< Ternary operator. + kExprNodeTernaryValue = 'C', ///< Ternary operator, colon. kExprNodeRegister = '@', ///< Register. kExprNodeSubscript = 's', ///< Subscript. kExprNodeListLiteral = 'l', ///< List literal. @@ -209,7 +210,10 @@ struct expr_ast_node { /// Points to inside parser reader state. const char *ident; size_t ident_len; ///< Actual identifier length. - } var; + } var; ///< For kExprNodePlainIdentifier. + struct { + bool got_colon; ///< True if colon was seen. + } ter; ///< For kExprNodeTernaryValue. } data; }; -- cgit From 6791c574209c83570746c139d93f8e6a6b9cd135 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 2 Oct 2017 01:22:35 +0300 Subject: viml/parser/expressions: Make sure that arrows outside lambda throw --- src/nvim/viml/parser/expressions.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 41c77c5c88..982465055e 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -1642,8 +1642,9 @@ viml_pexpr_parse_figure_brace_closing_error: lambda_node = NULL; } else { // Only first branch is valid. - is_invalid = true; ADD_VALUE_IF_MISSING(_("E15: Unexpected arrow: %.*s")); + ERROR_FROM_TOKEN_AND_MSG( + cur_token, _("E15: Arrow outside of lambda: %.*s")); NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeArrow); viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); } -- cgit From 6168e1127c1c80a3810854649b0776146545043b Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 2 Oct 2017 02:41:55 +0300 Subject: viml/parser/expressions: Add support for comparison operators --- src/nvim/viml/parser/expressions.c | 131 ++++++++++++++++++++++++++----------- src/nvim/viml/parser/expressions.h | 45 ++++++++----- 2 files changed, 122 insertions(+), 54 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 982465055e..8e6f991e03 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -102,7 +102,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) if (ret.len < pline.size \ && strchr("?#", pline.data[ret.len]) != NULL) { \ ret.data.cmp.ccs = \ - (CaseCompareStrategy)pline.data[ret.len]; \ + (ExprCaseCompareStrategy)pline.data[ret.len]; \ ret.len++; \ } else { \ ret.data.cmp.ccs = kCCStrategyUseOption; \ @@ -240,7 +240,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) && ((ret.len == 2 && memcmp(pline.data, "is", 2) == 0) || (ret.len == 5 && memcmp(pline.data, "isnot", 5) == 0))) { ret.type = kExprLexComparison; - ret.data.cmp.type = kExprLexCmpIdentical; + ret.data.cmp.type = kExprCmpIdentical; ret.data.cmp.inv = (ret.len == 5); GET_CCS(ret, pline); // Scope: `s:`, etc. @@ -381,10 +381,10 @@ viml_pexpr_next_token_invalid_comparison: ret.type = kExprLexComparison; ret.data.cmp.inv = (schar == '!'); if (pline.data[1] == '=') { - ret.data.cmp.type = kExprLexCmpEqual; + ret.data.cmp.type = kExprCmpEqual; ret.len++; } else if (pline.data[1] == '~') { - ret.data.cmp.type = kExprLexCmpMatches; + ret.data.cmp.type = kExprCmpMatches; ret.len++; } else { goto viml_pexpr_next_token_invalid_comparison; @@ -404,8 +404,8 @@ viml_pexpr_next_token_invalid_comparison: GET_CCS(ret, pline); ret.data.cmp.inv = (schar == '<'); ret.data.cmp.type = ((ret.data.cmp.inv ^ haseqsign) - ? kExprLexCmpGreaterOrEqual - : kExprLexCmpGreater); + ? kExprCmpGreaterOrEqual + : kExprCmpGreater); break; } @@ -503,11 +503,11 @@ static const char *const eltkn_type_tab[] = { }; static const char *const eltkn_cmp_type_tab[] = { - [kExprLexCmpEqual] = "Equal", - [kExprLexCmpMatches] = "Matches", - [kExprLexCmpGreater] = "Greater", - [kExprLexCmpGreaterOrEqual] = "GreaterOrEqual", - [kExprLexCmpIdentical] = "Identical", + [kExprCmpEqual] = "Equal", + [kExprCmpMatches] = "Matches", + [kExprCmpGreater] = "Greater", + [kExprCmpGreaterOrEqual] = "GreaterOrEqual", + [kExprCmpIdentical] = "Identical", }; static const char *const ccs_tab[] = { @@ -770,7 +770,8 @@ static inline void viml_pexpr_debug_print_token( // NVimOperator -> Operator // NVimUnaryOperator -> NVimOperator // NVimBinaryOperator -> NVimOperator -// NVimComparisonOperator -> NVimOperator +// NVimComparisonOperator -> NVimBinaryOperator +// NVimComparisonOperatorModifier -> NVimComparisonOperator // NVimTernary -> NVimOperator // NVimTernaryColon -> NVimTernary // @@ -805,6 +806,8 @@ static inline void viml_pexpr_debug_print_token( // NVimInvalidIdentifier -> NVimInvalidValue // NVimInvalidIdentifierScope -> NVimInvalidValue // NVimInvalidIdentifierScopeDelimiter -> NVimInvalidValue +// NVimInvalidComparisonOperator -> NVimInvalidOperator +// NVimInvalidComparisonOperatorModifier -> NVimInvalidComparisonOperator // // NVimUnaryPlus -> NVimUnaryOperator // NVimBinaryPlus -> NVimBinaryOperator @@ -849,6 +852,8 @@ static const ExprOpLvl node_type_to_op_lvl[] = { [kExprNodeTernaryValue] = kEOpLvlTernaryValue, + [kExprNodeComparison] = kEOpLvlComparison, + [kExprNodeBinaryPlus] = kEOpLvlAddition, [kExprNodeUnaryPlus] = kEOpLvlUnary, @@ -892,6 +897,8 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { [kExprNodeTernaryValue] = kEOpAssRight, + [kExprNodeComparison] = kEOpAssRight, + [kExprNodeBinaryPlus] = kEOpAssLeft, [kExprNodeUnaryPlus] = kEOpAssNo, @@ -935,11 +942,23 @@ static inline ExprOpAssociativity node_ass(const ExprASTNode node) /// Handle binary operator /// /// This function is responsible for handling priority levels as well. -static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, +/// +/// @param[in] pstate Parser state, used for error reporting. +/// @param ast_stack AST stack. May be popped of some values and will +/// definitely receive new ones. +/// @param bop_node New node to handle. +/// @param[out] want_node_p New value of want_node. +/// @param[out] ast_err Location where error is saved, if any. +/// +/// @return True if no errors occurred, false otherwise. +static bool viml_pexpr_handle_bop(const ParserState *const pstate, + ExprASTStack *const ast_stack, ExprASTNode *const bop_node, - ExprASTWantedNode *const want_node_p) + ExprASTWantedNode *const want_node_p, + ExprASTError *const ast_err) FUNC_ATTR_NONNULL_ALL { + bool ret = true; ExprASTNode **top_node_p = NULL; ExprASTNode *top_node; ExprOpLvl top_node_lvl; @@ -977,7 +996,6 @@ static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, break; } } while (kv_size(*ast_stack)); - // FIXME: Handle no associativity if (top_node_ass == kEOpAssLeft || top_node_lvl != bop_node_lvl) { // outer(op(x,y)) -> outer(new_op(op(x,y),*)) // @@ -1008,10 +1026,18 @@ static void viml_pexpr_handle_bop(ExprASTStack *const ast_stack, kvi_push(*ast_stack, top_node_p); kvi_push(*ast_stack, &top_node->children->next); kvi_push(*ast_stack, &bop_node->children->next); + // TODO(ZyX-I): Make this not error, but treat like Python does + if (bop_node->type == kExprNodeComparison) { + east_set_error(pstate, ast_err, + _("E15: Operator is not associative: %.*s"), + bop_node->start); + ret = false; + } } *want_node_p = (*want_node_p == kENodeArgumentSeparator ? kENodeArgument : kENodeValue); + return ret; } /// ParserPosition literal based on ParserPosition pos with columns shifted @@ -1074,6 +1100,13 @@ static inline ParserPosition shifted_pos(const ParserPosition pos, #define MAY_HAVE_NEXT_EXPR \ (kv_size(ast_stack) == 1) +/// Add operator node +/// +/// @param[in] cur_node Node to add. +#define ADD_OP_NODE(cur_node) \ + is_invalid |= !viml_pexpr_handle_bop(pstate, &ast_stack, cur_node, \ + &want_node, &ast.err) + /// Record missing operator: for things like /// /// :echo @a @a @@ -1094,7 +1127,7 @@ static inline ParserPosition shifted_pos(const ParserPosition pos, ERROR_FROM_TOKEN_AND_MSG(cur_token, _("E15: Missing operator: %.*s")); \ NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeOpMissing); \ cur_node->len = 0; \ - viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); \ + ADD_OP_NODE(cur_node); \ goto viml_pexpr_parse_process_token; \ } \ } while (0) @@ -1120,34 +1153,33 @@ static inline ParserPosition shifted_pos(const ParserPosition pos, /// @param[in] msg Error message, assumed to be already translated and /// containing a single %token "%.*s". /// @param[in] start Position at which error occurred. -static inline void east_set_error(ExprAST *const ret_ast, - const ParserState *const pstate, +static inline void east_set_error(const ParserState *const pstate, + ExprASTError *const ret_ast_err, const char *const msg, const ParserPosition start) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_ALWAYS_INLINE { - if (!ret_ast->correct) { + if (ret_ast_err->msg != NULL) { return; } const ParserLine pline = pstate->reader.lines.items[start.line]; - ret_ast->correct = false; - ret_ast->err.msg = msg; - ret_ast->err.arg_len = (int)(pline.size - start.col); - ret_ast->err.arg = pline.data + start.col; + ret_ast_err->msg = msg; + ret_ast_err->arg_len = (int)(pline.size - start.col); + ret_ast_err->arg = pline.data + start.col; } /// Set error from the given token and given message #define ERROR_FROM_TOKEN_AND_MSG(cur_token, msg) \ do { \ is_invalid = true; \ - east_set_error(&ast, pstate, msg, cur_token.start); \ + east_set_error(pstate, &ast.err, msg, cur_token.start); \ } while (0) /// Like #ERROR_FROM_TOKEN_AND_MSG, but gets position from a node #define ERROR_FROM_NODE_AND_MSG(node, msg) \ do { \ is_invalid = true; \ - east_set_error(&ast, pstate, msg, node->start); \ + east_set_error(pstate, &ast.err, msg, node->start); \ } while (0) /// Set error from the given kExprLexInvalid token @@ -1231,7 +1263,6 @@ ExprAST viml_pexpr_parse(ParserState *const pstate, const int flags) FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { ExprAST ast = { - .correct = true, .err = { .msg = NULL, .arg_len = 0, @@ -1359,12 +1390,38 @@ viml_pexpr_parse_process_token: HL_CUR_TOKEN(UnaryPlus); } else { NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeBinaryPlus); - viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); + ADD_OP_NODE(cur_node); HL_CUR_TOKEN(BinaryPlus); } want_node = kENodeValue; break; } + case kExprLexComparison: { + ADD_VALUE_IF_MISSING( + _("E15: Expected value, got comparison operator: %.*s")); + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeComparison); + if (cur_token.type == kExprLexInvalid) { + cur_node->data.cmp.ccs = kCCStrategyUseOption; + cur_node->data.cmp.type = kExprCmpEqual; + cur_node->data.cmp.inv = false; + } else { + cur_node->data.cmp.ccs = cur_token.data.cmp.ccs; + cur_node->data.cmp.type = cur_token.data.cmp.type; + cur_node->data.cmp.inv = cur_token.data.cmp.inv; + } + ADD_OP_NODE(cur_node); + if (cur_token.data.cmp.ccs != kCCStrategyUseOption) { + viml_parser_highlight(pstate, cur_token.start, cur_token.len - 1, + HL(ComparisonOperator)); + viml_parser_highlight( + pstate, shifted_pos(cur_token.start, cur_token.len - 1), 1, + HL(ComparisonOperatorModifier)); + } else { + HL_CUR_TOKEN(ComparisonOperator); + } + want_node = kENodeValue; + break; + } case kExprLexComma: { assert(want_node != kENodeArgument); if (want_node == kENodeValue) { @@ -1415,7 +1472,7 @@ viml_pexpr_parse_invalid_comma: } } NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeComma); - viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); + ADD_OP_NODE(cur_node); HL_CUR_TOKEN(Comma); break; } @@ -1474,7 +1531,7 @@ viml_pexpr_parse_invalid_colon: HL_CUR_TOKEN(TernaryColon); } else { NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeColon); - viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); + ADD_OP_NODE(cur_node); HL_CUR_TOKEN(Colon); } want_node = kENodeValue; @@ -1646,7 +1703,7 @@ viml_pexpr_parse_figure_brace_closing_error: ERROR_FROM_TOKEN_AND_MSG( cur_token, _("E15: Arrow outside of lambda: %.*s")); NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeArrow); - viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); + ADD_OP_NODE(cur_node); } want_node = kENodeValue; HL_CUR_TOKEN(Arrow); @@ -1775,7 +1832,7 @@ viml_pexpr_parse_no_paren_closing_error: {} } } NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeCall); - viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); + ADD_OP_NODE(cur_node); HL_CUR_TOKEN(CallingParenthesis); } else { // Currently it is impossible to reach this. @@ -1788,7 +1845,7 @@ viml_pexpr_parse_no_paren_closing_error: {} case kExprLexQuestion: { ADD_VALUE_IF_MISSING(_("E15: Expected value, got question mark: %.*s")); NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeTernary); - viml_pexpr_handle_bop(&ast_stack, cur_node, &want_node); + ADD_OP_NODE(cur_node); HL_CUR_TOKEN(Ternary); ExprASTNode *ter_val_node; NEW_NODE_WITH_CUR_POS(ter_val_node, kExprNodeTernaryValue); @@ -1808,7 +1865,7 @@ viml_pexpr_parse_cycle_end: } while (true); viml_pexpr_parse_end: if (want_node == kENodeValue) { - east_set_error(&ast, pstate, _("E15: Expected value, got EOC: %.*s"), + east_set_error(pstate, &ast.err, _("E15: Expected value, got EOC: %.*s"), pstate->pos); } else if (kv_size(ast_stack) != 1) { // Something may be wrong, check whether it really is. @@ -1819,7 +1876,7 @@ viml_pexpr_parse_end: // Topmost stack item must be a *finished* value, so it must not be // analyzed. E.g. it may contain an already finished nested expression. kv_drop(ast_stack, 1); - while (ast.correct && kv_size(ast_stack)) { + while (ast.err.msg == NULL && kv_size(ast_stack)) { const ExprASTNode *const cur_node = (*kv_pop(ast_stack)); // This should only happen when want_node == kENodeValue. assert(cur_node != NULL); @@ -1832,14 +1889,14 @@ viml_pexpr_parse_end: } case kExprNodeCall: { east_set_error( - &ast, pstate, + pstate, &ast.err, _("E116: Missing closing parenthesis for function call: %.*s"), cur_node->start); break; } case kExprNodeNested: { east_set_error( - &ast, pstate, + pstate, &ast.err, _("E110: Missing closing parenthesis for nested expression" ": %.*s"), cur_node->start); @@ -1855,7 +1912,7 @@ viml_pexpr_parse_end: if (!cur_node->data.ter.got_colon) { // Actually Vim throws E109 in more cases. east_set_error( - &ast, pstate, _("E109: Missing ':' after '?': %.*s"), + pstate, &ast.err, _("E109: Missing ':' after '?': %.*s"), cur_node->start); } break; diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index cf0907850a..8ca3ceacb9 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -16,7 +16,7 @@ typedef enum { kCCStrategyUseOption = 0, // 0 for xcalloc kCCStrategyMatchCase = '#', kCCStrategyIgnoreCase = '?', -} CaseCompareStrategy; +} ExprCaseCompareStrategy; /// Lexer token type typedef enum { @@ -52,6 +52,14 @@ typedef enum { kExprLexArrow, ///< Arrow, like from lambda expressions. } LexExprTokenType; +typedef enum { + kExprCmpEqual, ///< Equality, unequality. + kExprCmpMatches, ///< Matches regex, not matches regex. + kExprCmpGreater, ///< `>` or `<=` + kExprCmpGreaterOrEqual, ///< `>=` or `<`. + kExprCmpIdentical, ///< `is` or `isnot` +} ExprComparisonType; + /// Lexer token typedef struct { ParserPosition start; @@ -59,14 +67,8 @@ typedef struct { LexExprTokenType type; union { struct { - enum { - kExprLexCmpEqual, ///< Equality, unequality. - kExprLexCmpMatches, ///< Matches regex, not matches regex. - kExprLexCmpGreater, ///< `>` or `<=` - kExprLexCmpGreaterOrEqual, ///< `>=` or `<`. - kExprLexCmpIdentical, ///< `is` or `isnot` - } type; ///< Comparison type. - CaseCompareStrategy ccs; ///< Case comparison strategy. + ExprComparisonType type; ///< Comparison type. + ExprCaseCompareStrategy ccs; ///< Case comparison strategy. bool inv; ///< True if comparison is to be inverted. } cmp; ///< For kExprLexComparison. @@ -171,6 +173,7 @@ typedef enum { kExprNodeComma = ',', ///< Comma “operatorâ€. kExprNodeColon = ':', ///< Colon “operatorâ€. kExprNodeArrow = '>', ///< Arrow “operatorâ€. + kExprNodeComparison = '=', ///< Various comparison operators. } ExprASTNodeType; typedef struct expr_ast_node ExprASTNode; @@ -214,6 +217,11 @@ struct expr_ast_node { struct { bool got_colon; ///< True if colon was seen. } ter; ///< For kExprNodeTernaryValue. + struct { + ExprComparisonType type; ///< Comparison type. + ExprCaseCompareStrategy ccs; ///< Case comparison strategy. + bool inv; ///< True if comparison is to be inverted. + } cmp; ///< For kExprNodeComparison. } data; }; @@ -235,19 +243,22 @@ enum { // viml_expressions_parser.c. } ExprParserFlags; +/// AST error definition +typedef struct { + /// Error message. Must contain a single printf format atom: %.*s. + const char *msg; + /// Error message argument: points to the location of the error. + const char *arg; + /// Message argument length: length till the end of string. + int arg_len; +} ExprASTError; + /// Structure representing complety AST for one expression typedef struct { - /// True if represented AST is correct and can be executed. Incorrect ones may - /// still be used for completion, or in linters. - bool correct; /// When AST is not correct this message will be printed. /// /// Uses `emsgf(msg, arg_len, arg);`, `msg` is assumed to contain only `%.*s`. - struct { - const char *msg; - int arg_len; - const char *arg; - } err; + ExprASTError err; /// Root node of the AST. ExprASTNode *root; } ExprAST; -- cgit From 0bc4e2237960712426da3774c1430f5874c49aea Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 3 Oct 2017 00:39:40 +0300 Subject: viml/parser/expressions: Forbid dot or alpha characters after a float This is basically what Vim already does, in addition to forbidding floats should there be a concat immediately before it. --- src/nvim/viml/parser/expressions.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 8e6f991e03..8c95d1db14 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -186,6 +186,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) ret.data.num.is_float = false; CHARREG(kExprLexNumber, ascii_isdigit); if (flags & kELFlagAllowFloat) { + const LexExprToken non_float_ret = ret; if (pline.size > ret.len + 1 && pline.data[ret.len] == '.' && ascii_isdigit(pline.data[ret.len + 1])) { @@ -207,6 +208,11 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) CHARREG(kExprLexNumber, ascii_isdigit); } } + if (pline.size > ret.len + && (pline.data[ret.len] == '.' + || ASCII_ISALPHA(pline.data[ret.len]))) { + ret = non_float_ret; + } } break; } -- cgit From 163792e9b9854fe046ada3233dec0fd0f6c55737 Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 6 Oct 2017 01:19:43 +0300 Subject: viml/parser/expressions: Make lexer parse numbers, support non-decimal --- src/nvim/viml/parser/expressions.c | 146 ++++++++++++++++++++++++++++++++++--- src/nvim/viml/parser/expressions.h | 6 ++ 2 files changed, 141 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 8c95d1db14..5d892fb8f8 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -15,10 +15,13 @@ #include "nvim/ascii.h" #include "nvim/assert.h" #include "nvim/lib/kvec.h" +#include "nvim/eval/typval.h" #include "nvim/viml/parser/expressions.h" #include "nvim/viml/parser/parser.h" +#define vim_str2nr(s, ...) vim_str2nr((const char_u *)(s), __VA_ARGS__) + typedef kvec_withinit_t(ExprASTNode **, 16) ExprASTStack; /// Which nodes may be wanted @@ -72,6 +75,43 @@ typedef enum { /// Character used as a separator in autoload function/variable names. #define AUTOLOAD_CHAR '#' +/// Scale number by a given factor +/// +/// Used to apply exponent to a number. Idea taken from uClibc. +/// +/// @param[in] num Number to scale. Does not bother doing anything if it is +/// zero. +/// @param[in] base Base, should be 10 since non-decimal floating-point +/// numbers are not supported. +/// @param[in] exponent Exponent to scale by. +/// @param[in] exponent_negative True if exponent is negative. +static inline float_T scale_number(const float_T num, + const uint8_t base, + const uvarnumber_T exponent, + const bool exponent_negative) + FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_CONST +{ + if (num == 0 || exponent == 0) { + return num; + } + assert(base); + uvarnumber_T exp = exponent; + float_T p_base = (float_T)base; + float_T ret = num; + while (exp) { + if (exp & 1) { + if (exponent_negative) { + ret /= p_base; + } else { + ret *= p_base; + } + } + exp >>= 1; + p_base *= p_base; + } + return ret; +} + /// Get next token for the VimL expression input /// /// @param pstate Parser state. @@ -184,6 +224,11 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { ret.data.num.is_float = false; + ret.data.num.base = 10; + size_t frac_start = 0; + size_t exp_start = 0; + size_t frac_end = 0; + bool exp_negative = false; CHARREG(kExprLexNumber, ascii_isdigit); if (flags & kELFlagAllowFloat) { const LexExprToken non_float_ret = ret; @@ -191,8 +236,18 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) && pline.data[ret.len] == '.' && ascii_isdigit(pline.data[ret.len + 1])) { ret.len++; + frac_start = ret.len; + frac_end = ret.len; ret.data.num.is_float = true; - CHARREG(kExprLexNumber, ascii_isdigit); + for (; ret.len < pline.size && ascii_isdigit(pline.data[ret.len]) + ; ret.len++) { + // A small optimization: trailing zeroes in fractional part do not + // add anything to significand, so it is useless to include them in + // frac_end. + if (pline.data[ret.len] != '0') { + frac_end = ret.len + 1; + } + } if (pline.size > ret.len + 1 && (pline.data[ret.len] == 'e' || pline.data[ret.len] == 'E') @@ -202,9 +257,11 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) && ascii_isdigit(pline.data[ret.len + 2])) || ascii_isdigit(pline.data[ret.len + 1]))) { ret.len++; - if (pline.data[ret.len] == '+' || pline.data[ret.len] == '-') { + if (pline.data[ret.len] == '+' + || (exp_negative = (pline.data[ret.len] == '-'))) { ret.len++; } + exp_start = ret.len; CHARREG(kExprLexNumber, ascii_isdigit); } } @@ -214,6 +271,58 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) ret = non_float_ret; } } + // TODO(ZyX-I): detect overflows + if (ret.data.num.is_float) { + // Vim used to use string2float here which in turn uses strtod(). There + // are two problems with this approach: + // 1. strtod() is locale-dependent. Not sure how it is worked around so + // that I do not see relevant bugs, but it still does not look like + // a good idea. + // 2. strtod() does not accept length argument. + // + // The below variant of parsing floats was recognized as acceptable + // because it is basically how uClibc does the thing: it generates + // a number ignoring decimal point (but recording its position), then + // uses recorded position to scale number down when processing exponent. + float_T significand_part = 0; + uvarnumber_T exp_part = 0; + const size_t frac_size = (size_t)(frac_end - frac_start); + for (size_t i = 0; i < frac_end; i++) { + if (i == frac_start - 1) { + continue; + } + significand_part = significand_part * 10 + (pline.data[i] - '0'); + } + if (exp_start) { + vim_str2nr(pline.data + exp_start, NULL, NULL, 0, NULL, &exp_part, + (int)(ret.len - exp_start)); + } + if (exp_negative) { + exp_part += frac_size; + } else { + if (exp_part < frac_size) { + exp_negative = true; + exp_part = frac_size - exp_part; + } else { + exp_part -= frac_size; + } + } + ret.data.num.val.floating = scale_number(significand_part, 10, exp_part, + exp_negative); + } else { + int len; + int prep; + vim_str2nr(pline.data, &prep, &len, STR2NR_ALL, NULL, + &ret.data.num.val.integer, (int)pline.size); + ret.len = (size_t)len; + const uint8_t bases[] = { + [0] = 10, + ['0'] = 8, + ['x'] = 16, ['X'] = 16, + ['b'] = 2, ['B'] = 2, + }; + ret.data.num.base = bases[prep]; + } break; } @@ -474,7 +583,6 @@ viml_pexpr_next_token_adv_return: return ret; } -#ifdef UNIT_TESTING static const char *const eltkn_type_tab[] = { [kExprLexInvalid] = "Invalid", [kExprLexMissing] = "Missing", @@ -617,7 +725,12 @@ const char *viml_pexpr_repr_token(const ParserState *const pstate, (int)token.data.opt.len, token.data.opt.name) TKNARGS(kExprLexPlainIdentifier, "(scope=%s,autoload=%i)", intchar2str(token.data.var.scope), (int)token.data.var.autoload) - TKNARGS(kExprLexNumber, "(is_float=%i)", (int)token.data.num.is_float) + TKNARGS(kExprLexNumber, "(is_float=%i,base=%i,val=%lg)", + (int)token.data.num.is_float, + (int)token.data.num.base, + (double)(token.data.num.is_float + ? token.data.num.val.floating + : token.data.num.val.integer)) TKNARGS(kExprLexInvalid, "(msg=%s)", token.data.err.msg) default: { // No additional arguments. @@ -642,7 +755,6 @@ viml_pexpr_repr_token_end: } return ret; } -#endif #ifdef UNIT_TESTING #include @@ -776,8 +888,10 @@ static inline void viml_pexpr_debug_print_token( // NVimOperator -> Operator // NVimUnaryOperator -> NVimOperator // NVimBinaryOperator -> NVimOperator +// // NVimComparisonOperator -> NVimBinaryOperator // NVimComparisonOperatorModifier -> NVimComparisonOperator +// // NVimTernary -> NVimOperator // NVimTernaryColon -> NVimTernary // @@ -795,8 +909,21 @@ static inline void viml_pexpr_debug_print_token( // NVimIdentifierScope -> NVimIdentifier // NVimIdentifierScopeDelimiter -> NVimIdentifier // +// NVimIdentifierKey -> Identifier +// // NVimFigureBrace -> NVimInternalError // +// NVimUnaryPlus -> NVimUnaryOperator +// NVimBinaryPlus -> NVimBinaryOperator +// NVimConcatOrSubscript -> NVimBinaryOperator +// +// NVimRegister -> SpecialChar +// NVimNumber -> Number +// NVimFloat -> NVimNumber +// +// NVimNestingParenthesis -> NVimParenthesis +// NVimCallingParenthesis -> NVimParenthesis +// // NVimInvalidComma -> NVimInvalidDelimiter // NVimInvalidSpacing -> NVimInvalid // NVimInvalidTernary -> NVimInvalidOperator @@ -814,12 +941,9 @@ static inline void viml_pexpr_debug_print_token( // NVimInvalidIdentifierScopeDelimiter -> NVimInvalidValue // NVimInvalidComparisonOperator -> NVimInvalidOperator // NVimInvalidComparisonOperatorModifier -> NVimInvalidComparisonOperator -// -// NVimUnaryPlus -> NVimUnaryOperator -// NVimBinaryPlus -> NVimBinaryOperator -// NVimRegister -> SpecialChar -// NVimNestingParenthesis -> NVimParenthesis -// NVimCallingParenthesis -> NVimParenthesis +// NVimInvalidNumber -> NVimInvalidValue +// NVimInvalidFloat -> NVimInvalidValue +// NVimInvalidIdentifierKey -> NVimInvalidIdentifier /// Allocate a new node and set some of the values /// diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 8ca3ceacb9..29903490bb 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -7,6 +7,7 @@ #include "nvim/types.h" #include "nvim/viml/parser/parser.h" +#include "nvim/eval/typval.h" // Defines whether to ignore case: // == kCCStrategyUseOption @@ -113,6 +114,11 @@ typedef struct { } err; ///< For kExprLexInvalid struct { + union { + float_T floating; + uvarnumber_T integer; + } val; ///< Number value. + uint8_t base; ///< Base: 2, 8, 10 or 16. bool is_float; ///< True if number is a floating-point. } num; ///< For kExprLexNumber } data; ///< Additional data, if needed. -- cgit From 21a5ce033c5a853bed3204ea9f0f7a3cfc1d164f Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 3 Oct 2017 01:30:02 +0300 Subject: viml/parser/expressions: Add support for the dot operator and numbers --- src/nvim/viml/parser/expressions.c | 108 ++++++++++++++++++++++++++++++++++--- src/nvim/viml/parser/expressions.h | 23 +++++++- 2 files changed, 122 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 5d892fb8f8..4babf4312c 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -915,7 +915,8 @@ static inline void viml_pexpr_debug_print_token( // // NVimUnaryPlus -> NVimUnaryOperator // NVimBinaryPlus -> NVimBinaryOperator -// NVimConcatOrSubscript -> NVimBinaryOperator +// NVimConcat -> NVimBinaryOperator +// NVimConcatOrSubscript -> NVimConcat // // NVimRegister -> SpecialChar // NVimNumber -> Number @@ -971,6 +972,7 @@ static const ExprOpLvl node_type_to_op_lvl[] = { [kExprNodeUnknownFigure] = kEOpLvlParens, [kExprNodeLambda] = kEOpLvlParens, [kExprNodeDictLiteral] = kEOpLvlParens, + [kExprNodeListLiteral] = kEOpLvlParens, [kExprNodeArrow] = kEOpLvlArrow, @@ -985,17 +987,21 @@ static const ExprOpLvl node_type_to_op_lvl[] = { [kExprNodeComparison] = kEOpLvlComparison, [kExprNodeBinaryPlus] = kEOpLvlAddition, + [kExprNodeConcat] = kEOpLvlAddition, [kExprNodeUnaryPlus] = kEOpLvlUnary, + [kExprNodeConcatOrSubscript] = kEOpLvlSubscript, [kExprNodeSubscript] = kEOpLvlSubscript, [kExprNodeCurlyBracesIdentifier] = kEOpLvlComplexIdentifier, [kExprNodeComplexIdentifier] = kEOpLvlValue, [kExprNodePlainIdentifier] = kEOpLvlValue, + [kExprNodePlainKey] = kEOpLvlValue, [kExprNodeRegister] = kEOpLvlValue, - [kExprNodeListLiteral] = kEOpLvlValue, + [kExprNodeInteger] = kEOpLvlValue, + [kExprNodeFloat] = kEOpLvlValue, }; static const ExprOpAssociativity node_type_to_op_ass[] = { @@ -1008,6 +1014,7 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { [kExprNodeUnknownFigure] = kEOpAssLeft, [kExprNodeLambda] = kEOpAssNo, [kExprNodeDictLiteral] = kEOpAssNo, + [kExprNodeListLiteral] = kEOpAssNo, // Does not really matter. [kExprNodeArrow] = kEOpAssNo, @@ -1030,17 +1037,21 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { [kExprNodeComparison] = kEOpAssRight, [kExprNodeBinaryPlus] = kEOpAssLeft, + [kExprNodeConcat] = kEOpAssLeft, [kExprNodeUnaryPlus] = kEOpAssNo, + [kExprNodeConcatOrSubscript] = kEOpAssLeft, [kExprNodeSubscript] = kEOpAssLeft, [kExprNodeCurlyBracesIdentifier] = kEOpAssLeft, [kExprNodeComplexIdentifier] = kEOpAssLeft, [kExprNodePlainIdentifier] = kEOpAssNo, + [kExprNodePlainKey] = kEOpAssNo, [kExprNodeRegister] = kEOpAssNo, - [kExprNodeListLiteral] = kEOpAssNo, + [kExprNodeInteger] = kEOpAssNo, + [kExprNodeFloat] = kEOpAssNo, }; /// Get AST node priority level @@ -1420,10 +1431,20 @@ ExprAST viml_pexpr_parse(ParserState *const pstate, const int flags) [kENodeArgument] = kELFlagIsNotCmp, [kENodeArgumentSeparator] = kELFlagForbidScope, }; - // FIXME Determine when (not) to allow floating-point numbers. + const bool is_concat_or_subscript = ( + want_node == kENodeValue + && kv_size(ast_stack) > 1 + && (*kv_Z(ast_stack, 1))->type == kExprNodeConcatOrSubscript); const int lexer_additional_flags = ( kELFlagPeek - | ((flags & kExprFlagsDisallowEOC) ? kELFlagForbidEOC : 0)); + | ((flags & kExprFlagsDisallowEOC) ? kELFlagForbidEOC : 0) + | ((want_node == kENodeValue + && (kv_size(ast_stack) == 1 + || ((*kv_Z(ast_stack, 1))->type != kExprNodeConcat + && ((*kv_Z(ast_stack, 1))->type + != kExprNodeConcatOrSubscript)))) + ? kELFlagAllowFloat + : 0)); LexExprToken cur_token = viml_pexpr_next_token( pstate, want_node_to_lexer_flags[want_node] | lexer_additional_flags); if (cur_token.type == kExprLexEOC) { @@ -1456,11 +1477,42 @@ viml_pexpr_parse_process_token: ExprASTNode *cur_node = NULL; assert((want_node == kENodeValue || want_node == kENodeArgument) == (*top_node_p == NULL)); + // Note: in Vim whether expression "cond?d.a:2" is valid depends both on + // "cond" and whether "d" is a dictionary: expression is valid if condition + // is true and "d" is a dictionary (with "a" key or it will complain about + // missing one, but this is not relevant); if any of the requirements is + // broken then this thing is parsed as "d . a:2" yielding missing colon + // error. This parser does not allow such ambiguity, especially because it + // simply can’t: whether "d" is a dictionary is not known at the parsing + // time. + // + // Here example will always contain a concat with "a:2" sucking colon, + // making expression invalid both because there is no longer a spare colon + // for ternary and because concatenating dictionary with anything is not + // valid. There are more cases when this will make a difference though. + const bool node_is_key = ( + is_concat_or_subscript + && (cur_token.type == kExprLexPlainIdentifier + ? (!cur_token.data.var.autoload + && cur_token.data.var.scope == 0) + : (cur_token.type == kExprLexNumber)) + && prev_token.type != kExprLexSpacing); + if (is_concat_or_subscript && !node_is_key) { + // Note: in Vim "d. a" (this is the reason behind `prev_token.type != + // kExprLexSpacing` part of the condition) as well as any other "d.{expr}" + // where "{expr}" does not look like a key is invalid whenever "d" happens + // to be a dictionary. Since parser has no idea whether preceding + // expression is actually a dictionary it can’t outright reject anything, + // so it turns kExprNodeConcatOrSubscript into kExprNodeConcat instead, + // which will yield different errors then Vim does in a number of + // circumstances, and in any case runtime and not parse time errors. + (*kv_Z(ast_stack, 1))->type = kExprNodeConcat; + } if ((want_node == kENodeArgumentSeparator && tok_type != kExprLexComma && tok_type != kExprLexArrow) || (want_node == kENodeArgument - && !(tok_type == kExprLexPlainIdentifier + && !(cur_token.type == kExprLexPlainIdentifier && cur_token.data.var.scope == 0 && !cur_token.data.var.autoload) && tok_type != kExprLexArrow)) { @@ -1844,7 +1896,10 @@ viml_pexpr_parse_figure_brace_closing_error: want_node = (want_node == kENodeArgument ? kENodeArgumentSeparator : kENodeOperator); - NEW_NODE_WITH_CUR_POS(cur_node, kExprNodePlainIdentifier); + NEW_NODE_WITH_CUR_POS(cur_node, + (node_is_key + ? kExprNodePlainKey + : kExprNodePlainIdentifier)); cur_node->data.var.scope = cur_token.data.var.scope; const size_t scope_shift = (cur_token.data.var.scope == 0 ? 0 @@ -1854,6 +1909,7 @@ viml_pexpr_parse_figure_brace_closing_error: cur_node->data.var.ident_len = cur_token.len - scope_shift; *top_node_p = cur_node; if (scope_shift) { + assert(!node_is_key); viml_parser_highlight(pstate, cur_token.start, 1, HL(IdentifierScope)); viml_parser_highlight(pstate, shifted_pos(cur_token.start, 1), 1, @@ -1863,7 +1919,9 @@ viml_pexpr_parse_figure_brace_closing_error: viml_parser_highlight(pstate, shifted_pos(cur_token.start, scope_shift), cur_token.len - scope_shift, - HL(Identifier)); + (node_is_key + ? HL(IdentifierKey) + : HL(Identifier))); } } else { if (cur_token.data.var.scope == 0) { @@ -1882,6 +1940,40 @@ viml_pexpr_parse_figure_brace_closing_error: } break; } + case kExprLexNumber: { + if (want_node != kENodeValue) { + OP_MISSING; + } + if (node_is_key) { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodePlainKey); + cur_node->data.var.ident = pline.data + cur_token.start.col; + cur_node->data.var.ident_len = cur_token.len; + HL_CUR_TOKEN(IdentifierKey); + } else if (cur_token.data.num.is_float) { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeFloat); + cur_node->data.flt.value = cur_token.data.num.val.floating; + HL_CUR_TOKEN(Float); + } else { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeInteger); + cur_node->data.num.value = cur_token.data.num.val.integer; + HL_CUR_TOKEN(Number); + } + want_node = kENodeOperator; + *top_node_p = cur_node; + break; + } + case kExprLexDot: { + ADD_VALUE_IF_MISSING(_("E15: Unexpected dot: %.*s")); + if (prev_token.type == kExprLexSpacing) { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeConcat); + HL_CUR_TOKEN(Concat); + } else { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeConcatOrSubscript); + HL_CUR_TOKEN(ConcatOrSubscript); + } + ADD_OP_NODE(cur_node); + break; + } case kExprLexParenthesis: { if (cur_token.data.brc.closing) { if (want_node == kENodeValue) { diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 29903490bb..0d496c87ba 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -166,6 +166,8 @@ typedef enum { /// Looks like "string", "g:Foo", etc: consists from a single /// kExprLexPlainIdentifier token. kExprNodePlainIdentifier = 'i', + /// Plain dictionary key, for use with kExprNodeConcatOrSubscript + kExprNodePlainKey = 'k', /// Complex identifier: variable/function name with curly braces kExprNodeComplexIdentifier = 'I', /// Figure brace expression which is not yet known @@ -180,6 +182,19 @@ typedef enum { kExprNodeColon = ':', ///< Colon “operatorâ€. kExprNodeArrow = '>', ///< Arrow “operatorâ€. kExprNodeComparison = '=', ///< Various comparison operators. + /// Concat operator + /// + /// To be only used in cases when it is known for sure it is not a subscript. + kExprNodeConcat = '.', + /// Concat or subscript operator + /// + /// For cases when it is not obvious whether expression is a concat or + /// a subscript. May only have either number or plain identifier as the second + /// child. To make it easier to avoid curly braces in place of + /// kExprNodePlainIdentifier node kExprNodePlainKey is used. + kExprNodeConcatOrSubscript = 'S', + kExprNodeInteger = '0', ///< Integral number. + kExprNodeFloat = '1', ///< Floating-point number. } ExprASTNodeType; typedef struct expr_ast_node ExprASTNode; @@ -219,7 +234,7 @@ struct expr_ast_node { /// Points to inside parser reader state. const char *ident; size_t ident_len; ///< Actual identifier length. - } var; ///< For kExprNodePlainIdentifier. + } var; ///< For kExprNodePlainIdentifier and kExprNodePlainKey. struct { bool got_colon; ///< True if colon was seen. } ter; ///< For kExprNodeTernaryValue. @@ -228,6 +243,12 @@ struct expr_ast_node { ExprCaseCompareStrategy ccs; ///< Case comparison strategy. bool inv; ///< True if comparison is to be inverted. } cmp; ///< For kExprNodeComparison. + struct { + uvarnumber_T value; + } num; ///< For kExprNodeInteger. + struct { + float_T value; + } flt; ///< For kExprNodeFloat. } data; }; -- cgit From e45e519495832e3d1d0fde1e32723d4140c5fc65 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 8 Oct 2017 01:19:58 +0300 Subject: viml/parser/expressions: Error out on multiple colons in a row --- src/nvim/viml/parser/expressions.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 4babf4312c..fffae8833d 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -1691,8 +1691,10 @@ viml_pexpr_parse_invalid_comma: SELECT_FIGURE_BRACE_TYPE(*eastnode_p, DictLiteral, Dict); break; } else if (eastnode_type == kExprNodeDictLiteral - || eastnode_type == kExprNodeComma) { + || eastnode_type == kExprNodeSubscript) { break; + } else if (eastnode_type == kExprNodeColon) { + goto viml_pexpr_parse_invalid_colon; } else if (eastnode_lvl >= kEOpLvlTernaryValue) { // Do nothing } else if (eastnode_lvl > kEOpLvlComma) { -- cgit From bd3a4166b25a64dbe406be09b3140955cf694477 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 8 Oct 2017 02:17:05 +0300 Subject: viml/parser/expressions: Add support for subscript and list literals --- src/nvim/viml/parser/expressions.c | 164 ++++++++++++++++++++++++++++++++----- 1 file changed, 142 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index fffae8833d..0613cc66d5 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -905,6 +905,10 @@ static inline void viml_pexpr_debug_print_token( // NVimDict -> Delimiter // NVimCurly -> Delimiter // +// NVimList -> Delimiter +// NVimSubscript -> Delimiter +// NVimSubscriptColon -> NVimSubscript +// // NVimIdentifier -> Identifier // NVimIdentifierScope -> NVimIdentifier // NVimIdentifierScopeDelimiter -> NVimIdentifier @@ -945,6 +949,9 @@ static inline void viml_pexpr_debug_print_token( // NVimInvalidNumber -> NVimInvalidValue // NVimInvalidFloat -> NVimInvalidValue // NVimInvalidIdentifierKey -> NVimInvalidIdentifier +// NVimInvalidList -> NVimInvalidDelimiter +// NVimInvalidSubscript -> NVimInvalidDelimiter +// NVimInvalidSubscriptColon -> NVimInvalidSubscript /// Allocate a new node and set some of the values /// @@ -965,9 +972,10 @@ static const ExprOpLvl node_type_to_op_lvl[] = { [kExprNodeOpMissing] = kEOpLvlMultiplication, [kExprNodeNested] = kEOpLvlParens, - // Note: it is kEOpLvlSubscript for “binary operator†itself, but + // Note: below nodes are kEOpLvlSubscript for “binary operator†itself, but // kEOpLvlParens when it comes to inside the parenthesis. [kExprNodeCall] = kEOpLvlParens, + [kExprNodeSubscript] = kEOpLvlParens, [kExprNodeUnknownFigure] = kEOpLvlParens, [kExprNodeLambda] = kEOpLvlParens, @@ -992,7 +1000,6 @@ static const ExprOpLvl node_type_to_op_lvl[] = { [kExprNodeUnaryPlus] = kEOpLvlUnary, [kExprNodeConcatOrSubscript] = kEOpLvlSubscript, - [kExprNodeSubscript] = kEOpLvlSubscript, [kExprNodeCurlyBracesIdentifier] = kEOpLvlComplexIdentifier, @@ -1010,6 +1017,7 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { [kExprNodeNested] = kEOpAssNo, [kExprNodeCall] = kEOpAssNo, + [kExprNodeSubscript] = kEOpAssNo, [kExprNodeUnknownFigure] = kEOpAssLeft, [kExprNodeLambda] = kEOpAssNo, @@ -1042,7 +1050,6 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { [kExprNodeUnaryPlus] = kEOpAssNo, [kExprNodeConcatOrSubscript] = kEOpAssLeft, - [kExprNodeSubscript] = kEOpAssLeft, [kExprNodeCurlyBracesIdentifier] = kEOpAssLeft, @@ -1105,12 +1112,14 @@ static bool viml_pexpr_handle_bop(const ParserState *const pstate, ExprOpLvl top_node_lvl; ExprOpAssociativity top_node_ass; assert(kv_size(*ast_stack)); - const ExprOpLvl bop_node_lvl = (bop_node->type == kExprNodeCall + const ExprOpLvl bop_node_lvl = ((bop_node->type == kExprNodeCall + || bop_node->type == kExprNodeSubscript) ? kEOpLvlSubscript : node_lvl(*bop_node)); #ifndef NDEBUG const ExprOpAssociativity bop_node_ass = ( - bop_node->type == kExprNodeCall + (bop_node->type == kExprNodeCall + || bop_node->type == kExprNodeSubscript) ? kEOpAssLeft : node_ass(*bop_node)); #endif @@ -1214,8 +1223,8 @@ static inline ParserPosition shifted_pos(const ParserPosition pos, /// @param cur_token Token to set position from. #define POS_FROM_TOKEN(cur_node, cur_token) \ do { \ - cur_node->start = cur_token.start; \ - cur_node->len = cur_token.len; \ + (cur_node)->start = cur_token.start; \ + (cur_node)->len = cur_token.len; \ } while (0) /// Allocate new node and set its position from the current token @@ -1226,11 +1235,11 @@ static inline ParserPosition shifted_pos(const ParserPosition pos, /// @param typ Node type. #define NEW_NODE_WITH_CUR_POS(cur_node, typ) \ do { \ - cur_node = NEW_NODE(typ); \ - POS_FROM_TOKEN(cur_node, cur_token); \ + (cur_node) = NEW_NODE(typ); \ + POS_FROM_TOKEN((cur_node), cur_token); \ if (prev_token.type == kExprLexSpacing) { \ - cur_node->start = prev_token.start; \ - cur_node->len += prev_token.len; \ + (cur_node)->start = prev_token.start; \ + (cur_node)->len += prev_token.len; \ } \ } while (0) @@ -1280,9 +1289,8 @@ static inline ParserPosition shifted_pos(const ParserPosition pos, do { \ if (want_node == kENodeValue) { \ ERROR_FROM_TOKEN_AND_MSG(cur_token, (msg)); \ - NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeMissing); \ - cur_node->len = 0; \ - *top_node_p = cur_node; \ + NEW_NODE_WITH_CUR_POS((*top_node_p), kExprNodeMissing); \ + (*top_node_p)->len = 0; \ want_node = kENodeOperator; \ } \ } while (0) @@ -1658,13 +1666,14 @@ viml_pexpr_parse_invalid_comma: HL_CUR_TOKEN(Comma); break; } +#define EXP_VAL_COLON "E15: Expected value, got colon: %.*s" case kExprLexColon: { - ADD_VALUE_IF_MISSING(_("E15: Expected value, got colon: %.*s")); if (kv_size(ast_stack) < 2) { goto viml_pexpr_parse_invalid_colon; } bool is_ternary = false; bool can_be_ternary = true; + bool is_subscript = false; for (size_t i = 1; i < kv_size(ast_stack); i++) { ExprASTNode *const *const eastnode_p = (ExprASTNode *const *)kv_Z(ast_stack, i); @@ -1683,6 +1692,7 @@ viml_pexpr_parse_invalid_comma: } is_ternary = true; (*eastnode_p)->data.ter.got_colon = true; + ADD_VALUE_IF_MISSING(_(EXP_VAL_COLON)); assert((*eastnode_p)->children != NULL); assert((*eastnode_p)->children->next == NULL); kvi_push(ast_stack, &(*eastnode_p)->children->next); @@ -1690,14 +1700,18 @@ viml_pexpr_parse_invalid_comma: } else if (eastnode_type == kExprNodeUnknownFigure) { SELECT_FIGURE_BRACE_TYPE(*eastnode_p, DictLiteral, Dict); break; - } else if (eastnode_type == kExprNodeDictLiteral - || eastnode_type == kExprNodeSubscript) { + } else if (eastnode_type == kExprNodeDictLiteral) { + break; + } else if (eastnode_type == kExprNodeSubscript) { + is_subscript = true; + can_be_ternary = false; + assert(!is_ternary); break; } else if (eastnode_type == kExprNodeColon) { goto viml_pexpr_parse_invalid_colon; } else if (eastnode_lvl >= kEOpLvlTernaryValue) { // Do nothing - } else if (eastnode_lvl > kEOpLvlComma) { + } else if (eastnode_lvl >= kEOpLvlComma) { can_be_ternary = false; } else { viml_pexpr_parse_invalid_colon: @@ -1711,16 +1725,122 @@ viml_pexpr_parse_invalid_colon: goto viml_pexpr_parse_invalid_colon; } } - if (is_ternary) { - HL_CUR_TOKEN(TernaryColon); - } else { + if (is_subscript) { + assert(kv_size(ast_stack) > 1); + // Colon immediately following subscript start: it is empty subscript + // part like a[:2]. + if (want_node == kENodeValue + && (*kv_Z(ast_stack, 1))->type == kExprNodeSubscript) { + NEW_NODE_WITH_CUR_POS(*top_node_p, kExprNodeMissing); + (*top_node_p)->len = 0; + want_node = kENodeOperator; + } else { + ADD_VALUE_IF_MISSING(_(EXP_VAL_COLON)); + } NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeColon); ADD_OP_NODE(cur_node); - HL_CUR_TOKEN(Colon); + HL_CUR_TOKEN(SubscriptColon); + } else { + ADD_VALUE_IF_MISSING(_(EXP_VAL_COLON)); + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeColon); + if (is_ternary) { + HL_CUR_TOKEN(TernaryColon); + } else { + ADD_OP_NODE(cur_node); + HL_CUR_TOKEN(Colon); + } } want_node = kENodeValue; break; } +#undef EXP_VAL_COLON + case kExprLexBracket: { + if (cur_token.data.brc.closing) { + ExprASTNode **new_top_node_p = NULL; + // Always drop the topmost value: + // + // 1. When want_node != kENodeValue topmost item on stack is + // a *finished* left operand, which may as well be "{@a}" which + // needs not be finished again. + // 2. Otherwise it is pointing to NULL what nobody wants. + kv_drop(ast_stack, 1); + if (!kv_size(ast_stack)) { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeListLiteral); + cur_node->len = 0; + if (want_node != kENodeValue) { + cur_node->children = *top_node_p; + } + *top_node_p = cur_node; + goto viml_pexpr_parse_bracket_closing_error; + } + if (want_node == kENodeValue) { + // It is OK to want value if + // + // 1. It is empty list literal, in which case top node will be + // ListLiteral. + // 2. It is list literal with trailing comma, in which case top node + // will be that comma. + // 3. It is subscript with colon, but without one of the values: + // e.g. "a[:]", "a[1:]", top node will be colon in this case. + if ((*kv_last(ast_stack))->type != kExprNodeListLiteral + && (*kv_last(ast_stack))->type != kExprNodeComma + && (*kv_last(ast_stack))->type != kExprNodeColon) { + ERROR_FROM_TOKEN_AND_MSG( + cur_token, + _("E15: Expected value, got closing bracket: %.*s")); + } + } else { + if (!kv_size(ast_stack)) { + new_top_node_p = top_node_p; + goto viml_pexpr_parse_bracket_closing_error; + } + } + do { + new_top_node_p = kv_pop(ast_stack); + } while (kv_size(ast_stack) + && (new_top_node_p == NULL + || ((*new_top_node_p)->type != kExprNodeListLiteral + && (*new_top_node_p)->type != kExprNodeSubscript))); + ExprASTNode *new_top_node = *new_top_node_p; + switch (new_top_node->type) { + case kExprNodeListLiteral: { + HL_CUR_TOKEN(List); + break; + } + case kExprNodeSubscript: { + HL_CUR_TOKEN(Subscript); + break; + } + default: { +viml_pexpr_parse_bracket_closing_error: + assert(!kv_size(ast_stack)); + ERROR_FROM_TOKEN_AND_MSG( + cur_token, _("E15: Unexpected closing figure brace: %.*s")); + HL_CUR_TOKEN(List); + break; + } + } + kvi_push(ast_stack, new_top_node_p); + want_node = kENodeOperator; + } else { + if (want_node == kENodeValue) { + // Value means list literal. + HL_CUR_TOKEN(List); + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeListLiteral); + *top_node_p = cur_node; + kvi_push(ast_stack, &cur_node->children); + want_node = kENodeValue; + } else { + if (prev_token.type == kExprLexSpacing) { + OP_MISSING; + } + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeSubscript); + ADD_OP_NODE(cur_node); + HL_CUR_TOKEN(Subscript); + } + } + break; + } case kExprLexFigureBrace: { if (cur_token.data.brc.closing) { ExprASTNode **new_top_node_p = NULL; -- cgit From 6f22b5afad23ccc0390a6e2dd61d2e166ac6696a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 8 Oct 2017 21:19:10 +0300 Subject: mbyte: Lint some functions which are to be copied for symbolic tests --- src/nvim/globals.h | 23 ----- src/nvim/mbyte.c | 248 +++++++++++++++++++++++++++++------------------------ 2 files changed, 137 insertions(+), 134 deletions(-) (limited to 'src') diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 13ecafcbe3..86fff46737 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -725,29 +725,6 @@ EXTERN int vr_lines_changed INIT(= 0); /* #Lines changed by "gR" so far */ /// Encoding used when 'fencs' is set to "default" EXTERN char_u *fenc_default INIT(= NULL); -// To speed up BYTELEN(); keep a lookup table to quickly get the length in -// bytes of a UTF-8 character from the first byte of a UTF-8 string. Bytes -// which are illegal when used as the first byte have a 1. The NUL byte has -// length 1. -EXTERN char utf8len_tab[256] INIT(= { - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1, -}); - # if defined(USE_ICONV) && defined(DYNAMIC_ICONV) /* Pointers to functions and variables to be loaded at runtime */ EXTERN size_t (*iconv)(iconv_t cd, const char **inbuf, size_t *inbytesleft, diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index b24770a409..f65d7a6b13 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -72,19 +72,41 @@ struct interval { # include "unicode_tables.generated.h" #endif -/* - * Like utf8len_tab above, but using a zero for illegal lead bytes. - */ -const uint8_t utf8len_tab_zero[256] = -{ - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0, +// To speed up BYTELEN(); keep a lookup table to quickly get the length in +// bytes of a UTF-8 character from the first byte of a UTF-8 string. Bytes +// which are illegal when used as the first byte have a 1. The NUL byte has +// length 1. +const uint8_t utf8len_tab[] = { + // ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?A ?B ?C ?D ?E ?F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 8? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 9? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B? + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C? + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // D? + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // E? + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 1, 1, // F? +}; + +// Like utf8len_tab above, but using a zero for illegal lead bytes. +const uint8_t utf8len_tab_zero[] = { + //1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0 + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 2 + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 4 + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 6 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 8 + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // A + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // C + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0, // E }; /* @@ -528,45 +550,52 @@ int utf_off2cells(unsigned off, unsigned max_off) return (off + 1 < max_off && ScreenLines[off + 1] == 0) ? 2 : 1; } -/* - * Convert a UTF-8 byte sequence to a wide character. - * If the sequence is illegal or truncated by a NUL the first byte is - * returned. - * Does not include composing characters, of course. - */ -int utf_ptr2char(const char_u *p) +/// Convert a UTF-8 byte sequence to a wide character +/// +/// If the sequence is illegal or truncated by a NUL then the first byte is +/// returned. Does not include composing characters for obvious reasons. +/// +/// @param[in] p String to convert. +/// +/// @return Unicode codepoint or byte value. +int utf_ptr2char(const char_u *const p) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { - uint8_t len; - - if (p[0] < 0x80) /* be quick for ASCII */ + if (p[0] < 0x80) { // Be quick for ASCII. return p[0]; + } - len = utf8len_tab_zero[p[0]]; + const uint8_t len = utf8len_tab_zero[p[0]]; if (len > 1 && (p[1] & 0xc0) == 0x80) { - if (len == 2) + if (len == 2) { return ((p[0] & 0x1f) << 6) + (p[1] & 0x3f); + } if ((p[2] & 0xc0) == 0x80) { - if (len == 3) - return ((p[0] & 0x0f) << 12) + ((p[1] & 0x3f) << 6) - + (p[2] & 0x3f); + if (len == 3) { + return (((p[0] & 0x0f) << 12) + ((p[1] & 0x3f) << 6) + + (p[2] & 0x3f)); + } if ((p[3] & 0xc0) == 0x80) { - if (len == 4) - return ((p[0] & 0x07) << 18) + ((p[1] & 0x3f) << 12) - + ((p[2] & 0x3f) << 6) + (p[3] & 0x3f); + if (len == 4) { + return (((p[0] & 0x07) << 18) + ((p[1] & 0x3f) << 12) + + ((p[2] & 0x3f) << 6) + (p[3] & 0x3f)); + } if ((p[4] & 0xc0) == 0x80) { - if (len == 5) - return ((p[0] & 0x03) << 24) + ((p[1] & 0x3f) << 18) - + ((p[2] & 0x3f) << 12) + ((p[3] & 0x3f) << 6) - + (p[4] & 0x3f); - if ((p[5] & 0xc0) == 0x80 && len == 6) - return ((p[0] & 0x01) << 30) + ((p[1] & 0x3f) << 24) - + ((p[2] & 0x3f) << 18) + ((p[3] & 0x3f) << 12) - + ((p[4] & 0x3f) << 6) + (p[5] & 0x3f); + if (len == 5) { + return (((p[0] & 0x03) << 24) + ((p[1] & 0x3f) << 18) + + ((p[2] & 0x3f) << 12) + ((p[3] & 0x3f) << 6) + + (p[4] & 0x3f)); + } + if ((p[5] & 0xc0) == 0x80 && len == 6) { + return (((p[0] & 0x01) << 30) + ((p[1] & 0x3f) << 24) + + ((p[2] & 0x3f) << 18) + ((p[3] & 0x3f) << 12) + + ((p[4] & 0x3f) << 6) + (p[5] & 0x3f)); + } } } } } - /* Illegal value, just return the first byte */ + // Illegal value: just return the first byte. return p[0]; } @@ -767,23 +796,24 @@ int utfc_char2bytes(int off, char_u *buf) return len; } -/* - * Get the length of a UTF-8 byte sequence, not including any following - * composing characters. - * Returns 0 for "". - * Returns 1 for an illegal byte sequence. - */ -int utf_ptr2len(const char_u *p) +/// Get the length of a UTF-8 byte sequence representing a single codepoint +/// +/// @param[in] p UTF-8 string. +/// +/// @return Sequence length, 0 for empty string and 1 for non-UTF-8 byte +/// sequence. +int utf_ptr2len(const char_u *const p) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - int len; - int i; - - if (*p == NUL) + if (*p == NUL) { return 0; - len = utf8len_tab[*p]; - for (i = 1; i < len; ++i) - if ((p[i] & 0xc0) != 0x80) + } + const int len = utf8len_tab[*p]; + for (int i = 1; i < len; i++) { + if ((p[i] & 0xc0) != 0x80) { return 1; + } + } return len; } @@ -824,38 +854,38 @@ int utf_ptr2len_len(const char_u *p, int size) return len; } -/* - * Return the number of bytes the UTF-8 encoding of the character at "p" takes. - * This includes following composing characters. - */ -int utfc_ptr2len(const char_u *p) +/// Return the number of bytes occupied by a UTF-8 character in a string +/// +/// This includes following composing characters. +int utfc_ptr2len(const char_u *const p) + FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - int len; - int b0 = *p; - int prevlen; + uint8_t b0 = (uint8_t)(*p); - if (b0 == NUL) + if (b0 == NUL) { return 0; - if (b0 < 0x80 && p[1] < 0x80) /* be quick for ASCII */ + } + if (b0 < 0x80 && p[1] < 0x80) { // be quick for ASCII return 1; + } - /* Skip over first UTF-8 char, stopping at a NUL byte. */ - len = utf_ptr2len(p); + // Skip over first UTF-8 char, stopping at a NUL byte. + int len = utf_ptr2len(p); - /* Check for illegal byte. */ - if (len == 1 && b0 >= 0x80) + // Check for illegal byte. + if (len == 1 && b0 >= 0x80) { return 1; + } - /* - * Check for composing characters. We can handle only the first six, but - * skip all of them (otherwise the cursor would get stuck). - */ - prevlen = 0; - for (;; ) { - if (p[len] < 0x80 || !UTF_COMPOSINGLIKE(p + prevlen, p + len)) + // Check for composing characters. We can handle only the first six, but + // skip all of them (otherwise the cursor would get stuck). + int prevlen = 0; + for (;;) { + if (p[len] < 0x80 || !UTF_COMPOSINGLIKE(p + prevlen, p + len)) { return len; + } - /* Skip over composing char */ + // Skip over composing char. prevlen = len; len += utf_ptr2len(p + len); } @@ -913,23 +943,22 @@ int utfc_ptr2len_len(const char_u *p, int size) return len; } -/* - * Return the number of bytes the UTF-8 encoding of character "c" takes. - * This does not include composing characters. - */ -int utf_char2len(int c) +/// Determine how many bytes certain unicode codepoint will occupy +int utf_char2len(const int c) { - if (c < 0x80) + if (c < 0x80) { return 1; - if (c < 0x800) + } else if (c < 0x800) { return 2; - if (c < 0x10000) + } else if (c < 0x10000) { return 3; - if (c < 0x200000) + } else if (c < 0x200000) { return 4; - if (c < 0x4000000) + } else if (c < 0x4000000) { return 5; - return 6; + } else { + return 6; + } } /// Convert Unicode character to UTF-8 string @@ -937,46 +966,42 @@ int utf_char2len(int c) /// @param c character to convert to \p buf /// @param[out] buf UTF-8 string generated from \p c, does not add \0 /// @return Number of bytes (1-6). Does not include composing characters. -int utf_char2bytes(int c, char_u *const buf) +int utf_char2bytes(const int c, char_u *const buf) { - if (c < 0x80) { /* 7 bits */ + if (c < 0x80) { // 7 bits buf[0] = c; return 1; - } - if (c < 0x800) { /* 11 bits */ + } else if (c < 0x800) { // 11 bits buf[0] = 0xc0 + ((unsigned)c >> 6); buf[1] = 0x80 + (c & 0x3f); return 2; - } - if (c < 0x10000) { /* 16 bits */ + } else if (c < 0x10000) { // 16 bits buf[0] = 0xe0 + ((unsigned)c >> 12); buf[1] = 0x80 + (((unsigned)c >> 6) & 0x3f); buf[2] = 0x80 + (c & 0x3f); return 3; - } - if (c < 0x200000) { /* 21 bits */ + } else if (c < 0x200000) { // 21 bits buf[0] = 0xf0 + ((unsigned)c >> 18); buf[1] = 0x80 + (((unsigned)c >> 12) & 0x3f); buf[2] = 0x80 + (((unsigned)c >> 6) & 0x3f); buf[3] = 0x80 + (c & 0x3f); return 4; - } - if (c < 0x4000000) { /* 26 bits */ + } else if (c < 0x4000000) { // 26 bits buf[0] = 0xf8 + ((unsigned)c >> 24); buf[1] = 0x80 + (((unsigned)c >> 18) & 0x3f); buf[2] = 0x80 + (((unsigned)c >> 12) & 0x3f); buf[3] = 0x80 + (((unsigned)c >> 6) & 0x3f); buf[4] = 0x80 + (c & 0x3f); return 5; + } else { // 31 bits + buf[0] = 0xfc + ((unsigned)c >> 30); + buf[1] = 0x80 + (((unsigned)c >> 24) & 0x3f); + buf[2] = 0x80 + (((unsigned)c >> 18) & 0x3f); + buf[3] = 0x80 + (((unsigned)c >> 12) & 0x3f); + buf[4] = 0x80 + (((unsigned)c >> 6) & 0x3f); + buf[5] = 0x80 + (c & 0x3f); + return 6; } - /* 31 bits */ - buf[0] = 0xfc + ((unsigned)c >> 30); - buf[1] = 0x80 + (((unsigned)c >> 24) & 0x3f); - buf[2] = 0x80 + (((unsigned)c >> 18) & 0x3f); - buf[3] = 0x80 + (((unsigned)c >> 12) & 0x3f); - buf[4] = 0x80 + (((unsigned)c >> 6) & 0x3f); - buf[5] = 0x80 + (c & 0x3f); - return 6; } /* @@ -1513,14 +1538,15 @@ int utf_head_off(const char_u *base, const char_u *p) return (int)(p - q); } -/* - * Copy a character from "*fp" to "*tp" and advance the pointers. - */ -void mb_copy_char(const char_u **fp, char_u **tp) +/// Copy a character, advancing the pointers +/// +/// @param[in,out] fp Source of the character to copy. +/// @param[in,out] tp Destination to copy to. +void mb_copy_char(const char_u **const fp, char_u **const tp) { - int l = (*mb_ptr2len)(*fp); + const size_t l = (size_t)utfc_ptr2len(*fp); - memmove(*tp, *fp, (size_t)l); + memmove(*tp, *fp, l); *tp += l; *fp += l; } -- cgit From e423cfe1948d75285dad2df151f53400f3b3be4e Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 8 Oct 2017 21:41:34 +0300 Subject: edit: Lint some functions which are to be copied for symbolic tests --- src/nvim/edit.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index ca62679fab..e57598fc91 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -6074,27 +6074,30 @@ void free_last_insert(void) #endif -/* - * Add character "c" to buffer "s". Escape the special meaning of K_SPECIAL - * and CSI. Handle multi-byte characters. - * Returns a pointer to after the added bytes. - */ +/// Add character "c" to buffer "s" +/// +/// Escapes the special meaning of K_SPECIAL and CSI, handles multi-byte +/// characters. +/// +/// @param[in] c Character to add. +/// @param[out] s Buffer to add to. Must have at least MB_MAXBYTES + 1 bytes. +/// +/// @return Pointer to after the added bytes. char_u *add_char2buf(int c, char_u *s) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { char_u temp[MB_MAXBYTES + 1]; - int i; - int len; - - len = (*mb_char2bytes)(c, temp); - for (i = 0; i < len; ++i) { + const int len = utf_char2bytes(c, temp); + for (int i = 0; i < len; ++i) { c = temp[i]; - /* Need to escape K_SPECIAL and CSI like in the typeahead buffer. */ + // Need to escape K_SPECIAL and CSI like in the typeahead buffer. if (c == K_SPECIAL) { *s++ = K_SPECIAL; *s++ = KS_SPECIAL; *s++ = KE_FILLER; - } else + } else { *s++ = c; + } } return s; } -- cgit From c484613ce034cf9b10a4185621abdf8d82b570f8 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 8 Oct 2017 21:52:29 +0300 Subject: keymap: Lint some functions to be copied for symbolic tests --- src/nvim/keymap.c | 435 +++++++++++++++++++++++++++--------------------------- 1 file changed, 216 insertions(+), 219 deletions(-) (limited to 'src') diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index 3d7ebb6382..f344d65c8d 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -24,12 +24,11 @@ * Some useful tables. */ -static struct modmasktable { - short mod_mask; /* Bit-mask for particular key modifier */ - short mod_flag; /* Bit(s) for particular key modifier */ - char_u name; /* Single letter name of modifier */ -} mod_mask_table[] = -{ +static const struct modmasktable { + short mod_mask; ///< Bit-mask for particular key modifier. + short mod_flag; ///< Bit(s) for particular key modifier. + char_u name; ///< Single letter name of modifier. +} mod_mask_table[] = { {MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'M'}, {MOD_MASK_META, MOD_MASK_META, (char_u)'T'}, {MOD_MASK_CTRL, MOD_MASK_CTRL, (char_u)'C'}, @@ -139,155 +138,154 @@ static char_u modifier_keys_table[] = NUL }; -static struct key_name_entry { - int key; /* Special key code or ascii value */ - char_u *name; /* Name of key */ -} key_names_table[] = -{ - {' ', (char_u *)"Space"}, - {TAB, (char_u *)"Tab"}, - {K_TAB, (char_u *)"Tab"}, - {NL, (char_u *)"NL"}, - {NL, (char_u *)"NewLine"}, /* Alternative name */ - {NL, (char_u *)"LineFeed"}, /* Alternative name */ - {NL, (char_u *)"LF"}, /* Alternative name */ - {CAR, (char_u *)"CR"}, - {CAR, (char_u *)"Return"}, /* Alternative name */ - {CAR, (char_u *)"Enter"}, /* Alternative name */ - {K_BS, (char_u *)"BS"}, - {K_BS, (char_u *)"BackSpace"}, /* Alternative name */ - {ESC, (char_u *)"Esc"}, - {CSI, (char_u *)"CSI"}, - {K_CSI, (char_u *)"xCSI"}, - {'|', (char_u *)"Bar"}, - {'\\', (char_u *)"Bslash"}, - {K_DEL, (char_u *)"Del"}, - {K_DEL, (char_u *)"Delete"}, /* Alternative name */ - {K_KDEL, (char_u *)"kDel"}, - {K_UP, (char_u *)"Up"}, - {K_DOWN, (char_u *)"Down"}, - {K_LEFT, (char_u *)"Left"}, - {K_RIGHT, (char_u *)"Right"}, - {K_XUP, (char_u *)"xUp"}, - {K_XDOWN, (char_u *)"xDown"}, - {K_XLEFT, (char_u *)"xLeft"}, - {K_XRIGHT, (char_u *)"xRight"}, - - {K_F1, (char_u *)"F1"}, - {K_F2, (char_u *)"F2"}, - {K_F3, (char_u *)"F3"}, - {K_F4, (char_u *)"F4"}, - {K_F5, (char_u *)"F5"}, - {K_F6, (char_u *)"F6"}, - {K_F7, (char_u *)"F7"}, - {K_F8, (char_u *)"F8"}, - {K_F9, (char_u *)"F9"}, - {K_F10, (char_u *)"F10"}, - - {K_F11, (char_u *)"F11"}, - {K_F12, (char_u *)"F12"}, - {K_F13, (char_u *)"F13"}, - {K_F14, (char_u *)"F14"}, - {K_F15, (char_u *)"F15"}, - {K_F16, (char_u *)"F16"}, - {K_F17, (char_u *)"F17"}, - {K_F18, (char_u *)"F18"}, - {K_F19, (char_u *)"F19"}, - {K_F20, (char_u *)"F20"}, - - {K_F21, (char_u *)"F21"}, - {K_F22, (char_u *)"F22"}, - {K_F23, (char_u *)"F23"}, - {K_F24, (char_u *)"F24"}, - {K_F25, (char_u *)"F25"}, - {K_F26, (char_u *)"F26"}, - {K_F27, (char_u *)"F27"}, - {K_F28, (char_u *)"F28"}, - {K_F29, (char_u *)"F29"}, - {K_F30, (char_u *)"F30"}, - - {K_F31, (char_u *)"F31"}, - {K_F32, (char_u *)"F32"}, - {K_F33, (char_u *)"F33"}, - {K_F34, (char_u *)"F34"}, - {K_F35, (char_u *)"F35"}, - {K_F36, (char_u *)"F36"}, - {K_F37, (char_u *)"F37"}, - - {K_XF1, (char_u *)"xF1"}, - {K_XF2, (char_u *)"xF2"}, - {K_XF3, (char_u *)"xF3"}, - {K_XF4, (char_u *)"xF4"}, - - {K_HELP, (char_u *)"Help"}, - {K_UNDO, (char_u *)"Undo"}, - {K_INS, (char_u *)"Insert"}, - {K_INS, (char_u *)"Ins"}, /* Alternative name */ - {K_KINS, (char_u *)"kInsert"}, - {K_HOME, (char_u *)"Home"}, - {K_KHOME, (char_u *)"kHome"}, - {K_XHOME, (char_u *)"xHome"}, - {K_ZHOME, (char_u *)"zHome"}, - {K_END, (char_u *)"End"}, - {K_KEND, (char_u *)"kEnd"}, - {K_XEND, (char_u *)"xEnd"}, - {K_ZEND, (char_u *)"zEnd"}, - {K_PAGEUP, (char_u *)"PageUp"}, - {K_PAGEDOWN, (char_u *)"PageDown"}, - {K_KPAGEUP, (char_u *)"kPageUp"}, - {K_KPAGEDOWN, (char_u *)"kPageDown"}, - - {K_KPLUS, (char_u *)"kPlus"}, - {K_KMINUS, (char_u *)"kMinus"}, - {K_KDIVIDE, (char_u *)"kDivide"}, - {K_KMULTIPLY, (char_u *)"kMultiply"}, - {K_KENTER, (char_u *)"kEnter"}, - {K_KPOINT, (char_u *)"kPoint"}, - - {K_K0, (char_u *)"k0"}, - {K_K1, (char_u *)"k1"}, - {K_K2, (char_u *)"k2"}, - {K_K3, (char_u *)"k3"}, - {K_K4, (char_u *)"k4"}, - {K_K5, (char_u *)"k5"}, - {K_K6, (char_u *)"k6"}, - {K_K7, (char_u *)"k7"}, - {K_K8, (char_u *)"k8"}, - {K_K9, (char_u *)"k9"}, - - {'<', (char_u *)"lt"}, - - {K_MOUSE, (char_u *)"Mouse"}, - {K_LEFTMOUSE, (char_u *)"LeftMouse"}, - {K_LEFTMOUSE_NM, (char_u *)"LeftMouseNM"}, - {K_LEFTDRAG, (char_u *)"LeftDrag"}, - {K_LEFTRELEASE, (char_u *)"LeftRelease"}, - {K_LEFTRELEASE_NM, (char_u *)"LeftReleaseNM"}, - {K_MIDDLEMOUSE, (char_u *)"MiddleMouse"}, - {K_MIDDLEDRAG, (char_u *)"MiddleDrag"}, - {K_MIDDLERELEASE, (char_u *)"MiddleRelease"}, - {K_RIGHTMOUSE, (char_u *)"RightMouse"}, - {K_RIGHTDRAG, (char_u *)"RightDrag"}, - {K_RIGHTRELEASE, (char_u *)"RightRelease"}, - {K_MOUSEDOWN, (char_u *)"ScrollWheelUp"}, - {K_MOUSEUP, (char_u *)"ScrollWheelDown"}, - {K_MOUSELEFT, (char_u *)"ScrollWheelRight"}, - {K_MOUSERIGHT, (char_u *)"ScrollWheelLeft"}, - {K_MOUSEDOWN, (char_u *)"MouseDown"}, /* OBSOLETE: Use */ - {K_MOUSEUP, (char_u *)"MouseUp"}, /* ScrollWheelXXX instead */ - {K_X1MOUSE, (char_u *)"X1Mouse"}, - {K_X1DRAG, (char_u *)"X1Drag"}, - {K_X1RELEASE, (char_u *)"X1Release"}, - {K_X2MOUSE, (char_u *)"X2Mouse"}, - {K_X2DRAG, (char_u *)"X2Drag"}, - {K_X2RELEASE, (char_u *)"X2Release"}, - {K_DROP, (char_u *)"Drop"}, - {K_ZERO, (char_u *)"Nul"}, - {K_SNR, (char_u *)"SNR"}, - {K_PLUG, (char_u *)"Plug"}, - {K_PASTE, (char_u *)"Paste"}, - {K_FOCUSGAINED, (char_u *)"FocusGained"}, - {K_FOCUSLOST, (char_u *)"FocusLost"}, +static const struct key_name_entry { + int key; ///< Special key code or ASCII value. + const char *name; ///< Name of the key +} key_names_table[] = { + {' ', "Space"}, + {TAB, "Tab"}, + {K_TAB, "Tab"}, + {NL, "NL"}, + {NL, "NewLine"}, // Alternative name + {NL, "LineFeed"}, // Alternative name + {NL, "LF"}, // Alternative name + {CAR, "CR"}, + {CAR, "Return"}, // Alternative name + {CAR, "Enter"}, // Alternative name + {K_BS, "BS"}, + {K_BS, "BackSpace"}, // Alternative name + {ESC, "Esc"}, + {CSI, "CSI"}, + {K_CSI, "xCSI"}, + {'|', "Bar"}, + {'\\', "Bslash"}, + {K_DEL, "Del"}, + {K_DEL, "Delete"}, // Alternative name + {K_KDEL, "kDel"}, + {K_UP, "Up"}, + {K_DOWN, "Down"}, + {K_LEFT, "Left"}, + {K_RIGHT, "Right"}, + {K_XUP, "xUp"}, + {K_XDOWN, "xDown"}, + {K_XLEFT, "xLeft"}, + {K_XRIGHT, "xRight"}, + + {K_F1, "F1"}, + {K_F2, "F2"}, + {K_F3, "F3"}, + {K_F4, "F4"}, + {K_F5, "F5"}, + {K_F6, "F6"}, + {K_F7, "F7"}, + {K_F8, "F8"}, + {K_F9, "F9"}, + {K_F10, "F10"}, + + {K_F11, "F11"}, + {K_F12, "F12"}, + {K_F13, "F13"}, + {K_F14, "F14"}, + {K_F15, "F15"}, + {K_F16, "F16"}, + {K_F17, "F17"}, + {K_F18, "F18"}, + {K_F19, "F19"}, + {K_F20, "F20"}, + + {K_F21, "F21"}, + {K_F22, "F22"}, + {K_F23, "F23"}, + {K_F24, "F24"}, + {K_F25, "F25"}, + {K_F26, "F26"}, + {K_F27, "F27"}, + {K_F28, "F28"}, + {K_F29, "F29"}, + {K_F30, "F30"}, + + {K_F31, "F31"}, + {K_F32, "F32"}, + {K_F33, "F33"}, + {K_F34, "F34"}, + {K_F35, "F35"}, + {K_F36, "F36"}, + {K_F37, "F37"}, + + {K_XF1, "xF1"}, + {K_XF2, "xF2"}, + {K_XF3, "xF3"}, + {K_XF4, "xF4"}, + + {K_HELP, "Help"}, + {K_UNDO, "Undo"}, + {K_INS, "Insert"}, + {K_INS, "Ins"}, // Alternative name + {K_KINS, "kInsert"}, + {K_HOME, "Home"}, + {K_KHOME, "kHome"}, + {K_XHOME, "xHome"}, + {K_ZHOME, "zHome"}, + {K_END, "End"}, + {K_KEND, "kEnd"}, + {K_XEND, "xEnd"}, + {K_ZEND, "zEnd"}, + {K_PAGEUP, "PageUp"}, + {K_PAGEDOWN, "PageDown"}, + {K_KPAGEUP, "kPageUp"}, + {K_KPAGEDOWN, "kPageDown"}, + + {K_KPLUS, "kPlus"}, + {K_KMINUS, "kMinus"}, + {K_KDIVIDE, "kDivide"}, + {K_KMULTIPLY, "kMultiply"}, + {K_KENTER, "kEnter"}, + {K_KPOINT, "kPoint"}, + + {K_K0, "k0"}, + {K_K1, "k1"}, + {K_K2, "k2"}, + {K_K3, "k3"}, + {K_K4, "k4"}, + {K_K5, "k5"}, + {K_K6, "k6"}, + {K_K7, "k7"}, + {K_K8, "k8"}, + {K_K9, "k9"}, + + {'<', "lt"}, + + {K_MOUSE, "Mouse"}, + {K_LEFTMOUSE, "LeftMouse"}, + {K_LEFTMOUSE_NM, "LeftMouseNM"}, + {K_LEFTDRAG, "LeftDrag"}, + {K_LEFTRELEASE, "LeftRelease"}, + {K_LEFTRELEASE_NM, "LeftReleaseNM"}, + {K_MIDDLEMOUSE, "MiddleMouse"}, + {K_MIDDLEDRAG, "MiddleDrag"}, + {K_MIDDLERELEASE, "MiddleRelease"}, + {K_RIGHTMOUSE, "RightMouse"}, + {K_RIGHTDRAG, "RightDrag"}, + {K_RIGHTRELEASE, "RightRelease"}, + {K_MOUSEDOWN, "ScrollWheelUp"}, + {K_MOUSEUP, "ScrollWheelDown"}, + {K_MOUSELEFT, "ScrollWheelRight"}, + {K_MOUSERIGHT, "ScrollWheelLeft"}, + {K_MOUSEDOWN, "MouseDown"}, // OBSOLETE: Use ScrollWheelXXX instead + {K_MOUSEUP, "MouseUp"}, // Same + {K_X1MOUSE, "X1Mouse"}, + {K_X1DRAG, "X1Drag"}, + {K_X1RELEASE, "X1Release"}, + {K_X2MOUSE, "X2Mouse"}, + {K_X2DRAG, "X2Drag"}, + {K_X2RELEASE, "X2Release"}, + {K_DROP, "Drop"}, + {K_ZERO, "Nul"}, + {K_SNR, "SNR"}, + {K_PLUG, "Plug"}, + {K_PASTE, "Paste"}, + {K_FOCUSGAINED, "FocusGained"}, + {K_FOCUSLOST, "FocusLost"}, {0, NULL} }; @@ -320,73 +318,73 @@ static struct mousetable { {0, 0, 0, 0}, }; -/* - * Return the modifier mask bit (MOD_MASK_*) which corresponds to the given - * modifier name ('S' for Shift, 'C' for Ctrl etc). - */ +/// Return the modifier mask bit (#MOD_MASK_*) corresponding to mod name +/// +/// E.g. 'S' for shift, 'C' for ctrl. int name_to_mod_mask(int c) + FUNC_ATTR_CONST FUNC_ATTR_WARN_UNUSED_RESULT { - int i; - c = TOUPPER_ASC(c); - for (i = 0; mod_mask_table[i].mod_mask != 0; i++) - if (c == mod_mask_table[i].name) + for (size_t i = 0; mod_mask_table[i].mod_mask != 0; i++) { + if (c == mod_mask_table[i].name) { return mod_mask_table[i].mod_flag; + } + } return 0; } -/* - * Check if if there is a special key code for "key" that includes the - * modifiers specified. - */ -int simplify_key(int key, int *modifiers) +/// Check if there is a special key code for "key" with specified modifiers +/// +/// @param[in] key Initial key code. +/// @param[in,out] modifiers Initial modifiers, is adjusted to have simplified +/// modifiers. +/// +/// @return Simplified key code. +int simplify_key(const int key, int *modifiers) + FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL { - int i; - int key0; - int key1; - if (*modifiers & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT)) { - /* TAB is a special case */ + // TAB is a special case. if (key == TAB && (*modifiers & MOD_MASK_SHIFT)) { *modifiers &= ~MOD_MASK_SHIFT; return K_S_TAB; } - key0 = KEY2TERMCAP0(key); - key1 = KEY2TERMCAP1(key); - for (i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE) + const int key0 = KEY2TERMCAP0(key); + const int key1 = KEY2TERMCAP1(key); + for (int i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE) { if (key0 == modifier_keys_table[i + 3] && key1 == modifier_keys_table[i + 4] && (*modifiers & modifier_keys_table[i])) { *modifiers &= ~modifier_keys_table[i]; return TERMCAP2KEY(modifier_keys_table[i + 1], - modifier_keys_table[i + 2]); + modifier_keys_table[i + 2]); } + } } return key; } -/* - * Change to , to , etc. - */ -int handle_x_keys(int key) +/// Change to +int handle_x_keys(const int key) + FUNC_ATTR_CONST FUNC_ATTR_WARN_UNUSED_RESULT { switch (key) { - case K_XUP: return K_UP; - case K_XDOWN: return K_DOWN; - case K_XLEFT: return K_LEFT; - case K_XRIGHT: return K_RIGHT; - case K_XHOME: return K_HOME; - case K_ZHOME: return K_HOME; - case K_XEND: return K_END; - case K_ZEND: return K_END; - case K_XF1: return K_F1; - case K_XF2: return K_F2; - case K_XF3: return K_F3; - case K_XF4: return K_F4; - case K_S_XF1: return K_S_F1; - case K_S_XF2: return K_S_F2; - case K_S_XF3: return K_S_F3; - case K_S_XF4: return K_S_F4; + case K_XUP: return K_UP; + case K_XDOWN: return K_DOWN; + case K_XLEFT: return K_LEFT; + case K_XRIGHT: return K_RIGHT; + case K_XHOME: return K_HOME; + case K_ZHOME: return K_HOME; + case K_XEND: return K_END; + case K_ZEND: return K_END; + case K_XF1: return K_F1; + case K_XF2: return K_F2; + case K_XF3: return K_F3; + case K_XF4: return K_F4; + case K_S_XF1: return K_S_F1; + case K_S_XF2: return K_S_F2; + case K_S_XF3: return K_S_F3; + case K_S_XF4: return K_S_F4; } return key; } @@ -510,7 +508,7 @@ unsigned int trans_special(const char_u **srcp, const size_t src_len, return 0; } - /* Put the appropriate modifier in a string */ + // Put the appropriate modifier in a string. if (modifiers != 0) { dst[dlen++] = K_SPECIAL; dst[dlen++] = KS_MODIFIER; @@ -575,11 +573,7 @@ int find_special_key(const char_u **srcp, const size_t src_len, int *const modp, if (*bp == '-') { last_dash = bp; if (bp + 1 <= end) { - if (has_mbyte) { - l = mb_ptr2len_len(bp + 1, (int) (end - bp) + 1); - } else { - l = 1; - } + l = utfc_ptr2len_len(bp + 1, (int)(end - bp) + 1); // Anything accepted, like . // or are not special in strings as " is // the string delimiter. With a backslash it works: @@ -705,32 +699,35 @@ int find_special_key_in_table(int c) int i; for (i = 0; key_names_table[i].name != NULL; i++) - if (c == key_names_table[i].key) + if (c == (uint8_t)key_names_table[i].key) break; if (key_names_table[i].name == NULL) i = -1; return i; } -/* - * Find the special key with the given name (the given string does not have to - * end with NUL, the name is assumed to end before the first non-idchar). - * If the name starts with "t_" the next two characters are interpreted as a - * termcap name. - * Return the key code, or 0 if not found. - */ +/// Find the special key with the given name +/// +/// @param[in] name Name of the special. Does not have to end with NUL, it is +/// assumed to end before the first non-idchar. If name starts +/// with "t_" the next two characters are interpreted as +/// a termcap name. +/// +/// @return Key code or 0 if ton found. int get_special_key_code(const char_u *name) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { - char_u *table_name; - int i, j; - - for (i = 0; key_names_table[i].name != NULL; i++) { - table_name = key_names_table[i].name; - for (j = 0; vim_isIDc(name[j]) && table_name[j] != NUL; j++) - if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC(name[j])) + for (int i = 0; key_names_table[i].name != NULL; i++) { + const char *const table_name = key_names_table[i].name; + int j; + for (j = 0; vim_isIDc(name[j]) && table_name[j] != NUL; j++) { + if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC(name[j])) { break; - if (!vim_isIDc(name[j]) && table_name[j] == NUL) + } + } + if (!vim_isIDc(name[j]) && table_name[j] == NUL) { return key_names_table[i].key; + } } return 0; -- cgit From af38cea133f5ebb67208cedd289e408cd1dad15a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 8 Oct 2017 21:52:38 +0300 Subject: viml/parser/expressions: Add support for string parsing --- src/nvim/mbyte.h | 2 + src/nvim/viml/parser/expressions.c | 376 ++++++++++++++++++++++++++++++++++++- src/nvim/viml/parser/expressions.h | 7 + 3 files changed, 377 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h index bf6ccb13a5..fce600d0a9 100644 --- a/src/nvim/mbyte.h +++ b/src/nvim/mbyte.h @@ -73,6 +73,8 @@ typedef struct { extern const uint8_t utf8len_tab_zero[256]; +extern const uint8_t utf8len_tab[256]; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "mbyte.h.generated.h" #endif diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 0613cc66d5..3f30fe2a0e 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -915,8 +915,6 @@ static inline void viml_pexpr_debug_print_token( // // NVimIdentifierKey -> Identifier // -// NVimFigureBrace -> NVimInternalError -// // NVimUnaryPlus -> NVimUnaryOperator // NVimBinaryPlus -> NVimBinaryOperator // NVimConcat -> NVimBinaryOperator @@ -929,6 +927,18 @@ static inline void viml_pexpr_debug_print_token( // NVimNestingParenthesis -> NVimParenthesis // NVimCallingParenthesis -> NVimParenthesis // +// NVimString -> String +// NVimStringSpecial -> SpecialChar +// NVimSingleQuote -> NVimString +// NVimSingleQuotedBody -> NVimString +// NVimSingleQuotedQuote -> NVimStringSpecial +// NVimDoubleQuote -> NVimString +// NVimDoubleQuotedBody -> NVimString +// NVimDoubleQuotedEscape -> NVimStringSpecial +// NVimDoubleQuotedUnknownEscape -> NVimInvalid +// +// " Note: NVimDoubleQuotedUnknownEscape is not actually invalid +// // NVimInvalidComma -> NVimInvalidDelimiter // NVimInvalidSpacing -> NVimInvalid // NVimInvalidTernary -> NVimInvalidOperator @@ -952,6 +962,19 @@ static inline void viml_pexpr_debug_print_token( // NVimInvalidList -> NVimInvalidDelimiter // NVimInvalidSubscript -> NVimInvalidDelimiter // NVimInvalidSubscriptColon -> NVimInvalidSubscript +// NVimInvalidString -> NVimInvalidValue +// NVimInvalidStringSpecial -> NVimInvalidString +// NVimInvalidSingleQuote -> NVimInvalidString +// NVimInvalidSingleQuotedBody -> NVimInvalidString +// NVimInvalidSingleQuotedQuote -> NVimInvalidStringSpecial +// NVimInvalidDoubleQuote -> NVimInvalidString +// NVimInvalidDoubleQuotedBody -> NVimInvalidString +// NVimInvalidDoubleQuotedEscape -> NVimInvalidStringSpecial +// NVimInvalidDoubleQuotedUnknownEscape -> NVimInvalid +// +// NVimFigureBrace -> NVimInternalError +// NVimInvalidSingleQuotedUnknownEscape -> NVimInternalError +// NVimSingleQuotedUnknownEscape -> NVimInternalError /// Allocate a new node and set some of the values /// @@ -1402,6 +1425,318 @@ static inline void east_set_error(const ParserState *const pstate, } \ } while (0) +/// Structure used to define “string shifts†necessary to map string +/// highlighting to actual strings. +typedef struct { + size_t start; ///< Where special character starts in original string. + size_t orig_len; ///< Length of orininal string (e.g. 4 for "\x80"). + size_t act_len; ///< Length of resulting character(s) (e.g. 1 for "\x80"). + bool escape_not_known; ///< True if escape sequence in original is not known. +} StringShift; + +/// Parse and highlight single- or double-quoted string +/// +/// Function is supposed to detect and highlight regular expressions (but does +/// not do now). +/// +/// @param[out] pstate Parser state which also contains a place where +/// highlighting is saved. +/// @param[out] node Node where string parsing results are saved. +/// @param[in] token Token to highlight. +/// @param[in] ast_stack Parser AST stack, used to detect whether current +/// string is a regex. +/// @param[in] is_invalid Whether currently processed token is not valid. +static void parse_quoted_string(ParserState *const pstate, + ExprASTNode *const node, + const LexExprToken token, + const ExprASTStack ast_stack, + const bool is_invalid) + FUNC_ATTR_NONNULL_ALL +{ + const ParserLine pline = pstate->reader.lines.items[token.start.line]; + const char *const s = pline.data + token.start.col; + const char *const e = s + token.len - token.data.str.closed; + const char *p = s + 1; + const bool is_double = (token.type == kExprLexDoubleQuotedString); + size_t size = token.len - token.data.str.closed - 1; + kvec_withinit_t(StringShift, 16) shifts; + kvi_init(shifts); + if (!is_double) { + viml_parser_highlight(pstate, token.start, 1, HL(SingleQuotedString)); + while (p < e) { + const char *const chunk_e = memchr(p, '\'', (size_t)(e - p)); + if (chunk_e == NULL) { + break; + } + size--; + p = chunk_e + 2; + if (pstate->colors) { + kvi_push(shifts, ((StringShift) { + .start = token.start.col + (size_t)(chunk_e - s), + .orig_len = 2, + .act_len = 1, + .escape_not_known = false, + })); + } + } + node->data.str.size = size; + if (size == 0) { + node->data.str.value = NULL; + } else { + char *v_p; + v_p = node->data.str.value = xmalloc(size); + p = s + 1; + while (p < e) { + const char *const chunk_e = memchr(p, '\'', (size_t)(e - p)); + if (chunk_e == NULL) { + memcpy(v_p, p, (size_t)(e - p)); + break; + } + memcpy(v_p, p, (size_t)(chunk_e - p)); + v_p += (size_t)(chunk_e - p) + 1; + v_p[-1] = '\''; + p = chunk_e + 2; + } + } + } else { + viml_parser_highlight(pstate, token.start, 1, HL(DoubleQuotedString)); + for (p = s + 1; p < e; p++) { + if (*p == '\\' && p + 1 < e) { + p++; + if (p + 1 == e) { + size--; + break; + } + switch (*p) { + // A "\" form occupies at least 4 characters, and produces up to + // 6 characters: reserve space for 2 extra, but do not compute actual + // length just now, it would be costy. + case '<': { + size += 2; + break; + } + // Hexadecimal, always single byte, but at least three bytes each. + case 'x': case 'X': { + size--; + if (ascii_isxdigit(p[1])) { + size--; + if (p + 2 < e && ascii_isxdigit(p[2])) { + size--; + } + } + break; + } + // Unicode + // + // \uF takes 1 byte which is 2 bytes less then escape sequence. + // \uFF: 2 bytes, 2 bytes less. + // \uFFF: 3 bytes, 2 bytes less. + // \uFFFF: 3 bytes, 3 bytes less. + // \UFFFFF: 4 bytes, 3 bytes less. + // \UFFFFFF: 5 bytes, 3 bytes less. + // \UFFFFFFF: 6 bytes, 3 bytes less. + // \U7FFFFFFF: 6 bytes, 4 bytes less. + case 'u': case 'U': { + const char *const esc_start = p; + size_t n = (*p == 'u' ? 4 : 8); + int nr = 0; + p++; + while (n-- && ascii_isxdigit(p[1])) { + p++; + nr = (nr << 4) + hex2nr(*p); + } + // Escape length: (esc_start - 1) points to "\\", esc_start to "u" + // or "U", p to the byte after last byte. So escape sequence + // occupies p - (esc_start - 1), but it stands for a utf_char2len + // bytes. + size -= (size_t)((p - (esc_start - 1)) - utf_char2len(nr)); + p--; + break; + } + // Octal, always single byte, but at least two bytes each. + case '0': case '1': case '2': case '3': case '4': case '5': case '6': + case '7': { + size--; + p++; + if (*p >= '0' && *p <= '7') { + size--; + p++; + if (*p >= '0' && *p <= '7') { + size--; + p++; + } + } + break; + } + default: { + size--; + break; + } + } + } + } + if (size == 0) { + node->data.str.value = NULL; + node->data.str.size = 0; + } else { + char *v_p; + v_p = node->data.str.value = xmalloc(size); + p = s + 1; + while (p < e) { + const char *const chunk_e = memchr(p, '\\', (size_t)(e - p)); + if (chunk_e == NULL) { + memcpy(v_p, p, (size_t)(e - p)); + v_p += e - p; + break; + } + memcpy(v_p, p, (size_t)(chunk_e - p)); + v_p += (size_t)(chunk_e - p); + p = chunk_e + 1; + if (p == e) { + *v_p++ = '\\'; + break; + } + bool is_unknown = false; + const char *const v_p_start = v_p; + switch (*p) { +#define SINGLE_CHAR_ESC(ch, real_ch) \ + case ch: { \ + *v_p++ = real_ch; \ + p++; \ + break; \ + } + SINGLE_CHAR_ESC('b', BS) + SINGLE_CHAR_ESC('e', ESC) + SINGLE_CHAR_ESC('f', FF) + SINGLE_CHAR_ESC('n', NL) + SINGLE_CHAR_ESC('r', CAR) + SINGLE_CHAR_ESC('t', TAB) + SINGLE_CHAR_ESC('"', '"') + SINGLE_CHAR_ESC('\\', '\\') +#undef SINGLE_CHAR_ESC + + // Hexadecimal or unicode. + case 'X': case 'x': case 'u': case 'U': { + if (ascii_isxdigit(p[1])) { + size_t n; + int nr; + bool is_hex = (*p == 'x' || *p == 'X'); + + if (is_hex) { + n = 2; + } else if (*p == 'u') { + n = 4; + } else { + n = 8; + } + nr = 0; + while (n-- && ascii_isxdigit(p[1])) { + p++; + nr = (nr << 4) + hex2nr(*p); + } + p++; + if (is_hex) { + *v_p++ = (char)nr; + } else { + v_p += utf_char2bytes(nr, (char_u *)v_p); + } + } else { + is_unknown = true; + *v_p++ = *p; + p++; + } + break; + } + // Octal: "\1", "\12", "\123". + case '0': case '1': case '2': case '3': case '4': case '5': case '6': + case '7': { + uint8_t ch = (uint8_t)(*p++ - '0'); + if (*p >= '0' && *p <= '7') { + ch = (uint8_t)((ch << 3) + *p++ - '0'); + if (*p >= '0' && *p <= '7') { + ch = (uint8_t)((ch << 3) + *p++ - '0'); + } + } + *v_p++ = (char)ch; + break; + } + // Special key, e.g.: "\" + case '<': { + const size_t special_len = ( + trans_special((const char_u **)&p, (size_t)(e - p), + (char_u *)v_p, true, true)); + if (special_len != 0) { + v_p += special_len; + } else { + is_unknown = true; + mb_copy_char((const char_u **)&p, (char_u **)&v_p); + } + break; + } + default: { + is_unknown = true; + mb_copy_char((const char_u **)&p, (char_u **)&v_p); + break; + } + } + if (pstate->colors) { + kvi_push(shifts, ((StringShift) { + .start = token.start.col + (size_t)(chunk_e - s), + .orig_len = (size_t)(p - chunk_e), + .act_len = (size_t)(v_p - (char *)v_p_start), + .escape_not_known = is_unknown, + })); + } + } + node->data.str.size = (size_t)(v_p - node->data.str.value); + } + } + if (pstate->colors) { + // TODO(ZyX-I): use ast_stack to determine and highlight regular expressions + // TODO(ZyX-I): use ast_stack to determine and highlight printf format str + // TODO(ZyX-I): use ast_stack to determine and highlight expression strings + size_t next_col = 1; + const char *const body_str = (is_double + ? HL(DoubleQuotedBody) + : HL(SingleQuotedBody)); + const char *const esc_str = (is_double + ? HL(DoubleQuotedEscape) + : HL(SingleQuotedQuote)); + const char *const ukn_esc_str = (is_double + ? HL(DoubleQuotedUnknownEscape) + : HL(SingleQuotedUnknownEscape)); + for (size_t i = 0; i < kv_size(shifts); i++) { + const StringShift cur_shift = kv_A(shifts, i); + if (cur_shift.start > next_col) { + viml_parser_highlight(pstate, shifted_pos(token.start, next_col), + cur_shift.start - next_col, + body_str); + } + viml_parser_highlight(pstate, shifted_pos(token.start, cur_shift.start), + cur_shift.orig_len, + (cur_shift.escape_not_known + ? ukn_esc_str + : esc_str)); + next_col = cur_shift.start + cur_shift.orig_len; + } + if (next_col < token.len - token.data.str.closed) { + viml_parser_highlight(pstate, shifted_pos(token.start, next_col), + token.len - token.data.str.closed - next_col, + body_str); + } + } + if (token.data.str.closed) { + if (is_double) { + viml_parser_highlight(pstate, shifted_pos(token.start, token.len - 1), + 1, HL(DoubleQuotedString)); + } else { + viml_parser_highlight(pstate, shifted_pos(token.start, token.len - 1), + 1, HL(SingleQuotedString)); + } + } + kvi_destroy(shifts); +} + /// Parse one VimL expression /// /// @param pstate Parser state. @@ -1714,12 +2049,7 @@ viml_pexpr_parse_invalid_comma: } else if (eastnode_lvl >= kEOpLvlComma) { can_be_ternary = false; } else { -viml_pexpr_parse_invalid_colon: - ERROR_FROM_TOKEN_AND_MSG( - cur_token, - _("E15: Colon outside of dictionary or ternary operator: " - "%.*s")); - break; + goto viml_pexpr_parse_invalid_colon; } if (i == kv_size(ast_stack) - 1) { goto viml_pexpr_parse_invalid_colon; @@ -1741,6 +2071,12 @@ viml_pexpr_parse_invalid_colon: ADD_OP_NODE(cur_node); HL_CUR_TOKEN(SubscriptColon); } else { + goto viml_pexpr_parse_valid_colon; +viml_pexpr_parse_invalid_colon: + ERROR_FROM_TOKEN_AND_MSG( + cur_token, + _("E15: Colon outside of dictionary or ternary operator: %.*s")); +viml_pexpr_parse_valid_colon: ADD_VALUE_IF_MISSING(_(EXP_VAL_COLON)); NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeColon); if (is_ternary) { @@ -2201,6 +2537,30 @@ viml_pexpr_parse_no_paren_closing_error: {} kvi_push(ast_stack, &ter_val_node->children); break; } + case kExprLexDoubleQuotedString: + case kExprLexSingleQuotedString: { + const bool is_double = (tok_type == kExprLexDoubleQuotedString); + if (!cur_token.data.str.closed) { + // It is weird, but Vim has two identical errors messages with + // different error numbers: "E114: Missing quote" and + // "E115: Missing quote". + ERROR_FROM_TOKEN_AND_MSG( + cur_token, (is_double + ? _("E114: Missing double quote: %.*s") + : _("E115: Missing single quote: %.*s"))); + } + if (want_node == kENodeOperator) { + OP_MISSING; + } + NEW_NODE_WITH_CUR_POS( + cur_node, (is_double + ? kExprNodeDoubleQuotedString + : kExprNodeSingleQuotedString)); + *top_node_p = cur_node; + parse_quoted_string(pstate, cur_node, cur_token, ast_stack, is_invalid); + want_node = kENodeOperator; + break; + } } viml_pexpr_parse_cycle_end: prev_token = cur_token; diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 0d496c87ba..a09cdde4c0 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -195,6 +195,8 @@ typedef enum { kExprNodeConcatOrSubscript = 'S', kExprNodeInteger = '0', ///< Integral number. kExprNodeFloat = '1', ///< Floating-point number. + kExprNodeSingleQuotedString = '\'', + kExprNodeDoubleQuotedString = '"', } ExprASTNodeType; typedef struct expr_ast_node ExprASTNode; @@ -249,6 +251,11 @@ struct expr_ast_node { struct { float_T value; } flt; ///< For kExprNodeFloat. + struct { + char *value; + size_t size; + } str; ///< For kExprNodeSingleQuotedString and + ///< kExprNodeDoubleQuotedString. } data; }; -- cgit From fa3cfc0dd54df125a1dbabccda47a5f45dc483ae Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 9 Oct 2017 02:55:56 +0300 Subject: viml/parser/expressions: Finish parser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note: formatc.lua was unable to swallow some newer additions to ExprASTNodeType (specifically `kExprNodeOr = '|'` and probably something else), so all `= …` were dropped: in any case they only were there in order to not bother updating viml_pexpr_debug_print_ast_node and since it is now known all nodes which will be present it is not much of an issue. --- src/nvim/viml/parser/expressions.c | 369 +++++++++++++++++++++++++------------ src/nvim/viml/parser/expressions.h | 115 ++++++++---- src/nvim/viml/parser/parser.h | 2 +- 3 files changed, 331 insertions(+), 155 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 3f30fe2a0e..75fcb17bf6 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -361,11 +361,12 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) // Scope: `s:`, etc. } else if (ret.len == 1 && pline.size > 1 - && strchr("sgvbwtla", schar) != NULL + && memchr(EXPR_VAR_SCOPE_LIST, schar, + sizeof(EXPR_VAR_SCOPE_LIST)) != NULL && pline.data[ret.len] == ':' && !(flags & kELFlagForbidScope)) { ret.len++; - ret.data.var.scope = schar; + ret.data.var.scope = (ExprVarScope)schar; CHARREG(kExprLexPlainIdentifier, ISWORD_OR_AUTOLOAD); ret.data.var.autoload = ( memchr(pline.data + 2, AUTOLOAD_CHAR, ret.len - 2) @@ -408,14 +409,13 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) ret.type = kExprLexOption; if (pline.size > 2 && pline.data[2] == ':' - && strchr("gl", pline.data[1]) != NULL) { + && memchr(EXPR_OPT_SCOPE_LIST, pline.data[1], + sizeof(EXPR_OPT_SCOPE_LIST)) != NULL) { ret.len += 2; - ret.data.opt.scope = (pline.data[1] == 'g' - ? kExprLexOptGlobal - : kExprLexOptLocal); + ret.data.opt.scope = (ExprOptScope)pline.data[1]; ret.data.opt.name = pline.data + 3; } else { - ret.data.opt.scope = kExprLexOptUnspecified; + ret.data.opt.scope = kExprOptScopeUnspecified; ret.data.opt.name = pline.data + 1; } const char *p = ret.data.opt.name; @@ -637,9 +637,9 @@ static const char *const eltkn_mul_type_tab[] = { }; static const char *const eltkn_opt_scope_tab[] = { - [kExprLexOptUnspecified] = "Unspecified", - [kExprLexOptGlobal] = "Global", - [kExprLexOptLocal] = "Local", + [kExprOptScopeUnspecified] = "Unspecified", + [kExprOptScopeGlobal] = "Global", + [kExprOptScopeLocal] = "Local", }; /// Represent `int` character as a string @@ -990,67 +990,25 @@ static inline ExprASTNode *viml_pexpr_new_node(const ExprASTNodeType type) return ret; } -static const ExprOpLvl node_type_to_op_lvl[] = { - [kExprNodeMissing] = kEOpLvlInvalid, - [kExprNodeOpMissing] = kEOpLvlMultiplication, +static struct { + ExprOpLvl lvl; + ExprOpAssociativity ass; +} node_type_to_node_props[] = { + [kExprNodeMissing] = { kEOpLvlInvalid, kEOpAssNo, }, + [kExprNodeOpMissing] = { kEOpLvlMultiplication, kEOpAssNo }, - [kExprNodeNested] = kEOpLvlParens, + [kExprNodeNested] = { kEOpLvlParens, kEOpAssNo }, // Note: below nodes are kEOpLvlSubscript for “binary operator†itself, but // kEOpLvlParens when it comes to inside the parenthesis. - [kExprNodeCall] = kEOpLvlParens, - [kExprNodeSubscript] = kEOpLvlParens, + [kExprNodeCall] = { kEOpLvlParens, kEOpAssNo }, + [kExprNodeSubscript] = { kEOpLvlParens, kEOpAssNo }, - [kExprNodeUnknownFigure] = kEOpLvlParens, - [kExprNodeLambda] = kEOpLvlParens, - [kExprNodeDictLiteral] = kEOpLvlParens, - [kExprNodeListLiteral] = kEOpLvlParens, + [kExprNodeUnknownFigure] = { kEOpLvlParens, kEOpAssLeft }, + [kExprNodeLambda] = { kEOpLvlParens, kEOpAssNo }, + [kExprNodeDictLiteral] = { kEOpLvlParens, kEOpAssNo }, + [kExprNodeListLiteral] = { kEOpLvlParens, kEOpAssNo }, - [kExprNodeArrow] = kEOpLvlArrow, - - [kExprNodeComma] = kEOpLvlComma, - - [kExprNodeColon] = kEOpLvlColon, - - [kExprNodeTernary] = kEOpLvlTernary, - - [kExprNodeTernaryValue] = kEOpLvlTernaryValue, - - [kExprNodeComparison] = kEOpLvlComparison, - - [kExprNodeBinaryPlus] = kEOpLvlAddition, - [kExprNodeConcat] = kEOpLvlAddition, - - [kExprNodeUnaryPlus] = kEOpLvlUnary, - - [kExprNodeConcatOrSubscript] = kEOpLvlSubscript, - - [kExprNodeCurlyBracesIdentifier] = kEOpLvlComplexIdentifier, - - [kExprNodeComplexIdentifier] = kEOpLvlValue, - [kExprNodePlainIdentifier] = kEOpLvlValue, - [kExprNodePlainKey] = kEOpLvlValue, - [kExprNodeRegister] = kEOpLvlValue, - [kExprNodeInteger] = kEOpLvlValue, - [kExprNodeFloat] = kEOpLvlValue, -}; - -static const ExprOpAssociativity node_type_to_op_ass[] = { - [kExprNodeMissing] = kEOpAssNo, - [kExprNodeOpMissing] = kEOpAssNo, - - [kExprNodeNested] = kEOpAssNo, - [kExprNodeCall] = kEOpAssNo, - [kExprNodeSubscript] = kEOpAssNo, - - [kExprNodeUnknownFigure] = kEOpAssLeft, - [kExprNodeLambda] = kEOpAssNo, - [kExprNodeDictLiteral] = kEOpAssNo, - [kExprNodeListLiteral] = kEOpAssNo, - - // Does not really matter. - [kExprNodeArrow] = kEOpAssNo, - - [kExprNodeColon] = kEOpAssNo, + [kExprNodeArrow] = { kEOpLvlArrow, kEOpAssNo }, // Right associativity for comma because this means easier access to arguments // list, etc: for "[a, b, c, d]" you can access "a" in one step if it is @@ -1059,29 +1017,48 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { // traverse all three comma() structures. And with comma operator (including // actual comma operator from C which is not present in VimL) nobody cares // about associativity, only about order of execution. - [kExprNodeComma] = kEOpAssRight, + [kExprNodeComma] = { kEOpLvlComma, kEOpAssRight }, + + // Colons are not eligible for chaining, so nobody cares about associativity. + [kExprNodeColon] = { kEOpLvlColon, kEOpAssNo }, + + [kExprNodeTernary] = { kEOpLvlTernary, kEOpAssRight }, - [kExprNodeTernary] = kEOpAssRight, + [kExprNodeOr] = { kEOpLvlOr, kEOpAssLeft }, - [kExprNodeTernaryValue] = kEOpAssRight, + [kExprNodeAnd] = { kEOpLvlAnd, kEOpAssLeft }, - [kExprNodeComparison] = kEOpAssRight, + [kExprNodeTernaryValue] = { kEOpLvlTernaryValue, kEOpAssRight }, - [kExprNodeBinaryPlus] = kEOpAssLeft, - [kExprNodeConcat] = kEOpAssLeft, + [kExprNodeComparison] = { kEOpLvlComparison, kEOpAssRight }, - [kExprNodeUnaryPlus] = kEOpAssNo, + [kExprNodeBinaryPlus] = { kEOpLvlAddition, kEOpAssLeft }, + [kExprNodeBinaryMinus] = { kEOpLvlAddition, kEOpAssLeft }, + [kExprNodeConcat] = { kEOpLvlAddition, kEOpAssLeft }, - [kExprNodeConcatOrSubscript] = kEOpAssLeft, + [kExprNodeMultiplication] = { kEOpLvlMultiplication, kEOpAssLeft }, + [kExprNodeDivision] = { kEOpLvlMultiplication, kEOpAssLeft }, + [kExprNodeMod] = { kEOpLvlMultiplication, kEOpAssLeft }, - [kExprNodeCurlyBracesIdentifier] = kEOpAssLeft, + [kExprNodeUnaryPlus] = { kEOpLvlUnary, kEOpAssNo }, + [kExprNodeUnaryMinus] = { kEOpLvlUnary, kEOpAssNo }, + [kExprNodeNot] = { kEOpLvlUnary, kEOpAssNo }, - [kExprNodeComplexIdentifier] = kEOpAssLeft, - [kExprNodePlainIdentifier] = kEOpAssNo, - [kExprNodePlainKey] = kEOpAssNo, - [kExprNodeRegister] = kEOpAssNo, - [kExprNodeInteger] = kEOpAssNo, - [kExprNodeFloat] = kEOpAssNo, + [kExprNodeConcatOrSubscript] = { kEOpLvlSubscript, kEOpAssLeft }, + + [kExprNodeCurlyBracesIdentifier] = { kEOpLvlComplexIdentifier, kEOpAssLeft }, + + [kExprNodeComplexIdentifier] = { kEOpLvlValue, kEOpAssLeft }, + + [kExprNodePlainIdentifier] = { kEOpLvlValue, kEOpAssNo }, + [kExprNodePlainKey] = { kEOpLvlValue, kEOpAssNo }, + [kExprNodeRegister] = { kEOpLvlValue, kEOpAssNo }, + [kExprNodeInteger] = { kEOpLvlValue, kEOpAssNo }, + [kExprNodeFloat] = { kEOpLvlValue, kEOpAssNo }, + [kExprNodeDoubleQuotedString] = { kEOpLvlValue, kEOpAssNo }, + [kExprNodeSingleQuotedString] = { kEOpLvlValue, kEOpAssNo }, + [kExprNodeOption] = { kEOpLvlValue, kEOpAssNo }, + [kExprNodeEnvironment] = { kEOpLvlValue, kEOpAssNo }, }; /// Get AST node priority level @@ -1094,7 +1071,7 @@ static const ExprOpAssociativity node_type_to_op_ass[] = { static inline ExprOpLvl node_lvl(const ExprASTNode node) FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST FUNC_ATTR_WARN_UNUSED_RESULT { - return node_type_to_op_lvl[node.type]; + return node_type_to_node_props[node.type].lvl; } /// Get AST node associativity, to be used for operator nodes primary @@ -1107,7 +1084,7 @@ static inline ExprOpLvl node_lvl(const ExprASTNode node) static inline ExprOpAssociativity node_ass(const ExprASTNode node) FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST FUNC_ATTR_WARN_UNUSED_RESULT { - return node_type_to_op_ass[node.type]; + return node_type_to_node_props[node.type].ass; } /// Handle binary operator @@ -1837,7 +1814,7 @@ viml_pexpr_parse_process_token: is_concat_or_subscript && (cur_token.type == kExprLexPlainIdentifier ? (!cur_token.data.var.autoload - && cur_token.data.var.scope == 0) + && cur_token.data.var.scope == kExprVarScopeMissing) : (cur_token.type == kExprLexNumber)) && prev_token.type != kExprLexSpacing); if (is_concat_or_subscript && !node_is_key) { @@ -1856,7 +1833,7 @@ viml_pexpr_parse_process_token: && tok_type != kExprLexArrow) || (want_node == kENodeArgument && !(cur_token.type == kExprLexPlainIdentifier - && cur_token.data.var.scope == 0 + && cur_token.data.var.scope == kExprVarScopeMissing && !cur_token.data.var.autoload) && tok_type != kExprLexArrow)) { lambda_node->data.fig.type_guesses.allow_lambda = false; @@ -1885,6 +1862,8 @@ viml_pexpr_parse_process_token: || want_node == kENodeArgumentSeparator || want_node == kENodeArgument); switch (tok_type) { + case kExprLexMissing: + case kExprLexSpacing: case kExprLexEOC: { assert(false); } @@ -1894,31 +1873,111 @@ viml_pexpr_parse_process_token: goto viml_pexpr_parse_process_token; } case kExprLexRegister: { - if (want_node == kENodeValue) { - NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeRegister); - cur_node->data.reg.name = cur_token.data.reg.name; - *top_node_p = cur_node; - want_node = kENodeOperator; - HL_CUR_TOKEN(Register); - } else { + if (want_node == kENodeOperator) { // Register in operator position: e.g. @a @a OP_MISSING; } + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeRegister); + cur_node->data.reg.name = cur_token.data.reg.name; + *top_node_p = cur_node; + want_node = kENodeOperator; + HL_CUR_TOKEN(Register); break; } - case kExprLexPlus: { - if (want_node == kENodeValue) { - // Value level: assume unary plus - NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeUnaryPlus); - *top_node_p = cur_node; - kvi_push(ast_stack, &cur_node->children); - HL_CUR_TOKEN(UnaryPlus); - } else { - NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeBinaryPlus); - ADD_OP_NODE(cur_node); - HL_CUR_TOKEN(BinaryPlus); +#define SIMPLE_UB_OP(op) \ + case kExprLex##op: { \ + if (want_node == kENodeValue) { \ + /* Value level: assume unary operator. */ \ + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeUnary##op); \ + *top_node_p = cur_node; \ + kvi_push(ast_stack, &cur_node->children); \ + HL_CUR_TOKEN(Unary##op); \ + } else { \ + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeBinary##op); \ + ADD_OP_NODE(cur_node); \ + HL_CUR_TOKEN(Binary##op); \ + } \ + want_node = kENodeValue; \ + break; \ + } + SIMPLE_UB_OP(Plus) + SIMPLE_UB_OP(Minus) +#undef SIMPLE_UB_OP +#define SIMPLE_B_OP(op, msg) \ + case kExprLex##op: { \ + ADD_VALUE_IF_MISSING(_("E15: Unexpected " msg ": %.*s")); \ + NEW_NODE_WITH_CUR_POS(cur_node, kExprNode##op); \ + HL_CUR_TOKEN(op); \ + ADD_OP_NODE(cur_node); \ + break; \ + } + SIMPLE_B_OP(Or, "or operator") + SIMPLE_B_OP(And, "and operator") +#undef SIMPLE_B_OP + case kExprLexMultiplication: { + ADD_VALUE_IF_MISSING( + _("E15: Unexpected multiplication-like operator: %.*s")); + switch (cur_token.data.mul.type) { +#define MUL_OP(lex_op_tail, node_op_tail) \ + case kExprLexMul##lex_op_tail: { \ + NEW_NODE_WITH_CUR_POS(cur_node, kExprNode##node_op_tail); \ + HL_CUR_TOKEN(node_op_tail); \ + break; \ + } + MUL_OP(Mul, Multiplication) + MUL_OP(Div, Division) + MUL_OP(Mod, Mod) +#undef MUL_OP } - want_node = kENodeValue; + ADD_OP_NODE(cur_node); + break; + } + case kExprLexOption: { + if (want_node == kENodeOperator) { + OP_MISSING; + } + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeOption); + cur_node->data.opt.ident = cur_token.data.opt.name; + cur_node->data.opt.ident_len = cur_token.data.opt.len; + cur_node->data.opt.scope = cur_token.data.opt.scope; + *top_node_p = cur_node; + want_node = kENodeOperator; + viml_parser_highlight(pstate, cur_token.start, 1, HL(OptionSigil)); + const size_t scope_shift = ( + cur_token.data.opt.scope == kExprOptScopeUnspecified ? 0 : 2); + if (scope_shift) { + viml_parser_highlight(pstate, shifted_pos(cur_token.start, 1), 1, + HL(OptionScope)); + viml_parser_highlight(pstate, shifted_pos(cur_token.start, 2), 1, + HL(OptionScopeDelimiter)); + } + viml_parser_highlight( + pstate, shifted_pos(cur_token.start, scope_shift + 1), + cur_token.len - scope_shift + 1, HL(Option)); + break; + } + case kExprLexEnv: { + if (want_node == kENodeOperator) { + OP_MISSING; + } + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeEnvironment); + cur_node->data.env.ident = pline.data + cur_token.start.col + 1; + cur_node->data.env.ident_len = cur_token.len - 1; + *top_node_p = cur_node; + want_node = kENodeOperator; + viml_parser_highlight(pstate, cur_token.start, 1, HL(EnvironmentSigil)); + viml_parser_highlight(pstate, shifted_pos(cur_token.start, 1), + cur_token.len - 1, HL(Environment)); + break; + } + case kExprLexNot: { + if (want_node == kENodeOperator) { + OP_MISSING; + } + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeNot); + *top_node_p = cur_node; + kvi_push(ast_stack, &cur_node->children); + HL_CUR_TOKEN(Not); break; } case kExprLexComparison: { @@ -2359,9 +2418,8 @@ viml_pexpr_parse_figure_brace_closing_error: ? kExprNodePlainKey : kExprNodePlainIdentifier)); cur_node->data.var.scope = cur_token.data.var.scope; - const size_t scope_shift = (cur_token.data.var.scope == 0 - ? 0 - : 2); + const size_t scope_shift = ( + cur_token.data.var.scope == kExprVarScopeMissing ? 0 : 2); cur_node->data.var.ident = (pline.data + cur_token.start.col + scope_shift); cur_node->data.var.ident_len = cur_token.len - scope_shift; @@ -2373,16 +2431,14 @@ viml_pexpr_parse_figure_brace_closing_error: viml_parser_highlight(pstate, shifted_pos(cur_token.start, 1), 1, HL(IdentifierScopeDelimiter)); } - if (scope_shift < cur_token.len) { - viml_parser_highlight(pstate, shifted_pos(cur_token.start, - scope_shift), - cur_token.len - scope_shift, - (node_is_key - ? HL(IdentifierKey) - : HL(Identifier))); - } + viml_parser_highlight(pstate, shifted_pos(cur_token.start, + scope_shift), + cur_token.len - scope_shift, + (node_is_key + ? HL(IdentifierKey) + : HL(Identifier))); } else { - if (cur_token.data.var.scope == 0) { + if (cur_token.data.var.scope == kExprVarScopeMissing) { ADD_IDENT( do { NEW_NODE_WITH_CUR_POS(cur_node, kExprNodePlainIdentifier); @@ -2606,9 +2662,85 @@ viml_pexpr_parse_end: cur_node->start); break; } - case kExprNodeBinaryPlus: + case kExprNodeListLiteral: { + // For whatever reason "[1" yields "E696: Missing comma in list" error + // in Vim while "[1," yields E697. + east_set_error( + pstate, &ast.err, + _("E697: Missing end of List ']': %.*s"), + cur_node->start); + break; + } + case kExprNodeDictLiteral: { + // Same problem like with list literal with E722 (missing comma) vs + // E723, but additionally just "{" yields only E15. + east_set_error( + pstate, &ast.err, + _("E723: Missing end of Dictionary '}': %.*s"), + cur_node->start); + break; + } + case kExprNodeUnknownFigure: { + east_set_error( + pstate, &ast.err, + _("E15: Missing closing figure brace: %.*s"), + cur_node->start); + break; + } + case kExprNodeLambda: { + east_set_error( + pstate, &ast.err, + _("E15: Missing closing figure brace for lambda: %.*s"), + cur_node->start); + break; + } + case kExprNodeCurlyBracesIdentifier: { + // Until trailing "}" it is impossible to distinguish curly braces + // identifier and dictionary, so it must not appear in the stack like + // this. + assert(false); + } + case kExprNodeInteger: + case kExprNodeFloat: + case kExprNodeSingleQuotedString: + case kExprNodeDoubleQuotedString: + case kExprNodeOption: + case kExprNodeEnvironment: + case kExprNodeRegister: + case kExprNodePlainIdentifier: + case kExprNodePlainKey: { + // These are plain values and not containers, for them it should only + // be possible to show up in the topmost stack element, but it was + // unconditionally popped at the start. + assert(false); + } + case kExprNodeComma: + case kExprNodeColon: + case kExprNodeArrow: { + // It is actually only valid inside something else, but everything + // where one of the above is valid requires to be closed and thus is + // to be caught later. + break; + } + case kExprNodeConcatOrSubscript: + case kExprNodeComplexIdentifier: + case kExprNodeSubscript: { + // FIXME: Investigate whether above are OK to be present in the stack. + break; + } + case kExprNodeMod: + case kExprNodeDivision: + case kExprNodeMultiplication: + case kExprNodeNot: + case kExprNodeAnd: + case kExprNodeOr: + case kExprNodeConcat: + case kExprNodeComparison: + case kExprNodeUnaryMinus: case kExprNodeUnaryPlus: - case kExprNodeRegister: { + case kExprNodeBinaryMinus: + case kExprNodeTernary: + case kExprNodeBinaryPlus: { // It is OK to see these in the stack. break; } @@ -2621,7 +2753,6 @@ viml_pexpr_parse_end: } break; } - // TODO(ZyX-I): handle other values } } } diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index a09cdde4c0..0198852bed 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -61,6 +61,36 @@ typedef enum { kExprCmpIdentical, ///< `is` or `isnot` } ExprComparisonType; +/// All possible option scopes +typedef enum { + kExprOptScopeUnspecified = 0, + kExprOptScopeGlobal = 'g', + kExprOptScopeLocal = 'l', +} ExprOptScope; + +#define EXPR_OPT_SCOPE_LIST \ + ((char *)(char[]){ kExprOptScopeGlobal, kExprOptScopeLocal }) + +/// All possible variable scopes +typedef enum { + kExprVarScopeMissing = 0, + kExprVarScopeScript = 's', + kExprVarScopeGlobal = 'g', + kExprVarScopeVim = 'v', + kExprVarScopeBuffer = 'b', + kExprVarScopeWindow = 'w', + kExprVarScopeTabpage = 't', + kExprVarScopeLocal = 'l', + kExprVarScopeArguments = 'a', +} ExprVarScope; + +#define EXPR_VAR_SCOPE_LIST \ + ((char[]) { \ + kExprVarScopeScript, kExprVarScopeGlobal, kExprVarScopeVim, \ + kExprVarScopeBuffer, kExprVarScopeWindow, kExprVarScopeTabpage, \ + kExprVarScopeLocal, kExprVarScopeBuffer, kExprVarScopeArguments, \ + }) + /// Lexer token typedef struct { ParserPosition start; @@ -96,15 +126,11 @@ typedef struct { struct { const char *name; ///< Option name start. size_t len; ///< Option name length. - enum { - kExprLexOptUnspecified = 0, - kExprLexOptGlobal = 1, - kExprLexOptLocal = 2, - } scope; ///< Option scope: &l:, &g: or not specified. + ExprOptScope scope; ///< Option scope: &l:, &g: or not specified. } opt; ///< Option properties. struct { - int scope; ///< Scope character or 0 if not present. + ExprVarScope scope; ///< Scope character or 0 if not present. bool autoload; ///< Has autoload characters. } var; ///< For kExprLexPlainIdentifier @@ -150,53 +176,63 @@ typedef enum { /// Expression AST node type typedef enum { - kExprNodeMissing = 'X', - kExprNodeOpMissing = '_', - kExprNodeTernary = '?', ///< Ternary operator. - kExprNodeTernaryValue = 'C', ///< Ternary operator, colon. - kExprNodeRegister = '@', ///< Register. - kExprNodeSubscript = 's', ///< Subscript. - kExprNodeListLiteral = 'l', ///< List literal. - kExprNodeUnaryPlus = 'p', - kExprNodeBinaryPlus = '+', - kExprNodeNested = 'e', ///< Nested parenthesised expression. - kExprNodeCall = 'c', ///< Function call. + kExprNodeMissing = 0, + kExprNodeOpMissing, + kExprNodeTernary, ///< Ternary operator. + kExprNodeTernaryValue, ///< Ternary operator, colon. + kExprNodeRegister, ///< Register. + kExprNodeSubscript, ///< Subscript. + kExprNodeListLiteral, ///< List literal. + kExprNodeUnaryPlus, + kExprNodeBinaryPlus, + kExprNodeNested, ///< Nested parenthesised expression. + kExprNodeCall, ///< Function call. /// Plain identifier: simple variable/function name /// /// Looks like "string", "g:Foo", etc: consists from a single /// kExprLexPlainIdentifier token. - kExprNodePlainIdentifier = 'i', + kExprNodePlainIdentifier, /// Plain dictionary key, for use with kExprNodeConcatOrSubscript - kExprNodePlainKey = 'k', + kExprNodePlainKey, /// Complex identifier: variable/function name with curly braces - kExprNodeComplexIdentifier = 'I', + kExprNodeComplexIdentifier, /// Figure brace expression which is not yet known /// /// May resolve to any of kExprNodeDictLiteral, kExprNodeLambda or /// kExprNodeCurlyBracesIdentifier. - kExprNodeUnknownFigure = '{', - kExprNodeLambda = '\\', ///< Lambda. - kExprNodeDictLiteral = 'd', ///< Dictionary literal. - kExprNodeCurlyBracesIdentifier= '}', ///< Part of the curly braces name. - kExprNodeComma = ',', ///< Comma “operatorâ€. - kExprNodeColon = ':', ///< Colon “operatorâ€. - kExprNodeArrow = '>', ///< Arrow “operatorâ€. - kExprNodeComparison = '=', ///< Various comparison operators. + kExprNodeUnknownFigure, + kExprNodeLambda, ///< Lambda. + kExprNodeDictLiteral, ///< Dictionary literal. + kExprNodeCurlyBracesIdentifier, ///< Part of the curly braces name. + kExprNodeComma, ///< Comma “operatorâ€. + kExprNodeColon, ///< Colon “operatorâ€. + kExprNodeArrow, ///< Arrow “operatorâ€. + kExprNodeComparison, ///< Various comparison operators. /// Concat operator /// /// To be only used in cases when it is known for sure it is not a subscript. - kExprNodeConcat = '.', + kExprNodeConcat, /// Concat or subscript operator /// /// For cases when it is not obvious whether expression is a concat or /// a subscript. May only have either number or plain identifier as the second /// child. To make it easier to avoid curly braces in place of /// kExprNodePlainIdentifier node kExprNodePlainKey is used. - kExprNodeConcatOrSubscript = 'S', - kExprNodeInteger = '0', ///< Integral number. - kExprNodeFloat = '1', ///< Floating-point number. - kExprNodeSingleQuotedString = '\'', - kExprNodeDoubleQuotedString = '"', + kExprNodeConcatOrSubscript, + kExprNodeInteger, ///< Integral number. + kExprNodeFloat, ///< Floating-point number. + kExprNodeSingleQuotedString, + kExprNodeDoubleQuotedString, + kExprNodeOr, + kExprNodeAnd, + kExprNodeUnaryMinus, + kExprNodeBinaryMinus, + kExprNodeNot, + kExprNodeMultiplication, + kExprNodeDivision, + kExprNodeMod, + kExprNodeOption, + kExprNodeEnvironment, } ExprASTNodeType; typedef struct expr_ast_node ExprASTNode; @@ -230,7 +266,7 @@ struct expr_ast_node { size_t opening_hl_idx; } fig; ///< For kExprNodeUnknownFigure. struct { - int scope; ///< Scope character or 0 if not present. + ExprVarScope scope; ///< Scope character or 0 if not present. /// Actual identifier without scope. /// /// Points to inside parser reader state. @@ -256,6 +292,15 @@ struct expr_ast_node { size_t size; } str; ///< For kExprNodeSingleQuotedString and ///< kExprNodeDoubleQuotedString. + struct { + const char *ident; ///< Option name start. + size_t ident_len; ///< Option name length. + ExprOptScope scope; ///< Option scope: &l:, &g: or not specified. + } opt; ///< For kExprNodeOption. + struct { + const char *ident; ///< Environment variable name start. + size_t ident_len; ///< Environment variable name length. + } env; ///< For kExprNodeEnvironment. } data; }; diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h index a17edac403..10ced57977 100644 --- a/src/nvim/viml/parser/parser.h +++ b/src/nvim/viml/parser/parser.h @@ -173,7 +173,7 @@ static inline void viml_parser_highlight(ParserState *const pstate, const size_t len, const char *const group) { - if (pstate->colors == NULL) { + if (pstate->colors == NULL || len == 0) { return; } // TODO(ZyX-I): May do some assert() sanitizing here. -- cgit From c286155bfa53c828ebe5479fd81a544740a92403 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 15 Oct 2017 19:06:41 +0300 Subject: viml/parser/expressions: Create tests for latest additions --- src/nvim/viml/parser/expressions.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 75fcb17bf6..8928179349 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -1937,9 +1937,22 @@ viml_pexpr_parse_process_token: OP_MISSING; } NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeOption); - cur_node->data.opt.ident = cur_token.data.opt.name; - cur_node->data.opt.ident_len = cur_token.data.opt.len; - cur_node->data.opt.scope = cur_token.data.opt.scope; + if (cur_token.type == kExprLexInvalid) { + assert(cur_token.len == 1 + || (cur_token.len == 3 + && pline.data[cur_token.start.col + 2] == ':')); + cur_node->data.opt.ident = ( + pline.data + cur_token.start.col + cur_token.len); + cur_node->data.opt.ident_len = 0; + cur_node->data.opt.scope = ( + cur_token.len == 3 + ? (ExprOptScope)pline.data[cur_token.start.col + 1] + : kExprOptScopeUnspecified); + } else { + cur_node->data.opt.ident = cur_token.data.opt.name; + cur_node->data.opt.ident_len = cur_token.data.opt.len; + cur_node->data.opt.scope = cur_token.data.opt.scope; + } *top_node_p = cur_node; want_node = kENodeOperator; viml_parser_highlight(pstate, cur_token.start, 1, HL(OptionSigil)); @@ -1953,7 +1966,7 @@ viml_pexpr_parse_process_token: } viml_parser_highlight( pstate, shifted_pos(cur_token.start, scope_shift + 1), - cur_token.len - scope_shift + 1, HL(Option)); + cur_token.len - (scope_shift + 1), HL(Option)); break; } case kExprLexEnv: { @@ -1963,6 +1976,10 @@ viml_pexpr_parse_process_token: NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeEnvironment); cur_node->data.env.ident = pline.data + cur_token.start.col + 1; cur_node->data.env.ident_len = cur_token.len - 1; + if (cur_node->data.env.ident_len == 0) { + ERROR_FROM_TOKEN_AND_MSG(cur_token, + _("E15: Environment variable name missing")); + } *top_node_p = cur_node; want_node = kENodeOperator; viml_parser_highlight(pstate, cur_token.start, 1, HL(EnvironmentSigil)); -- cgit From 6c19cbef2611c389da6f3e06d8c8eb635d065774 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 15 Oct 2017 20:05:35 +0300 Subject: viml/parser/expressions,tests: Add AST freeing, with sanity checks --- src/nvim/viml/parser/expressions.c | 239 +++++++++++++++++++++++++++++++------ 1 file changed, 205 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 8928179349..2f7ec6bcca 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -642,37 +642,6 @@ static const char *const eltkn_opt_scope_tab[] = { [kExprOptScopeLocal] = "Local", }; -/// Represent `int` character as a string -/// -/// Converts -/// - ASCII digits into '{digit}' -/// - ASCII printable characters into a single-character strings -/// - everything else to numbers. -/// -/// @param[in] ch Character to convert. -/// -/// @return Converted string, stored in a static buffer (overriden after each -/// call). -static const char *intchar2str(const int ch) - FUNC_ATTR_WARN_UNUSED_RESULT -{ - static char buf[sizeof(int) * 3 + 1]; - if (' ' <= ch && ch < 0x7f) { - if (ascii_isdigit(ch)) { - buf[0] = '\''; - buf[1] = (char)ch; - buf[2] = '\''; - buf[3] = NUL; - } else { - buf[0] = (char)ch; - buf[1] = NUL; - } - } else { - snprintf(buf, sizeof(buf), "%i", ch); - } - return buf; -} - /// Represent token as a string /// /// Intended for testing and debugging purposes. @@ -756,6 +725,78 @@ viml_pexpr_repr_token_end: return ret; } +static const char *const east_node_type_tab[] = { + [kExprNodeMissing] = "Missing", + [kExprNodeOpMissing] = "OpMissing", + [kExprNodeTernary] = "Ternary", + [kExprNodeTernaryValue] = "TernaryValue", + [kExprNodeRegister] = "Register", + [kExprNodeSubscript] = "Subscript", + [kExprNodeListLiteral] = "ListLiteral", + [kExprNodeUnaryPlus] = "UnaryPlus", + [kExprNodeBinaryPlus] = "BinaryPlus", + [kExprNodeNested] = "Nested", + [kExprNodeCall] = "Call", + [kExprNodePlainIdentifier] = "PlainIdentifier", + [kExprNodePlainKey] = "PlainKey", + [kExprNodeComplexIdentifier] = "ComplexIdentifier", + [kExprNodeUnknownFigure] = "UnknownFigure", + [kExprNodeLambda] = "Lambda", + [kExprNodeDictLiteral] = "DictLiteral", + [kExprNodeCurlyBracesIdentifier] = "CurlyBracesIdentifier", + [kExprNodeComma] = "Comma", + [kExprNodeColon] = "Colon", + [kExprNodeArrow] = "Arrow", + [kExprNodeComparison] = "Comparison", + [kExprNodeConcat] = "Concat", + [kExprNodeConcatOrSubscript] = "ConcatOrSubscript", + [kExprNodeInteger] = "Integer", + [kExprNodeFloat] = "Float", + [kExprNodeSingleQuotedString] = "SingleQuotedString", + [kExprNodeDoubleQuotedString] = "DoubleQuotedString", + [kExprNodeOr] = "Or", + [kExprNodeAnd] = "And", + [kExprNodeUnaryMinus] = "UnaryMinus", + [kExprNodeBinaryMinus] = "BinaryMinus", + [kExprNodeNot] = "Not", + [kExprNodeMultiplication] = "Multiplication", + [kExprNodeDivision] = "Division", + [kExprNodeMod] = "Mod", + [kExprNodeOption] = "Option", + [kExprNodeEnvironment] = "Environment", +}; + +/// Represent `int` character as a string +/// +/// Converts +/// - ASCII digits into '{digit}' +/// - ASCII printable characters into a single-character strings +/// - everything else to numbers. +/// +/// @param[in] ch Character to convert. +/// +/// @return Converted string, stored in a static buffer (overriden after each +/// call). +static const char *intchar2str(const int ch) + FUNC_ATTR_WARN_UNUSED_RESULT +{ + static char buf[sizeof(int) * 3 + 1]; + if (' ' <= ch && ch < 0x7f) { + if (ascii_isdigit(ch)) { + buf[0] = '\''; + buf[1] = (char)ch; + buf[2] = '\''; + buf[3] = NUL; + } else { + buf[0] = (char)ch; + buf[1] = NUL; + } + } else { + snprintf(buf, sizeof(buf), "%i", ch); + } + return buf; +} + #ifdef UNIT_TESTING #include @@ -767,9 +808,9 @@ static inline void viml_pexpr_debug_print_ast_node( if (*eastnode_p == NULL) { fprintf(stderr, "%s %p : NULL\n", prefix, (void *)eastnode_p); } else { - fprintf(stderr, "%s %p : %p : %c : %zu:%zu:%zu\n", + fprintf(stderr, "%s %p : %p : %s : %zu:%zu:%zu\n", prefix, (void *)eastnode_p, (void *)(*eastnode_p), - (*eastnode_p)->type, (*eastnode_p)->start.line, + east_node_type_tab[(*eastnode_p)->type], (*eastnode_p)->start.line, (*eastnode_p)->start.col, (*eastnode_p)->len); } } @@ -800,11 +841,141 @@ static inline void viml_pexpr_debug_print_token( #define PSTACK_P(msg) \ viml_pexpr_debug_print_ast_stack(ast_stack, #msg) #define PNODE_P(eastnode_p, msg) \ - viml_pexpr_debug_print_ast_node((const ExprASTNode *const *)ast_stack, #msg) + viml_pexpr_debug_print_ast_node((const ExprASTNode *const *)eastnode_p, \ + (#msg)) #define PTOKEN(tkn) \ viml_pexpr_debug_print_token(pstate, tkn) #endif +#ifndef NDEBUG +static const uint8_t node_maxchildren[] = { + [kExprNodeMissing] = 0, + [kExprNodeOpMissing] = 2, + [kExprNodeTernary] = 2, + [kExprNodeTernaryValue] = 2, + [kExprNodeRegister] = 0, + [kExprNodeSubscript] = 2, + [kExprNodeListLiteral] = 1, + [kExprNodeUnaryPlus] = 1, + [kExprNodeBinaryPlus] = 2, + [kExprNodeNested] = 1, + [kExprNodeCall] = 2, + [kExprNodePlainIdentifier] = 0, + [kExprNodePlainKey] = 0, + [kExprNodeComplexIdentifier] = 2, + [kExprNodeUnknownFigure] = 1, + [kExprNodeLambda] = 2, + [kExprNodeDictLiteral] = 1, + [kExprNodeCurlyBracesIdentifier] = 1, + [kExprNodeComma] = 2, + [kExprNodeColon] = 2, + [kExprNodeArrow] = 2, + [kExprNodeComparison] = 2, + [kExprNodeConcat] = 2, + [kExprNodeConcatOrSubscript] = 2, + [kExprNodeInteger] = 0, + [kExprNodeFloat] = 0, + [kExprNodeSingleQuotedString] = 0, + [kExprNodeDoubleQuotedString] = 0, + [kExprNodeOr] = 2, + [kExprNodeAnd] = 2, + [kExprNodeUnaryMinus] = 1, + [kExprNodeBinaryMinus] = 2, + [kExprNodeNot] = 1, + [kExprNodeMultiplication] = 2, + [kExprNodeDivision] = 2, + [kExprNodeMod] = 2, + [kExprNodeOption] = 0, + [kExprNodeEnvironment] = 0, +}; +#endif + +/// Free memory occupied by AST +/// +/// @param ast AST stack to free. +void viml_pexpr_free_ast(ExprAST ast) +{ + ExprASTStack ast_stack; + kvi_init(ast_stack); + kvi_push(ast_stack, &ast.root); + while (kv_size(ast_stack)) { + ExprASTNode **const cur_node = kv_last(ast_stack); +#ifndef NDEBUG + // Explicitly check for AST recursiveness. + for (size_t i = 0 ; i < kv_size(ast_stack) - 1 ; i++) { + assert(*kv_A(ast_stack, i) != *cur_node); + } +#endif + if (*cur_node == NULL) { + assert(kv_size(ast_stack) == 1); + kv_drop(ast_stack, 1); + } else if ((*cur_node)->children != NULL) { +#ifndef NDEBUG + const uint8_t maxchildren = node_maxchildren[(*cur_node)->type]; + assert(maxchildren > 0); + assert(maxchildren <= 2); + assert(maxchildren == 1 + ? (*cur_node)->children->next == NULL + : ((*cur_node)->children->next == NULL + || (*cur_node)->children->next->next == NULL)); +#endif + kvi_push(ast_stack, &(*cur_node)->children); + } else if ((*cur_node)->next != NULL) { + kvi_push(ast_stack, &(*cur_node)->next); + } else if (*cur_node != NULL) { + kv_drop(ast_stack, 1); + switch ((*cur_node)->type) { + case kExprNodeDoubleQuotedString: + case kExprNodeSingleQuotedString: { + xfree((*cur_node)->data.str.value); + break; + } + case kExprNodeMissing: + case kExprNodeOpMissing: + case kExprNodeTernary: + case kExprNodeTernaryValue: + case kExprNodeRegister: + case kExprNodeSubscript: + case kExprNodeListLiteral: + case kExprNodeUnaryPlus: + case kExprNodeBinaryPlus: + case kExprNodeNested: + case kExprNodeCall: + case kExprNodePlainIdentifier: + case kExprNodePlainKey: + case kExprNodeComplexIdentifier: + case kExprNodeUnknownFigure: + case kExprNodeLambda: + case kExprNodeDictLiteral: + case kExprNodeCurlyBracesIdentifier: + case kExprNodeComma: + case kExprNodeColon: + case kExprNodeArrow: + case kExprNodeComparison: + case kExprNodeConcat: + case kExprNodeConcatOrSubscript: + case kExprNodeInteger: + case kExprNodeFloat: + case kExprNodeOr: + case kExprNodeAnd: + case kExprNodeUnaryMinus: + case kExprNodeBinaryMinus: + case kExprNodeNot: + case kExprNodeMultiplication: + case kExprNodeDivision: + case kExprNodeMod: + case kExprNodeOption: + case kExprNodeEnvironment: { + break; + } + } + xfree(*cur_node); + *cur_node = NULL; + } + } + kvi_destroy(ast_stack); +} + // start = s ternary_expr s EOC // ternary_expr = binop_expr // ( s Question s ternary_expr s Colon s ternary_expr s )? -- cgit From 57bb3346d95f325d4894d41c88d3a1434de2d2df Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 15 Oct 2017 20:43:16 +0300 Subject: viml/parser/expressions: Update some comments and add another check --- src/nvim/viml/parser/expressions.c | 104 ++++++++++++++----------------------- 1 file changed, 38 insertions(+), 66 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 2f7ec6bcca..370034943e 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -976,59 +976,6 @@ void viml_pexpr_free_ast(ExprAST ast) kvi_destroy(ast_stack); } -// start = s ternary_expr s EOC -// ternary_expr = binop_expr -// ( s Question s ternary_expr s Colon s ternary_expr s )? -// binop_expr = unaryop_expr ( binop unaryop_expr )? -// unaryop_expr = ( unaryop )? subscript_expr -// subscript_expr = subscript_expr subscript -// | value_expr -// subscript = Bracket('[') s ternary_expr s Bracket(']') -// | s Parenthesis('(') call_args Parenthesis(')') -// | Dot ( PlainIdentifier | Number )+ -// # Note: `s` before Parenthesis('(') is only valid if preceding subscript_expr -// # is PlainIdentifier -// value_expr = ( float | Number -// | DoubleQuotedString | SingleQuotedString -// | paren_expr -// | list_literal -// | lambda_literal -// | dict_literal -// | Environment -// | Option -// | Register -// | var ) -// float = Number Dot Number ( PlainIdentifier('e') ( Plus | Minus )? Number )? -// # Note: `1.2.3` is concat and not float. `"abc".2.3` is also concat without -// # floats. -// paren_expr = Parenthesis('(') s ternary_expr s Parenthesis(')') -// list_literal = Bracket('[') s -// ( ternary_expr s Comma s )* -// ternary_expr? s -// Bracket(']') -// dict_literal = FigureBrace('{') s -// ( ternary_expr s Colon s ternary_expr s Comma s )* -// ( ternary_expr s Colon s ternary_expr s )? -// FigureBrace('}') -// lambda_literal = FigureBrace('{') s -// ( PlainIdentifier s Comma s )* -// PlainIdentifier s -// Arrow s -// ternary_expr s -// FigureBrace('}') -// var = varchunk+ -// varchunk = PlainIdentifier -// | Comparison("is" | "is#" | "isnot" | "isnot#") -// | FigureBrace('{') s ternary_expr s FigureBrace('}') -// call_args = ( s ternary_expr s Comma s )* s ternary_expr? s -// binop = s ( Plus | Minus | Dot -// | Comparison -// | Multiplication -// | Or -// | And ) s -// unaryop = s ( Not | Plus | Minus ) s -// s = Spacing? -// // Binary operator precedence and associativity: // // Operator | Precedence | Associativity @@ -1885,6 +1832,14 @@ static void parse_quoted_string(ParserState *const pstate, kvi_destroy(shifts); } +/// Additional flags to pass to lexer depending on want_node +static const int want_node_to_lexer_flags[] = { + [kENodeValue] = kELFlagIsNotCmp, + [kENodeOperator] = kELFlagForbidScope, + [kENodeArgument] = kELFlagIsNotCmp, + [kENodeArgumentSeparator] = kELFlagForbidScope, +}; + /// Parse one VimL expression /// /// @param pstate Parser state. @@ -1902,26 +1857,25 @@ ExprAST viml_pexpr_parse(ParserState *const pstate, const int flags) }, .root = NULL, }; + // Expression stack contains current branch in AST tree: that is + // - Stack item 0 contains root of the tree, i.e. &ast->root. + // - Stack item i points to the previous stack items’ last child. + // + // When parser expects “value†node that is something like identifier or "[" + // (list start) last stack item contains NULL. Otherwise last stack item is + // supposed to contain last “finished†value: e.g. "1" or "+(1, 1)" (node + // representing "1+1"). + // + // Both kENodeValue and kENodeArgument stand for “value†nodes. ExprASTStack ast_stack; kvi_init(ast_stack); kvi_push(ast_stack, &ast.root); - // Expressions stack: - // 1. *last is NULL if want_node is kExprLexValue. Indicates where expression - // is to be put. - // 2. *last is not NULL otherwise, indicates current expression to be used as - // an operator argument. ExprASTWantedNode want_node = kENodeValue; LexExprToken prev_token = { .type = kExprLexMissing }; bool highlighted_prev_spacing = false; // Lambda node, valid when parsing lambda arguments only. ExprASTNode *lambda_node = NULL; do { - const int want_node_to_lexer_flags[] = { - [kENodeValue] = kELFlagIsNotCmp, - [kENodeOperator] = kELFlagForbidScope, - [kENodeArgument] = kELFlagIsNotCmp, - [kENodeArgumentSeparator] = kELFlagForbidScope, - }; const bool is_concat_or_subscript = ( want_node == kENodeValue && kv_size(ast_stack) > 1 @@ -1965,9 +1919,27 @@ viml_pexpr_parse_process_token: } const ParserLine pline = pstate->reader.lines.items[cur_token.start.line]; ExprASTNode **const top_node_p = kv_last(ast_stack); + assert(kv_size(ast_stack) >= 1); ExprASTNode *cur_node = NULL; - assert((want_node == kENodeValue || want_node == kENodeArgument) - == (*top_node_p == NULL)); +#ifndef NDEBUG + const bool want_value = ( + want_node == kENodeValue || want_node == kENodeArgument); + assert(want_value == (*top_node_p == NULL)); + assert(kv_A(ast_stack, 0) == &ast.root); + // Check that stack item i + 1 points to stack items’ i *last* child. + for (size_t i = 0; i + 1 < kv_size(ast_stack); i++) { + const bool item_null = (want_value && i + 2 == kv_size(ast_stack)); + assert((&(*kv_A(ast_stack, i))->children == kv_A(ast_stack, i + 1) + && (item_null + ? (*kv_A(ast_stack, i))->children == NULL + : (*kv_A(ast_stack, i))->children->next == NULL)) + || ((&(*kv_A(ast_stack, i))->children->next + == kv_A(ast_stack, i + 1)) + && (item_null + ? (*kv_A(ast_stack, i))->children->next == NULL + : (*kv_A(ast_stack, i))->children->next->next == NULL))); + } +#endif // Note: in Vim whether expression "cond?d.a:2" is valid depends both on // "cond" and whether "d" is a dictionary: expression is valid if condition // is true and "d" is a dictionary (with "a" key or it will complain about -- cgit From bc386c48829c431fe5b17592c82eb4099621953a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 15 Oct 2017 21:09:08 +0300 Subject: charset: Fix out-of-bounds array access It is incorrect to *first* access ptr[2] and *then* check whether maxlen allows it. --- src/nvim/charset.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 403ef65c4f..1147b78c9a 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1621,6 +1621,7 @@ bool vim_isblankline(char_u *lbuf) void vim_str2nr(const char_u *const start, int *const prep, int *const len, const int what, varnumber_T *const nptr, uvarnumber_T *const unptr, const int maxlen) + FUNC_ATTR_NONNULL_ARG(1) { const char_u *ptr = start; int pre = 0; // default is decimal @@ -1633,20 +1634,21 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, } // Recognize hex, octal and bin. - if ((ptr[0] == '0') && (ptr[1] != '8') && (ptr[1] != '9') - && (maxlen == 0 || maxlen > 1)) { + if ((what & (STR2NR_HEX|STR2NR_OCT|STR2NR_BIN)) + && (maxlen == 0 || maxlen > 1) + && (ptr[0] == '0') && (ptr[1] != '8') && (ptr[1] != '9')) { pre = ptr[1]; if ((what & STR2NR_HEX) + && (maxlen == 0 || maxlen > 2) && ((pre == 'X') || (pre == 'x')) - && ascii_isxdigit(ptr[2]) - && (maxlen == 0 || maxlen > 2)) { + && ascii_isxdigit(ptr[2])) { // hexadecimal ptr += 2; } else if ((what & STR2NR_BIN) + && (maxlen == 0 || maxlen > 2) && ((pre == 'B') || (pre == 'b')) - && ascii_isbdigit(ptr[2]) - && (maxlen == 0 || maxlen > 2)) { + && ascii_isbdigit(ptr[2])) { // binary ptr += 2; } else { @@ -1675,7 +1677,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, // Do the string-to-numeric conversion "manually" to avoid sscanf quirks. int n = 1; - if ((pre == 'B') || (pre == 'b') || what == STR2NR_BIN + STR2NR_FORCE) { + if (pre == 'B' || pre == 'b' || what == (STR2NR_BIN|STR2NR_FORCE)) { // bin if (pre != 0) { n += 2; // skip over "0b" @@ -1692,7 +1694,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, break; } } - } else if ((pre == '0') || what == STR2NR_OCT + STR2NR_FORCE) { + } else if (pre == '0' || what == (STR2NR_OCT|STR2NR_FORCE)) { // octal while ('0' <= *ptr && *ptr <= '7') { // avoid ubsan error for overflow @@ -1706,8 +1708,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, break; } } - } else if ((pre == 'X') || (pre == 'x') - || what == STR2NR_HEX + STR2NR_FORCE) { + } else if (pre == 'X' || pre == 'x' || what == (STR2NR_HEX|STR2NR_FORCE)) { // hex if (pre != 0) { n += 2; // skip over "0x" -- cgit From 3aa2c0d63ae488e302a89fdcdd650404cb2670fd Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 15 Oct 2017 21:11:00 +0300 Subject: viml/parser/expressions,klee: Fix some problems found by KLEE run --- src/nvim/viml/parser/expressions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 0198852bed..025f0f766e 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -69,7 +69,7 @@ typedef enum { } ExprOptScope; #define EXPR_OPT_SCOPE_LIST \ - ((char *)(char[]){ kExprOptScopeGlobal, kExprOptScopeLocal }) + ((char[]){ kExprOptScopeGlobal, kExprOptScopeLocal }) /// All possible variable scopes typedef enum { -- cgit From 4ccaf861107f8c737ba5b749a69c75d7f097d1f1 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 15 Oct 2017 21:22:49 +0300 Subject: keymap: Readd figure braces disappeared when resolving conflicts --- src/nvim/keymap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index a44b663cc6..55ac835663 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -719,8 +719,8 @@ int get_special_key_code(const char_u *name) for (int i = 0; key_names_table[i].name != NULL; i++) { const char *const table_name = key_names_table[i].name; int j; - for (j = 0; vim_isIDc(name[j]) && table_name[j] != NUL; j++) - if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC(name[j])) + for (j = 0; vim_isIDc(name[j]) && table_name[j] != NUL; j++) { + if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC(name[j])) { break; } } -- cgit From 2cb95bd9378d3c45f2eea527683546825e16f7d3 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 15 Oct 2017 21:39:01 +0300 Subject: viml/parser/expressions: Define east_node_type_tab only when needed --- src/nvim/viml/parser/expressions.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 370034943e..4801d66988 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -725,6 +725,7 @@ viml_pexpr_repr_token_end: return ret; } +#ifdef UNIT_TESTING static const char *const east_node_type_tab[] = { [kExprNodeMissing] = "Missing", [kExprNodeOpMissing] = "OpMissing", @@ -765,6 +766,7 @@ static const char *const east_node_type_tab[] = { [kExprNodeOption] = "Option", [kExprNodeEnvironment] = "Environment", }; +#endif /// Represent `int` character as a string /// -- cgit From 1a3635304b80b48625bcd9d48f4f38778b42e4af Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 16 Oct 2017 00:07:32 +0300 Subject: charset: Avoid overflow in vim_str2nr --- src/nvim/charset.c | 60 +++++++++++++++++++----------------------------------- 1 file changed, 21 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/nvim/charset.c b/src/nvim/charset.c index f824717fcd..7b307b8160 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1620,13 +1620,16 @@ bool vim_isblankline(char_u *lbuf) /// @param maxlen Max length of string to check. void vim_str2nr(const char_u *const start, int *const prep, int *const len, const int what, varnumber_T *const nptr, - uvarnumber_T *const unptr, const int maxlen) + uvarnumber_T *const unptr, int maxlen) FUNC_ATTR_NONNULL_ARG(1) { - const char_u *ptr = start; + const char *ptr = (const char *)start; + if (maxlen == 0) { + maxlen = (int)strlen(ptr); + } + const char *const e = ptr + maxlen; int pre = 0; // default is decimal bool negative = false; - uvarnumber_T un = 0; if (ptr[0] == '-') { negative = true; @@ -1635,19 +1638,19 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, // Recognize hex, octal and bin. if ((what & (STR2NR_HEX|STR2NR_OCT|STR2NR_BIN)) - && (maxlen == 0 || maxlen > 1) - && (ptr[0] == '0') && (ptr[1] != '8') && (ptr[1] != '9')) { + && maxlen > 1 + && ptr[0] == '0' && ptr[1] != '8' && ptr[1] != '9') { pre = ptr[1]; if ((what & STR2NR_HEX) - && (maxlen == 0 || maxlen > 2) - && ((pre == 'X') || (pre == 'x')) + && maxlen > 2 + && (pre == 'X' || pre == 'x') && ascii_isxdigit(ptr[2])) { // hexadecimal ptr += 2; } else if ((what & STR2NR_BIN) - && (maxlen == 0 || maxlen > 2) - && ((pre == 'B') || (pre == 'b')) + && maxlen > 2 + && (pre == 'B' || pre == 'b') && ascii_isbdigit(ptr[2])) { // binary ptr += 2; @@ -1657,32 +1660,26 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, if (what & STR2NR_OCT) { // Don't interpret "0", "08" or "0129" as octal. - for (int n = 1; ascii_isdigit(ptr[n]); ++n) { - if (ptr[n] > '7') { + for (int i = 1; i < maxlen && ascii_isdigit(ptr[i]); i++) { + if (ptr[i] > '7') { // can't be octal pre = 0; break; } - if (ptr[n] >= '0') { + if (ptr[i] >= '0') { // assume octal pre = '0'; } - if (n == maxlen) { - break; - } } } } } // Do the string-to-numeric conversion "manually" to avoid sscanf quirks. - int n = 1; + uvarnumber_T un = 0; if (pre == 'B' || pre == 'b' || what == (STR2NR_BIN|STR2NR_FORCE)) { // bin - if (pre != 0) { - n += 2; // skip over "0b" - } - while ('0' <= *ptr && *ptr <= '1') { + while (ptr < e && '0' <= *ptr && *ptr <= '1') { // avoid ubsan error for overflow if (un < UVARNUMBER_MAX / 2) { un = 2 * un + (uvarnumber_T)(*ptr - '0'); @@ -1690,13 +1687,10 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, un = UVARNUMBER_MAX; } ptr++; - if (n++ == maxlen) { - break; - } } } else if (pre == '0' || what == (STR2NR_OCT|STR2NR_FORCE)) { // octal - while ('0' <= *ptr && *ptr <= '7') { + while (ptr < e && '0' <= *ptr && *ptr <= '7') { // avoid ubsan error for overflow if (un < UVARNUMBER_MAX / 8) { un = 8 * un + (uvarnumber_T)(*ptr - '0'); @@ -1704,16 +1698,10 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, un = UVARNUMBER_MAX; } ptr++; - if (n++ == maxlen) { - break; - } } } else if (pre == 'X' || pre == 'x' || what == (STR2NR_HEX|STR2NR_FORCE)) { // hex - if (pre != 0) { - n += 2; // skip over "0x" - } - while (ascii_isxdigit(*ptr)) { + while (ptr < e && ascii_isxdigit(*ptr)) { // avoid ubsan error for overflow if (un < UVARNUMBER_MAX / 16) { un = 16 * un + (uvarnumber_T)hex2nr(*ptr); @@ -1721,13 +1709,10 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, un = UVARNUMBER_MAX; } ptr++; - if (n++ == maxlen) { - break; - } } } else { // decimal - while (ascii_isdigit(*ptr)) { + while (ptr < e && ascii_isdigit(*ptr)) { // avoid ubsan error for overflow if (un < UVARNUMBER_MAX / 10) { un = 10 * un + (uvarnumber_T)(*ptr - '0'); @@ -1735,9 +1720,6 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, un = UVARNUMBER_MAX; } ptr++; - if (n++ == maxlen) { - break; - } } } @@ -1746,7 +1728,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, } if (len != NULL) { - *len = (int)(ptr - start); + *len = (int)(ptr - (const char *)start); } if (nptr != NULL) { -- cgit From 5e92ee6565233c56e7a33b12ef6a61f05eae91aa Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 16 Oct 2017 00:19:02 +0300 Subject: charset: Do not call strlen() from vim_str2nr --- src/nvim/charset.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 7b307b8160..a7ffa4bc00 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1620,14 +1620,12 @@ bool vim_isblankline(char_u *lbuf) /// @param maxlen Max length of string to check. void vim_str2nr(const char_u *const start, int *const prep, int *const len, const int what, varnumber_T *const nptr, - uvarnumber_T *const unptr, int maxlen) + uvarnumber_T *const unptr, const int maxlen) FUNC_ATTR_NONNULL_ARG(1) { const char *ptr = (const char *)start; - if (maxlen == 0) { - maxlen = (int)strlen(ptr); - } - const char *const e = ptr + maxlen; +#define STRING_ENDED(ptr) \ + (!(maxlen == 0 || (int)((ptr) - (const char *)start) < maxlen)) int pre = 0; // default is decimal bool negative = false; @@ -1638,18 +1636,18 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, // Recognize hex, octal and bin. if ((what & (STR2NR_HEX|STR2NR_OCT|STR2NR_BIN)) - && maxlen > 1 + && !STRING_ENDED(ptr + 1) && ptr[0] == '0' && ptr[1] != '8' && ptr[1] != '9') { pre = ptr[1]; if ((what & STR2NR_HEX) - && maxlen > 2 + && !STRING_ENDED(ptr + 2) && (pre == 'X' || pre == 'x') && ascii_isxdigit(ptr[2])) { // hexadecimal ptr += 2; } else if ((what & STR2NR_BIN) - && maxlen > 2 + && !STRING_ENDED(ptr + 2) && (pre == 'B' || pre == 'b') && ascii_isbdigit(ptr[2])) { // binary @@ -1660,7 +1658,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, if (what & STR2NR_OCT) { // Don't interpret "0", "08" or "0129" as octal. - for (int i = 1; i < maxlen && ascii_isdigit(ptr[i]); i++) { + for (int i = 1; !STRING_ENDED(ptr + i) && ascii_isdigit(ptr[i]); i++) { if (ptr[i] > '7') { // can't be octal pre = 0; @@ -1679,7 +1677,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, uvarnumber_T un = 0; if (pre == 'B' || pre == 'b' || what == (STR2NR_BIN|STR2NR_FORCE)) { // bin - while (ptr < e && '0' <= *ptr && *ptr <= '1') { + while (!STRING_ENDED(ptr) && '0' <= *ptr && *ptr <= '1') { // avoid ubsan error for overflow if (un < UVARNUMBER_MAX / 2) { un = 2 * un + (uvarnumber_T)(*ptr - '0'); @@ -1690,7 +1688,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, } } else if (pre == '0' || what == (STR2NR_OCT|STR2NR_FORCE)) { // octal - while (ptr < e && '0' <= *ptr && *ptr <= '7') { + while (!STRING_ENDED(ptr) && '0' <= *ptr && *ptr <= '7') { // avoid ubsan error for overflow if (un < UVARNUMBER_MAX / 8) { un = 8 * un + (uvarnumber_T)(*ptr - '0'); @@ -1701,7 +1699,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, } } else if (pre == 'X' || pre == 'x' || what == (STR2NR_HEX|STR2NR_FORCE)) { // hex - while (ptr < e && ascii_isxdigit(*ptr)) { + while (!STRING_ENDED(ptr) && ascii_isxdigit(*ptr)) { // avoid ubsan error for overflow if (un < UVARNUMBER_MAX / 16) { un = 16 * un + (uvarnumber_T)hex2nr(*ptr); @@ -1712,7 +1710,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, } } else { // decimal - while (ptr < e && ascii_isdigit(*ptr)) { + while (!STRING_ENDED(ptr) && ascii_isdigit(*ptr)) { // avoid ubsan error for overflow if (un < UVARNUMBER_MAX / 10) { un = 10 * un + (uvarnumber_T)(*ptr - '0'); @@ -1750,6 +1748,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, if (unptr != NULL) { *unptr = un; } +#undef STRING_ENDED } /// Return the value of a single hex character. -- cgit From fe81380bf5d4d161187998088aa9cff948b7c891 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 16 Oct 2017 00:30:55 +0300 Subject: viml/parser/expressions: Highlight prefix separately from number Should make accidental octals more visible. --- src/nvim/viml/parser/expressions.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 4801d66988..35f4385f33 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -1042,6 +1042,7 @@ void viml_pexpr_free_ast(ExprAST ast) // // NVimRegister -> SpecialChar // NVimNumber -> Number +// NVimNumberPrefix -> SpecialChar // NVimFloat -> NVimNumber // // NVimNestingParenthesis -> NVimParenthesis @@ -1842,6 +1843,14 @@ static const int want_node_to_lexer_flags[] = { [kENodeArgumentSeparator] = kELFlagForbidScope, }; +/// Number of characters to highlight as NumberPrefix depending on the base +static const uint8_t base_to_prefix_length[] = { + [2] = 2, + [8] = 1, + [10] = 0, + [16] = 2, +}; + /// Parse one VimL expression /// /// @param pstate Parser state. @@ -2632,7 +2641,13 @@ viml_pexpr_parse_figure_brace_closing_error: } else { NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeInteger); cur_node->data.num.value = cur_token.data.num.val.integer; - HL_CUR_TOKEN(Number); + const uint8_t prefix_length = base_to_prefix_length[ + cur_token.data.num.base]; + viml_parser_highlight(pstate, cur_token.start, prefix_length, + HL(NumberPrefix)); + viml_parser_highlight( + pstate, shifted_pos(cur_token.start, prefix_length), + cur_token.len - prefix_length, HL(Number)); } want_node = kENodeOperator; *top_node_p = cur_node; -- cgit From ed253b5fe6515840fe6dd9df83855a0316de8bad Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 16 Oct 2017 00:39:48 +0300 Subject: klee: Include colors in test --- src/nvim/viml/parser/parser.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h index 10ced57977..fbc5ba5f07 100644 --- a/src/nvim/viml/parser/parser.h +++ b/src/nvim/viml/parser/parser.h @@ -176,8 +176,9 @@ static inline void viml_parser_highlight(ParserState *const pstate, if (pstate->colors == NULL || len == 0) { return; } - // TODO(ZyX-I): May do some assert() sanitizing here. - // TODO(ZyX-I): May join chunks. + assert(kv_size(*pstate->colors) == 0 + || kv_Z(*pstate->colors, 0).start.line < start.line + || kv_Z(*pstate->colors, 0).end_col <= start.col); kvi_push(*pstate->colors, ((ParserHighlightChunk) { .start = start, .end_col = start.col + len, -- cgit From 15043e93b681ffdf1142d24aa918997e2e63a4b1 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 16 Oct 2017 00:41:41 +0300 Subject: klee: Update key_name_entry table --- src/nvim/keymap.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index 55ac835663..4f120e66f7 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -141,8 +141,7 @@ static char_u modifier_keys_table[] = static const struct key_name_entry { int key; // Special key code or ascii value const char *name; // Name of key -} key_names_table[] = -{ +} key_names_table[] = { { ' ', "Space" }, { TAB, "Tab" }, { K_TAB, "Tab" }, -- cgit From a535d68380e472a661478cd6a65aad243ebd6a82 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 16 Oct 2017 01:00:58 +0300 Subject: keymap: Remove incorrect cast --- src/nvim/keymap.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index 4f120e66f7..6ed54464e8 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -696,11 +696,14 @@ int find_special_key_in_table(int c) { int i; - for (i = 0; key_names_table[i].name != NULL; i++) - if (c == (uint8_t)key_names_table[i].key) + for (i = 0; key_names_table[i].name != NULL; i++) { + if (c == key_names_table[i].key) { break; - if (key_names_table[i].name == NULL) + } + } + if (key_names_table[i].name == NULL) { i = -1; + } return i; } -- cgit From 4c8ed65b608df06b4c72b641f4ecc86985295633 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 16 Oct 2017 03:04:22 +0300 Subject: viml/parser/expressions: Fix memory leak when processing ternary --- src/nvim/viml/parser/expressions.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 35f4385f33..876fbc8d37 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -2308,10 +2308,10 @@ viml_pexpr_parse_invalid_colon: _("E15: Colon outside of dictionary or ternary operator: %.*s")); viml_pexpr_parse_valid_colon: ADD_VALUE_IF_MISSING(_(EXP_VAL_COLON)); - NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeColon); if (is_ternary) { HL_CUR_TOKEN(TernaryColon); } else { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeColon); ADD_OP_NODE(cur_node); HL_CUR_TOKEN(Colon); } -- cgit From c9f511d24a64da135bef4b9874c7bec04d9330e4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 16 Oct 2017 09:06:05 +0300 Subject: viml/parser/expressions: Remove unused flag --- src/nvim/viml/parser/expressions.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 025f0f766e..d783518b3a 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -314,10 +314,6 @@ enum { /// When parsing expressions input by user bar is assumed to be a binary /// operator and other two are spacings. kExprFlagsDisallowEOC = (1 << 1), - /// Print errors when encountered - /// - /// Without the flag they are only taken into account when parsing. - kExprFlagsPrintError = (1 << 2), // WARNING: whenever you add a new flag, alter klee_assume() statement in // viml_expressions_parser.c. } ExprParserFlags; -- cgit From 895793fc820e04ea2d6bdaa90c6643c4dce2f0e7 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 16 Oct 2017 09:14:02 +0300 Subject: viml/parser/expressions: Add some casts --- src/nvim/viml/parser/expressions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 876fbc8d37..69817bf24f 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -698,8 +698,8 @@ const char *viml_pexpr_repr_token(const ParserState *const pstate, (int)token.data.num.is_float, (int)token.data.num.base, (double)(token.data.num.is_float - ? token.data.num.val.floating - : token.data.num.val.integer)) + ? (double)token.data.num.val.floating + : (double)token.data.num.val.integer)) TKNARGS(kExprLexInvalid, "(msg=%s)", token.data.err.msg) default: { // No additional arguments. -- cgit From 56eda2aa17c80ba380b606f9466f288fb8162dd3 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 16 Oct 2017 08:18:03 +0200 Subject: syntax: 'cursorline': revert priority change (#7400) ref #7383 reverts d1874ab2821d076397290cc154d87ec2dc352c79 ref #6380 --- src/nvim/screen.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 5659f30f64..f5730cf70a 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2202,7 +2202,6 @@ win_line ( colnr_T trailcol = MAXCOL; /* start of trailing spaces */ int need_showbreak = false; // overlong line, skip first x chars int line_attr = 0; // attribute for the whole line - int line_attr_low_priority = 0; // current line, lowest priority matchitem_T *cur; // points to the match list match_T *shl; // points to search_hl or a match int shl_flag; // flag to indicate whether search_hl @@ -2428,13 +2427,7 @@ win_line ( filler_lines = wp->w_topfill; filler_todo = filler_lines; - // 'cursorline' highlighting for the current window. Not when Visual mode is - // active, because it's not clear what is selected then. - if (wp->w_p_cul && lnum == wp->w_cursor.lnum - && !(wp == curwin && VIsual_active)) { - line_attr_low_priority = win_hl_attr(wp, HLF_CUL); - } - + // If this line has a sign with line highlighting set line_attr. v = buf_getsigntype(wp->w_buffer, lnum, SIGN_LINEHL); if (v != 0) { line_attr = sign_get_attr((int)v, true); @@ -2449,7 +2442,7 @@ win_line ( line_attr = hl_combine_attr(wp->w_hl_attr_normal, line_attr); } - if (line_attr_low_priority || line_attr) { + if (line_attr != 0) { area_highlighting = true; } @@ -2671,6 +2664,20 @@ win_line ( cur = cur->next; } + // Cursor line highlighting for 'cursorline' in the current window. Not + // when Visual mode is active, because it's not clear what is selected + // then. + if (wp->w_p_cul && lnum == wp->w_cursor.lnum + && !(wp == curwin && VIsual_active)) { + if (line_attr != 0 && !(State & INSERT) && bt_quickfix(wp->w_buffer) + && qf_current_entry(wp) == lnum) { + line_attr = hl_combine_attr(win_hl_attr(wp, HLF_CUL), line_attr); + } else { + line_attr = win_hl_attr(wp, HLF_CUL); + } + area_highlighting = true; + } + off = (unsigned)(current_ScreenLine - ScreenLines); col = 0; if (wp->w_p_rl) { @@ -3589,9 +3596,7 @@ win_line ( // Display a '$' after the line or highlight an extra // character if the line break is included. // For a diff line the highlighting continues after the "$". - if (diff_hlf == (hlf_T)0 - && line_attr == 0 - && line_attr_low_priority == 0) { + if (diff_hlf == (hlf_T)0 && line_attr == 0) { // In virtualedit, visual selections may extend beyond end of line. if (area_highlighting && virtual_active() && tocol != MAXCOL && vcol < tocol) { @@ -3655,7 +3660,7 @@ win_line ( (col < wp->w_width))) { c = ' '; ptr--; // put it back at the NUL - } else if ((diff_hlf != (hlf_T)0 || line_attr_low_priority || line_attr) + } else if ((diff_hlf != (hlf_T)0 || line_attr != 0) && (wp->w_p_rl ? (col >= 0) : (col - boguscols < wp->w_width))) { @@ -3667,8 +3672,7 @@ win_line ( did_line_attr++; // don't do search HL for the rest of the line - if ((line_attr_low_priority || line_attr) - && char_attr == search_attr && col > 0) { + if (line_attr != 0 && char_attr == search_attr && col > 0) { char_attr = line_attr; } if (diff_hlf == HLF_TXD) { @@ -4037,9 +4041,6 @@ win_line ( } } - // Apply `line_attr_low_priority` now, so that everthing can override it. - char_attr = hl_combine_attr(line_attr_low_priority, char_attr); - /* * Store character to be displayed. * Skip characters that are left of the screen for 'nowrap'. -- cgit From 5baeb4a49c061472a125f98af798c522d8504fbe Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 15 Oct 2017 18:29:53 +0200 Subject: ex-cmds: :checkhealth Built-in `:checkhealth` checks for valid $VIMRUNTIME by attempting to autoload `health#check()`. closes #2977 closes #3159 --- src/nvim/eval.c | 29 +++++++++++++++++++++++++++++ src/nvim/ex_cmds.lua | 6 ++++++ 2 files changed, 35 insertions(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b2a0d9a767..986c4a9a17 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -22850,3 +22850,32 @@ void eval_format_source_name_line(char *buf, size_t bufsize) (sourcing_name ? sourcing_name : (char_u *)"?"), (sourcing_name ? sourcing_lnum : 0)); } + +/// ":checkhealth [plugins]" +void ex_checkhealth(exarg_T *eap) +{ + bool found = !!find_func((char_u *)"health#check"); + if (!found + && script_autoload("health#check", sizeof("health#check") - 1, false)) { + found = !!find_func((char_u *)"health#check"); + } + if (!found) { + const char *vimruntime_env = os_getenv("VIMRUNTIME"); + if (vimruntime_env == NULL) { + EMSG(_("E5009: $VIMRUNTIME is empty or unset")); + return; + } else { + EMSG2(_("E5009: Invalid $VIMRUNTIME: %s"), os_getenv("VIMRUNTIME")); + return; + } + } + + size_t bufsize = STRLEN(eap->arg) + strlen("CheckHealth ") + 1; + char *buf = xmalloc(bufsize); + snprintf(buf, bufsize, "CheckHealth %s", eap->arg); + + do_cmdline_cmd(buf); + + xfree(buf); +} + diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index 5a578cd088..f99954db7a 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -450,6 +450,12 @@ return { addr_type=ADDR_LINES, func='ex_changes', }, + { + command='checkhealth', + flags=bit.bor(EXTRA, TRLBAR), + addr_type=ADDR_LINES, + func='ex_checkhealth', + }, { command='checkpath', flags=bit.bor(TRLBAR, BANG, CMDWIN), -- cgit From d214df4e9b23b5f2d9f7e6c78624881a7d298cdb Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 15 Oct 2017 20:31:12 +0200 Subject: doc: replace ":CheckHealth" with ":checkhealth" --- src/nvim/ops.c | 2 +- src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index e7bc20698b..c6df71ea46 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -5535,7 +5535,7 @@ int get_default_register_name(void) static yankreg_T *adjust_clipboard_name(int *name, bool quiet, bool writing) { #define MSG_NO_CLIP "clipboard: No provider. " \ - "Try \":CheckHealth\" or \":h clipboard\"." + "Try \":checkhealth\" or \":h clipboard\"." yankreg_T *target = NULL; bool explicit_cb_reg = (*name == '*' || *name == '+'); diff --git a/src/nvim/version.c b/src/nvim/version.c index 7e59f3327a..c2a8dcac07 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1365,7 +1365,7 @@ void intro_message(int colon) N_("https://neovim.io/community"), "", N_("type :help nvim if you are new! "), - N_("type :CheckHealth to optimize Nvim"), + N_("type :checkhealth to optimize Nvim"), N_("type :q to exit "), N_("type :help for help "), "", -- cgit From 014bd59957beb3f94cfb014a7acde3d2544bdfd9 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 16 Oct 2017 00:05:35 +0200 Subject: ex_checkhealth: call health#check() directly This allows us to remove :CheckHealth later (avoids wildmenu noise). --- src/nvim/eval.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 986c4a9a17..aab777955c 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -22870,9 +22870,9 @@ void ex_checkhealth(exarg_T *eap) } } - size_t bufsize = STRLEN(eap->arg) + strlen("CheckHealth ") + 1; + size_t bufsize = STRLEN(eap->arg) + sizeof("call health#check('')"); char *buf = xmalloc(bufsize); - snprintf(buf, bufsize, "CheckHealth %s", eap->arg); + snprintf(buf, bufsize, "call health#check('%s')", eap->arg); do_cmdline_cmd(buf); -- cgit From 70b574dab36a99e676b1845bdfe0fef4bfa63584 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 17 Oct 2017 12:55:12 -0400 Subject: vim-patch:8.0.0118 Runtime updates that were bundled into the otherwise NA commit: Problem: "make proto" adds extra function prototype. Solution: Add vim/vim#ifdef. https://github.com/vim/vim/commit/5162822914372fc916a93f85848c0c82209e7cec --- src/nvim/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 7f1a219322..60066ec8d3 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -985,7 +985,7 @@ static const int included_patches[] = { 121, // 120 NA 119, - // 118, + 118, // 117 NA 116, // 115 NA -- cgit From 47938e1e22816381f26e8882eacd6e7e8baf37fd Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 19 Oct 2017 10:48:05 +0300 Subject: viml/parser/expressions: Fix some errors spotted by KLEE Not all of them are fixed yet though. --- src/nvim/viml/parser/expressions.c | 58 +++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 69817bf24f..da22cf4cdb 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -1091,7 +1091,7 @@ void viml_pexpr_free_ast(ExprAST ast) // NVimInvalidDoubleQuote -> NVimInvalidString // NVimInvalidDoubleQuotedBody -> NVimInvalidString // NVimInvalidDoubleQuotedEscape -> NVimInvalidStringSpecial -// NVimInvalidDoubleQuotedUnknownEscape -> NVimInvalid +// NVimInvalidDoubleQuotedUnknownEscape -> NVimInvalidDoubleQuotedEscape // // NVimFigureBrace -> NVimInternalError // NVimInvalidSingleQuotedUnknownEscape -> NVimInternalError @@ -1313,7 +1313,7 @@ static bool viml_pexpr_handle_bop(const ParserState *const pstate, /// ParserPosition literal based on ParserPosition pos with columns shifted /// -/// Function does not check whether remaining position is valid. +/// Function does not check whether resulting position is valid. /// /// @param[in] pos Position to shift. /// @param[in] shift Number of bytes to shift. @@ -1326,6 +1326,21 @@ static inline ParserPosition shifted_pos(const ParserPosition pos, return (ParserPosition) { .line = pos.line, .col = pos.col + shift }; } +/// ParserPosition literal based on ParserPosition pos with specified column +/// +/// Function does not check whether remaining position is valid. +/// +/// @param[in] pos Position to adjust. +/// @param[in] new_col New column. +/// +/// @return Shifted position. +static inline ParserPosition recol_pos(const ParserPosition pos, + const size_t new_col) + FUNC_ATTR_CONST FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_WARN_UNUSED_RESULT +{ + return (ParserPosition) { .line = pos.line, .col = new_col }; +} + /// Get highlight group name #define HL(g) (is_invalid ? "NVimInvalid" #g : "NVim" #g) @@ -1639,7 +1654,7 @@ static void parse_quoted_string(ParserState *const pstate, size_t n = (*p == 'u' ? 4 : 8); int nr = 0; p++; - while (n-- && ascii_isxdigit(p[1])) { + while (p + 1 < e && n-- && ascii_isxdigit(p[1])) { p++; nr = (nr << 4) + hex2nr(*p); } @@ -1659,7 +1674,7 @@ static void parse_quoted_string(ParserState *const pstate, if (*p >= '0' && *p <= '7') { size--; p++; - if (*p >= '0' && *p <= '7') { + if (p < e && *p >= '0' && *p <= '7') { size--; p++; } @@ -1715,7 +1730,7 @@ static void parse_quoted_string(ParserState *const pstate, // Hexadecimal or unicode. case 'X': case 'x': case 'u': case 'U': { - if (ascii_isxdigit(p[1])) { + if (p + 1 < e && ascii_isxdigit(p[1])) { size_t n; int nr; bool is_hex = (*p == 'x' || *p == 'X'); @@ -1728,7 +1743,7 @@ static void parse_quoted_string(ParserState *const pstate, n = 8; } nr = 0; - while (n-- && ascii_isxdigit(p[1])) { + while (p + 1 < e && n-- && ascii_isxdigit(p[1])) { p++; nr = (nr << 4) + hex2nr(*p); } @@ -1749,9 +1764,9 @@ static void parse_quoted_string(ParserState *const pstate, case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': { uint8_t ch = (uint8_t)(*p++ - '0'); - if (*p >= '0' && *p <= '7') { + if (p < e && *p >= '0' && *p <= '7') { ch = (uint8_t)((ch << 3) + *p++ - '0'); - if (*p >= '0' && *p <= '7') { + if (p < e && *p >= '0' && *p <= '7') { ch = (uint8_t)((ch << 3) + *p++ - '0'); } } @@ -1793,7 +1808,7 @@ static void parse_quoted_string(ParserState *const pstate, // TODO(ZyX-I): use ast_stack to determine and highlight regular expressions // TODO(ZyX-I): use ast_stack to determine and highlight printf format str // TODO(ZyX-I): use ast_stack to determine and highlight expression strings - size_t next_col = 1; + size_t next_col = token.start.col + 1; const char *const body_str = (is_double ? HL(DoubleQuotedBody) : HL(SingleQuotedBody)); @@ -1806,20 +1821,23 @@ static void parse_quoted_string(ParserState *const pstate, for (size_t i = 0; i < kv_size(shifts); i++) { const StringShift cur_shift = kv_A(shifts, i); if (cur_shift.start > next_col) { - viml_parser_highlight(pstate, shifted_pos(token.start, next_col), + viml_parser_highlight(pstate, recol_pos(token.start, next_col), cur_shift.start - next_col, body_str); } - viml_parser_highlight(pstate, shifted_pos(token.start, cur_shift.start), + viml_parser_highlight(pstate, recol_pos(token.start, cur_shift.start), cur_shift.orig_len, (cur_shift.escape_not_known ? ukn_esc_str : esc_str)); next_col = cur_shift.start + cur_shift.orig_len; } - if (next_col < token.len - token.data.str.closed) { - viml_parser_highlight(pstate, shifted_pos(token.start, next_col), - token.len - token.data.str.closed - next_col, + if (next_col - token.start.col < token.len - token.data.str.closed) { + viml_parser_highlight(pstate, recol_pos(token.start, next_col), + (token.start.col + + token.len + - token.data.str.closed + - next_col), body_str); } } @@ -2580,6 +2598,9 @@ viml_pexpr_parse_figure_brace_closing_error: break; } case kExprLexPlainIdentifier: { + const ExprVarScope scope = (cur_token.type == kExprLexInvalid + ? kExprVarScopeMissing + : cur_token.data.var.scope); if (want_node == kENodeValue || want_node == kENodeArgument) { want_node = (want_node == kENodeArgument ? kENodeArgumentSeparator @@ -2588,9 +2609,8 @@ viml_pexpr_parse_figure_brace_closing_error: (node_is_key ? kExprNodePlainKey : kExprNodePlainIdentifier)); - cur_node->data.var.scope = cur_token.data.var.scope; - const size_t scope_shift = ( - cur_token.data.var.scope == kExprVarScopeMissing ? 0 : 2); + cur_node->data.var.scope = scope; + const size_t scope_shift = (scope == kExprVarScopeMissing ? 0 : 2); cur_node->data.var.ident = (pline.data + cur_token.start.col + scope_shift); cur_node->data.var.ident_len = cur_token.len - scope_shift; @@ -2609,11 +2629,11 @@ viml_pexpr_parse_figure_brace_closing_error: ? HL(IdentifierKey) : HL(Identifier))); } else { - if (cur_token.data.var.scope == kExprVarScopeMissing) { + if (scope == kExprVarScopeMissing) { ADD_IDENT( do { NEW_NODE_WITH_CUR_POS(cur_node, kExprNodePlainIdentifier); - cur_node->data.var.scope = cur_token.data.var.scope; + cur_node->data.var.scope = scope; cur_node->data.var.ident = pline.data + cur_token.start.col; cur_node->data.var.ident_len = cur_token.len; want_node = kENodeOperator; -- cgit From 295c90989d10bf221eff7babc1cf9484ec0f4560 Mon Sep 17 00:00:00 2001 From: relnod Date: Sat, 15 Jul 2017 14:27:59 +0200 Subject: refactor/single-include: terminal.h --- src/nvim/CMakeLists.txt | 1 - src/nvim/terminal.h | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index e2f1f16635..da8ec354d9 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -543,7 +543,6 @@ set(NO_SINGLE_CHECK_HEADERS os/pty_process_win.h regexp_defs.h syntax_defs.h - terminal.h undo.h undo_defs.h ) diff --git a/src/nvim/terminal.h b/src/nvim/terminal.h index 25e609fb68..f2b0e232c3 100644 --- a/src/nvim/terminal.h +++ b/src/nvim/terminal.h @@ -10,6 +10,8 @@ typedef void (*terminal_write_cb)(char *buffer, size_t size, void *data); typedef void (*terminal_resize_cb)(uint16_t width, uint16_t height, void *data); typedef void (*terminal_close_cb)(void *data); +#include "nvim/buffer_defs.h" + typedef struct { void *data; uint16_t width, height; -- cgit From 69199958b7ed9ec87a83b2ac0fd37a0c3e41a506 Mon Sep 17 00:00:00 2001 From: relnod Date: Sat, 15 Jul 2017 16:44:06 +0200 Subject: refactor/single-include: regexp_defs.h --- src/nvim/CMakeLists.txt | 1 - src/nvim/regexp_defs.h | 46 ++++++++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index da8ec354d9..7bd121050e 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -541,7 +541,6 @@ endfunction() set(NO_SINGLE_CHECK_HEADERS os/win_defs.h os/pty_process_win.h - regexp_defs.h syntax_defs.h undo.h undo_defs.h diff --git a/src/nvim/regexp_defs.h b/src/nvim/regexp_defs.h index 6426ee441b..7492a86697 100644 --- a/src/nvim/regexp_defs.h +++ b/src/nvim/regexp_defs.h @@ -15,6 +15,8 @@ #include #include "nvim/pos.h" +#include "nvim/types.h" +#include "nvim/profile.h" /* * The number of sub-matches is limited to 10. @@ -41,18 +43,38 @@ #define NFA_ENGINE 2 typedef struct regengine regengine_T; +typedef struct regprog regprog_T; +typedef struct reg_extmatch reg_extmatch_T; + +/* + * Structure to be used for multi-line matching. + * Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col" + * and ends in line "endpos[no].lnum" just before column "endpos[no].col". + * The line numbers are relative to the first line, thus startpos[0].lnum is + * always 0. + * When there is no match, the line number is -1. + */ +typedef struct { + regprog_T *regprog; + lpos_T startpos[NSUBEXP]; + lpos_T endpos[NSUBEXP]; + int rmm_ic; + colnr_T rmm_maxcol; /* when not zero: maximum column */ +} regmmatch_T; + +#include "nvim/buffer_defs.h" /* * Structure returned by vim_regcomp() to pass on to vim_regexec(). * This is the general structure. For the actual matcher, two specific * structures are used. See code below. */ -typedef struct regprog { +struct regprog { regengine_T *engine; unsigned regflags; unsigned re_engine; ///< Automatic, backtracking or NFA engine. unsigned re_flags; ///< Second argument for vim_regcomp(). -} regprog_T; +}; /* * Structure used by the back track matcher. @@ -125,31 +147,15 @@ typedef struct { bool rm_ic; } regmatch_T; -/* - * Structure to be used for multi-line matching. - * Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col" - * and ends in line "endpos[no].lnum" just before column "endpos[no].col". - * The line numbers are relative to the first line, thus startpos[0].lnum is - * always 0. - * When there is no match, the line number is -1. - */ -typedef struct { - regprog_T *regprog; - lpos_T startpos[NSUBEXP]; - lpos_T endpos[NSUBEXP]; - int rmm_ic; - colnr_T rmm_maxcol; /* when not zero: maximum column */ -} regmmatch_T; - /* * Structure used to store external references: "\z\(\)" to "\z\1". * Use a reference count to avoid the need to copy this around. When it goes * from 1 to zero the matches need to be freed. */ -typedef struct { +struct reg_extmatch { short refcnt; char_u *matches[NSUBEXP]; -} reg_extmatch_T; +}; struct regengine { regprog_T *(*regcomp)(char_u*, int); -- cgit From 4b0a086d165013ff5726b987b353d88a863491a9 Mon Sep 17 00:00:00 2001 From: relnod Date: Sat, 15 Jul 2017 16:47:12 +0200 Subject: refactor/single-include: syntax_defs.h --- src/nvim/CMakeLists.txt | 1 - src/nvim/syntax_defs.h | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 7bd121050e..2cc236101c 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -541,7 +541,6 @@ endfunction() set(NO_SINGLE_CHECK_HEADERS os/win_defs.h os/pty_process_win.h - syntax_defs.h undo.h undo_defs.h ) diff --git a/src/nvim/syntax_defs.h b/src/nvim/syntax_defs.h index 56fadbe7f6..7260853703 100644 --- a/src/nvim/syntax_defs.h +++ b/src/nvim/syntax_defs.h @@ -2,7 +2,6 @@ #define NVIM_SYNTAX_DEFS_H #include "nvim/highlight_defs.h" -#include "nvim/regexp_defs.h" # define SST_MIN_ENTRIES 150 /* minimal size for state stack array */ # define SST_MAX_ENTRIES 1000 /* maximal size for state stack array */ @@ -10,6 +9,11 @@ # define SST_DIST 16 /* normal distance between entries */ # define SST_INVALID (synstate_T *)-1 /* invalid syn_state pointer */ +typedef struct syn_state synstate_T; + +#include "nvim/buffer_defs.h" +#include "nvim/regexp_defs.h" + typedef unsigned short disptick_T; /* display tick type */ /* struct passed to in_id_list() */ @@ -48,8 +52,6 @@ typedef struct buf_state { * syn_state contains the syntax state stack for the start of one line. * Used by b_sst_array[]. */ -typedef struct syn_state synstate_T; - struct syn_state { synstate_T *sst_next; /* next entry in used or free list */ linenr_T sst_lnum; /* line number for this state */ -- cgit From 14e63271cc216ef60036891f7f79d8509c8f52c1 Mon Sep 17 00:00:00 2001 From: relnod Date: Sat, 15 Jul 2017 16:50:22 +0200 Subject: refactor/single-include: undo_defs.h --- src/nvim/CMakeLists.txt | 1 - src/nvim/undo_defs.h | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 2cc236101c..09d50f0f00 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -542,7 +542,6 @@ set(NO_SINGLE_CHECK_HEADERS os/win_defs.h os/pty_process_win.h undo.h - undo_defs.h ) foreach(hfile ${NVIM_HEADERS}) get_test_target(test-includes "${hfile}" relative_path texe) diff --git a/src/nvim/undo_defs.h b/src/nvim/undo_defs.h index d841210815..6c7e2bba41 100644 --- a/src/nvim/undo_defs.h +++ b/src/nvim/undo_defs.h @@ -4,9 +4,10 @@ #include // for time_t #include "nvim/pos.h" -#include "nvim/buffer_defs.h" #include "nvim/mark_defs.h" +typedef struct u_header u_header_T; + /* Structure to store info about the Visual area. */ typedef struct { pos_T vi_start; /* start pos of last VIsual */ @@ -15,8 +16,9 @@ typedef struct { colnr_T vi_curswant; /* MAXCOL from w_curswant */ } visualinfo_T; +#include "nvim/buffer_defs.h" + typedef struct u_entry u_entry_T; -typedef struct u_header u_header_T; struct u_entry { u_entry_T *ue_next; /* pointer to next entry in list */ linenr_T ue_top; /* number of line above undo block */ -- cgit From 0f74b7afeb3a4b85302268e7cb04f0faefda397d Mon Sep 17 00:00:00 2001 From: relnod Date: Sat, 15 Jul 2017 16:52:32 +0200 Subject: refactor/single-include: undo.h --- src/nvim/CMakeLists.txt | 1 - src/nvim/undo.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index 09d50f0f00..eb3b60f0b5 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -541,7 +541,6 @@ endfunction() set(NO_SINGLE_CHECK_HEADERS os/win_defs.h os/pty_process_win.h - undo.h ) foreach(hfile ${NVIM_HEADERS}) get_test_target(test-includes "${hfile}" relative_path texe) diff --git a/src/nvim/undo.h b/src/nvim/undo.h index ab8584fbb2..802cdc5583 100644 --- a/src/nvim/undo.h +++ b/src/nvim/undo.h @@ -2,6 +2,7 @@ #define NVIM_UNDO_H #include "nvim/undo_defs.h" +#include "nvim/ex_cmds_defs.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "undo.h.generated.h" -- cgit From dde3ece10ed4ee62744009fa1fd347be740fc845 Mon Sep 17 00:00:00 2001 From: relnod Date: Sat, 15 Jul 2017 17:52:06 +0200 Subject: lint --- src/nvim/regexp_defs.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/regexp_defs.h b/src/nvim/regexp_defs.h index 7492a86697..b5d56e07fc 100644 --- a/src/nvim/regexp_defs.h +++ b/src/nvim/regexp_defs.h @@ -46,20 +46,18 @@ typedef struct regengine regengine_T; typedef struct regprog regprog_T; typedef struct reg_extmatch reg_extmatch_T; -/* - * Structure to be used for multi-line matching. - * Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col" - * and ends in line "endpos[no].lnum" just before column "endpos[no].col". - * The line numbers are relative to the first line, thus startpos[0].lnum is - * always 0. - * When there is no match, the line number is -1. - */ +/// Structure to be used for multi-line matching. +/// Sub-match "no" starts in line "startpos[no].lnum" column "startpos[no].col" +/// and ends in line "endpos[no].lnum" just before column "endpos[no].col". +/// The line numbers are relative to the first line, thus startpos[0].lnum is +/// always 0. +/// When there is no match, the line number is -1. typedef struct { regprog_T *regprog; lpos_T startpos[NSUBEXP]; lpos_T endpos[NSUBEXP]; int rmm_ic; - colnr_T rmm_maxcol; /* when not zero: maximum column */ + colnr_T rmm_maxcol; /// when not zero: maximum column } regmmatch_T; #include "nvim/buffer_defs.h" @@ -153,7 +151,7 @@ typedef struct { * from 1 to zero the matches need to be freed. */ struct reg_extmatch { - short refcnt; + int16_t refcnt; char_u *matches[NSUBEXP]; }; -- cgit From dfe806ea8b90ace9ef2ee63aafbf10ebea2df7ef Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Thu, 19 Oct 2017 11:46:07 +0200 Subject: bufhl: support creating new groups --- src/nvim/api/buffer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 82de8fd4a2..c381e92dc7 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -793,7 +793,11 @@ Integer nvim_buf_add_highlight(Buffer buffer, col_end = MAXCOL; } - int hlg_id = syn_name2id((char_u *)(hl_group.data ? hl_group.data : "")); + int hlg_id = 0; + if (hl_group.size > 0) { + hlg_id = syn_check_group((char_u *)hl_group.data, (int)hl_group.size); + } + src_id = bufhl_add_hl(buf, (int)src_id, hlg_id, (linenr_T)line+1, (colnr_T)col_start+1, (colnr_T)col_end); return src_id; -- cgit From 82b8382abe6c533fbdd01529cfc93a8d1c5231e2 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 21 Oct 2017 02:04:35 +0200 Subject: vim-patch:8.0.0962 closes #6726 Problem: Crash with virtualedit and joining lines. (Joshua T Corbin, Neovim #6726) Solution: When using a mark check that coladd is valid. https://github.com/vim/vim/commit/9aa156912867c05e0a6480925afe11c590378f09 --- src/nvim/cursor.c | 26 ++++++++++++++++++-------- src/nvim/normal.c | 13 +++++++++---- src/nvim/testdir/test_alot.vim | 1 + src/nvim/testdir/test_virtualedit.vim | 31 +++++++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 src/nvim/testdir/test_virtualedit.vim (limited to 'src') diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c index 60002f3cea..e575143af0 100644 --- a/src/nvim/cursor.c +++ b/src/nvim/cursor.c @@ -375,17 +375,27 @@ void check_cursor_col_win(win_T *win) win->w_cursor.col = 0; } - /* If virtual editing is on, we can leave the cursor on the old position, - * only we must set it to virtual. But don't do it when at the end of the - * line. */ - if (oldcol == MAXCOL) + // If virtual editing is on, we can leave the cursor on the old position, + // only we must set it to virtual. But don't do it when at the end of the + // line. + if (oldcol == MAXCOL) { win->w_cursor.coladd = 0; - else if (ve_flags == VE_ALL) { - if (oldcoladd > win->w_cursor.col) + } else if (ve_flags == VE_ALL) { + if (oldcoladd > win->w_cursor.col) { win->w_cursor.coladd = oldcoladd - win->w_cursor.col; - else - /* avoid weird number when there is a miscalculation or overflow */ + if (win->w_cursor.col < len && win->w_cursor.coladd > 0) { + int cs, ce; + + // check that coladd is not more than the char width + getvcol(win, &win->w_cursor, &cs, NULL, &ce); + if (win->w_cursor.coladd > ce - cs) { + win->w_cursor.coladd = ce - cs; + } + } + } else { + // avoid weird number when there is a miscalculation or overflow win->w_cursor.coladd = 0; + } } } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index c40ed58550..1103fe15d2 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -1548,8 +1548,10 @@ void do_pending_operator(cmdarg_T *cap, int old_col, bool gui_yank) } oap->start = VIsual; - if (VIsual_mode == 'V') + if (VIsual_mode == 'V') { oap->start.col = 0; + oap->start.coladd = 0; + } } /* @@ -6260,15 +6262,18 @@ static void nv_gomark(cmdarg_T *cap) } else nv_cursormark(cap, cap->arg, pos); - /* May need to clear the coladd that a mark includes. */ - if (!virtual_active()) + // May need to clear the coladd that a mark includes. + if (!virtual_active()) { curwin->w_cursor.coladd = 0; + } + check_cursor_col(); if (cap->oap->op_type == OP_NOP && pos != NULL && (pos == (pos_T *)-1 || !equalpos(old_cursor, *pos)) && (fdo_flags & FDO_MARK) - && old_KeyTyped) + && old_KeyTyped) { foldOpenCursor(); + } } /* diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index d55170c27c..535e290a34 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -34,4 +34,5 @@ source test_taglist.vim source test_true_false.vim source test_unlet.vim source test_utf8.vim +source test_virtualedit.vim source test_window_cmd.vim diff --git a/src/nvim/testdir/test_virtualedit.vim b/src/nvim/testdir/test_virtualedit.vim new file mode 100644 index 0000000000..da143c518f --- /dev/null +++ b/src/nvim/testdir/test_virtualedit.vim @@ -0,0 +1,31 @@ +" Tests for 'virtualedit'. + +func Test_yank_move_change() + split + call setline(1, [ + \ "func foo() error {", + \ "\tif n, err := bar();", + \ "\terr != nil {", + \ "\t\treturn err", + \ "\t}", + \ "\tn = n * n", + \ ]) + set virtualedit=all + set ts=4 + function! MoveSelectionDown(count) abort + normal! m` + silent! exe "'<,'>move'>+".a:count + norm! `` + endfunction + + xmap ]e :call MoveSelectionDown(v:count1) + 2 + normal 2gg + normal J + normal jVj + normal ]e + normal ce + bwipe! + set virtualedit= + set ts=8 +endfunc -- cgit From b5b8966760773421b285ee8b63015fc767bca18d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 21 Oct 2017 02:20:17 +0200 Subject: vim-patch:8.0.1019 Problem: Pasting in virtual edit happens in the wrong place. Solution: Do not adjust coladd when after the end of the line (closes vim/vim#2015) https://github.com/vim/vim/commit/d41babef89a50cdf165f15bc1834c0a4e89ffff8 --- src/nvim/cursor.c | 7 +++++-- src/nvim/testdir/test_virtualedit.vim | 14 +++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c index e575143af0..0e97e2203f 100644 --- a/src/nvim/cursor.c +++ b/src/nvim/cursor.c @@ -383,10 +383,13 @@ void check_cursor_col_win(win_T *win) } else if (ve_flags == VE_ALL) { if (oldcoladd > win->w_cursor.col) { win->w_cursor.coladd = oldcoladd - win->w_cursor.col; - if (win->w_cursor.col < len && win->w_cursor.coladd > 0) { + + // Make sure that coladd is not more than the char width. + // Not for the last character, coladd is then used when the cursor + // is actually after the last character. + if (win->w_cursor.col + 1 < len && win->w_cursor.coladd > 0) { int cs, ce; - // check that coladd is not more than the char width getvcol(win, &win->w_cursor, &cs, NULL, &ce); if (win->w_cursor.coladd > ce - cs) { win->w_cursor.coladd = ce - cs; diff --git a/src/nvim/testdir/test_virtualedit.vim b/src/nvim/testdir/test_virtualedit.vim index da143c518f..2b8849f488 100644 --- a/src/nvim/testdir/test_virtualedit.vim +++ b/src/nvim/testdir/test_virtualedit.vim @@ -1,7 +1,7 @@ " Tests for 'virtualedit'. func Test_yank_move_change() - split + new call setline(1, [ \ "func foo() error {", \ "\tif n, err := bar();", @@ -29,3 +29,15 @@ func Test_yank_move_change() set virtualedit= set ts=8 endfunc + +func Test_paste_end_of_line() + new + set virtualedit=all + call setline(1, ['456', '123']) + normal! gg0"ay$ + exe "normal! 2G$lllA\:normal! \"agP\r" + call assert_equal('123456', getline(2)) + + bwipe! + set virtualedit= +endfunc -- cgit From 37420ef942085bf5e9344842a57c796b4d4c9684 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 21 Oct 2017 02:30:21 +0200 Subject: build: set MIN_LOG_LEVEL correctly (#7419) closes #7283 regression by 42d892913daa215c27e41b2255e96c1ce09ea56c - Don't need to explicitly put "-O2 -g" in RelWithDebInfo; CMake does that already. That was left-over from 42d892913daa2 which removed the "Dev" custom build-type, but repurposed the logic for RelWithDebInfo. - `if(DEFINED MIN_LOG_LEVEL)` doesn't work. - `if(${MIN_LOG_LEVEL} MATCHES "^$")` doesn't work if -DMIN_LOG_LEVEL is omitted. - `if(MIN_LOG_LEVEL)` also isn't what we want: it would be true if MIN_LOG_LEVEL=0. --- src/nvim/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index e2f1f16635..bcbbc76cbc 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -164,7 +164,7 @@ if(NOT MSVC) endif() endif() -if(DEFINED MIN_LOG_LEVEL) +if(NOT "${MIN_LOG_LEVEL}" MATCHES "^$") add_definitions(-DMIN_LOG_LEVEL=${MIN_LOG_LEVEL}) endif() -- cgit From bead15f10dbdd71c0091bbfa18ec0aab9b8b2e82 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 22 Oct 2017 18:13:46 +0800 Subject: vim-patch:8.0.0140 (#7428) Problem: Pasting inserted text in Visual mode does not work properly. (Matthew Malcomson) Solution: Stop Visual mode before stuffing the inserted text. (Christian Brabandt, from neovim #5709) https://github.com/vim/vim/commit/f8eb9c51e5bbd10e59c9b1247f8f6c7f5b77ccd0 --- src/nvim/testdir/test_visual.vim | 18 +++++++++++++----- src/nvim/version.c | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 8cb59ca32a..1694adbd32 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -1,13 +1,13 @@ -" Tests for Visual mode -if !has('multi_byte') - finish -endif - +" Tests for various Visual mode. if !has('visual') finish endif func Test_block_shift_multibyte() + " Uses double-wide character. + if !has('multi_byte') + return + endif split call setline(1, ['xヹxxx', 'ヹxxx']) exe "normal 1G0l\jl>" @@ -35,3 +35,11 @@ func Test_Visual_vapo() normal vapo bwipe! endfunc + +func Test_dotregister_paste() + new + exe "norm! ihello world\" + norm! 0ve".p + call assert_equal('hello world world', getline(1)) + q! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index fb3eadac3d..30ebbb22bc 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -963,7 +963,7 @@ static const int included_patches[] = { 143, 142, // 141, - // 140, + 140, // 139 NA // 138 NA 137, -- cgit From 9db42d4ce99c5b5747e9d83045b37e93d55c4249 Mon Sep 17 00:00:00 2001 From: Josh Leeb-du Toit Date: Fri, 29 Sep 2017 01:12:56 +1000 Subject: :cquit : take an error code argument #7336 closes #2699 ex_cmds.lua: use flags consistent with similar commands such as `cnext`. upstream discussion: "[patch] :qcuit can take exit code" https://groups.google.com/d/msg/vim_dev/_PjyNbUKyRc/oPgr5_ZXc6AJ --- src/nvim/ex_cmds.lua | 2 +- src/nvim/ex_docmd.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.lua b/src/nvim/ex_cmds.lua index f99954db7a..e57e662039 100644 --- a/src/nvim/ex_cmds.lua +++ b/src/nvim/ex_cmds.lua @@ -620,7 +620,7 @@ return { }, { command='cquit', - flags=bit.bor(TRLBAR, BANG), + flags=bit.bor(RANGE, NOTADR, COUNT, ZEROR, TRLBAR, BANG), addr_type=ADDR_LINES, func='ex_cquit', }, diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 3130747e08..f64c9fded8 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include "nvim/vim.h" @@ -5995,7 +5996,7 @@ static void ex_quit(exarg_T *eap) */ static void ex_cquit(exarg_T *eap) { - getout(1); + getout(eap->addr_count > 0 ? (int)eap->line2 : EXIT_FAILURE); } /* -- cgit From e4a974c7cc6dea53b9457bbd29a4e48f221720cb Mon Sep 17 00:00:00 2001 From: Victor Adam Date: Wed, 17 Jun 2015 11:38:47 +0200 Subject: plines_win_nofold(): Ignore virtcols after 32000th computation #3527 Avoid crashing or hanging when editing a file than contains ludicrously long lines (more than 100,000,000 virtual columns). The change is in plines_win_nofold, which is called by wrapping and folding code. As a result, wrapping and folding may be done incorrectly when the UI is capable of rendering more than 32000 characters at a time (tiny font). fixes #2838 --- src/nvim/misc1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 5270687a4d..2f02985875 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -1273,7 +1273,7 @@ int plines_win_nofold(win_T *wp, linenr_T lnum) * Add column offset for 'number', 'relativenumber' and 'foldcolumn'. */ width = wp->w_width - win_col_off(wp); - if (width <= 0) { + if (width <= 0 || col > 32000) { return 32000; // bigger than the number of lines of the screen } if (col <= (unsigned int)width) { -- cgit From a3134bc4809dff52cc9a635103a48b48d7c2d148 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 22 Oct 2017 13:51:50 +0200 Subject: test: tabstop= #2838 --- src/nvim/misc1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 2f02985875..137de84953 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -1274,7 +1274,7 @@ int plines_win_nofold(win_T *wp, linenr_T lnum) */ width = wp->w_width - win_col_off(wp); if (width <= 0 || col > 32000) { - return 32000; // bigger than the number of lines of the screen + return 32000; // bigger than the number of screen columns } if (col <= (unsigned int)width) { return 1; -- cgit From fdd9b1982ba2bce586e30a5a119273aa448bf049 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 24 Oct 2017 21:57:11 +0200 Subject: :version : show Lua[Jit] version (#7436) Also remove vestigial `extra_patches` code. --- src/nvim/version.c | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 30ebbb22bc..6f3ca12458 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -22,6 +22,7 @@ #include "nvim/message.h" #include "nvim/screen.h" #include "nvim/strings.h" +#include "nvim/lua/executor.h" // version info generated by the build system #include "auto/versiondef.h" @@ -1107,16 +1108,6 @@ static const int included_patches[] = { }; // clang-format on -/// Place to put a short description when adding a feature with a patch. -/// Keep it short, e.g.,: "relative numbers", "persistent undo". -/// Also add a comment marker to separate the lines. -/// See the official Vim patches for the diff format: It must use a context of -/// one line only. Create it by hand or use "diff -C2" and edit the patch. -static char *(extra_patches[]) = { - // Add your patch description below this line - NULL -}; - /// Compares a version string to the current Nvim version. /// /// @param version Version string like "1.3.42" @@ -1251,27 +1242,24 @@ static void list_features(void) MSG_PUTS("See \":help feature-compile\"\n\n"); } +void list_lua_version(void) +{ + typval_T luaver_tv; + typval_T arg = { .v_type = VAR_UNKNOWN }; // No args. + char *luaver_expr = "((jit and jit.version) and jit.version or _VERSION)"; + executor_eval_lua(cstr_as_string(luaver_expr), &arg, &luaver_tv); + assert(luaver_tv.v_type == VAR_STRING); + MSG(luaver_tv.vval.v_string); + xfree(luaver_tv.vval.v_string); +} + void list_version(void) { - // When adding features here, don't forget to update the list of - // internal variables in eval.c! MSG(longVersion); MSG(version_buildtype); + list_lua_version(); MSG(version_cflags); - // Print the list of extra patch descriptions if there is at least one. - char *s = ""; - if (extra_patches[0] != NULL) { - MSG_PUTS(_("\nExtra patches: ")); - s = ""; - - for (int i = 0; extra_patches[i] != NULL; ++i) { - MSG_PUTS(s); - s = ", "; - MSG_PUTS(extra_patches[i]); - } - } - #ifdef HAVE_PATHDEF if ((*compiled_user != NUL) || (*compiled_sys != NUL)) { @@ -1312,6 +1300,8 @@ void list_version(void) version_msg("\"\n"); } #endif // ifdef HAVE_PATHDEF + + version_msg("\nRun :checkhealth for more info"); } /// Output a string for the version message. If it's going to wrap, output a -- cgit From f1f7f3b5123edbd312ae92e9510c4c86cfe1171d Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 23 Oct 2017 19:52:23 -0400 Subject: inccommand: Ignore leading modifiers in the command --- src/nvim/ex_docmd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index f64c9fded8..096187b162 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9883,7 +9883,7 @@ static void ex_terminal(exarg_T *eap) /// Checks if `cmd` is "previewable" (i.e. supported by 'inccommand'). /// -/// @param[in] cmd Commandline to check. May start with a range. +/// @param[in] cmd Commandline to check. May start with a range or modifier. /// /// @return true if `cmd` is previewable bool cmd_can_preview(char_u *cmd) @@ -9892,6 +9892,12 @@ bool cmd_can_preview(char_u *cmd) return false; } + // Ignore any leading modifiers (:keeppatterns, :verbose, etc.) + for (int len = modifier_len(cmd); len != 0; len = modifier_len(cmd)) { + cmd += len; + cmd = skipwhite(cmd); + } + exarg_T ea; // parse the command line ea.cmd = skip_range(cmd, NULL); -- cgit From 439c39a2cfb0712eb68ad76354b1fd7e92bb71fe Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Thu, 23 Feb 2017 05:33:14 +0000 Subject: ext_cmdline: allow external ui to draw cmdline --- src/nvim/ex_getln.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++------ src/nvim/ui.c | 2 ++ 2 files changed, 73 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 54e5bcb9ff..87bf46d4d0 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -185,6 +185,8 @@ static int cmd_showtail; /* Only show path tail in lists ? */ static int new_cmdpos; /* position set by set_cmdline_pos() */ +static bool cmdline_external = false; + /* * Type used by call_user_expand_func */ @@ -281,7 +283,9 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) if (!cmd_silent) { s->i = msg_scrolled; msg_scrolled = 0; // avoid wait_return message - gotocmdline(true); + if (!cmdline_external) { + gotocmdline(true); + } msg_scrolled += s->i; redrawcmdprompt(); // draw prompt or indent set_cmdspos(); @@ -1828,7 +1832,16 @@ getcmdline ( int indent // indent for inside conditionals ) { - return command_line_enter(firstc, count, indent); + if (cmdline_external) { + Array args = ARRAY_DICT_INIT; + ui_event("cmdline_enter", args); + } + char_u *p = command_line_enter(firstc, count, indent); + if (cmdline_external) { + Array args = ARRAY_DICT_INIT; + ui_event("cmdline_leave", args); + } + return p; } /// Get a command line with a prompt @@ -2589,6 +2602,14 @@ static void draw_cmdline(int start, int len) return; } + if (cmdline_external) { + Array args = ARRAY_DICT_INIT; + ADD(args, STRING_OBJ(cstr_to_string((char *)(ccline.cmdbuff)))); + ADD(args, INTEGER_OBJ(ccline.cmdpos)); + ui_event("cmdline", args); + return; + } + if (cmdline_star > 0) { for (int i = 0; i < len; i++) { msg_putchar('*'); @@ -2713,11 +2734,28 @@ void putcmdline(int c, int shift) { if (cmd_silent) return; - msg_no_more = TRUE; - msg_putchar(c); - if (shift) - draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos); - msg_no_more = FALSE; + if (!cmdline_external) { + msg_no_more = TRUE; + msg_putchar(c); + if (shift) + draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos); + msg_no_more = FALSE; + } else { + char_u *p; + if (ccline.cmdpos == ccline.cmdlen || shift) { + p = vim_strnsave(ccline.cmdbuff, ccline.cmdlen + 1); + } else { + p = vim_strsave(ccline.cmdbuff); + } + p[ccline.cmdpos] = c; + if (shift) + STRCPY(p + ccline.cmdpos + 1, ccline.cmdbuff + ccline.cmdpos); + Array args = ARRAY_DICT_INIT; + ADD(args, STRING_OBJ(cstr_to_string((char *)(p)))); + ADD(args, INTEGER_OBJ(ccline.cmdpos)); + ui_event("cmdline", args); + xfree(p); + } cursorcmd(); ui_cursor_shape(); } @@ -3066,8 +3104,15 @@ static void redrawcmdprompt(void) if (cmd_silent) return; - if (ccline.cmdfirstc != NUL) - msg_putchar(ccline.cmdfirstc); + if (ccline.cmdfirstc != NUL) { + if (cmdline_external) { + Array args = ARRAY_DICT_INIT; + ADD(args, STRING_OBJ(cstr_to_string((char *)(&ccline.cmdfirstc)))); + ui_event("cmdline_firstc", args); + } else { + msg_putchar(ccline.cmdfirstc); + } + } if (ccline.cmdprompt != NULL) { msg_puts_attr((const char *)ccline.cmdprompt, ccline.cmdattr); ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns; @@ -3087,6 +3132,11 @@ void redrawcmd(void) if (cmd_silent) return; + if (cmdline_external) { + draw_cmdline(0, ccline.cmdlen); + return; + } + /* when 'incsearch' is set there may be no command line while redrawing */ if (ccline.cmdbuff == NULL) { ui_cursor_goto(cmdline_row, 0); @@ -3130,6 +3180,13 @@ static void cursorcmd(void) if (cmd_silent) return; + if (cmdline_external) { + Array args = ARRAY_DICT_INIT; + ADD(args, INTEGER_OBJ(ccline.cmdpos)); + ui_event("cmdline_pos", args); + return; + } + if (cmdmsg_rl) { msg_row = cmdline_row + (ccline.cmdspos / (int)(Columns - 1)); msg_col = (int)Columns - (ccline.cmdspos % (int)(Columns - 1)) - 1; @@ -5974,3 +6031,8 @@ static void set_search_match(pos_T *t) coladvance((colnr_T)MAXCOL); } } + +void cmdline_set_external(bool external) +{ + cmdline_external = external; +} diff --git a/src/nvim/ui.c b/src/nvim/ui.c index afe7a51d43..0fa4034ff6 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -30,6 +30,7 @@ #include "nvim/os/input.h" #include "nvim/os/signal.h" #include "nvim/popupmnu.h" +#include "nvim/ex_getln.h" #include "nvim/screen.h" #include "nvim/syntax.h" #include "nvim/window.h" @@ -280,6 +281,7 @@ void ui_refresh(void) int save_p_lz = p_lz; p_lz = false; // convince redrawing() to return true ... + cmdline_set_external(cmdline_external); screen_resize(width, height); p_lz = save_p_lz; -- cgit From 6e90bc7200c87f0af448a8cf0998715db9175f15 Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Thu, 23 Feb 2017 09:53:12 +0000 Subject: ext_cmdline: Added cmdline prompt --- src/nvim/eval.c | 18 +++++++++++------- src/nvim/ex_getln.c | 21 ++++++++++++++++----- 2 files changed, 27 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index aab777955c..72b97cbab9 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -11149,15 +11149,19 @@ void get_user_input(const typval_T *const argvars, // Only the part of the message after the last NL is considered as // prompt for the command line. const char *p = strrchr(prompt, '\n'); - if (p == NULL) { + if (ui_is_external(kUICmdline)) { p = prompt; } else { - p++; - msg_start(); - msg_clr_eos(); - msg_puts_attr_len(prompt, p - prompt, echo_attr); - msg_didout = false; - msg_starthere(); + if (p == NULL) { + p = prompt; + } else { + p++; + msg_start(); + msg_clr_eos(); + msg_puts_attr_len(prompt, p - prompt, echo_attr); + msg_didout = false; + msg_starthere(); + } } cmdline_row = msg_row; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 87bf46d4d0..a05331d13a 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3114,11 +3114,17 @@ static void redrawcmdprompt(void) } } if (ccline.cmdprompt != NULL) { - msg_puts_attr((const char *)ccline.cmdprompt, ccline.cmdattr); - ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns; - /* do the reverse of set_cmdspos() */ - if (ccline.cmdfirstc != NUL) - --ccline.cmdindent; + if (cmdline_external) { + Array args = ARRAY_DICT_INIT; + ADD(args, STRING_OBJ(cstr_to_string((char *)(ccline.cmdprompt)))); + ui_event("cmdline_prompt", args); + } else { + msg_puts_attr((const char *)ccline.cmdprompt, ccline.cmdattr); + ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns; + /* do the reverse of set_cmdspos() */ + if (ccline.cmdfirstc != NUL) + --ccline.cmdindent; + } } else for (i = ccline.cmdindent; i > 0; --i) msg_putchar(' '); @@ -6036,3 +6042,8 @@ void cmdline_set_external(bool external) { cmdline_external = external; } + +bool cmdline_get_external(void) +{ + return cmdline_external; +} -- cgit From 26fd70bd18283701a2ade11407694485cd0f7e35 Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Fri, 24 Feb 2017 07:26:39 +0000 Subject: ext_cmdline: add tests --- src/nvim/ex_getln.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index a05331d13a..18d6b26595 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -283,9 +283,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) if (!cmd_silent) { s->i = msg_scrolled; msg_scrolled = 0; // avoid wait_return message - if (!cmdline_external) { - gotocmdline(true); - } + gotocmdline(true); msg_scrolled += s->i; redrawcmdprompt(); // draw prompt or indent set_cmdspos(); @@ -808,7 +806,9 @@ static int command_line_execute(VimState *state, int key) } if (!cmd_silent) { - ui_cursor_goto(msg_row, 0); + if (!cmdline_external) { + ui_cursor_goto(msg_row, 0); + } ui_flush(); } return 0; @@ -3210,6 +3210,9 @@ static void cursorcmd(void) void gotocmdline(int clr) { + if (cmdline_external) { + return; + } msg_start(); if (cmdmsg_rl) msg_col = Columns - 1; -- cgit From b7a8a76f6e3b2de1cfdf32e3ccc66d87ab8e5cad Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Mon, 27 Feb 2017 02:56:38 +0000 Subject: ext_cmdline: lint --- src/nvim/ex_getln.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 18d6b26595..0fae6c9810 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3121,13 +3121,16 @@ static void redrawcmdprompt(void) } else { msg_puts_attr((const char *)ccline.cmdprompt, ccline.cmdattr); ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns; - /* do the reverse of set_cmdspos() */ - if (ccline.cmdfirstc != NUL) - --ccline.cmdindent; + // do the reverse of set_cmdspos() + if (ccline.cmdfirstc != NUL) { + ccline.cmdindent--; + } } - } else - for (i = ccline.cmdindent; i > 0; --i) + } else { + for (i = ccline.cmdindent; i > 0; i--) { msg_putchar(' '); + } + } } /* -- cgit From 550651c130c014e6c668644273db31dd96be475e Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Fri, 28 Apr 2017 06:51:16 +0100 Subject: ext_cmdline: use standard external ui functions --- src/nvim/eval.c | 15 +++----- src/nvim/ex_getln.c | 104 ++++++++++++++++++++++++---------------------------- src/nvim/ui.c | 1 - 3 files changed, 54 insertions(+), 66 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 72b97cbab9..3c9614dfcd 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -11147,15 +11147,12 @@ void get_user_input(const typval_T *const argvars, cmd_silent = false; // Want to see the prompt. // Only the part of the message after the last NL is considered as - // prompt for the command line. - const char *p = strrchr(prompt, '\n'); - if (ui_is_external(kUICmdline)) { - p = prompt; - } else { - if (p == NULL) { - p = prompt; - } else { - p++; + // prompt for the command line, unlsess cmdline is externalized + const char *p = prompt; + if (!ui_is_external(kUICmdline)) { + const char *lastnl = strrchr(prompt, '\n'); + if (lastnl != NULL) { + p = lastnl+1; msg_start(); msg_clr_eos(); msg_puts_attr_len(prompt, p - prompt, echo_attr); diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 0fae6c9810..8c9e081c89 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -185,8 +185,6 @@ static int cmd_showtail; /* Only show path tail in lists ? */ static int new_cmdpos; /* position set by set_cmdline_pos() */ -static bool cmdline_external = false; - /* * Type used by call_user_expand_func */ @@ -806,7 +804,7 @@ static int command_line_execute(VimState *state, int key) } if (!cmd_silent) { - if (!cmdline_external) { + if (!ui_is_external(kUICmdline)) { ui_cursor_goto(msg_row, 0); } ui_flush(); @@ -1832,12 +1830,12 @@ getcmdline ( int indent // indent for inside conditionals ) { - if (cmdline_external) { + if (ui_is_external(kUICmdline)) { Array args = ARRAY_DICT_INIT; ui_event("cmdline_enter", args); } char_u *p = command_line_enter(firstc, count, indent); - if (cmdline_external) { + if (ui_is_external(kUICmdline)) { Array args = ARRAY_DICT_INIT; ui_event("cmdline_leave", args); } @@ -2602,11 +2600,8 @@ static void draw_cmdline(int start, int len) return; } - if (cmdline_external) { - Array args = ARRAY_DICT_INIT; - ADD(args, STRING_OBJ(cstr_to_string((char *)(ccline.cmdbuff)))); - ADD(args, INTEGER_OBJ(ccline.cmdpos)); - ui_event("cmdline", args); + if (ui_is_external(kUICmdline)) { + ui_ext_cmdline_show(); return; } @@ -2725,6 +2720,32 @@ draw_cmdline_no_arabicshape: } } +void ui_ext_cmdline_char(int c, int shift) +{ + Array args = ARRAY_DICT_INIT; + ADD(args, STRING_OBJ(cstr_to_string((char *)(&c)))); + ADD(args, INTEGER_OBJ(shift)); + ui_event("cmdline_char", args); +} + +void ui_ext_cmdline_show(void) +{ + Array args = ARRAY_DICT_INIT; + ADD(args, STRING_OBJ(cstr_to_string((char *)(ccline.cmdbuff)))); + ADD(args, INTEGER_OBJ(ccline.cmdpos)); + if (ccline.cmdfirstc != NUL) { + ADD(args, STRING_OBJ(cstr_to_string((char *)(&ccline.cmdfirstc)))); + } else { + ADD(args, STRING_OBJ(cstr_to_string(""))); + } + if (ccline.cmdprompt != NULL) { + ADD(args, STRING_OBJ(cstr_to_string((char *)(ccline.cmdprompt)))); + } else { + ADD(args, STRING_OBJ(cstr_to_string(""))); + } + ui_event("cmdline_show", args); +} + /* * Put a character on the command line. Shifts the following text to the * right when "shift" is TRUE. Used for CTRL-V, CTRL-K, etc. @@ -2732,29 +2753,17 @@ draw_cmdline_no_arabicshape: */ void putcmdline(int c, int shift) { - if (cmd_silent) + if (cmd_silent) { return; - if (!cmdline_external) { + } + if (!ui_is_external(kUICmdline)) { msg_no_more = TRUE; msg_putchar(c); if (shift) draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos); msg_no_more = FALSE; } else { - char_u *p; - if (ccline.cmdpos == ccline.cmdlen || shift) { - p = vim_strnsave(ccline.cmdbuff, ccline.cmdlen + 1); - } else { - p = vim_strsave(ccline.cmdbuff); - } - p[ccline.cmdpos] = c; - if (shift) - STRCPY(p + ccline.cmdpos + 1, ccline.cmdbuff + ccline.cmdpos); - Array args = ARRAY_DICT_INIT; - ADD(args, STRING_OBJ(cstr_to_string((char *)(p)))); - ADD(args, INTEGER_OBJ(ccline.cmdpos)); - ui_event("cmdline", args); - xfree(p); + ui_ext_cmdline_char(c, shift); } cursorcmd(); ui_cursor_shape(); @@ -3104,27 +3113,19 @@ static void redrawcmdprompt(void) if (cmd_silent) return; + if (ui_is_external(kUICmdline)) { + ui_ext_cmdline_show(); + return; + } if (ccline.cmdfirstc != NUL) { - if (cmdline_external) { - Array args = ARRAY_DICT_INIT; - ADD(args, STRING_OBJ(cstr_to_string((char *)(&ccline.cmdfirstc)))); - ui_event("cmdline_firstc", args); - } else { - msg_putchar(ccline.cmdfirstc); - } + msg_putchar(ccline.cmdfirstc); } if (ccline.cmdprompt != NULL) { - if (cmdline_external) { - Array args = ARRAY_DICT_INIT; - ADD(args, STRING_OBJ(cstr_to_string((char *)(ccline.cmdprompt)))); - ui_event("cmdline_prompt", args); - } else { - msg_puts_attr((const char *)ccline.cmdprompt, ccline.cmdattr); - ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns; - // do the reverse of set_cmdspos() - if (ccline.cmdfirstc != NUL) { - ccline.cmdindent--; - } + msg_puts_attr((const char *)ccline.cmdprompt, ccline.cmdattr); + ccline.cmdindent = msg_col + (msg_row - cmdline_row) * Columns; + // do the reverse of set_cmdspos() + if (ccline.cmdfirstc != NUL) { + ccline.cmdindent--; } } else { for (i = ccline.cmdindent; i > 0; i--) { @@ -3141,7 +3142,7 @@ void redrawcmd(void) if (cmd_silent) return; - if (cmdline_external) { + if (ui_is_external(kUICmdline)) { draw_cmdline(0, ccline.cmdlen); return; } @@ -3189,7 +3190,7 @@ static void cursorcmd(void) if (cmd_silent) return; - if (cmdline_external) { + if (ui_is_external(kUICmdline)) { Array args = ARRAY_DICT_INIT; ADD(args, INTEGER_OBJ(ccline.cmdpos)); ui_event("cmdline_pos", args); @@ -3213,7 +3214,7 @@ static void cursorcmd(void) void gotocmdline(int clr) { - if (cmdline_external) { + if (ui_is_external(kUICmdline)) { return; } msg_start(); @@ -6044,12 +6045,3 @@ static void set_search_match(pos_T *t) } } -void cmdline_set_external(bool external) -{ - cmdline_external = external; -} - -bool cmdline_get_external(void) -{ - return cmdline_external; -} diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 0fa4034ff6..6b09f6e6db 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -281,7 +281,6 @@ void ui_refresh(void) int save_p_lz = p_lz; p_lz = false; // convince redrawing() to return true ... - cmdline_set_external(cmdline_external); screen_resize(width, height); p_lz = save_p_lz; -- cgit From daec81ab5179c7ce8e3813af556b1e2f05fc59c6 Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Fri, 28 Apr 2017 07:49:45 +0100 Subject: ext_cmdline: change the content format --- src/nvim/ex_getln.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 8c9e081c89..12f3f53c81 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2731,7 +2731,12 @@ void ui_ext_cmdline_char(int c, int shift) void ui_ext_cmdline_show(void) { Array args = ARRAY_DICT_INIT; - ADD(args, STRING_OBJ(cstr_to_string((char *)(ccline.cmdbuff)))); + Array content = ARRAY_DICT_INIT; + Array text = ARRAY_DICT_INIT; + ADD(text, STRING_OBJ(cstr_to_string("Normal"))); + ADD(text, STRING_OBJ(cstr_to_string((char *)(ccline.cmdbuff)))); + ADD(content, ARRAY_OBJ(text)); + ADD(args, ARRAY_OBJ(content)); ADD(args, INTEGER_OBJ(ccline.cmdpos)); if (ccline.cmdfirstc != NUL) { ADD(args, STRING_OBJ(cstr_to_string((char *)(&ccline.cmdfirstc)))); -- cgit From e164ba41c8460d4e5b2e7e2b929d8479a0310738 Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Thu, 11 May 2017 04:48:59 +0100 Subject: ext_cmdline: fix firstc, change cmdline_leave to cmdline_hide --- src/nvim/ex_getln.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 12f3f53c81..34547c59c9 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1837,7 +1837,7 @@ getcmdline ( char_u *p = command_line_enter(firstc, count, indent); if (ui_is_external(kUICmdline)) { Array args = ARRAY_DICT_INIT; - ui_event("cmdline_leave", args); + ui_event("cmdline_hide", args); } return p; } @@ -2738,16 +2738,13 @@ void ui_ext_cmdline_show(void) ADD(content, ARRAY_OBJ(text)); ADD(args, ARRAY_OBJ(content)); ADD(args, INTEGER_OBJ(ccline.cmdpos)); - if (ccline.cmdfirstc != NUL) { - ADD(args, STRING_OBJ(cstr_to_string((char *)(&ccline.cmdfirstc)))); - } else { - ADD(args, STRING_OBJ(cstr_to_string(""))); - } - if (ccline.cmdprompt != NULL) { - ADD(args, STRING_OBJ(cstr_to_string((char *)(ccline.cmdprompt)))); - } else { - ADD(args, STRING_OBJ(cstr_to_string(""))); - } + char *firstc = (char []) { (char)ccline.cmdfirstc }; + String str = (String) { + .data = xmemdupz(firstc, 1), + .size = 1 + }; + ADD(args, STRING_OBJ(str)); + ADD(args, STRING_OBJ(cstr_to_string((char *)(ccline.cmdprompt)))); ui_event("cmdline_show", args); } -- cgit From ab85999eb7c53e9d2b5bca5f8896ea11cb1df13e Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Thu, 11 May 2017 07:11:21 +0100 Subject: ext_cmdline: change to use ui_call --- src/nvim/api/ui_events.in.h | 11 +++++++++++ src/nvim/ex_getln.c | 27 +++++---------------------- 2 files changed, 16 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index 1b5d17584f..093251bb00 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -68,4 +68,15 @@ void popupmenu_select(Integer selected) void tabline_update(Tabpage current, Array tabs) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; +void cmdline_enter(void) + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; +void cmdline_show(Array content, Integer pos, String firstc, String prompt) + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; +void cmdline_pos(Integer pos) + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; +void cmdline_char(String c, Integer shift) + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; +void cmdline_hide(void) + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; + #endif // NVIM_API_UI_EVENTS_IN_H diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 34547c59c9..0223d9e936 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1831,13 +1831,11 @@ getcmdline ( ) { if (ui_is_external(kUICmdline)) { - Array args = ARRAY_DICT_INIT; - ui_event("cmdline_enter", args); + ui_call_cmdline_enter(); } char_u *p = command_line_enter(firstc, count, indent); if (ui_is_external(kUICmdline)) { - Array args = ARRAY_DICT_INIT; - ui_event("cmdline_hide", args); + ui_call_cmdline_hide(); } return p; } @@ -2720,32 +2718,19 @@ draw_cmdline_no_arabicshape: } } -void ui_ext_cmdline_char(int c, int shift) -{ - Array args = ARRAY_DICT_INIT; - ADD(args, STRING_OBJ(cstr_to_string((char *)(&c)))); - ADD(args, INTEGER_OBJ(shift)); - ui_event("cmdline_char", args); -} - void ui_ext_cmdline_show(void) { - Array args = ARRAY_DICT_INIT; Array content = ARRAY_DICT_INIT; Array text = ARRAY_DICT_INIT; ADD(text, STRING_OBJ(cstr_to_string("Normal"))); ADD(text, STRING_OBJ(cstr_to_string((char *)(ccline.cmdbuff)))); ADD(content, ARRAY_OBJ(text)); - ADD(args, ARRAY_OBJ(content)); - ADD(args, INTEGER_OBJ(ccline.cmdpos)); char *firstc = (char []) { (char)ccline.cmdfirstc }; String str = (String) { .data = xmemdupz(firstc, 1), .size = 1 }; - ADD(args, STRING_OBJ(str)); - ADD(args, STRING_OBJ(cstr_to_string((char *)(ccline.cmdprompt)))); - ui_event("cmdline_show", args); + ui_call_cmdline_show(content, ccline.cmdpos, str, cstr_to_string((char *)(ccline.cmdprompt))); } /* @@ -2765,7 +2750,7 @@ void putcmdline(int c, int shift) draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos); msg_no_more = FALSE; } else { - ui_ext_cmdline_char(c, shift); + ui_call_cmdline_char(cstr_to_string((char *)(&c)), shift); } cursorcmd(); ui_cursor_shape(); @@ -3193,9 +3178,7 @@ static void cursorcmd(void) return; if (ui_is_external(kUICmdline)) { - Array args = ARRAY_DICT_INIT; - ADD(args, INTEGER_OBJ(ccline.cmdpos)); - ui_event("cmdline_pos", args); + ui_call_cmdline_pos(ccline.cmdpos); return; } -- cgit From 866dadaf753ba3733feb8c22d7da47af757bd35c Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Thu, 11 May 2017 07:51:10 +0100 Subject: ext_cmdline: added cmdline level add cchar_to_string --- src/nvim/api/private/helpers.c | 16 ++++++++++++++++ src/nvim/api/ui_events.in.h | 11 ++++------- src/nvim/ex_getln.c | 40 ++++++++++++++++++---------------------- 3 files changed, 38 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index e736e29e2d..f00fbf69ea 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -667,6 +667,22 @@ tabpage_T *find_tab_by_handle(Tabpage tabpage, Error *err) return rv; } +/// Allocates a String consisting of a single char. Does not support multibyte +/// characters. The resulting string is also NUL-terminated, to facilitate +/// interoperating with code using C strings. +/// +/// @param char the char to convert +/// @return the resulting String, if the input char was NUL, an +/// empty String is returned +String cchar_to_string(char c) +{ + char buf[] = { c, NUL }; + return (String) { + .data = xmemdupz(buf, 1), + .size = (c != NUL) ? 1 : 0 + }; +} + /// Copies a C string into a String (binary safe string, characters + length). /// The resulting string is also NUL-terminated, to facilitate interoperating /// with code using C strings. diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index 093251bb00..17eefbe1d6 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -66,17 +66,14 @@ void popupmenu_hide(void) void popupmenu_select(Integer selected) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void tabline_update(Tabpage current, Array tabs) - FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; - -void cmdline_enter(void) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; -void cmdline_show(Array content, Integer pos, String firstc, String prompt) +void cmdline_show(Array content, Integer pos, String firstc, String prompt, Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; -void cmdline_pos(Integer pos) +void cmdline_pos(Integer pos, Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; -void cmdline_char(String c, Integer shift) +void cmdline_char(String c, Integer shift, Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; -void cmdline_hide(void) +void cmdline_hide(Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; #endif // NVIM_API_UI_EVENTS_IN_H diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 0223d9e936..548459a8ce 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -91,6 +91,7 @@ struct cmdline_info { int input_fn; // when TRUE Invoked for input() function unsigned prompt_id; ///< Prompt number, used to disable coloring on errors. Callback highlight_callback; ///< Callback used for coloring user input. + int level; // current cmdline level }; /// Last value of prompt_id, incremented when doing new prompt static unsigned last_prompt_id = 0; @@ -238,7 +239,9 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) cmd_hkmap = 0; } + // TODO(bfredl): can these be combined? ccline.prompt_id = last_prompt_id++; + ccline.level++; ccline.overstrike = false; // always start in insert mode clearpos(&s->match_end); s->save_cursor = curwin->w_cursor; // may be restored later @@ -414,6 +417,11 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) // Make ccline empty, getcmdline() may try to use it. ccline.cmdbuff = NULL; + + if (ui_is_external(kUICmdline)) { + ui_call_cmdline_hide(ccline.level); + } + ccline.level--; return p; } } @@ -1830,14 +1838,7 @@ getcmdline ( int indent // indent for inside conditionals ) { - if (ui_is_external(kUICmdline)) { - ui_call_cmdline_enter(); - } - char_u *p = command_line_enter(firstc, count, indent); - if (ui_is_external(kUICmdline)) { - ui_call_cmdline_hide(); - } - return p; + return command_line_enter(firstc, count, indent); } /// Get a command line with a prompt @@ -2720,17 +2721,12 @@ draw_cmdline_no_arabicshape: void ui_ext_cmdline_show(void) { - Array content = ARRAY_DICT_INIT; - Array text = ARRAY_DICT_INIT; - ADD(text, STRING_OBJ(cstr_to_string("Normal"))); - ADD(text, STRING_OBJ(cstr_to_string((char *)(ccline.cmdbuff)))); - ADD(content, ARRAY_OBJ(text)); - char *firstc = (char []) { (char)ccline.cmdfirstc }; - String str = (String) { - .data = xmemdupz(firstc, 1), - .size = 1 - }; - ui_call_cmdline_show(content, ccline.cmdpos, str, cstr_to_string((char *)(ccline.cmdprompt))); + Array content = ARRAY_DICT_INIT; + Array text = ARRAY_DICT_INIT; + ADD(text, STRING_OBJ(cstr_to_string("Normal"))); + ADD(text, STRING_OBJ(cstr_to_string((char *)(ccline.cmdbuff)))); + ADD(content, ARRAY_OBJ(text)); + ui_call_cmdline_show(content, ccline.cmdpos, cchar_to_string((char)ccline.cmdfirstc), cstr_to_string((char *)(ccline.cmdprompt)), ccline.level); } /* @@ -2750,7 +2746,7 @@ void putcmdline(int c, int shift) draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos); msg_no_more = FALSE; } else { - ui_call_cmdline_char(cstr_to_string((char *)(&c)), shift); + ui_call_cmdline_char(cchar_to_string((char)(c)), shift, ccline.level); } cursorcmd(); ui_cursor_shape(); @@ -3178,7 +3174,7 @@ static void cursorcmd(void) return; if (ui_is_external(kUICmdline)) { - ui_call_cmdline_pos(ccline.cmdpos); + ui_call_cmdline_pos(ccline.cmdpos, ccline.level); return; } @@ -3200,7 +3196,7 @@ static void cursorcmd(void) void gotocmdline(int clr) { if (ui_is_external(kUICmdline)) { - return; + return; } msg_start(); if (cmdmsg_rl) -- cgit From 461ae698242458bffbf5fb68de89fe8b2a3defd2 Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Mon, 26 Jun 2017 11:19:40 +0100 Subject: ext_cmdline: Add function block support --- src/nvim/api/ui_events.in.h | 4 ++++ src/nvim/eval.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index 17eefbe1d6..5602dc6df3 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -75,5 +75,9 @@ void cmdline_char(String c, Integer shift, Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_hide(Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; +void cmdline_function_show(void) + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; +void cmdline_function_hide(void) + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; #endif // NVIM_API_UI_EVENTS_IN_H diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 3c9614dfcd..d5ff01e922 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -19816,6 +19816,10 @@ void ex_function(exarg_T *eap) goto errret_2; } + if (ui_is_external(kUICmdline)) { + ui_call_cmdline_function_show(); + } + // find extra arguments "range", "dict", "abort" and "closure" for (;; ) { p = skipwhite(p); @@ -19868,7 +19872,9 @@ void ex_function(exarg_T *eap) if (!eap->skip && did_emsg) goto erret; - msg_putchar('\n'); /* don't overwrite the function name */ + if (!ui_is_external(kUICmdline)) { + msg_putchar('\n'); /* don't overwrite the function name */ + } cmdline_row = msg_row; } @@ -20194,6 +20200,9 @@ ret_free: xfree(name); did_emsg |= saved_did_emsg; need_wait_return |= saved_wait_return; + if (ui_is_external(kUICmdline)) { + ui_call_cmdline_function_hide(); + } } /// Get a function name, translating "" and "". -- cgit From fb389a6b4b1e6fedb559dc2e5845dd138e8ff264 Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Mon, 26 Jun 2017 15:27:49 +0100 Subject: ext_cmdline: added indent --- src/nvim/api/ui_events.in.h | 2 +- src/nvim/ex_getln.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index 5602dc6df3..700d99dc6b 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -67,7 +67,7 @@ void popupmenu_select(Integer selected) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void tabline_update(Tabpage current, Array tabs) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; -void cmdline_show(Array content, Integer pos, String firstc, String prompt, Integer level) +void cmdline_show(Array content, Integer pos, String firstc, String prompt, Integer indent, Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_pos(Integer pos, Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 548459a8ce..6f941e66ef 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2726,7 +2726,11 @@ void ui_ext_cmdline_show(void) ADD(text, STRING_OBJ(cstr_to_string("Normal"))); ADD(text, STRING_OBJ(cstr_to_string((char *)(ccline.cmdbuff)))); ADD(content, ARRAY_OBJ(text)); - ui_call_cmdline_show(content, ccline.cmdpos, cchar_to_string((char)ccline.cmdfirstc), cstr_to_string((char *)(ccline.cmdprompt)), ccline.level); + ui_call_cmdline_show(content, ccline.cmdpos, + cchar_to_string((char)ccline.cmdfirstc), + cstr_to_string((char *)(ccline.cmdprompt)), + ccline.cmdindent, + ccline.level); } /* -- cgit From 5ad591ef2d0ef184f78c728b1774c2a55fe2e581 Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Tue, 27 Jun 2017 02:20:27 +0100 Subject: ext_cmdline: lint --- src/nvim/api/ui_events.in.h | 17 +++++++++-------- src/nvim/eval.c | 2 +- src/nvim/ex_getln.c | 7 ++++--- 3 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index 700d99dc6b..bb1084c838 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -66,18 +66,19 @@ void popupmenu_hide(void) void popupmenu_select(Integer selected) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void tabline_update(Tabpage current, Array tabs) - FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; -void cmdline_show(Array content, Integer pos, String firstc, String prompt, Integer indent, Integer level) - FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; +void cmdline_show(Array content, Integer pos, String firstc, String prompt, + Integer indent, Integer level) + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_pos(Integer pos, Integer level) - FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_char(String c, Integer shift, Integer level) - FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_hide(Integer level) - FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_function_show(void) - FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_function_hide(void) - FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; #endif // NVIM_API_UI_EVENTS_IN_H diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d5ff01e922..5f655cdc7b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -19873,7 +19873,7 @@ void ex_function(exarg_T *eap) goto erret; if (!ui_is_external(kUICmdline)) { - msg_putchar('\n'); /* don't overwrite the function name */ + msg_putchar('\n'); // don't overwrite the function name } cmdline_row = msg_row; } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 6f941e66ef..93c060b4b7 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2744,11 +2744,12 @@ void putcmdline(int c, int shift) return; } if (!ui_is_external(kUICmdline)) { - msg_no_more = TRUE; + msg_no_more = true; msg_putchar(c); - if (shift) + if (shift) { draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos); - msg_no_more = FALSE; + } + msg_no_more = false; } else { ui_call_cmdline_char(cchar_to_string((char)(c)), shift, ccline.level); } -- cgit From 22402fb99d05191cf140293cfb5f67902e78a8a8 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Wed, 16 Aug 2017 12:19:29 +0200 Subject: ext_cmdline: add support for highlighting --- src/nvim/api/private/helpers.c | 17 +++++++++++++++++ src/nvim/ex_getln.c | 31 ++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index f00fbf69ea..2944925a9c 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -703,6 +703,23 @@ String cstr_to_string(const char *str) }; } +/// Copies buffer to an allocated String. +/// The resulting string is also NUL-terminated, to facilitate interoperating +/// with code using C strings. +/// +/// @param buf the buffer to copy +/// @param size length of the buffer +/// @return the resulting String, if the input string was NULL, an +/// empty String is returned +String cbuf_to_string(const char *buf, size_t size) + FUNC_ATTR_NONNULL_ALL +{ + return (String) { + .data = xmemdupz(buf, size), + .size = size + }; +} + /// Creates a String using the given C string. Unlike /// cstr_to_string this function DOES NOT copy the C string. /// diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 93c060b4b7..624a108bd4 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2372,6 +2372,7 @@ static bool color_cmdline(const CmdlineInfo *const colored_ccline, FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { bool printed_errmsg = false; + #define PRINT_ERRMSG(...) \ do { \ msg_putchar('\n'); \ @@ -2405,7 +2406,7 @@ static bool color_cmdline(const CmdlineInfo *const colored_ccline, static unsigned prev_prompt_id = UINT_MAX; static int prev_prompt_errors = 0; - Callback color_cb = { .type = kCallbackNone }; + Callback color_cb = CALLBACK_NONE; bool can_free_cb = false; TryState tstate; Error err = ERROR_INIT; @@ -2722,10 +2723,30 @@ draw_cmdline_no_arabicshape: void ui_ext_cmdline_show(void) { Array content = ARRAY_DICT_INIT; - Array text = ARRAY_DICT_INIT; - ADD(text, STRING_OBJ(cstr_to_string("Normal"))); - ADD(text, STRING_OBJ(cstr_to_string((char *)(ccline.cmdbuff)))); - ADD(content, ARRAY_OBJ(text)); + if (kv_size(last_ccline_colors.colors)) { + for (size_t i = 0; i < kv_size(last_ccline_colors.colors); i++) { + CmdlineColorChunk chunk = kv_A(last_ccline_colors.colors, i); + Array item = ARRAY_DICT_INIT; + + if (chunk.attr) { + attrentry_T *aep = syn_cterm_attr2entry(chunk.attr); + // TODO(bfredl): this desicion could be delayed by making attr_code a + // recognized type + HlAttrs rgb_attrs = attrentry2hlattrs(aep, true); + ADD(item, DICTIONARY_OBJ(hlattrs2dict(rgb_attrs))); + } else { + ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT)); + } + ADD(item, STRING_OBJ(cbuf_to_string((char *)ccline.cmdbuff + chunk.start, + chunk.end-chunk.start))); + ADD(content, ARRAY_OBJ(item)); + } + } else { + Array item = ARRAY_DICT_INIT; + ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT)); + ADD(item, STRING_OBJ(cstr_to_string((char *)(ccline.cmdbuff)))); + ADD(content, ARRAY_OBJ(item)); + } ui_call_cmdline_show(content, ccline.cmdpos, cchar_to_string((char)ccline.cmdfirstc), cstr_to_string((char *)(ccline.cmdprompt)), -- cgit From ddfc077da468450d1fab81fe3b3f594bb6ebf6dd Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Wed, 16 Aug 2017 13:36:02 +0200 Subject: ext_cmdline: disable some redraws --- src/nvim/ex_getln.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 624a108bd4..0e620e59d8 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -1144,7 +1144,7 @@ static int command_line_handle_key(CommandLineState *s) xfree(ccline.cmdbuff); // no commandline to return ccline.cmdbuff = NULL; - if (!cmd_silent) { + if (!cmd_silent && !ui_is_external(kUICmdline)) { if (cmdmsg_rl) { msg_col = Columns; } else { @@ -1596,9 +1596,14 @@ static int command_line_handle_key(CommandLineState *s) s->do_abbr = false; // don't do abbreviation now // may need to remove ^ when composing char was typed if (enc_utf8 && utf_iscomposing(s->c) && !cmd_silent) { - draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos); - msg_putchar(' '); - cursorcmd(); + if (ui_is_external(kUICmdline)) { + // TODO(bfredl): why not make unputcmdline also work with true? + unputcmdline(); + } else { + draw_cmdline(ccline.cmdpos, ccline.cmdlen - ccline.cmdpos); + msg_putchar(' '); + cursorcmd(); + } } break; @@ -2778,22 +2783,19 @@ void putcmdline(int c, int shift) ui_cursor_shape(); } -/* - * Undo a putcmdline(c, FALSE). - */ +/// Undo a putcmdline(c, FALSE). void unputcmdline(void) { - if (cmd_silent) + if (cmd_silent) { return; - msg_no_more = TRUE; - if (ccline.cmdlen == ccline.cmdpos) + } + msg_no_more = true; + if (ccline.cmdlen == ccline.cmdpos && !ui_is_external(kUICmdline)) { msg_putchar(' '); - else if (has_mbyte) - draw_cmdline(ccline.cmdpos, - (*mb_ptr2len)(ccline.cmdbuff + ccline.cmdpos)); - else - draw_cmdline(ccline.cmdpos, 1); - msg_no_more = FALSE; + } else { + draw_cmdline(ccline.cmdpos, mb_ptr2len(ccline.cmdbuff + ccline.cmdpos)); + } + msg_no_more = false; cursorcmd(); ui_cursor_shape(); } -- cgit From a68817f56517a31943806bd0b5a0030cdd35e182 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Wed, 16 Aug 2017 13:57:58 +0200 Subject: ext_cmdline: extend "function" to generic "block" mechanism --- src/nvim/api/ui_events.in.h | 7 +++++-- src/nvim/eval.c | 13 +++++++++---- src/nvim/ex_getln.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index bb1084c838..764078c6bd 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -67,6 +67,7 @@ void popupmenu_select(Integer selected) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void tabline_update(Tabpage current, Array tabs) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; + void cmdline_show(Array content, Integer pos, String firstc, String prompt, Integer indent, Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; @@ -76,9 +77,11 @@ void cmdline_char(String c, Integer shift, Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_hide(Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; -void cmdline_function_show(void) +void cmdline_block_show(Array lines) + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; +void cmdline_block_append(Array lines) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; -void cmdline_function_hide(void) +void cmdline_block_hide(void) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; #endif // NVIM_API_UI_EVENTS_IN_H diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 5f655cdc7b..50044718b6 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -19643,6 +19643,7 @@ void ex_function(exarg_T *eap) int todo; hashitem_T *hi; int sourcing_lnum_off; + bool show_block = false; /* * ":function" without argument: list functions. @@ -19816,8 +19817,9 @@ void ex_function(exarg_T *eap) goto errret_2; } - if (ui_is_external(kUICmdline)) { - ui_call_cmdline_function_show(); + if (KeyTyped && ui_is_external(kUICmdline)) { + show_block = true; + ui_ext_cmdline_block_append(0, (const char *)eap->cmd); } // find extra arguments "range", "dict", "abort" and "closure" @@ -19908,6 +19910,9 @@ void ex_function(exarg_T *eap) EMSG(_("E126: Missing :endfunction")); goto erret; } + if (show_block) { + ui_ext_cmdline_block_append(indent, (const char *)theline); + } /* Detect line continuation: sourcing_lnum increased more than one. */ if (sourcing_lnum > sourcing_lnum_off + 1) @@ -20200,8 +20205,8 @@ ret_free: xfree(name); did_emsg |= saved_did_emsg; need_wait_return |= saved_wait_return; - if (ui_is_external(kUICmdline)) { - ui_call_cmdline_function_hide(); + if (show_block) { + ui_ext_cmdline_block_leave(); } } diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 0e620e59d8..50cccc8d10 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -186,6 +186,8 @@ static int cmd_showtail; /* Only show path tail in lists ? */ static int new_cmdpos; /* position set by set_cmdline_pos() */ +static Array cmdline_block; ///< currently displayed block of context + /* * Type used by call_user_expand_func */ @@ -2759,6 +2761,32 @@ void ui_ext_cmdline_show(void) ccline.level); } +void ui_ext_cmdline_block_append(int indent, const char *line) +{ + char *buf = xmallocz(indent + strlen(line)); + memset(buf, ' ', indent); + memcpy(buf+indent, line, strlen(line)); + + Array item = ARRAY_DICT_INIT; + ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT)); + ADD(item, STRING_OBJ(cstr_as_string(buf))); + Array content = ARRAY_DICT_INIT; + ADD(content, ARRAY_OBJ(item)); + ADD(cmdline_block, ARRAY_OBJ(content)); + if (cmdline_block.size > 1) { + ui_call_cmdline_block_append(copy_array(content)); + } else { + ui_call_cmdline_block_show(copy_array(cmdline_block)); + } +} + +void ui_ext_cmdline_block_leave(void) +{ + api_free_array(cmdline_block); + ui_call_cmdline_block_hide(); +} + + /* * Put a character on the command line. Shifts the following text to the * right when "shift" is TRUE. Used for CTRL-V, CTRL-K, etc. -- cgit From f2aaa4ae8b84f74666b4379b391f333f34868a45 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Wed, 16 Aug 2017 15:38:12 +0200 Subject: ext_cmdline: rename cmdline_char to cmdline_special_char --- src/nvim/api/ui_events.in.h | 2 +- src/nvim/ex_getln.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index 764078c6bd..65357d008a 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -73,7 +73,7 @@ void cmdline_show(Array content, Integer pos, String firstc, String prompt, FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_pos(Integer pos, Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; -void cmdline_char(String c, Integer shift, Integer level) +void cmdline_special_char(String c, Boolean shift, Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void cmdline_hide(Integer level) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 50cccc8d10..b9cf7b977c 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2805,7 +2805,8 @@ void putcmdline(int c, int shift) } msg_no_more = false; } else { - ui_call_cmdline_char(cchar_to_string((char)(c)), shift, ccline.level); + ui_call_cmdline_special_char(cchar_to_string((char)(c)), shift, + ccline.level); } cursorcmd(); ui_cursor_shape(); -- cgit From 2050e6604632e190a04d52829f4469f1ef7f7018 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 20 Aug 2017 16:30:09 +0200 Subject: ext_cmdline: turn nested cmdlines into a linked list --- src/nvim/ex_getln.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index b9cf7b977c..2ac9ecdc2b 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -92,6 +92,7 @@ struct cmdline_info { unsigned prompt_id; ///< Prompt number, used to disable coloring on errors. Callback highlight_callback; ///< Callback used for coloring user input. int level; // current cmdline level + struct cmdline_info *prev_ccline; ///< pointer to saved cmdline state }; /// Last value of prompt_id, incremented when doing new prompt static unsigned last_prompt_id = 0; @@ -2958,9 +2959,6 @@ void put_on_cmdline(char_u *str, int len, int redraw) msg_check(); } -static struct cmdline_info prev_ccline; -static int prev_ccline_used = FALSE; - /* * Save ccline, because obtaining the "=" register may execute "normal :cmd" * and overwrite it. But get_cmdline_str() may need it, thus make it @@ -2968,12 +2966,8 @@ static int prev_ccline_used = FALSE; */ static void save_cmdline(struct cmdline_info *ccp) { - if (!prev_ccline_used) { - memset(&prev_ccline, 0, sizeof(struct cmdline_info)); - prev_ccline_used = TRUE; - } - *ccp = prev_ccline; - prev_ccline = ccline; + *ccp = ccline; + ccline.prev_ccline = ccp; ccline.cmdbuff = NULL; ccline.cmdprompt = NULL; ccline.xpc = NULL; @@ -2984,8 +2978,7 @@ static void save_cmdline(struct cmdline_info *ccp) */ static void restore_cmdline(struct cmdline_info *ccp) { - ccline = prev_ccline; - prev_ccline = *ccp; + ccline = *ccp; } /* @@ -5312,13 +5305,15 @@ int get_history_idx(int histype) */ static struct cmdline_info *get_ccline_ptr(void) { - if ((State & CMDLINE) == 0) + if ((State & CMDLINE) == 0) { return NULL; - if (ccline.cmdbuff != NULL) + } else if (ccline.cmdbuff != NULL) { return &ccline; - if (prev_ccline_used && prev_ccline.cmdbuff != NULL) - return &prev_ccline; - return NULL; + } else if (ccline.prev_ccline && ccline.prev_ccline->cmdbuff != NULL) { + return ccline.prev_ccline; + } else { + return NULL; + } } /* -- cgit From bed0a3a8428027af32602ccb169e81767c55e257 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 20 Aug 2017 17:47:42 +0200 Subject: ext_cmdline: implement redraw! --- src/nvim/ex_getln.c | 166 +++++++++++++++++++++++++++++++--------------------- src/nvim/screen.c | 5 +- 2 files changed, 102 insertions(+), 69 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 2ac9ecdc2b..933aea7b93 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -67,6 +67,30 @@ #include "nvim/api/private/helpers.h" #include "nvim/highlight_defs.h" +/// Command-line colors: one chunk +/// +/// Defines a region which has the same highlighting. +typedef struct { + int start; ///< Colored chunk start. + int end; ///< Colored chunk end (exclusive, > start). + int attr; ///< Highlight attr. +} CmdlineColorChunk; + +/// Command-line colors +/// +/// Holds data about all colors. +typedef kvec_t(CmdlineColorChunk) CmdlineColors; + +/// Command-line coloring +/// +/// Holds both what are the colors and what have been colored. Latter is used to +/// suppress unnecessary calls to coloring callbacks. +typedef struct { + unsigned prompt_id; ///< ID of the prompt which was colored last. + char *cmdbuff; ///< What exactly was colored last time or NULL. + CmdlineColors colors; ///< Last colors. +} ColoredCmdline; + /* * Variables shared between getcmdline(), redrawcmdline() and others. * These need to be saved when using CTRL-R |, that's why they are in a @@ -91,8 +115,11 @@ struct cmdline_info { int input_fn; // when TRUE Invoked for input() function unsigned prompt_id; ///< Prompt number, used to disable coloring on errors. Callback highlight_callback; ///< Callback used for coloring user input. + ColoredCmdline last_colors; ///< Last cmdline colors int level; // current cmdline level struct cmdline_info *prev_ccline; ///< pointer to saved cmdline state + char special_char; ///< last putcmdline char (used for redraws) + bool special_shift; ///< shift of last putcmdline char }; /// Last value of prompt_id, incremented when doing new prompt static unsigned last_prompt_id = 0; @@ -145,36 +172,6 @@ typedef struct command_line_state { struct cmdline_info save_ccline; } CommandLineState; -/// Command-line colors: one chunk -/// -/// Defines a region which has the same highlighting. -typedef struct { - int start; ///< Colored chunk start. - int end; ///< Colored chunk end (exclusive, > start). - int attr; ///< Highlight attr. -} CmdlineColorChunk; - -/// Command-line colors -/// -/// Holds data about all colors. -typedef kvec_t(CmdlineColorChunk) CmdlineColors; - -/// Command-line coloring -/// -/// Holds both what are the colors and what have been colored. Latter is used to -/// suppress unnecessary calls to coloring callbacks. -typedef struct { - unsigned prompt_id; ///< ID of the prompt which was colored last. - char *cmdbuff; ///< What exactly was colored last time or NULL. - CmdlineColors colors; ///< Last colors. -} ColoredCmdline; - -/// Last command-line colors. -ColoredCmdline last_ccline_colors = { - .cmdbuff = NULL, - .colors = KV_INITIAL_VALUE -}; - typedef struct cmdline_info CmdlineInfo; /* The current cmdline_info. It is initialized in getcmdline() and after that @@ -242,7 +239,6 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) cmd_hkmap = 0; } - // TODO(bfredl): can these be combined? ccline.prompt_id = last_prompt_id++; ccline.level++; ccline.overstrike = false; // always start in insert mode @@ -264,6 +260,9 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) ccline.cmdlen = ccline.cmdpos = 0; ccline.cmdbuff[0] = NUL; + ccline.last_colors = (ColoredCmdline){ .cmdbuff = NULL, + .colors = KV_INITIAL_VALUE }; + // autoindent for :insert and :append if (s->firstc <= 0) { memset(ccline.cmdbuff, ' ', s->indent); @@ -414,6 +413,8 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) setmouse(); ui_cursor_shape(); // may show different cursor shape xfree(s->save_p_icm); + xfree(ccline.last_colors.cmdbuff); + kv_destroy(ccline.last_colors.colors); { char_u *p = ccline.cmdbuff; @@ -2364,8 +2365,7 @@ enum { MAX_CB_ERRORS = 1 }; /// Should use built-in command parser or user-specified one. Currently only the /// latter is supported. /// -/// @param[in] colored_ccline Command-line to color. -/// @param[out] ret_ccline_colors What should be colored. Also holds a cache: +/// @param[in,out] colored_ccline Command-line to color. Also holds a cache: /// if ->prompt_id and ->cmdbuff values happen /// to be equal to those from colored_cmdline it /// will just do nothing, assuming that ->colors @@ -2375,8 +2375,7 @@ enum { MAX_CB_ERRORS = 1 }; /// /// @return true if draw_cmdline may proceed, false if it does not need anything /// to do. -static bool color_cmdline(const CmdlineInfo *const colored_ccline, - ColoredCmdline *const ret_ccline_colors) +static bool color_cmdline(CmdlineInfo *colored_ccline) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { bool printed_errmsg = false; @@ -2389,19 +2388,21 @@ static bool color_cmdline(const CmdlineInfo *const colored_ccline, } while (0) bool ret = true; + ColoredCmdline *ccline_colors = &colored_ccline->last_colors; + // Check whether result of the previous call is still valid. - if (ret_ccline_colors->prompt_id == colored_ccline->prompt_id - && ret_ccline_colors->cmdbuff != NULL - && STRCMP(ret_ccline_colors->cmdbuff, colored_ccline->cmdbuff) == 0) { + if (ccline_colors->prompt_id == colored_ccline->prompt_id + && ccline_colors->cmdbuff != NULL + && STRCMP(ccline_colors->cmdbuff, colored_ccline->cmdbuff) == 0) { return ret; } - kv_size(ret_ccline_colors->colors) = 0; + kv_size(ccline_colors->colors) = 0; if (colored_ccline->cmdbuff == NULL || *colored_ccline->cmdbuff == NUL) { // Nothing to do, exiting. - xfree(ret_ccline_colors->cmdbuff); - ret_ccline_colors->cmdbuff = NULL; + xfree(ccline_colors->cmdbuff); + ccline_colors->cmdbuff = NULL; return ret; } @@ -2523,7 +2524,7 @@ static bool color_cmdline(const CmdlineInfo *const colored_ccline, goto color_cmdline_error; } if (start != prev_end) { - kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) { + kv_push(ccline_colors->colors, ((CmdlineColorChunk) { .start = prev_end, .end = start, .attr = 0, @@ -2552,14 +2553,14 @@ static bool color_cmdline(const CmdlineInfo *const colored_ccline, } const int id = syn_name2id((char_u *)group); const int attr = (id == 0 ? 0 : syn_id2attr(id)); - kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) { + kv_push(ccline_colors->colors, ((CmdlineColorChunk) { .start = start, .end = end, .attr = attr, })); } if (prev_end < colored_ccline->cmdlen) { - kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) { + kv_push(ccline_colors->colors, ((CmdlineColorChunk) { .start = prev_end, .end = colored_ccline->cmdlen, .attr = 0, @@ -2571,14 +2572,14 @@ color_cmdline_end: if (can_free_cb) { callback_free(&color_cb); } - xfree(ret_ccline_colors->cmdbuff); + xfree(ccline_colors->cmdbuff); // Note: errors “output†is cached just as well as regular results. - ret_ccline_colors->prompt_id = colored_ccline->prompt_id; + ccline_colors->prompt_id = colored_ccline->prompt_id; if (arg_allocated) { - ret_ccline_colors->cmdbuff = (char *)arg.vval.v_string; + ccline_colors->cmdbuff = (char *)arg.vval.v_string; } else { - ret_ccline_colors->cmdbuff = xmemdupz((const char *)colored_ccline->cmdbuff, - (size_t)colored_ccline->cmdlen); + ccline_colors->cmdbuff = xmemdupz((const char *)colored_ccline->cmdbuff, + (size_t)colored_ccline->cmdlen); } tv_clear(&tv); return ret; @@ -2591,7 +2592,7 @@ color_cmdline_error: (void)printed_errmsg; prev_prompt_errors++; - kv_size(ret_ccline_colors->colors) = 0; + kv_size(ccline_colors->colors) = 0; redrawcmdline(); ret = false; goto color_cmdline_end; @@ -2604,12 +2605,13 @@ color_cmdline_error: */ static void draw_cmdline(int start, int len) { - if (!color_cmdline(&ccline, &last_ccline_colors)) { + if (!color_cmdline(&ccline)) { return; } if (ui_is_external(kUICmdline)) { - ui_ext_cmdline_show(); + ccline.special_char = NUL; + ui_ext_cmdline_show(&ccline); return; } @@ -2711,9 +2713,9 @@ static void draw_cmdline(int start, int len) msg_outtrans_len(arshape_buf, newlen); } else { draw_cmdline_no_arabicshape: - if (kv_size(last_ccline_colors.colors)) { - for (size_t i = 0; i < kv_size(last_ccline_colors.colors); i++) { - CmdlineColorChunk chunk = kv_A(last_ccline_colors.colors, i); + if (kv_size(ccline.last_colors.colors)) { + for (size_t i = 0; i < kv_size(ccline.last_colors.colors); i++) { + CmdlineColorChunk chunk = kv_A(ccline.last_colors.colors, i); if (chunk.end <= start) { continue; } @@ -2728,12 +2730,12 @@ draw_cmdline_no_arabicshape: } } -void ui_ext_cmdline_show(void) +static void ui_ext_cmdline_show(CmdlineInfo *line) { Array content = ARRAY_DICT_INIT; - if (kv_size(last_ccline_colors.colors)) { - for (size_t i = 0; i < kv_size(last_ccline_colors.colors); i++) { - CmdlineColorChunk chunk = kv_A(last_ccline_colors.colors, i); + if (kv_size(line->last_colors.colors)) { + for (size_t i = 0; i < kv_size(line->last_colors.colors); i++) { + CmdlineColorChunk chunk = kv_A(line->last_colors.colors, i); Array item = ARRAY_DICT_INIT; if (chunk.attr) { @@ -2745,21 +2747,26 @@ void ui_ext_cmdline_show(void) } else { ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT)); } - ADD(item, STRING_OBJ(cbuf_to_string((char *)ccline.cmdbuff + chunk.start, + ADD(item, STRING_OBJ(cbuf_to_string((char *)line->cmdbuff + chunk.start, chunk.end-chunk.start))); ADD(content, ARRAY_OBJ(item)); } } else { Array item = ARRAY_DICT_INIT; ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT)); - ADD(item, STRING_OBJ(cstr_to_string((char *)(ccline.cmdbuff)))); + ADD(item, STRING_OBJ(cstr_to_string((char *)(line->cmdbuff)))); ADD(content, ARRAY_OBJ(item)); } - ui_call_cmdline_show(content, ccline.cmdpos, - cchar_to_string((char)ccline.cmdfirstc), - cstr_to_string((char *)(ccline.cmdprompt)), - ccline.cmdindent, - ccline.level); + ui_call_cmdline_show(content, line->cmdpos, + cchar_to_string((char)line->cmdfirstc), + cstr_to_string((char *)(line->cmdprompt)), + line->cmdindent, + line->level); + if (line->special_char) { + ui_call_cmdline_special_char(cchar_to_string((char)(line->special_char)), + line->special_shift, + line->level); + } } void ui_ext_cmdline_block_append(int indent, const char *line) @@ -2787,6 +2794,28 @@ void ui_ext_cmdline_block_leave(void) ui_call_cmdline_block_hide(); } +/// Extra redrawing needed for redraw! and on ui_attach +/// assumes "redrawcmdline()" will already be invoked +void cmdline_screen_cleared(void) +{ + if (!ui_is_external(kUICmdline)) { + return; + } + + if (cmdline_block.size) { + ui_call_cmdline_block_show(copy_array(cmdline_block)); + } + + int prev_level = ccline.level-1; + CmdlineInfo *prev_ccline = ccline.prev_ccline; + while (prev_level > 0 && prev_ccline) { + if (prev_ccline->level == prev_level) { + ui_ext_cmdline_show(prev_ccline); + prev_level--; + } + prev_ccline = prev_ccline->prev_ccline; + } +} /* * Put a character on the command line. Shifts the following text to the @@ -2806,6 +2835,8 @@ void putcmdline(int c, int shift) } msg_no_more = false; } else { + ccline.special_char = c; + ccline.special_shift = shift; ui_call_cmdline_special_char(cchar_to_string((char)(c)), shift, ccline.level); } @@ -2971,6 +3002,7 @@ static void save_cmdline(struct cmdline_info *ccp) ccline.cmdbuff = NULL; ccline.cmdprompt = NULL; ccline.xpc = NULL; + ccline.special_char = NUL; } /* @@ -3147,7 +3179,7 @@ static void redrawcmdprompt(void) if (cmd_silent) return; if (ui_is_external(kUICmdline)) { - ui_ext_cmdline_show(); + ui_ext_cmdline_show(&ccline); return; } if (ccline.cmdfirstc != NUL) { diff --git a/src/nvim/screen.c b/src/nvim/screen.c index f5730cf70a..0f47103a84 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -345,8 +345,9 @@ void update_screen(int type) if (need_highlight_changed) highlight_changed(); - if (type == CLEAR) { /* first clear screen */ - screenclear(); /* will reset clear_cmdline */ + if (type == CLEAR) { // first clear screen + screenclear(); // will reset clear_cmdline + cmdline_screen_cleared(); // clear external cmdline state type = NOT_VALID; } -- cgit From 91d8e26bc7471378b8005b8843182dc1af90d81a Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 27 Aug 2017 09:57:30 +0200 Subject: ext_cmdline: interact with cmdline window --- src/nvim/ex_getln.c | 10 +++++++++- src/nvim/globals.h | 7 ++++--- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 933aea7b93..bcc8d598db 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2810,7 +2810,10 @@ void cmdline_screen_cleared(void) CmdlineInfo *prev_ccline = ccline.prev_ccline; while (prev_level > 0 && prev_ccline) { if (prev_ccline->level == prev_level) { - ui_ext_cmdline_show(prev_ccline); + // don't redraw a cmdline already shown in the cmdline window + if (prev_level != cmdwin_level) { + ui_ext_cmdline_show(prev_ccline); + } prev_level--; } prev_ccline = prev_ccline->prev_ccline; @@ -5781,6 +5784,7 @@ static int ex_window(void) return K_IGNORE; } cmdwin_type = get_cmdline_type(); + cmdwin_level = ccline.level; // Create empty command-line buffer. buf_open_scratch(0, "[Command Line]"); @@ -5833,6 +5837,9 @@ static int ex_window(void) curwin->w_cursor.col = ccline.cmdpos; changed_line_abv_curs(); invalidate_botline(); + if (ui_is_external(kUICmdline)) { + ui_call_cmdline_hide(ccline.level); + } redraw_later(SOME_VALID); // Save the command line info, can be used recursively. @@ -5875,6 +5882,7 @@ static int ex_window(void) // Restore the command line info. restore_cmdline(&save_ccline); cmdwin_type = 0; + cmdwin_level = 0; exmode_active = save_exmode; diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 300e506854..f24286360a 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -981,9 +981,10 @@ EXTERN int fill_diff INIT(= '-'); EXTERN int km_stopsel INIT(= FALSE); EXTERN int km_startsel INIT(= FALSE); -EXTERN int cedit_key INIT(= -1); /* key value of 'cedit' option */ -EXTERN int cmdwin_type INIT(= 0); /* type of cmdline window or 0 */ -EXTERN int cmdwin_result INIT(= 0); /* result of cmdline window or 0 */ +EXTERN int cedit_key INIT(= -1); ///< key value of 'cedit' option +EXTERN int cmdwin_type INIT(= 0); ///< type of cmdline window or 0 +EXTERN int cmdwin_result INIT(= 0); ///< result of cmdline window or 0 +EXTERN int cmdwin_level INIT(= 0); ///< cmdline level of cmdline window or 0 EXTERN char_u no_lines_msg[] INIT(= N_("--No lines in buffer--")); -- cgit From 445f25998c66ee7e4dc5bbfeed4108818e439b92 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Wed, 30 Aug 2017 08:51:39 +0200 Subject: ext_cmdline: fix inputsecret() --- src/nvim/ex_getln.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index bcc8d598db..e79476ab53 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2733,7 +2733,18 @@ draw_cmdline_no_arabicshape: static void ui_ext_cmdline_show(CmdlineInfo *line) { Array content = ARRAY_DICT_INIT; - if (kv_size(line->last_colors.colors)) { + if (cmdline_star) { + size_t len = 0; + for (char_u *p = ccline.cmdbuff; *p; mb_ptr_adv(p)) { + len++; + } + char *buf = xmallocz(len); + memset(buf, '*', len); + Array item = ARRAY_DICT_INIT; + ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT)); + ADD(item, STRING_OBJ(((String) { .data = buf, .size = len }))); + ADD(content, ARRAY_OBJ(item)); + } else if (kv_size(line->last_colors.colors)) { for (size_t i = 0; i < kv_size(line->last_colors.colors); i++) { CmdlineColorChunk chunk = kv_A(line->last_colors.colors, i); Array item = ARRAY_DICT_INIT; -- cgit From aab16e6939a45b3c08f21cd4b5f348e9e612d947 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Fri, 27 Oct 2017 09:41:41 +0800 Subject: vim-patch:8.0.0189 Problem: There are no tests for the :profile command. Solution: Add tests. (Dominique Pelle, closes vim/vim#1383) https://github.com/vim/vim/commit/296b1f28ca9cedeb55872f306808b2214b519ce7 --- src/nvim/testdir/Makefile | 1 + src/nvim/testdir/test_profile.vim | 135 ++++++++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 src/nvim/testdir/test_profile.vim (limited to 'src') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 38caa8815d..fb68292c77 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -62,6 +62,7 @@ NEW_TESTS ?= \ test_mksession_utf8.res \ test_nested_function.res \ test_normal.res \ + test_profile.res \ test_quickfix.res \ test_search.res \ test_signs.res \ diff --git a/src/nvim/testdir/test_profile.vim b/src/nvim/testdir/test_profile.vim new file mode 100644 index 0000000000..36c05683d5 --- /dev/null +++ b/src/nvim/testdir/test_profile.vim @@ -0,0 +1,135 @@ +" Test Vim profiler +if !has('profile') + finish +endif + +func Test_profile_func() + if !has('unix') + return + endif + let lines = [ + \ "func! Foo1()", + \ "endfunc", + \ "func! Foo2()", + \ " let count = 100", + \ " while count > 0", + \ " let count = count - 1", + \ " endwhile", + \ "endfunc", + \ "func! Foo3()", + \ "endfunc", + \ "func! Bar()", + \ "endfunc", + \ "call Foo1()", + \ "call Foo1()", + \ "profile pause", + \ "call Foo1()", + \ "profile continue", + \ "call Foo2()", + \ "call Foo3()", + \ "call Bar()", + \ "if !v:profiling", + \ " delfunc Foo2", + \ "endif", + \ "delfunc Foo3", + \ ] + + call writefile(lines, 'Xprofile_func.vim') + let a = system(v:progpath + \ . " -u NONE -i NONE --noplugin" + \ . " -c 'profile start Xprofile_func.log'" + \ . " -c 'profile func Foo*'" + \ . " -c 'so Xprofile_func.vim'" + \ . " -c 'qall!'") + let lines = readfile('Xprofile_func.log') + + call assert_equal(28, len(lines)) + + call assert_equal('FUNCTION Foo1()', lines[0]) + call assert_equal('Called 2 times', lines[1]) + call assert_equal('FUNCTION Foo2()', lines[7]) + call assert_equal('Called 1 time', lines[8]) + + " - Foo1() is called 3 times but should be reported as called twice + " since one call is in between "profile pause" .. "profile continue". + " - Foo2() should come before Foo1() since Foo1() does much more work.\ + " - Foo3() is not reported because function is deleted. + " - Unlike Foo3(), Foo2() should not be deleted since there is a check + " for v:profiling. + " - Bar() is not reported since it does not match "profile func Foo*". + call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[18]) + call assert_equal('count total (s) self (s) function', lines[19]) + call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[20]) + call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[21]) + call assert_equal('', lines[22]) + call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[23]) + call assert_equal('count total (s) self (s) function', lines[24]) + call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[25]) + call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[26]) + call assert_equal('', lines[27]) + + call delete('Xprofile_func.vim') + call delete('Xprofile_func.log') +endfunc + +func Test_profile_file() + if !has('unix') + return + endif + let lines = [ + \ 'func! Foo()', + \ 'endfunc', + \ 'for i in range(10)', + \ ' " a comment', + \ ' call Foo()', + \ 'endfor', + \ 'call Foo()', + \ ] + + call writefile(lines, 'Xprofile_file.vim') + let a = system(v:progpath + \ . " -u NONE -i NONE --noplugin" + \ . " -c 'profile start Xprofile_file.log'" + \ . " -c 'profile file Xprofile_file.vim'" + \ . " -c 'so Xprofile_file.vim'" + \ . " -c 'so Xprofile_file.vim'" + \ . " -c 'qall!'") + + let lines = readfile('Xprofile_file.log') + + call assert_equal(14, len(lines)) + + call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0]) + call assert_equal('Sourced 2 times', lines[1]) + call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2]) + call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3]) + call assert_equal('', lines[4]) + call assert_equal('count total (s) self (s)', lines[5]) + call assert_equal(' func! Foo()', lines[6]) + call assert_equal(' endfunc', lines[7]) + " Loop iterates 10 times. Since script runs twice, body executes 20 times. + " First line of loop executes one more time than body to detect end of loop. + call assert_match('^\s*22\s\+\d\+\.\d\+\s\+for i in range(10)$', lines[8]) + call assert_equal(' " a comment', lines[9]) + call assert_match('^\s*20\s\+\d\+\.\d\+\s\+\d\+\.\d\+\s\+call Foo()$', lines[10]) + call assert_match('^\s*20\s\+\d\+\.\d\+\s\+endfor$', lines[11]) + call assert_match('^\s*2\s\+\d\+\.\d\+\s\+\d\+\.\d\+\s\+call Foo()$', lines[12]) + call assert_equal('', lines[13]) + + call delete('Xprofile_file.vim') + call delete('Xprofile_file.log') +endfunc + +func Test_profile_completion() + call feedkeys(":profile \\\"\", 'tx') + call assert_equal('"profile continue file func pause start', @:) + + call feedkeys(":profile start test_prof\\\"\", 'tx') + call assert_match('^"profile start.* test_profile\.vim', @:) +endfunc + +func Test_profile_errors() + call assert_fails("profile func Foo", 'E750:') + call assert_fails("profile pause", 'E750:') + call assert_fails("profile continue", 'E750:') +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 6f3ca12458..3e4d51d70c 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -915,7 +915,7 @@ static const int included_patches[] = { // 192 NA // 191 NA 190, - // 189, + 189, 188, // 187 NA 186, -- cgit From 2bd424c1c5493f3311239a2c0932dd9ff6fac5a5 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Fri, 27 Oct 2017 09:48:22 +0800 Subject: vim-patch:8.0.0194 Problem: Profile tests fails if total and self time are equal. Solution: Make one time optional. https://github.com/vim/vim/commit/e32bbded641a5da0263ecf82f9ccc95a8e0a089e --- src/nvim/testdir/test_profile.vim | 3 ++- src/nvim/version.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_profile.vim b/src/nvim/testdir/test_profile.vim index 36c05683d5..23d148e47d 100644 --- a/src/nvim/testdir/test_profile.vim +++ b/src/nvim/testdir/test_profile.vim @@ -113,7 +113,8 @@ func Test_profile_file() call assert_equal(' " a comment', lines[9]) call assert_match('^\s*20\s\+\d\+\.\d\+\s\+\d\+\.\d\+\s\+call Foo()$', lines[10]) call assert_match('^\s*20\s\+\d\+\.\d\+\s\+endfor$', lines[11]) - call assert_match('^\s*2\s\+\d\+\.\d\+\s\+\d\+\.\d\+\s\+call Foo()$', lines[12]) + " if self and total are equal we only get one number + call assert_match('^\s*2\s\+\(\d\+\.\d\+\s\+\)\=\d\+\.\d\+\s\+call Foo()$', lines[12]) call assert_equal('', lines[13]) call delete('Xprofile_file.vim') diff --git a/src/nvim/version.c b/src/nvim/version.c index 3e4d51d70c..7c2cb4d580 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -910,7 +910,7 @@ static const int included_patches[] = { // 197, // 196, 195, - // 194, + 194, // 193 NA // 192 NA // 191 NA -- cgit From 45a95a8a5b75473bf9d8f707ed10794ae4ae1528 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Fri, 27 Oct 2017 09:49:36 +0800 Subject: vim-patch:8.0.0196 Problem: The test for :profile is slow and does not work on MS-Windows. Solution: Use the "-es" argument. (Dominique Pelle) Swap single and double quotes for system() https://github.com/vim/vim/commit/c011a3d083001bcd9853b4447422f1819f3cee2f --- src/nvim/testdir/test_profile.vim | 90 ++++++++++++++++++++++----------------- src/nvim/version.c | 2 +- 2 files changed, 51 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_profile.vim b/src/nvim/testdir/test_profile.vim index 23d148e47d..5f15d51b47 100644 --- a/src/nvim/testdir/test_profile.vim +++ b/src/nvim/testdir/test_profile.vim @@ -4,16 +4,13 @@ if !has('profile') endif func Test_profile_func() - if !has('unix') - return - endif let lines = [ \ "func! Foo1()", \ "endfunc", \ "func! Foo2()", - \ " let count = 100", - \ " while count > 0", - \ " let count = count - 1", + \ " let l:count = 100", + \ " while l:count > 0", + \ " let l:count = l:count - 1", \ " endwhile", \ "endfunc", \ "func! Foo3()", @@ -35,47 +32,59 @@ func Test_profile_func() \ ] call writefile(lines, 'Xprofile_func.vim') - let a = system(v:progpath - \ . " -u NONE -i NONE --noplugin" - \ . " -c 'profile start Xprofile_func.log'" - \ . " -c 'profile func Foo*'" - \ . " -c 'so Xprofile_func.vim'" - \ . " -c 'qall!'") - let lines = readfile('Xprofile_func.log') - - call assert_equal(28, len(lines)) + call system(v:progpath + \ . ' -es -u NONE -U NONE -i NONE --noplugin' + \ . ' -c "profile start Xprofile_func.log"' + \ . ' -c "profile func Foo*"' + \ . ' -c "so Xprofile_func.vim"' + \ . ' -c "qall!"') + call assert_equal(0, v:shell_error) - call assert_equal('FUNCTION Foo1()', lines[0]) - call assert_equal('Called 2 times', lines[1]) - call assert_equal('FUNCTION Foo2()', lines[7]) - call assert_equal('Called 1 time', lines[8]) + let lines = readfile('Xprofile_func.log') " - Foo1() is called 3 times but should be reported as called twice " since one call is in between "profile pause" .. "profile continue". - " - Foo2() should come before Foo1() since Foo1() does much more work.\ + " - Foo2() should come before Foo1() since Foo1() does much more work. " - Foo3() is not reported because function is deleted. " - Unlike Foo3(), Foo2() should not be deleted since there is a check " for v:profiling. " - Bar() is not reported since it does not match "profile func Foo*". - call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[18]) - call assert_equal('count total (s) self (s) function', lines[19]) - call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[20]) - call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[21]) - call assert_equal('', lines[22]) - call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[23]) - call assert_equal('count total (s) self (s) function', lines[24]) - call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[25]) - call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[26]) - call assert_equal('', lines[27]) + call assert_equal(28, len(lines)) + + call assert_equal('FUNCTION Foo1()', lines[0]) + call assert_equal('Called 2 times', lines[1]) + call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2]) + call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3]) + call assert_equal('', lines[4]) + call assert_equal('count total (s) self (s)', lines[5]) + call assert_equal('', lines[6]) + call assert_equal('FUNCTION Foo2()', lines[7]) + call assert_equal('Called 1 time', lines[8]) + call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[9]) + call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[10]) + call assert_equal('', lines[11]) + call assert_equal('count total (s) self (s)', lines[12]) + call assert_match('^\s*1\s\+.*\slet l:count = 100$', lines[13]) + call assert_match('^\s*101\s\+.*\swhile l:count > 0$', lines[14]) + call assert_match('^\s*100\s\+.*\s let l:count = l:count - 1$', lines[15]) + call assert_match('^\s*100\s\+.*\sendwhile$', lines[16]) + call assert_equal('', lines[17]) + call assert_equal('FUNCTIONS SORTED ON TOTAL TIME', lines[18]) + call assert_equal('count total (s) self (s) function', lines[19]) + call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[20]) + call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[21]) + call assert_equal('', lines[22]) + call assert_equal('FUNCTIONS SORTED ON SELF TIME', lines[23]) + call assert_equal('count total (s) self (s) function', lines[24]) + call assert_match('^\s*1\s\+\d\+\.\d\+\s\+Foo2()$', lines[25]) + call assert_match('^\s*2\s\+\d\+\.\d\+\s\+Foo1()$', lines[26]) + call assert_equal('', lines[27]) call delete('Xprofile_func.vim') call delete('Xprofile_func.log') endfunc func Test_profile_file() - if !has('unix') - return - endif let lines = [ \ 'func! Foo()', \ 'endfunc', @@ -87,13 +96,14 @@ func Test_profile_file() \ ] call writefile(lines, 'Xprofile_file.vim') - let a = system(v:progpath - \ . " -u NONE -i NONE --noplugin" - \ . " -c 'profile start Xprofile_file.log'" - \ . " -c 'profile file Xprofile_file.vim'" - \ . " -c 'so Xprofile_file.vim'" - \ . " -c 'so Xprofile_file.vim'" - \ . " -c 'qall!'") + call system(v:progpath + \ . ' -es -u NONE -U NONE -i NONE --noplugin' + \ . ' -c "profile start Xprofile_file.log"' + \ . ' -c "profile file Xprofile_file.vim"' + \ . ' -c "so Xprofile_file.vim"' + \ . ' -c "so Xprofile_file.vim"' + \ . ' -c "qall!"') + call assert_equal(0, v:shell_error) let lines = readfile('Xprofile_file.log') diff --git a/src/nvim/version.c b/src/nvim/version.c index 7c2cb4d580..7fd5f2c588 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -908,7 +908,7 @@ static const int included_patches[] = { // 199 NA // 198, // 197, - // 196, + 196, 195, 194, // 193 NA -- cgit From 20f1bf325cf82ab80206115231e8aeed27253bf5 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Fri, 27 Oct 2017 21:49:28 +0800 Subject: fix TEST_FILE=test_profile.res make oldtest failed --- src/nvim/testdir/test_profile.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_profile.vim b/src/nvim/testdir/test_profile.vim index 5f15d51b47..f58dba9b14 100644 --- a/src/nvim/testdir/test_profile.vim +++ b/src/nvim/testdir/test_profile.vim @@ -133,7 +133,7 @@ endfunc func Test_profile_completion() call feedkeys(":profile \\\"\", 'tx') - call assert_equal('"profile continue file func pause start', @:) + call assert_equal('"profile continue dump file func pause start stop', @:) call feedkeys(":profile start test_prof\\\"\", 'tx') call assert_match('^"profile start.* test_profile\.vim', @:) -- cgit From b8a67551d8360ba095d1ffdbc9f8c40b612e9320 Mon Sep 17 00:00:00 2001 From: Sam Wilson Date: Wed, 25 Oct 2017 11:18:47 -0400 Subject: terminal: Account for number column (#5310) --- src/nvim/buffer.c | 2 +- src/nvim/eval.c | 5 +++-- src/nvim/screen.c | 6 ++++++ src/nvim/window.c | 8 ++++++-- 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index fc5bb90973..9d42fbc1b3 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1466,7 +1466,7 @@ void enter_buffer(buf_T *buf) if (buf->terminal) { terminal_resize(buf->terminal, - (uint16_t)curwin->w_width, + (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), (uint16_t)curwin->w_height); } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index aab777955c..ef2f671f36 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -16723,9 +16723,10 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } + uint16_t term_width = MAX(0, curwin->w_width - win_col_off(curwin)); TerminalJobData *data = common_job_init(argv, on_stdout, on_stderr, on_exit, true, false, false, cwd); - data->proc.pty.width = curwin->w_width; + data->proc.pty.width = term_width; data->proc.pty.height = curwin->w_height; data->proc.pty.term_name = xstrdup("xterm-256color"); if (!common_job_start(data, rettv)) { @@ -16733,7 +16734,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) } TerminalOptions topts; topts.data = data; - topts.width = curwin->w_width; + topts.width = term_width; topts.height = curwin->w_height; topts.write_cb = term_write; topts.resize_cb = term_resize; diff --git a/src/nvim/screen.c b/src/nvim/screen.c index f5730cf70a..28b85dcc5f 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -692,6 +692,12 @@ static void win_update(win_T *wp) if (wp->w_nrwidth != i) { type = NOT_VALID; wp->w_nrwidth = i; + + if (buf->terminal) { + terminal_resize(buf->terminal, + (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), + (uint16_t)curwin->w_height); + } } else if (buf->b_mod_set && buf->b_mod_xlines != 0 && wp->w_redraw_top != 0) { /* * When there are both inserted/deleted lines and specific lines to be diff --git a/src/nvim/window.c b/src/nvim/window.c index c2d0a9b3b1..2d64409a1c 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -3747,7 +3747,9 @@ static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid, do_autochdir(); if (curbuf->terminal) { - terminal_resize(curbuf->terminal, curwin->w_width, curwin->w_height); + terminal_resize(curbuf->terminal, + (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), + (uint16_t)curwin->w_height); } } @@ -4946,7 +4948,9 @@ void win_new_width(win_T *wp, int width) if (wp->w_buffer->terminal) { if (wp->w_height != 0) { - terminal_resize(wp->w_buffer->terminal, wp->w_width, 0); + terminal_resize(wp->w_buffer->terminal, + (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), + 0); } } } -- cgit From bcf266de46b054b564727d5d31e4421ba09f5704 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 28 Oct 2017 17:54:29 +0200 Subject: test: :terminal + numberwidth=9 --- src/nvim/screen.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 28b85dcc5f..38ecd88ec0 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -698,12 +698,12 @@ static void win_update(win_T *wp) (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), (uint16_t)curwin->w_height); } - } else if (buf->b_mod_set && buf->b_mod_xlines != 0 && wp->w_redraw_top != 0) { - /* - * When there are both inserted/deleted lines and specific lines to be - * redrawn, w_redraw_top and w_redraw_bot may be invalid, just redraw - * everything (only happens when redrawing is off for while). - */ + } else if (buf->b_mod_set + && buf->b_mod_xlines != 0 + && wp->w_redraw_top != 0) { + // When there are both inserted/deleted lines and specific lines to be + // redrawn, w_redraw_top and w_redraw_bot may be invalid, just redraw + // everything (only happens when redrawing is off for while). type = NOT_VALID; } else { /* -- cgit From 122f52bf897abd1cda4fa467157657fee6bcfe94 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 29 Oct 2017 00:05:59 +0800 Subject: vim-patch:8.0.0206 (#7446) Problem: Test coverage for :retab insufficient. Solution: Add test for :retab. (Dominique Pelle, closes vim/vim#1391) https://github.com/vim/vim/commit/8822744b4d9d40aa1fd59870a8bdd7c64c59a42b --- src/nvim/testdir/Makefile | 1 + src/nvim/testdir/test_retab.vim | 77 +++++++++++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 src/nvim/testdir/test_retab.vim (limited to 'src') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 38caa8815d..979021ff92 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -63,6 +63,7 @@ NEW_TESTS ?= \ test_nested_function.res \ test_normal.res \ test_quickfix.res \ + test_retab.res \ test_search.res \ test_signs.res \ test_smartindent.res \ diff --git a/src/nvim/testdir/test_retab.vim b/src/nvim/testdir/test_retab.vim new file mode 100644 index 0000000000..f11a32bade --- /dev/null +++ b/src/nvim/testdir/test_retab.vim @@ -0,0 +1,77 @@ +" Test :retab +func SetUp() + new + call setline(1, "\ta \t b c ") +endfunc + +func TearDown() + bwipe! +endfunc + +func Retab(bang, n) + let l:old_tabstop = &tabstop + let l:old_line = getline(1) + exe "retab" . a:bang . a:n + let l:line = getline(1) + call setline(1, l:old_line) + if a:n > 0 + " :retab changes 'tabstop' to n with argument n > 0. + call assert_equal(a:n, &tabstop) + exe 'set tabstop=' . l:old_tabstop + else + " :retab does not change 'tabstop' with empty or n <= 0. + call assert_equal(l:old_tabstop, &tabstop) + endif + return l:line +endfunc + +func Test_retab() + set tabstop=8 noexpandtab + call assert_equal("\ta\t b c ", Retab('', '')) + call assert_equal("\ta\t b c ", Retab('', 0)) + call assert_equal("\ta\t b c ", Retab('', 8)) + call assert_equal("\ta\t b\t c\t ", Retab('!', '')) + call assert_equal("\ta\t b\t c\t ", Retab('!', 0)) + call assert_equal("\ta\t b\t c\t ", Retab('!', 8)) + + call assert_equal("\t\ta\t\t\tb c ", Retab('', 4)) + call assert_equal("\t\ta\t\t\tb\t\t c\t ", Retab('!', 4)) + + call assert_equal(" a\t\tb c ", Retab('', 10)) + call assert_equal(" a\t\tb c ", Retab('!', 10)) + + set tabstop=8 expandtab + call assert_equal(" a b c ", Retab('', '')) + call assert_equal(" a b c ", Retab('', 0)) + call assert_equal(" a b c ", Retab('', 8)) + call assert_equal(" a b c ", Retab('!', '')) + call assert_equal(" a b c ", Retab('!', 0)) + call assert_equal(" a b c ", Retab('!', 8)) + + call assert_equal(" a b c ", Retab(' ', 4)) + call assert_equal(" a b c ", Retab('!', 4)) + + call assert_equal(" a b c ", Retab(' ', 10)) + call assert_equal(" a b c ", Retab('!', 10)) + + set tabstop=4 noexpandtab + call assert_equal("\ta\t\tb c ", Retab('', '')) + call assert_equal("\ta\t\tb\t\t c\t ", Retab('!', '')) + call assert_equal("\t a\t\t\tb c ", Retab('', 3)) + call assert_equal("\t a\t\t\tb\t\t\tc\t ", Retab('!', 3)) + call assert_equal(" a\t b c ", Retab('', 5)) + call assert_equal(" a\t b\t\t c\t ", Retab('!', 5)) + + set tabstop=4 expandtab + call assert_equal(" a b c ", Retab('', '')) + call assert_equal(" a b c ", Retab('!', '')) + call assert_equal(" a b c ", Retab('', 3)) + call assert_equal(" a b c ", Retab('!', 3)) + call assert_equal(" a b c ", Retab('', 5)) + call assert_equal(" a b c ", Retab('!', 5)) +endfunc + +func Test_retab_error() + call assert_fails('retab -1', 'E487:') + call assert_fails('retab! -1', 'E487:') +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 6f3ca12458..d841f58b92 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -898,7 +898,7 @@ static const int included_patches[] = { 209, 208, // 207, - // 206, + 206, 205, // 204, // 203 NA -- cgit From b574e95850c064d4e746a7373aff1a3d7bd4de27 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 29 Oct 2017 01:17:00 +0300 Subject: charset: Some more refactoring of vim_str2nr --- src/nvim/charset.c | 78 +++++++++++++++++++++--------------------------------- src/nvim/version.c | 2 ++ 2 files changed, 32 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/nvim/charset.c b/src/nvim/charset.c index a7ffa4bc00..c895d65eb7 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1656,18 +1656,19 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, // decimal or octal, default is decimal pre = 0; - if (what & STR2NR_OCT) { - // Don't interpret "0", "08" or "0129" as octal. - for (int i = 1; !STRING_ENDED(ptr + i) && ascii_isdigit(ptr[i]); i++) { + if (what & STR2NR_OCT + && !STRING_ENDED(ptr + 1) + && ('0' <= ptr[1] && ptr[1] <= '7')) { + // Assume octal now: what we already know is that string starts with + // zero and some octal digit. + pre = '0'; + // Don’t interpret "0", "008" or "0129" as octal. + for (int i = 2; !STRING_ENDED(ptr + i) && ascii_isdigit(ptr[i]); i++) { if (ptr[i] > '7') { - // can't be octal + // Can’t be octal. pre = 0; break; } - if (ptr[i] >= '0') { - // assume octal - pre = '0'; - } } } } @@ -1675,51 +1676,32 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, // Do the string-to-numeric conversion "manually" to avoid sscanf quirks. uvarnumber_T un = 0; +#define PARSE_NUMBER(base, cond, conv) \ + do { \ + while (!STRING_ENDED(ptr) && (cond)) { \ + /* avoid ubsan error for overflow */ \ + if (un < UVARNUMBER_MAX / base) { \ + un = base * un + (uvarnumber_T)(conv); \ + } else { \ + un = UVARNUMBER_MAX; \ + } \ + ptr++; \ + } \ + } while (0) if (pre == 'B' || pre == 'b' || what == (STR2NR_BIN|STR2NR_FORCE)) { - // bin - while (!STRING_ENDED(ptr) && '0' <= *ptr && *ptr <= '1') { - // avoid ubsan error for overflow - if (un < UVARNUMBER_MAX / 2) { - un = 2 * un + (uvarnumber_T)(*ptr - '0'); - } else { - un = UVARNUMBER_MAX; - } - ptr++; - } + // Binary number. + PARSE_NUMBER(2, (*ptr == '0' || *ptr == '1'), (*ptr - '0')); } else if (pre == '0' || what == (STR2NR_OCT|STR2NR_FORCE)) { - // octal - while (!STRING_ENDED(ptr) && '0' <= *ptr && *ptr <= '7') { - // avoid ubsan error for overflow - if (un < UVARNUMBER_MAX / 8) { - un = 8 * un + (uvarnumber_T)(*ptr - '0'); - } else { - un = UVARNUMBER_MAX; - } - ptr++; - } + // Octal number. + PARSE_NUMBER(8, ('0' <= *ptr && *ptr <= '7'), (*ptr - '0')); } else if (pre == 'X' || pre == 'x' || what == (STR2NR_HEX|STR2NR_FORCE)) { - // hex - while (!STRING_ENDED(ptr) && ascii_isxdigit(*ptr)) { - // avoid ubsan error for overflow - if (un < UVARNUMBER_MAX / 16) { - un = 16 * un + (uvarnumber_T)hex2nr(*ptr); - } else { - un = UVARNUMBER_MAX; - } - ptr++; - } + // Hexadecimal number. + PARSE_NUMBER(16, (ascii_isxdigit(*ptr)), (hex2nr(*ptr))); } else { - // decimal - while (!STRING_ENDED(ptr) && ascii_isdigit(*ptr)) { - // avoid ubsan error for overflow - if (un < UVARNUMBER_MAX / 10) { - un = 10 * un + (uvarnumber_T)(*ptr - '0'); - } else { - un = UVARNUMBER_MAX; - } - ptr++; - } + // Decimal number. + PARSE_NUMBER(10, (ascii_isdigit(*ptr)), (*ptr - '0')); } +#undef PARSE_NUMBER if (prep != NULL) { *prep = pre; diff --git a/src/nvim/version.c b/src/nvim/version.c index 7e59f3327a..3382e394f8 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -77,6 +77,8 @@ static char *features[] = { // clang-format off static const int included_patches[] = { + 1229, + 1230, // 1026, 1025, 1024, -- cgit From 568cf73c90af2966ee091f2180905a8cf9582064 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 29 Oct 2017 01:29:48 +0300 Subject: viml/parser/expressions: Fix last error found by KLEE --- src/nvim/viml/parser/expressions.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index da22cf4cdb..b413d56592 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -2445,6 +2445,7 @@ viml_pexpr_parse_bracket_closing_error: cur_node->children = *top_node_p; } *top_node_p = cur_node; + new_top_node_p = top_node_p; goto viml_pexpr_parse_figure_brace_closing_error; } if (want_node == kENodeValue) { -- cgit From 8526902790680b9eea5462c19bd7d45caa40f16d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 28 Oct 2017 23:49:41 +0200 Subject: doc/ui.txt --- src/nvim/globals.h | 2 +- src/nvim/ui.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/globals.h b/src/nvim/globals.h index f24286360a..0f3e132bc0 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -984,7 +984,7 @@ EXTERN int km_startsel INIT(= FALSE); EXTERN int cedit_key INIT(= -1); ///< key value of 'cedit' option EXTERN int cmdwin_type INIT(= 0); ///< type of cmdline window or 0 EXTERN int cmdwin_result INIT(= 0); ///< result of cmdline window or 0 -EXTERN int cmdwin_level INIT(= 0); ///< cmdline level of cmdline window or 0 +EXTERN int cmdwin_level INIT(= 0); ///< cmdline recursion level EXTERN char_u no_lines_msg[] INIT(= N_("--No lines in buffer--")); diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 6b09f6e6db..afe7a51d43 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -30,7 +30,6 @@ #include "nvim/os/input.h" #include "nvim/os/signal.h" #include "nvim/popupmnu.h" -#include "nvim/ex_getln.h" #include "nvim/screen.h" #include "nvim/syntax.h" #include "nvim/window.h" -- cgit From 2a3bcd1ff883429a3dd17e7ae5ddc1396abbad17 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 29 Oct 2017 03:06:53 +0100 Subject: rpc: Don't delay notifications when request is pending (#6544) With the old behavior, if a GUI makes a blocking request that requires user interaction (like nvim_input()), it would not get any screen updates. The client, not nvim, should decide how to handle notifications during a pending request. If an rplugin wants to avoid async calls while a sync call is busy, it likely wants to avoid processing async calls while another async call also is handled as well. This may break the expectation of some existing rplugins. For compatibility, remote/define.vim reimplements the old behavior. Clients can opt-out by specifying `sync=urgent`. - Legacy hosts should be updated to use `sync=urgent`. They could add a flag indicating which async methods are always safe to call and which must wait until the main loop returns. - New hosts can expose the full asyncness, they don't need to offer both behaviors. ref #6532 ref #1398 d83868fe9071af1b4866594eac12f7aa0fa71b53 --- src/clint.py | 1 + src/nvim/msgpack_rpc/channel.c | 36 ++---------------------------------- 2 files changed, 3 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/clint.py b/src/clint.py index 4a41650ec4..e63175a69b 100755 --- a/src/clint.py +++ b/src/clint.py @@ -2531,6 +2531,7 @@ def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): r'(?pending_requests) { - // Pending request, queue the notification for later sending. - const String method = cstr_as_string((char *)name); - WBuffer *buffer = serialize_request(id, 0, method, args, &out_buffer, 1); - kv_push(channel->delayed_notifications, buffer); - } else { - send_event(channel, name, args); - } + send_event(channel, name, args); } else { broadcast_event(name, args); } @@ -248,10 +239,8 @@ Object channel_send_call(uint64_t id, // Push the frame ChannelCallFrame frame = { request_id, false, false, NIL }; kv_push(channel->call_stack, &frame); - channel->pending_requests++; LOOP_PROCESS_EVENTS_UNTIL(&main_loop, channel->events, -1, frame.returned); (void)kv_pop(channel->call_stack); - channel->pending_requests--; if (frame.errored) { if (frame.result.type == kObjectTypeString) { @@ -276,10 +265,6 @@ Object channel_send_call(uint64_t id, api_free_object(frame.result); } - if (!channel->pending_requests) { - send_delayed_notifications(channel); - } - decref(channel); return frame.errored ? NIL : frame.result; @@ -704,11 +689,7 @@ static void broadcast_event(const char *name, Array args) for (size_t i = 0; i < kv_size(subscribed); i++) { Channel *channel = kv_A(subscribed, i); - if (channel->pending_requests) { - kv_push(channel->delayed_notifications, buffer); - } else { - channel_write(channel, buffer); - } + channel_write(channel, buffer); } end: @@ -786,7 +767,6 @@ static void free_channel(Channel *channel) pmap_free(cstr_t)(channel->subscribed_events); kv_destroy(channel->call_stack); - kv_destroy(channel->delayed_notifications); if (channel->type != kChannelTypeProc) { multiqueue_free(channel->events); } @@ -811,11 +791,9 @@ static Channel *register_channel(ChannelType type, uint64_t id, rv->closed = false; rv->unpacker = msgpack_unpacker_new(MSGPACK_UNPACKER_INIT_BUFFER_SIZE); rv->id = id > 0 ? id : next_chan_id++; - rv->pending_requests = 0; rv->subscribed_events = pmap_new(cstr_t)(); rv->next_request_id = 1; kv_init(rv->call_stack); - kv_init(rv->delayed_notifications); pmap_put(uint64_t)(channels, rv->id, rv); ILOG("new channel %" PRIu64 " (%s): %s", rv->id, @@ -912,16 +890,6 @@ static WBuffer *serialize_response(uint64_t channel_id, return rv; } -static void send_delayed_notifications(Channel* channel) -{ - for (size_t i = 0; i < kv_size(channel->delayed_notifications); i++) { - WBuffer *buffer = kv_A(channel->delayed_notifications, i); - channel_write(channel, buffer); - } - - kv_size(channel->delayed_notifications) = 0; -} - static void incref(Channel *channel) { channel->refcount++; -- cgit From 39e83fa7cb4486d30f788c3b27594d106d5e76ab Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Fri, 24 Feb 2017 06:12:34 +0000 Subject: ui: allow external ui to draw wildmenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Björn Linse Updated docs and tests. --- src/nvim/api/ui_events.in.h | 7 +++++++ src/nvim/ex_getln.c | 27 ++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index 65357d008a..579ba1441a 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -65,6 +65,7 @@ void popupmenu_hide(void) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; void popupmenu_select(Integer selected) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; + void tabline_update(Tabpage current, Array tabs) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; @@ -84,4 +85,10 @@ void cmdline_block_append(Array lines) void cmdline_block_hide(void) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; +void wildmenu_show(Array content) + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; +void wildmenu_select(Integer selected) + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; +void wildmenu_hide(void) + FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; #endif // NVIM_API_UI_EVENTS_IN_H diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e79476ab53..3d5e1a5476 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -534,6 +534,9 @@ static int command_line_execute(VimState *state, int key) if (!(s->c == p_wc && KeyTyped) && s->c != p_wcm && s->c != Ctrl_N && s->c != Ctrl_P && s->c != Ctrl_A && s->c != Ctrl_L) { + if (ui_is_external(kUIWildmenu)) { + ui_call_wildmenu_hide(); + } if (s->xpc.xp_numfiles != -1) { (void)ExpandOne(&s->xpc, NULL, NULL, 0, WILD_FREE); } @@ -3515,11 +3518,17 @@ ExpandOne ( else findex = -1; } - if (p_wmnu) - win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files, - findex, cmd_showtail); - if (findex == -1) + if (p_wmnu) { + if (ui_is_external(kUIWildmenu)) { + ui_call_wildmenu_select(findex); + } else { + win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files, + findex, cmd_showtail); + } + } + if (findex == -1) { return vim_strsave(orig_save); + } return vim_strsave(xp->xp_files[findex]); } else return NULL; @@ -3876,6 +3885,15 @@ static int showmatches(expand_T *xp, int wildmenu) showtail = cmd_showtail; } + if (ui_is_external(kUIWildmenu)) { + Array args = ARRAY_DICT_INIT; + for (i = 0; i < num_files; i++) { + ADD(args, STRING_OBJ(cstr_to_string((char *)files_found[i]))); + } + ui_call_wildmenu_show(args); + return EXPAND_OK; + } + if (!wildmenu) { msg_didany = FALSE; /* lines_left will be set */ msg_start(); /* prepare for paging */ @@ -6128,4 +6146,3 @@ static void set_search_match(pos_T *t) coladvance((colnr_T)MAXCOL); } } - -- cgit From 6c43fccb278382e5ce59b6035a84fbdb3e7a1734 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 29 Oct 2017 13:46:40 +0100 Subject: vim-patch:8.0.0944 Problem: Test_profile is a little bit flaky. Solution: Accept a match when self and total time are the same. (James McCoy, closes vim/vim#1972) https://github.com/vim/vim/commit/d21b16f3c0c676bfe3a37aef1ac3118e1ecded60 --- src/nvim/testdir/test_profile.vim | 3 ++- src/nvim/version.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_profile.vim b/src/nvim/testdir/test_profile.vim index f58dba9b14..183f52b8ac 100644 --- a/src/nvim/testdir/test_profile.vim +++ b/src/nvim/testdir/test_profile.vim @@ -121,7 +121,8 @@ func Test_profile_file() " First line of loop executes one more time than body to detect end of loop. call assert_match('^\s*22\s\+\d\+\.\d\+\s\+for i in range(10)$', lines[8]) call assert_equal(' " a comment', lines[9]) - call assert_match('^\s*20\s\+\d\+\.\d\+\s\+\d\+\.\d\+\s\+call Foo()$', lines[10]) + " if self and total are equal we only get one number + call assert_match('^\s*20\s\+\(\d\+\.\d\+\s\+\)\=\d\+\.\d\+\s\+call Foo()$', lines[10]) call assert_match('^\s*20\s\+\d\+\.\d\+\s\+endfor$', lines[11]) " if self and total are equal we only get one number call assert_match('^\s*2\s\+\(\d\+\.\d\+\s\+\)\=\d\+\.\d\+\s\+call Foo()$', lines[12]) diff --git a/src/nvim/version.c b/src/nvim/version.c index 7fd5f2c588..e8d82d3b87 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -160,7 +160,7 @@ static const int included_patches[] = { // 947, // 946, // 945, - // 944, + 944, // 943, // 942, // 941, -- cgit From b935a12dab17c3887db9c5fd7c90b34b2c51170f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 29 Oct 2017 16:32:13 +0300 Subject: ex_getln: Make use of new parser to color expressions Retires g:Nvim_color_expr callback. --- src/nvim/ex_getln.c | 67 ++++++++++++++++++++++++++++++++++++++----- src/nvim/mbyte.c | 4 +-- src/nvim/mbyte.h | 6 ++++ src/nvim/viml/parser/parser.c | 13 +++++++++ src/nvim/viml/parser/parser.h | 55 +++++++++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+), 10 deletions(-) create mode 100644 src/nvim/viml/parser/parser.c (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 54e5bcb9ff..386e9e81aa 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -66,6 +66,8 @@ #include "nvim/lib/kvec.h" #include "nvim/api/private/helpers.h" #include "nvim/highlight_defs.h" +#include "nvim/viml/parser/parser.h" +#include "nvim/viml/parser/expressions.h" /* * Variables shared between getcmdline(), redrawcmdline() and others. @@ -2341,6 +2343,62 @@ void free_cmdline_buf(void) enum { MAX_CB_ERRORS = 1 }; +/// Color expression cmdline using built-in expressions parser +/// +/// @param[in] colored_ccline Command-line to color. +/// @param[out] ret_ccline_colors What should be colored. +/// +/// Always colors the whole cmdline. +static void color_expr_cmdline(const CmdlineInfo *const colored_ccline, + ColoredCmdline *const ret_ccline_colors) + FUNC_ATTR_NONNULL_ALL +{ + ParserLine plines[] = { + { + .data = (const char *)colored_ccline->cmdbuff, + .size = STRLEN(colored_ccline->cmdbuff), + .allocated = false, + }, + { NULL, 0, false }, + }; + ParserLine *plines_p = plines; + ParserHighlight colors; + kvi_init(colors); + ParserState pstate; + viml_parser_init( + &pstate, parser_simple_get_line, &plines_p, &colors); + ExprAST east = viml_pexpr_parse(&pstate, kExprFlagsDisallowEOC); + viml_pexpr_free_ast(east); + viml_parser_destroy(&pstate); + kv_resize(ret_ccline_colors->colors, kv_size(colors)); + size_t prev_end = 0; + for (size_t i = 0 ; i < kv_size(colors) ; i++) { + const ParserHighlightChunk chunk = kv_A(colors, i); + if (chunk.start.col != prev_end) { + kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) { + .start = prev_end, + .end = chunk.start.col, + .attr = 0, + })); + } + const int id = syn_name2id((const char_u *)chunk.group); + const int attr = (id == 0 ? 0 : syn_id2attr(id)); + kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) { + .start = chunk.start.col, + .end = chunk.end_col, + .attr = attr, + })); + prev_end = chunk.end_col; + } + if (prev_end < (size_t)colored_ccline->cmdlen) { + kv_push(ret_ccline_colors->colors, ((CmdlineColorChunk) { + .start = prev_end, + .end = (size_t)colored_ccline->cmdlen, + .attr = 0, + })); + } +} + /// Color command-line /// /// Should use built-in command parser or user-specified one. Currently only the @@ -2422,13 +2480,8 @@ static bool color_cmdline(const CmdlineInfo *const colored_ccline, tl_ret = try_leave(&tstate, &err); can_free_cb = true; } else if (colored_ccline->cmdfirstc == '=') { - try_enter(&tstate); - err_errmsg = N_( - "E5409: Unable to get g:Nvim_color_expr callback: %s"); - dgc_ret = tv_dict_get_callback(&globvardict, S_LEN("Nvim_color_expr"), - &color_cb); - tl_ret = try_leave(&tstate, &err); - can_free_cb = true; + color_expr_cmdline(colored_ccline, ret_ccline_colors); + can_free_cb = false; } if (!tl_ret || !dgc_ret) { goto color_cmdline_error; diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index f65d7a6b13..843007b97b 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -2288,9 +2288,7 @@ int convert_setup_ext(vimconv_T *vcp, char_u *from, bool from_unicode_is_utf8, if (vcp->vc_type == CONV_ICONV && vcp->vc_fd != (iconv_t)-1) iconv_close(vcp->vc_fd); # endif - vcp->vc_type = CONV_NONE; - vcp->vc_factor = 1; - vcp->vc_fail = false; + *vcp = (vimconv_T)MBYTE_NONE_CONV; /* No conversion when one of the names is empty or they are equal. */ if (from == NULL || *from == NUL || to == NULL || *to == NUL diff --git a/src/nvim/mbyte.h b/src/nvim/mbyte.h index fce600d0a9..a5ce1b0a15 100644 --- a/src/nvim/mbyte.h +++ b/src/nvim/mbyte.h @@ -60,6 +60,12 @@ typedef enum { CONV_ICONV = 5, } ConvFlags; +#define MBYTE_NONE_CONV { \ + .vc_type = CONV_NONE, \ + .vc_factor = 1, \ + .vc_fail = false, \ +} + /// Structure used for string conversions typedef struct { int vc_type; ///< Zero or more ConvFlags. diff --git a/src/nvim/viml/parser/parser.c b/src/nvim/viml/parser/parser.c new file mode 100644 index 0000000000..08d8846018 --- /dev/null +++ b/src/nvim/viml/parser/parser.c @@ -0,0 +1,13 @@ +#include "nvim/viml/parser/parser.h" + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "viml/parser/parser.c.generated.h" +#endif + + +void parser_simple_get_line(void *cookie, ParserLine *ret_pline) +{ + ParserLine **plines_p = (ParserLine **)cookie; + *ret_pline = **plines_p; + (*plines_p)++; +} diff --git a/src/nvim/viml/parser/parser.h b/src/nvim/viml/parser/parser.h index fbc5ba5f07..7ac49709d8 100644 --- a/src/nvim/viml/parser/parser.h +++ b/src/nvim/viml/parser/parser.h @@ -8,6 +8,7 @@ #include "nvim/lib/kvec.h" #include "nvim/func_attr.h" #include "nvim/mbyte.h" +#include "nvim/memory.h" /// One parsed line typedef struct { @@ -80,6 +81,56 @@ typedef struct { bool can_continuate; } ParserState; +static inline void viml_parser_init( + ParserState *const ret_pstate, + const ParserLineGetter get_line, void *const cookie, + ParserHighlight *const colors) + REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ARG(1, 2); + +/// Initialize a new parser state instance +/// +/// @param[out] ret_pstate Parser state to initialize. +/// @param[in] get_line Line getter function. +/// @param[in] cookie Argument for the get_line function. +/// @param[in] colors Where to save highlighting. May be NULL if it is not +/// needed. +static inline void viml_parser_init( + ParserState *const ret_pstate, + const ParserLineGetter get_line, void *const cookie, + ParserHighlight *const colors) +{ + *ret_pstate = (ParserState) { + .reader = { + .get_line = get_line, + .cookie = cookie, + .conv = MBYTE_NONE_CONV, + }, + .pos = { 0, 0 }, + .colors = colors, + .can_continuate = false, + }; + kvi_init(ret_pstate->reader.lines); + kvi_init(ret_pstate->stack); +} + +static inline void viml_parser_destroy(ParserState *const pstate) + REAL_FATTR_NONNULL_ALL REAL_FATTR_ALWAYS_INLINE; + +/// Free all memory allocated by the parser on heap +/// +/// @param pstate Parser state to free. +static inline void viml_parser_destroy(ParserState *const pstate) +{ + for (size_t i = 0; i < kv_size(pstate->reader.lines); i++) { + ParserLine pline = kv_A(pstate->reader.lines, i); + if (pline.allocated) { + xfree((void *)pline.data); + } + } + kvi_destroy(pstate->reader.lines); + kvi_destroy(pstate->stack); +} + static inline void viml_preader_get_line(ParserInputReader *const preader, ParserLine *const ret_pline) REAL_FATTR_NONNULL_ALL; @@ -186,4 +237,8 @@ static inline void viml_parser_highlight(ParserState *const pstate, })); } +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "viml/parser/parser.h.generated.h" +#endif + #endif // NVIM_VIML_PARSER_PARSER_H -- cgit From 1be29dc5acc071591bd776890fc3b61aba1488f9 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 29 Oct 2017 16:54:50 +0300 Subject: gen_declarations: Do not generate line numbers by default --- src/nvim/generators/gen_declarations.lua | 43 ++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua index e999e53e4a..0c73376ba0 100755 --- a/src/nvim/generators/gen_declarations.lua +++ b/src/nvim/generators/gen_declarations.lua @@ -164,9 +164,40 @@ local pattern = concat( ) if fname == '--help' then - print'Usage:' - print() - print' gendeclarations.lua definitions.c static.h non-static.h preprocessor.i' + print([[ +Usage: + + gendeclarations.lua definitions.c static.h non-static.h definitions.i + +Generates declarations for a C file defitions.c, putting declarations for +static functions into static.h and declarations for non-static functions into +non-static.h. File `definitions.i' should contain an already preprocessed +version of defintions.c and it is the only one which is actually parsed, +definitions.c is needed only to determine functions from which file out of all +functions found in definitions.i are needed. + +Additionally uses the following environment variables: + + NVIM_GEN_DECLARATIONS_LINE_NUMBERS: + If set to 1 then all generated declarations receive a comment with file + name and line number after the declaration. This may be useful for + debugging gen_declarations script, but not much beyound that with + configured development environment (i.e. with ctags/cscope/finding + definitions with clang/etc). + + WARNING: setting this to 1 will cause extensive rebuilds: declarations + generator script will not regenerate non-static.h file if its + contents did not change, but including line numbers will make + contents actually change. + + With contents changed timestamp of the file is regenerated even + when no real changes were made (e.g. a few lines were added to + a function which is not at the bottom of the file). + + With changed timestamp build system will assume that header + changed, triggering rebuilds of all C files which depend on the + "changed" header. +]]) os.exit() end @@ -249,8 +280,10 @@ while init ~= nil do declaration = declaration:gsub(' $', '') declaration = declaration:gsub('^ ', '') declaration = declaration .. ';' - declaration = declaration .. (' // %s/%s:%u'):format( - curdir, curfile, declline) + if os.getenv('NVIM_GEN_DECLARATIONS_LINE_NUMBERS') == '1' then + declaration = declaration .. (' // %s/%s:%u'):format( + curdir, curfile, declline) + end declaration = declaration .. '\n' if declaration:sub(1, 6) == 'static' then static = static .. declaration -- cgit From 1e2ae942f303e149ec7e69e1ca36c7defa21f65d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 29 Oct 2017 17:26:49 +0100 Subject: vim-patch:8.0.1207 Problem: Profiling skips the first and last script line. Solution: Check for BOM after setting script ID. (Lemonboy, closes vim/vim#2103, closes vim/vim#2112) Add a test. List the trailing script lines. https://github.com/vim/vim/commit/67435d9983965c5c77fc74f0559779ce4554dacb --- src/nvim/ex_cmds2.c | 45 +++++++++++++++++++++------------------ src/nvim/testdir/test_profile.vim | 38 ++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 371f7b3bce..19e7f1bbc5 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1068,7 +1068,7 @@ static void profile_init(scriptitem_T *si) si->sn_pr_nest = 0; } -/// save time when starting to invoke another script or function. +/// Save time when starting to invoke another script or function. void script_prof_save( proftime_T *tm // place to store wait time ) @@ -1141,12 +1141,14 @@ static void script_dump_profile(FILE *fd) if (sfd == NULL) { fprintf(fd, "Cannot open file!\n"); } else { - for (int i = 0; i < si->sn_prl_ga.ga_len; i++) { + // Keep going till the end of file, so that trailing + // continuation lines are listed. + for (int i = 0; ; i++) { if (vim_fgets(IObuff, IOSIZE, sfd)) { break; } - pp = &PRL_ITEM(si, i); - if (pp->snp_count > 0) { + if (i < si->sn_prl_ga.ga_len + && (pp = &PRL_ITEM(si, i))->snp_count > 0) { fprintf(fd, "%5d ", pp->snp_count); if (profile_equal(pp->sn_prl_total, pp->sn_prl_self)) { fprintf(fd, " "); @@ -2871,22 +2873,6 @@ int do_source(char_u *fname, int check_other, int is_vimrc) save_sourcing_lnum = sourcing_lnum; sourcing_lnum = 0; - cookie.conv.vc_type = CONV_NONE; // no conversion - - // Read the first line so we can check for a UTF-8 BOM. - firstline = getsourceline(0, (void *)&cookie, 0); - if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef - && firstline[1] == 0xbb && firstline[2] == 0xbf) { - // Found BOM; setup conversion, skip over BOM and recode the line. - convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc); - p = string_convert(&cookie.conv, firstline + 3, NULL); - if (p == NULL) { - p = vim_strsave(firstline + 3); - } - xfree(firstline); - firstline = p; - } - // start measuring script load time if --startuptime was passed and // time_fd was successfully opened afterwards. proftime_T rel_time; @@ -2959,6 +2945,22 @@ int do_source(char_u *fname, int check_other, int is_vimrc) } } + cookie.conv.vc_type = CONV_NONE; // no conversion + + // Read the first line so we can check for a UTF-8 BOM. + firstline = getsourceline(0, (void *)&cookie, 0); + if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef + && firstline[1] == 0xbb && firstline[2] == 0xbf) { + // Found BOM; setup conversion, skip over BOM and recode the line. + convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc); + p = string_convert(&cookie.conv, firstline + 3, NULL); + if (p == NULL) { + p = vim_strsave(firstline + 3); + } + xfree(firstline); + firstline = p; + } + // Call do_cmdline, which will call getsourceline() to get the lines. do_cmdline(firstline, getsourceline, (void *)&cookie, DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT); @@ -3281,7 +3283,8 @@ void script_line_start(void) if (si->sn_prof_on && sourcing_lnum >= 1) { // Grow the array before starting the timer, so that the time spent // here isn't counted. - ga_grow(&si->sn_prl_ga, (int)(sourcing_lnum - si->sn_prl_ga.ga_len)); + (void)ga_grow(&si->sn_prl_ga, + (int)(sourcing_lnum - si->sn_prl_ga.ga_len)); si->sn_prl_idx = sourcing_lnum - 1; while (si->sn_prl_ga.ga_len <= si->sn_prl_idx && si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen) { diff --git a/src/nvim/testdir/test_profile.vim b/src/nvim/testdir/test_profile.vim index 183f52b8ac..4cbd800da5 100644 --- a/src/nvim/testdir/test_profile.vim +++ b/src/nvim/testdir/test_profile.vim @@ -115,7 +115,7 @@ func Test_profile_file() call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3]) call assert_equal('', lines[4]) call assert_equal('count total (s) self (s)', lines[5]) - call assert_equal(' func! Foo()', lines[6]) + call assert_match(' 2 0.\d\+ func! Foo()', lines[6]) call assert_equal(' endfunc', lines[7]) " Loop iterates 10 times. Since script runs twice, body executes 20 times. " First line of loop executes one more time than body to detect end of loop. @@ -132,6 +132,42 @@ func Test_profile_file() call delete('Xprofile_file.log') endfunc +func Test_profile_file_with_cont() + let lines = [ + \ 'echo "hello', + \ ' \ world"', + \ 'echo "foo ', + \ ' \bar"', + \ ] + + call writefile(lines, 'Xprofile_file.vim') + call system(v:progpath + \ . ' -es -u NONE -U NONE -i NONE --noplugin' + \ . ' -c "profile start Xprofile_file.log"' + \ . ' -c "profile file Xprofile_file.vim"' + \ . ' -c "so Xprofile_file.vim"' + \ . ' -c "qall!"') + call assert_equal(0, v:shell_error) + + let lines = readfile('Xprofile_file.log') + call assert_equal(11, len(lines)) + + call assert_match('^SCRIPT .*Xprofile_file.vim$', lines[0]) + call assert_equal('Sourced 1 time', lines[1]) + call assert_match('^Total time:\s\+\d\+\.\d\+$', lines[2]) + call assert_match('^ Self time:\s\+\d\+\.\d\+$', lines[3]) + call assert_equal('', lines[4]) + call assert_equal('count total (s) self (s)', lines[5]) + call assert_match(' 1 0.\d\+ echo "hello', lines[6]) + call assert_equal(' \ world"', lines[7]) + call assert_match(' 1 0.\d\+ echo "foo ', lines[8]) + call assert_equal(' \bar"', lines[9]) + call assert_equal('', lines[10]) + + call delete('Xprofile_file.vim') + call delete('Xprofile_file.log') +endfunc + func Test_profile_completion() call feedkeys(":profile \\\"\", 'tx') call assert_equal('"profile continue dump file func pause start stop', @:) -- cgit From 8d929f558c981c75f19dfc22e54e36c904be887e Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sat, 2 Sep 2017 23:28:49 +0200 Subject: Inccommand: Multiline substitutions, highlighting, multibyte. Make inccomand work with multiline patterns and substitutions. Also care for proper highlighting and multibyte characters. --- src/nvim/buffer.c | 37 +++++++++ src/nvim/ex_cmds.c | 224 +++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 193 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 9d42fbc1b3..3080d4960d 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -5278,6 +5278,43 @@ int bufhl_add_hl(buf_T *buf, return src_id; } +/// Add highlighting to a buffer, bounded by two cursor positions, +/// with an offset +/// @param buf The buffer to add highlights to +/// @param src_id src_id to use or 0 to use a new src_id group, +/// or -1 for ungrouped highlight. +/// @param hl_id Id of the highlight group to use +/// @param lpos_start Cursor position to start the hightlighting at +/// @param lpos_end Cursor position to end the highlighting at +/// @param offset Move the whole highlighting this many columns to the right +void bufhl_add_hl_pos_offset(buf_T *buf, + int src_id, + int hl_id, + lpos_T pos_start, + lpos_T pos_end, + colnr_T offset) +{ + colnr_T hl_start = 0; + colnr_T hl_end = 0; + + for (linenr_T lnum = pos_start.lnum; lnum <= pos_end.lnum; lnum ++) { + if (pos_start.lnum < lnum && lnum < pos_end.lnum) { + hl_start = offset; + hl_end = MAXCOL; + } else if (lnum == pos_start.lnum && lnum < pos_end.lnum) { + hl_start = pos_start.col + offset + 1; + hl_end = MAXCOL; + } else if (pos_start.lnum < lnum && lnum == pos_end.lnum) { + hl_start = offset; + hl_end = pos_end.col + offset; + } else if (pos_start.lnum == lnum && pos_end.lnum == lnum) { + hl_start = pos_start.col + offset + 1; + hl_end = pos_end.col + offset; + } + (void)bufhl_add_hl(buf, src_id, hl_id, lnum, hl_start, hl_end); + } +} + /// Clear bufhl highlights from a given source group and range of lines. /// /// @param buf The buffer to remove highlights from diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 918e7a0c91..fe0c662898 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -90,14 +90,20 @@ typedef struct { SubIgnoreType do_ic; ///< ignore case flag } subflags_T; -/// Lines matched during :substitute. +/// Partial result of a substitution during :substitute. +/// Numbers refer to the buffer _after_ substitution typedef struct { - linenr_T lnum; - long nmatch; - char_u *line; - kvec_t(colnr_T) cols; ///< columns of in-line matches -} MatchedLine; -typedef kvec_t(MatchedLine) MatchedLineVec; + lpos_T start; // start of the match + lpos_T end; // end of the match + linenr_T pre_match; // where to begin showing lines before the match +} SubResult; + +// Collected results of a substitution for showing them in +// the preview window +typedef struct { + kvec_t(SubResult) subresults; + linenr_T lines_needed; // lines neede in the preview window +} PreviewLines; #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ex_cmds.c.generated.h" @@ -3168,7 +3174,10 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) linenr_T old_line_count = curbuf->b_ml.ml_line_count; char_u *sub_firstline; // allocated copy of first sub line bool endcolumn = false; // cursor in last column when done - MatchedLineVec matched_lines = KV_INITIAL_VALUE; + PreviewLines preview_lines = { KV_INITIAL_VALUE, 0 }; + static int pre_src_id = 0; // Source id for the preview highlight + static int pre_hl_id = 0; + buf_T *orig_buf = curbuf; // save to reset highlighting pos_T old_cursor = curwin->w_cursor; int start_nsubs; int save_ma = 0; @@ -3336,7 +3345,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) linenr_T line2 = eap->line2; for (linenr_T lnum = eap->line1; lnum <= line2 && !got_quit && !aborting() - && (!preview || matched_lines.size < (size_t)p_cwh + && (!preview || preview_lines.lines_needed <= (linenr_T)p_cwh || lnum <= curwin->w_botline); lnum++) { long nmatch = vim_regexec_multi(®match, curwin, curbuf, lnum, @@ -3401,8 +3410,6 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) sub_firstlnum = lnum; copycol = 0; matchcol = 0; - // the current match - MatchedLine matched_line = { 0, 0, NULL, KV_INITIAL_VALUE }; /* At first match, remember current cursor position. */ if (!got_match) { @@ -3419,10 +3426,19 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) * 5. break if there isn't another match in this line */ for (;; ) { + SubResult current_match = { + .start = { 0, 0 }, + .end = { 0, 0 }, + .pre_match = 0, + }; + // lnum is where the match start, but maybe not the pattern match, + // since we can have \n before \zs in the pattern + /* Advance "lnum" to the line where the match starts. The * match does not start in the first line when there is a line * break before \zs. */ if (regmatch.startpos[0].lnum > 0) { + current_match.pre_match = lnum; lnum += regmatch.startpos[0].lnum; sub_firstlnum += regmatch.startpos[0].lnum; nmatch -= regmatch.startpos[0].lnum; @@ -3430,6 +3446,10 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) sub_firstline = NULL; } + // Now we're at the line where the pattern match starts + // Note: If not first match on a line, column can't be known here + current_match.start.lnum = sub_firstlnum; + if (sub_firstline == NULL) { sub_firstline = vim_strsave(ml_get(sub_firstlnum)); } @@ -3439,12 +3459,6 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) curwin->w_cursor.lnum = lnum; do_again = FALSE; - if (preview) { - // Increment the in-line match count and store the column. - matched_line.nmatch++; - kv_push(matched_line.cols, regmatch.startpos[0].col); - } - /* * 1. Match empty string does not count, except for first * match. This reproduces the strange vi behaviour. @@ -3696,8 +3710,17 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) } \ } while (0) + // Save the line numbers for the preview buffer + // NOTE: If the pattern matches a final newline, the next line will + // be shown also, but should not be highlighted. Intentional for now. if (preview && !has_second_delim) { + current_match.start.col = regmatch.startpos[0].col; + current_match.end.lnum = sub_firstlnum + nmatch - 1; + current_match.end.col = regmatch.endpos[0].col; + ADJUST_SUB_FIRSTLNUM(); + lnum += nmatch - 1; + goto skip; } @@ -3747,6 +3770,10 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) memmove(new_end, sub_firstline + copycol, (size_t)copy_len); new_end += copy_len; + // Finally, at this point we can know where the match actually will + // start in the new text + current_match.start.col = new_end - new_start; + (void)vim_regsub_multi(®match, sub_firstlnum - regmatch.startpos[0].lnum, sub, new_end, true, p_magic, true); @@ -3799,6 +3826,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) p1 += (*mb_ptr2len)(p1) - 1; } } + current_match.end.col = STRLEN(new_start); + current_match.end.lnum = lnum; } // 4. If subflags.do_all is set, find next match. @@ -3907,9 +3936,35 @@ skip: * found the match. */ if (nmatch == -1) lnum -= regmatch.startpos[0].lnum; + + // Push the match to preview_lines + // TODO(KillTheMule): Code duplication at line 3961 + linenr_T match_lines = current_match.end.lnum + - current_match.start.lnum +1; + if (preview_lines.subresults.size > 0) { + linenr_T last_lnum = kv_last(preview_lines.subresults).end.lnum; + if (last_lnum == current_match.start.lnum) { + preview_lines.lines_needed += match_lines - 1; + } + } else { + preview_lines.lines_needed += match_lines; + } + kv_push(preview_lines.subresults, current_match); break; } } + // Push the match to preview_lines + linenr_T match_lines = current_match.end.lnum + - current_match.start.lnum +1; + if (preview_lines.subresults.size > 0) { + linenr_T last_lnum = kv_last(preview_lines.subresults).end.lnum; + if (last_lnum == current_match.start.lnum) { + preview_lines.lines_needed += match_lines - 1; + } + } else { + preview_lines.lines_needed += match_lines; + } + kv_push(preview_lines.subresults, current_match); line_breakcheck(); } @@ -3919,12 +3974,6 @@ skip: xfree(new_start); /* for when substitute was cancelled */ xfree(sub_firstline); /* free the copy of the original line */ sub_firstline = NULL; - - if (preview) { - matched_line.lnum = lnum; - matched_line.line = vim_strsave(ml_get(lnum)); - kv_push(matched_lines, matched_line); - } } line_breakcheck(); @@ -4003,18 +4052,23 @@ skip: if (got_quit) { // Substitution is too slow, disable 'inccommand'. set_string_option_direct((char_u *)"icm", -1, (char_u *)"", OPT_FREE, SID_NONE); - } else if (*p_icm != NUL && matched_lines.size != 0 && pat != NULL) { + } else if (*p_icm != NUL && preview_lines.subresults.size != 0 && pat != NULL) { + if (pre_src_id == 0) { + // Get a unique new src_id, saved in a static + pre_src_id = bufhl_add_hl(NULL, 0, -1, 0, 0, 0); + } + if (pre_hl_id == 0) { + pre_hl_id = syn_check_group((char_u *)"Substitute", 13); + } curbuf->b_changed = save_b_changed; // preserve 'modified' during preview - preview_buf = show_sub(eap, old_cursor, pat, sub, &matched_lines); + preview_buf = show_sub(eap, old_cursor, pat, sub, &preview_lines, + has_second_delim, pre_hl_id, pre_src_id); + bufhl_clear_line_range(orig_buf, pre_src_id, eap->line1, + kv_last(preview_lines.subresults).end.lnum); } } - for (MatchedLine m; kv_size(matched_lines);) { - m = kv_pop(matched_lines); - xfree(m.line); - kv_destroy(m.cols); - } - kv_destroy(matched_lines); + kv_destroy(preview_lines.subresults); return preview_buf; #undef ADJUST_SUB_FIRSTLNUM @@ -6018,7 +6072,8 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg) /// Shows the effects of the :substitute command being typed ('inccommand'). /// If inccommand=split, shows a preview window and later restores the layout. static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub, - MatchedLineVec *matched_lines) + PreviewLines *preview_lines, bool show_hl, int hl_id, + int src_id) FUNC_ATTR_NONNULL_ALL { static handle_T bufnr = 0; // special buffer, re-used on each visit @@ -6028,6 +6083,8 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub, char_u *save_shm_p = vim_strsave(p_shm); size_t sub_size = mb_string2cells(sub); size_t pat_size = mb_string2cells(pat); + PreviewLines lines = *preview_lines; + buf_T *orig_buf = curbuf; // We keep a special-purpose buffer around, but don't assume it exists. buf_T *preview_buf = bufnr ? buflist_findnr(bufnr) : 0; @@ -6046,15 +6103,19 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub, } // Place cursor on nearest matching line, to undo do_sub() cursor placement. - for (size_t i = 0; i < matched_lines->size; i++) { - MatchedLine curmatch = matched_lines->items[i]; - if (curmatch.lnum >= old_cusr.lnum) { - curwin->w_cursor.lnum = curmatch.lnum; - curwin->w_cursor.col = curmatch.cols.items[0]; + for (size_t i = 0; i < lines.subresults.size; i++) { + SubResult curres = lines.subresults.items[i]; + if (curres.start.lnum >= old_cusr.lnum) { + curwin->w_cursor.lnum = curres.start.lnum; + curwin->w_cursor.col = curres.start.col; break; } // Else: All matches are above, do_sub() already placed cursor. } + // Width of the "| lnum|..." column which displays the line numbers. + linenr_T highest_num_line = 0; + int col_width = 0; + if (split && win_split((int)p_cwh, WSP_BOT) != FAIL) { buf_open_scratch(preview_buf ? bufnr : 0, "[Preview]"); buf_clear(); @@ -6070,43 +6131,70 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub, curwin->w_p_fen = false; // Width of the "| lnum|..." column which displays the line numbers. - linenr_T highest_num_line = kv_last(*matched_lines).lnum; - int col_width = log10(highest_num_line) + 1 + 3; - - char *str = NULL; - size_t old_line_size = 0; - size_t line_size; - int src_id_highlight = 0; - int hl_id = syn_check_group((char_u *)"Substitute", 13); - - // Dump the lines into the preview buffer. - for (size_t line = 0; line < matched_lines->size; line++) { - MatchedLine mat = matched_lines->items[line]; - line_size = mb_string2cells(mat.line) + col_width + 1; - - // Reallocate if str not long enough - if (line_size > old_line_size) { - str = xrealloc(str, line_size * sizeof(char)); - old_line_size = line_size; + highest_num_line = kv_last(lines.subresults).end.lnum; + col_width = log10(highest_num_line) + 1 + 3; + } + + char *str = NULL; // construct the line to show in here + size_t old_line_size = 0; + size_t line_size = 0; + linenr_T linenr_preview = 0; // # of last line added to preview buffer + linenr_T linenr_origbuf = 0; // # of last line added to original number + linenr_T next_linenr = 0; // # of the next line to show for the match + + for (size_t matchidx = 0; matchidx < lines.subresults.size; matchidx++) { + SubResult match = lines.subresults.items[matchidx]; + + if (split && preview_buf) { + lpos_T p_start = { 0, match.start.col }; // match starts here in preview + lpos_T p_end = { 0, match.end.col }; // ... and ends here + + if (match.pre_match == 0) { + next_linenr = match.start.lnum; + } else { + next_linenr = match.pre_match; } + // Don't add a line twice + if (next_linenr == linenr_origbuf) { + next_linenr++; + p_start.lnum = linenr_preview; // might be redefined below + p_end.lnum = linenr_preview; // might be redefined below + } + + for (; next_linenr <= match.end.lnum; next_linenr++) { + if (next_linenr == match.start.lnum) { + p_start.lnum = linenr_preview + 1; + } + if (next_linenr == match.end.lnum) { + p_end.lnum = linenr_preview + 1; + } + char_u *line = ml_get_buf(orig_buf, next_linenr, false); + line_size = STRLEN(line) + col_width + 1; - // Put "|lnum| line" into `str` and append it to the preview buffer. - snprintf(str, line_size, "|%*ld| %s", col_width - 3, mat.lnum, mat.line); - ml_append(line, (char_u *)str, (colnr_T)line_size, false); - - // highlight the replaced part - if (sub_size > 0) { - for (size_t i = 0; i < mat.cols.size; i++) { - colnr_T col_start = mat.cols.items[i] + col_width - + i * (sub_size - pat_size) + 1; - colnr_T col_end = col_start - 1 + sub_size; - src_id_highlight = bufhl_add_hl(curbuf, src_id_highlight, hl_id, - line + 1, col_start, col_end); + // Reallocate if line not long enough + if (line_size > old_line_size) { + str = xrealloc(str, line_size * sizeof(char)); + old_line_size = line_size; } + // Put "|lnum| line" into `str` and append it to the preview buffer. + snprintf(str, line_size, "|%*ld| %s", col_width - 3, + next_linenr, line); + ml_append(linenr_preview, (char_u *)str, (colnr_T)line_size, false); + linenr_preview += 1; + } + linenr_origbuf = match.end.lnum; + + if (show_hl) { + bufhl_add_hl_pos_offset(preview_buf, src_id, hl_id, p_start, + p_end, col_width); } } - xfree(str); + if (show_hl) { + bufhl_add_hl_pos_offset(orig_buf, src_id, hl_id, match.start, + match.end, 0); + } } + xfree(str); redraw_later(SOME_VALID); win_enter(save_curwin, false); // Return to original window -- cgit From 35b867d78687484a1153e957748547e4d043934a Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Mon, 18 Sep 2017 22:35:05 +0200 Subject: Lint --- src/nvim/ex_cmds.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index fe0c662898..022ba6a4dd 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -100,9 +100,9 @@ typedef struct { // Collected results of a substitution for showing them in // the preview window -typedef struct { +typedef struct { kvec_t(SubResult) subresults; - linenr_T lines_needed; // lines neede in the preview window + linenr_T lines_needed; // lines neede in the preview window } PreviewLines; #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -3434,9 +3434,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) // lnum is where the match start, but maybe not the pattern match, // since we can have \n before \zs in the pattern - /* Advance "lnum" to the line where the match starts. The - * match does not start in the first line when there is a line - * break before \zs. */ + // Advance "lnum" to the line where the match starts. The + // match does not start in the first line when there is a line + // break before \zs. if (regmatch.startpos[0].lnum > 0) { current_match.pre_match = lnum; lnum += regmatch.startpos[0].lnum; @@ -3965,7 +3965,6 @@ skip: preview_lines.lines_needed += match_lines; } kv_push(preview_lines.subresults, current_match); - line_breakcheck(); } @@ -4048,11 +4047,12 @@ skip: // Show 'inccommand' preview if there are matched lines. buf_T *preview_buf = NULL; + size_t subsize = preview_lines.subresults.size; if (preview && !aborting()) { if (got_quit) { // Substitution is too slow, disable 'inccommand'. set_string_option_direct((char_u *)"icm", -1, (char_u *)"", OPT_FREE, SID_NONE); - } else if (*p_icm != NUL && preview_lines.subresults.size != 0 && pat != NULL) { + } else if (*p_icm != NUL && subsize != 0 && pat != NULL) { if (pre_src_id == 0) { // Get a unique new src_id, saved in a static pre_src_id = bufhl_add_hl(NULL, 0, -1, 0, 0, 0); -- cgit From 3e5ecd95386da2122e495ed4fda566f6e1997206 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Fri, 22 Sep 2017 21:37:13 +0200 Subject: Remove pat/sub from show_sub They were only used to not show the preview window when typing "s/" or "s//" only, in which case the previous pattern would be reused. Now the window is shown in that case. --- src/nvim/ex_cmds.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 022ba6a4dd..b74aad46bf 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4061,8 +4061,8 @@ skip: pre_hl_id = syn_check_group((char_u *)"Substitute", 13); } curbuf->b_changed = save_b_changed; // preserve 'modified' during preview - preview_buf = show_sub(eap, old_cursor, pat, sub, &preview_lines, - has_second_delim, pre_hl_id, pre_src_id); + preview_buf = show_sub(eap, old_cursor, &preview_lines, has_second_delim, + pre_hl_id, pre_src_id); bufhl_clear_line_range(orig_buf, pre_src_id, eap->line1, kv_last(preview_lines.subresults).end.lnum); } @@ -6071,7 +6071,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg) /// Shows the effects of the :substitute command being typed ('inccommand'). /// If inccommand=split, shows a preview window and later restores the layout. -static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub, +static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, PreviewLines *preview_lines, bool show_hl, int hl_id, int src_id) FUNC_ATTR_NONNULL_ALL @@ -6081,8 +6081,6 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub, win_T *save_curwin = curwin; cmdmod_T save_cmdmod = cmdmod; char_u *save_shm_p = vim_strsave(p_shm); - size_t sub_size = mb_string2cells(sub); - size_t pat_size = mb_string2cells(pat); PreviewLines lines = *preview_lines; buf_T *orig_buf = curbuf; @@ -6096,7 +6094,7 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, char_u *pat, char_u *sub, bool outside_curline = (eap->line1 != old_cusr.lnum || eap->line2 != old_cusr.lnum); - bool split = outside_curline && (*p_icm != 'n') && (sub_size || pat_size); + bool split = outside_curline && (*p_icm != 'n'); if (preview_buf == curbuf) { // Preview buffer cannot preview itself! split = false; preview_buf = NULL; -- cgit From d8bb1dabb63501fe4075f062d4ed81bbc62170d0 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sat, 23 Sep 2017 22:57:15 +0200 Subject: Fix the last line in the preview buffer It would always show an empty line at the end that didn't belong. --- src/nvim/ex_cmds.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index b74aad46bf..b9f14f27ea 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -6177,7 +6177,11 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, // Put "|lnum| line" into `str` and append it to the preview buffer. snprintf(str, line_size, "|%*ld| %s", col_width - 3, next_linenr, line); - ml_append(linenr_preview, (char_u *)str, (colnr_T)line_size, false); + if (linenr_preview == 0) { + ml_replace(1, (char_u *)str, true); + } else { + ml_append(linenr_preview, (char_u *)str, (colnr_T)line_size, false); + } linenr_preview += 1; } linenr_origbuf = match.end.lnum; -- cgit From 353c81af1e3cea8d32f834def9ffcbae86c5c727 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sat, 30 Sep 2017 23:20:28 +0200 Subject: Clear highlight when there's no match --- src/nvim/ex_cmds.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index b9f14f27ea..baf2595772 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4052,7 +4052,7 @@ skip: if (got_quit) { // Substitution is too slow, disable 'inccommand'. set_string_option_direct((char_u *)"icm", -1, (char_u *)"", OPT_FREE, SID_NONE); - } else if (*p_icm != NUL && subsize != 0 && pat != NULL) { + } else if (*p_icm != NUL && pat != NULL) { if (pre_src_id == 0) { // Get a unique new src_id, saved in a static pre_src_id = bufhl_add_hl(NULL, 0, -1, 0, 0, 0); @@ -4063,8 +4063,10 @@ skip: curbuf->b_changed = save_b_changed; // preserve 'modified' during preview preview_buf = show_sub(eap, old_cursor, &preview_lines, has_second_delim, pre_hl_id, pre_src_id); - bufhl_clear_line_range(orig_buf, pre_src_id, eap->line1, - kv_last(preview_lines.subresults).end.lnum); + if (subsize > 0) { + bufhl_clear_line_range(orig_buf, pre_src_id, eap->line1, + kv_last(preview_lines.subresults).end.lnum); + } } } @@ -6128,9 +6130,11 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, curwin->w_p_spell = false; curwin->w_p_fen = false; - // Width of the "| lnum|..." column which displays the line numbers. - highest_num_line = kv_last(lines.subresults).end.lnum; - col_width = log10(highest_num_line) + 1 + 3; + if (lines.subresults.size > 0) { + // Width of the "| lnum|..." column which displays the line numbers. + highest_num_line = kv_last(lines.subresults).end.lnum; + col_width = log10(highest_num_line) + 1 + 3; + } } char *str = NULL; // construct the line to show in here -- cgit From 0c358725b189f7d25c15c4fc7c454218316793b5 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sat, 23 Sep 2017 20:38:52 +0200 Subject: Fix highlighting conflict --- src/nvim/ex_cmds.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index baf2595772..ab4c52a635 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3683,6 +3683,7 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) // go beyond the last line of the buffer. if (nmatch > curbuf->b_ml.ml_line_count - sub_firstlnum + 1) { nmatch = curbuf->b_ml.ml_line_count - sub_firstlnum + 1; + current_match.end.lnum = sub_firstlnum + nmatch; skip_match = true; } @@ -3715,7 +3716,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) // be shown also, but should not be highlighted. Intentional for now. if (preview && !has_second_delim) { current_match.start.col = regmatch.startpos[0].col; - current_match.end.lnum = sub_firstlnum + nmatch - 1; + if (current_match.end.lnum == 0) { + current_match.end.lnum = sub_firstlnum + nmatch - 1; + } current_match.end.col = regmatch.endpos[0].col; ADJUST_SUB_FIRSTLNUM(); @@ -4061,7 +4064,7 @@ skip: pre_hl_id = syn_check_group((char_u *)"Substitute", 13); } curbuf->b_changed = save_b_changed; // preserve 'modified' during preview - preview_buf = show_sub(eap, old_cursor, &preview_lines, has_second_delim, + preview_buf = show_sub(eap, old_cursor, &preview_lines, true, pre_hl_id, pre_src_id); if (subsize > 0) { bufhl_clear_line_range(orig_buf, pre_src_id, eap->line1, @@ -6170,13 +6173,18 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, if (next_linenr == match.end.lnum) { p_end.lnum = linenr_preview + 1; } - char_u *line = ml_get_buf(orig_buf, next_linenr, false); - line_size = STRLEN(line) + col_width + 1; + char_u *line; + if (next_linenr == orig_buf->b_ml.ml_line_count + 1) { + line = (char_u *)""; + } else { + line = ml_get_buf(orig_buf, next_linenr, false); + line_size = STRLEN(line) + col_width + 1; - // Reallocate if line not long enough - if (line_size > old_line_size) { - str = xrealloc(str, line_size * sizeof(char)); - old_line_size = line_size; + // Reallocate if line not long enough + if (line_size > old_line_size) { + str = xrealloc(str, line_size * sizeof(char)); + old_line_size = line_size; + } } // Put "|lnum| line" into `str` and append it to the preview buffer. snprintf(str, line_size, "|%*ld| %s", col_width - 3, @@ -6250,7 +6258,11 @@ void ex_substitute(exarg_T *eap) curwin->w_p_cul = false; // Disable 'cursorline' curwin->w_p_cuc = false; // Disable 'cursorcolumn' + // Don't show search highlighting during live substitution + bool save_hls = p_hls; + p_hls = false; buf_T *preview_buf = do_sub(eap, profile_setlimit(p_rdt)); + p_hls = save_hls; if (save_changedtick != curbuf->b_changedtick) { // Undo invisibly. This also moves the cursor! -- cgit From 7b4baad6747a1f812bdf62e5c8c7b59a6977ce44 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sun, 24 Sep 2017 14:17:59 +0200 Subject: Remove superflous parameter from show_sub --- src/nvim/ex_cmds.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index ab4c52a635..85e65f32c2 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4064,7 +4064,7 @@ skip: pre_hl_id = syn_check_group((char_u *)"Substitute", 13); } curbuf->b_changed = save_b_changed; // preserve 'modified' during preview - preview_buf = show_sub(eap, old_cursor, &preview_lines, true, + preview_buf = show_sub(eap, old_cursor, &preview_lines, pre_hl_id, pre_src_id); if (subsize > 0) { bufhl_clear_line_range(orig_buf, pre_src_id, eap->line1, @@ -6077,8 +6077,7 @@ void set_context_in_sign_cmd(expand_T *xp, char_u *arg) /// Shows the effects of the :substitute command being typed ('inccommand'). /// If inccommand=split, shows a preview window and later restores the layout. static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, - PreviewLines *preview_lines, bool show_hl, int hl_id, - int src_id) + PreviewLines *preview_lines, int hl_id, int src_id) FUNC_ATTR_NONNULL_ALL { static handle_T bufnr = 0; // special buffer, re-used on each visit @@ -6198,15 +6197,11 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr, } linenr_origbuf = match.end.lnum; - if (show_hl) { - bufhl_add_hl_pos_offset(preview_buf, src_id, hl_id, p_start, - p_end, col_width); - } - } - if (show_hl) { - bufhl_add_hl_pos_offset(orig_buf, src_id, hl_id, match.start, - match.end, 0); + bufhl_add_hl_pos_offset(preview_buf, src_id, hl_id, p_start, + p_end, col_width); } + bufhl_add_hl_pos_offset(orig_buf, src_id, hl_id, match.start, + match.end, 0); } xfree(str); -- cgit From 22d161a5dd1c519f998916f45d61be92662fbb44 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 29 Oct 2017 20:11:44 +0300 Subject: api/vim: Add nvim_parse_expression function --- src/nvim/api/vim.c | 66 ++++++++++++++++++++++++++++++++++++++ src/nvim/viml/parser/expressions.c | 4 +-- src/nvim/viml/parser/expressions.h | 3 ++ 3 files changed, 70 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 98f4410347..9daa2fb398 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -886,6 +886,72 @@ theend: return rv; } +/// Parse a VimL expression +/// +/// @param[in] expr Expression to parse. Is always treated as a single line. +/// @param[in] flags Flags: "m" if multiple expressions in a row are allowed +/// (only the first one will be parsed), "E" if EOC tokens +/// are not allowed (determines whether they will stop +/// parsing process or be recognized as an operator/space, +/// though also yielding an error). +/// +/// Use only "m" to parse like for "=", only "E" to +/// parse like for ":echo", empty string for ":let". +/// +/// @return AST: top-level dectionary holds keys +/// +/// "error": Dictionary with error, present only if parser saw some +/// error. Contains the following keys: +/// +/// "message": String, error message in printf format, translated. +/// Must contain exactly one "%.*s". +/// "arg": String, error message argument. +/// +/// "ast": actual AST, a dictionary with the following keys: +/// +/// "type": node type, one of the value names from ExprASTNodeType +/// stringified without "kExprNode" prefix. +/// "start": a pair [line, column] describing where node is “started†+/// where "line" is always 0 (will not be 0 if you will be +/// using nvim_parse_viml() on e.g. ":let", but that is not +/// present yet). Both elements are Integers. +/// "len": “length†of the node. This and "start" are there for +/// debugging purposes primary (debugging parser and providing +/// debug information). +/// "children": a list of nodes described in top/"ast". There always +/// is zero, one or two children, key will contain an +/// empty array if node can have children, but has no and +/// will not be present at all if node can’t have any +/// children. Maximum number of children may be found in +/// node_maxchildren array. +/// +/// Local values (present only for certain nodes): +/// +/// "scope": a single Integer, specifies scope for "Option" and +/// "PlainIdentifier" nodes. For "Option" it is one of +/// ExprOptScope values, for "PlainIdentifier" it is one of +/// ExprVarScope values. +/// "ident": identifier (without scope, if any), present for "Option", +/// "PlainIdentifier", "PlainKey" and "Environment" nodes. +/// "name": Integer, register name (one character) or -1. Only present +/// for "Register" nodes. +/// "cmp_type": String, comparison type, one of the value names from +/// ExprComparisonType, stringified without "kExprCmp" +/// prefix. Only present for "Comparison" nodes. +/// "ccs_strategy": String, case comparison strategy, one of the +/// value names from ExprCaseCompareStrategy, +/// stringified without "kCCStrategy" prefix. Only +/// present for "Comparison" nodes. +/// "ivalue": Integer, integer value for "Integer" nodes. +/// "fvalue": Float, floating-point value for "Float" nodes. +/// "svalue": String, value for "SingleQuotedString" and +/// "DoubleQuotedString" nodes. +Dictionary nvim_parse_expression(String expr, String flags, Error *err) + FUNC_API_SINCE(4) +{ + return (Dictionary)ARRAY_DICT_INIT; +} + /// Writes a message to vim output or error buffer. The string is split /// and flushed after each newline. Incomplete lines are kept for writing diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index b413d56592..4e8a9b8523 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -849,8 +849,7 @@ static inline void viml_pexpr_debug_print_token( viml_pexpr_debug_print_token(pstate, tkn) #endif -#ifndef NDEBUG -static const uint8_t node_maxchildren[] = { +const uint8_t node_maxchildren[] = { [kExprNodeMissing] = 0, [kExprNodeOpMissing] = 2, [kExprNodeTernary] = 2, @@ -890,7 +889,6 @@ static const uint8_t node_maxchildren[] = { [kExprNodeOption] = 0, [kExprNodeEnvironment] = 0, }; -#endif /// Free memory occupied by AST /// diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index d783518b3a..d00d4855f3 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -338,6 +338,9 @@ typedef struct { ExprASTNode *root; } ExprAST; +/// Array mapping ExprASTNodeType to maximum amount of children node may have +extern const uint8_t node_maxchildren[]; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "viml/parser/expressions.h.generated.h" #endif -- cgit From 748f3ad5bbf9706dddddeea5df693221d6ae5e94 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 29 Oct 2017 21:30:06 +0300 Subject: syntax,viml/expressions/parser: Create defaults for expr highlighting --- src/nvim/ex_docmd.c | 5 +- src/nvim/syntax.c | 599 +++++++++++++++++++++++-------------- src/nvim/viml/parser/expressions.c | 115 +------ 3 files changed, 386 insertions(+), 333 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 3130747e08..664ab69792 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5911,9 +5911,10 @@ static void ex_colorscheme(exarg_T *eap) static void ex_highlight(exarg_T *eap) { - if (*eap->arg == NUL && eap->cmd[2] == '!') + if (*eap->arg == NUL && eap->cmd[2] == '!') { MSG(_("Greetings, Vim user!")); - do_highlight(eap->arg, eap->forceit, FALSE); + } + do_highlight((const char *)eap->arg, eap->forceit, false); } diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 70bda42d83..b418df77a4 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5929,8 +5929,7 @@ static void syntime_report(void) // // When making changes here, also change runtime/colors/default.vim! -static char *highlight_init_both[] = -{ +static const char *highlight_init_both[] = { "Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey", "Cursor guibg=fg guifg=bg", "lCursor guibg=fg guifg=bg", @@ -5954,8 +5953,7 @@ static char *highlight_init_both[] = NULL }; -static char *highlight_init_light[] = -{ +static const char *highlight_init_light[] = { "ColorColumn ctermbg=LightRed guibg=LightRed", "CursorColumn ctermbg=LightGrey guibg=Grey90", "CursorLine cterm=underline guibg=Grey90", @@ -5988,8 +5986,7 @@ static char *highlight_init_light[] = NULL }; -static char *highlight_init_dark[] = -{ +static const char *highlight_init_dark[] = { "ColorColumn ctermbg=DarkRed guibg=DarkRed", "CursorColumn ctermbg=DarkGrey guibg=Grey40", "CursorLine cterm=underline guibg=Grey40", @@ -6022,6 +6019,157 @@ static char *highlight_init_dark[] = NULL }; +static const char *highlight_init_cmdline[] = { + // NVimInternalError should appear only when highlighter has a bug. + "NVimInternalError ctermfg=Red ctermbg=Red guifg=Red guibg=Red", + + // Highlight groups (links) used by parser: + + "default link NVimOperator Operator", + + "default link NVimUnaryOperator NVimOperator", + "default link NVimUnaryPlus NVimUnaryOperator", + + "default link NVimBinaryOperator NVimOperator", + "default link NVimComparison NVimBinaryOperator", + "default link NVimComparisonModifier NVimComparison", + "default link NVimBinaryPlus NVimBinaryOperator", + "default link NVimConcat NVimBinaryOperator", + "default link NVimConcatOrSubscript NVimConcat", + + "default link NVimTernary NVimOperator", + "default link NVimTernaryColon NVimTernary", + + "default link NVimParenthesis Delimiter", + "default link NVimLambda NVimParenthesis", + "default link NVimNestingParenthesis NVimParenthesis", + "default link NVimCallingParenthesis NVimParenthesis", + + "default link NVimSubscript NVimParenthesis", + "default link NVimSubscriptBracket NVimSubscript", + "default link NVimSubscriptColon NVimSubscript", + "default link NVimSubscriptColon NVimSubscript", + "default link NVimCurly NVimSubscript", + + "default link NVimContainer NVimParenthesis", + "default link NVimDict NVimContainer", + "default link NVimList NVimContainer", + + "default link NVimIdentifier Identifier", + "default link NVimIdentifierScope NVimIdentifier", + "default link NVimIdentifierScopeDelimiter NVimIdentifier", + "default link NVimIdentifierName NVimIdentifier", + "default link NVimIdentifierKey NVimIdentifier", + + "default link NVimColon Delimiter", + "default link NVimComma Delimiter", + "default link NVimArrow Delimiter", + + "default link NVimRegister SpecialChar", + "default link NVimNumber Number", + "default link NVimFloat NVimNumber", + "default link NVimNumberPrefix SpecialChar", + + "default link NVimString String", + "default link NVimStringBody NVimString", + "default link NVimStringQuote NVimString", + "default link NVimStringSpecial SpecialChar", + + "default link NVimSingleQuote NVimStringQuote", + "default link NVimSingleQuotedBody NVimStringBody", + "default link NVimSingleQuotedQuote NVimStringSpecial", + + "default link NVimDoubleQuote NVimStringQuote", + "default link NVimDoubleQuotedBody NVimStringBody", + "default link NVimDoubleQuotedEscape NVimStringSpecial", + // Not actually invalid, but we highlight user that he is doing something + // wrong. + "default link NVimDoubleQuotedUnknownEscape NVimInvalidValue", + + "default link NVimFigureBrace NVimInternalError", + "default link NVimSingleQuotedUnknownEscape NVimInternalError", + + // NVimInvalid groups: + + "default link NVimInvalidSingleQuotedUnknownEscape NVimInternalError", + + "default link NVimInvalid Error", + + "default link NVimInvalidOperator NVimInvalid", + + "default link NVimInvalidUnaryOperator NVimInvalidOperator", + "default link NVimInvalidUnaryPlus NVimInvalidUnaryOperator", + + "default link NVimInvalidBinaryOperator NVimInvalidOperator", + "default link NVimInvalidComparison NVimInvalidBinaryOperator", + "default link NVimInvalidComparisonModifier NVimInvalidComparison", + "default link NVimInvalidBinaryPlus NVimInvalidBinaryOperator", + "default link NVimInvalidConcat NVimInvalidBinaryOperator", + "default link NVimInvalidConcatOrSubscript NVimInvalidConcat", + + "default link NVimInvalidTernary NVimInvalidOperator", + "default link NVimInvalidTernaryColon NVimInvalidTernary", + + "default link NVimInvalidDelimiter NVimInvalid", + + "default link NVimInvalidParenthesis NVimInvalidDelimiter", + "default link NVimInvalidLambda NVimInvalidParenthesis", + "default link NVimInvalidNestingParenthesis NVimInvalidParenthesis", + "default link NVimInvalidCallingParenthesis NVimInvalidParenthesis", + + "default link NVimInvalidSubscript NVimInvalidParenthesis", + "default link NVimInvalidSubscriptBracket NVimInvalidSubscript", + "default link NVimInvalidSubscriptColon NVimInvalidSubscript", + "default link NVimInvalidSubscriptColon NVimInvalidSubscript", + "default link NVimInvalidCurly NVimInvalidSubscript", + + "default link NVimInvalidContainer NVimInvalidParenthesis", + "default link NVimInvalidDict NVimInvalidContainer", + "default link NVimInvalidList NVimInvalidContainer", + + "default link NVimInvalidIdentifier Identifier", + "default link NVimInvalidIdentifierScope NVimIdentifier", + "default link NVimInvalidIdentifierScopeDelimiter NVimIdentifier", + "default link NVimInvalidIdentifierName NVimIdentifier", + "default link NVimInvalidIdentifierKey NVimIdentifier", + + "default link NVimInvalidColon NVimInvalidDelimiter", + "default link NVimInvalidComma NVimInvalidDelimiter", + "default link NVimInvalidArrow NVimInvalidDelimiter", + + "default link NVimInvalidValue NVimInvalid", + + "default link NVimInvalidRegister NVimInvalidValue", + "default link NVimInvalidNumber NVimInvalidValue", + "default link NVimInvalidFloat NVimInvalidNumber", + "default link NVimInvalidNumberPrefix NVimInvalidNumber", + + // Invalid string bodies and specials are still highlighted as valid ones to + // minimize the red area. + "default link NVimInvalidString NVimInvalidValue", + "default link NVimInvalidStringBody NVimString", + "default link NVimInvalidStringQuote NVimInvalidString", + "default link NVimInvalidStringSpecial NVimStringSpecial", + + "default link NVimInvalidSingleQuote NVimInvalidStringQuote", + "default link NVimInvalidSingleQuotedBody NVimInvalidStringBody", + "default link NVimInvalidSingleQuotedQuote NVimInvalidStringSpecial", + + "default link NVimInvalidDoubleQuote NVimInvalidStringQuote", + "default link NVimInvalidDoubleQuotedBody NVimInvalidStringBody", + "default link NVimInvalidDoubleQuotedEscape NVimInvalidStringSpecial", + "default link NVimInvalidDoubleQuotedUnknownEscape NVimInvalidValue", + + "default link NVimInvalidFigureBrace NVimInternalError", +}; + +/// Create default links for NVim* highlight groups used for cmdline coloring +void syn_init_cmdline_highlight(bool reset, bool init) +{ + for (size_t i = 0 ; i < ARRAY_SIZE(highlight_init_cmdline) ; i++) { + do_highlight(highlight_init_cmdline[i], reset, init); + } +} /// Load colors from a file if "g:colors_name" is set, otherwise load builtin /// colors @@ -6032,7 +6180,6 @@ void init_highlight(int both, int reset) { int i; - char **pp; static int had_both = FALSE; // Try finding the color scheme file. Used when a color file was loaded @@ -6054,9 +6201,9 @@ init_highlight(int both, int reset) */ if (both) { had_both = TRUE; - pp = highlight_init_both; + const char *const *const pp = highlight_init_both; for (i = 0; pp[i] != NULL; i++) { - do_highlight((char_u *)pp[i], reset, true); + do_highlight(pp[i], reset, true); } } else if (!had_both) { // Don't do anything before the call with both == TRUE from main(). @@ -6065,10 +6212,11 @@ init_highlight(int both, int reset) return; } - pp = (*p_bg == 'l') ? highlight_init_light : highlight_init_dark; - + const char *const *const pp = ((*p_bg == 'l') + ? highlight_init_light + : highlight_init_dark); for (i = 0; pp[i] != NULL; i++) { - do_highlight((char_u *)pp[i], reset, true); + do_highlight(pp[i], reset, true); } /* Reverse looks ugly, but grey may not work for 8 colors. Thus let it @@ -6078,15 +6226,13 @@ init_highlight(int both, int reset) * Clear the attributes, needed when changing the t_Co value. */ if (t_colors > 8) { do_highlight( - (char_u *)(*p_bg == 'l' - ? "Visual cterm=NONE ctermbg=LightGrey" - : "Visual cterm=NONE ctermbg=DarkGrey"), false, - true); + (*p_bg == 'l' + ? "Visual cterm=NONE ctermbg=LightGrey" + : "Visual cterm=NONE ctermbg=DarkGrey"), false, true); } else { - do_highlight((char_u *)"Visual cterm=reverse ctermbg=NONE", - FALSE, TRUE); + do_highlight("Visual cterm=reverse ctermbg=NONE", false, true); if (*p_bg == 'l') - do_highlight((char_u *)"Search ctermfg=black", FALSE, TRUE); + do_highlight("Search ctermfg=black", false, true); } /* @@ -6102,6 +6248,10 @@ init_highlight(int both, int reset) (void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL); recursive--; } + // Without syncolor.vim it is going to screw everything over by defining + // cleared highlight groups by creating links to non-existent groups. This + // effectively prevents ":highlight default" from working properly. + syn_init_cmdline_highlight(reset, true); } } @@ -6137,17 +6287,22 @@ int load_colors(char_u *name) } -/// Handle the ":highlight .." command. -/// When using ":hi clear" this is called recursively for each group with -/// "forceit" and "init" both TRUE. -/// @param init TRUE when called for initializing -void -do_highlight(char_u *line, int forceit, int init) { - char_u *name_end; - char_u *linep; - char_u *key_start; - char_u *arg_start; - char_u *key = NULL, *arg = NULL; +/// Handle ":highlight" command +/// +/// When using ":highlight clear" this is called recursively for each group with +/// forceit and init being both true. +/// +/// @param[in] line Command arguments. +/// @param[in] forceit True when bang is given, allows to link group even if +/// it has its own settings. +/// @param[in] init True when initializing. +void do_highlight(const char *line, const bool forceit, const bool init) + FUNC_ATTR_NONNULL_ALL +{ + const char *name_end; + const char *linep; + const char *key_start; + const char *arg_start; long i; int off; int len; @@ -6161,94 +6316,87 @@ do_highlight(char_u *line, int forceit, int init) { int color; bool is_normal_group = false; // "Normal" group - /* - * If no argument, list current highlighting. - */ - if (ends_excmd(*line)) { + // If no argument, list current highlighting. + if (ends_excmd((uint8_t)(*line))) { for (int i = 1; i <= highlight_ga.ga_len && !got_int; i++) { - // todo(vim): only call when the group has attributes set + // TODO(brammool): only call when the group has attributes set highlight_list_one(i); } return; } - /* - * Isolate the name. - */ - name_end = skiptowhite(line); - linep = skipwhite(name_end); + // Isolate the name. + name_end = (const char *)skiptowhite((const char_u *)line); + linep = (const char *)skipwhite((const char_u *)name_end); - /* - * Check for "default" argument. - */ - if (STRNCMP(line, "default", name_end - line) == 0) { - dodefault = TRUE; + // Check for "default" argument. + if (strncmp(line, "default", name_end - line) == 0) { + dodefault = true; line = linep; - name_end = skiptowhite(line); - linep = skipwhite(name_end); + name_end = (const char *)skiptowhite((const char_u *)line); + linep = (const char *)skipwhite((const char_u *)name_end); } - /* - * Check for "clear" or "link" argument. - */ - if (STRNCMP(line, "clear", name_end - line) == 0) - doclear = TRUE; - if (STRNCMP(line, "link", name_end - line) == 0) - dolink = TRUE; + // Check for "clear" or "link" argument. + if (strncmp(line, "clear", name_end - line) == 0) { + doclear = true; + } else if (strncmp(line, "link", name_end - line) == 0) { + dolink = true; + } - /* - * ":highlight {group-name}": list highlighting for one group. - */ - if (!doclear && !dolink && ends_excmd(*linep)) { - id = syn_namen2id(line, (int)(name_end - line)); - if (id == 0) - EMSG2(_("E411: highlight group not found: %s"), line); - else + // ":highlight {group-name}": list highlighting for one group. + if (!doclear && !dolink && ends_excmd((uint8_t)(*linep))) { + id = syn_namen2id((const char_u *)line, (int)(name_end - line)); + if (id == 0) { + emsgf(_("E411: highlight group not found: %s"), line); + } else { highlight_list_one(id); + } return; } - /* - * Handle ":highlight link {from} {to}" command. - */ + // Handle ":highlight link {from} {to}" command. if (dolink) { - char_u *from_start = linep; - char_u *from_end; - char_u *to_start; - char_u *to_end; + const char *from_start = linep; + const char *from_end; + const char *to_start; + const char *to_end; int from_id; int to_id; - from_end = skiptowhite(from_start); - to_start = skipwhite(from_end); - to_end = skiptowhite(to_start); + from_end = (const char *)skiptowhite((const char_u *)from_start); + to_start = (const char *)skipwhite((const char_u *)from_end); + to_end = (const char *)skiptowhite((const char_u *)to_start); - if (ends_excmd(*from_start) || ends_excmd(*to_start)) { - EMSG2(_("E412: Not enough arguments: \":highlight link %s\""), - from_start); + if (ends_excmd((uint8_t)(*from_start)) + || ends_excmd((uint8_t)(*to_start))) { + emsgf(_("E412: Not enough arguments: \":highlight link %s\""), + from_start); return; } - if (!ends_excmd(*skipwhite(to_end))) { - EMSG2(_("E413: Too many arguments: \":highlight link %s\""), from_start); + if (!ends_excmd(*skipwhite((const char_u *)to_end))) { + emsgf(_("E413: Too many arguments: \":highlight link %s\""), from_start); return; } - from_id = syn_check_group(from_start, (int)(from_end - from_start)); - if (STRNCMP(to_start, "NONE", 4) == 0) + from_id = syn_check_group((const char_u *)from_start, + (int)(from_end - from_start)); + if (strncmp(to_start, "NONE", 4) == 0) { to_id = 0; - else - to_id = syn_check_group(to_start, (int)(to_end - to_start)); + } else { + to_id = syn_check_group((const char_u *)to_start, + (int)(to_end - to_start)); + } if (from_id > 0 && (!init || HL_TABLE()[from_id - 1].sg_set == 0)) { - /* - * Don't allow a link when there already is some highlighting - * for the group, unless '!' is used - */ + // Don't allow a link when there already is some highlighting + // for the group, unless '!' is used if (to_id > 0 && !forceit && !init && hl_has_settings(from_id - 1, dodefault)) { - if (sourcing_name == NULL && !dodefault) + if (sourcing_name == NULL && !dodefault) { EMSG(_("E414: group has settings, highlight link ignored")); + } } else { if (!init) HL_TABLE()[from_id - 1].sg_set |= SG_LINK; @@ -6258,43 +6406,38 @@ do_highlight(char_u *line, int forceit, int init) { } } - /* Only call highlight_changed() once, after sourcing a syntax file */ - need_highlight_changed = TRUE; + // Only call highlight_changed() once, after sourcing a syntax file. + need_highlight_changed = true; return; } if (doclear) { - /* - * ":highlight clear [group]" command. - */ + // ":highlight clear [group]" command. line = linep; - if (ends_excmd(*line)) { + if (ends_excmd((uint8_t)(*line))) { do_unlet(S_LEN("colors_name"), true); restore_cterm_colors(); - /* - * Clear all default highlight groups and load the defaults. - */ + // Clear all default highlight groups and load the defaults. for (int idx = 0; idx < highlight_ga.ga_len; ++idx) { highlight_clear(idx); } - init_highlight(TRUE, TRUE); + init_highlight(true, true); highlight_changed(); redraw_later_clear(); return; } - name_end = skiptowhite(line); - linep = skipwhite(name_end); + name_end = (const char *)skiptowhite((const char_u *)line); + linep = (const char *)skipwhite((const char_u *)name_end); } - /* - * Find the group name in the table. If it does not exist yet, add it. - */ - id = syn_check_group(line, (int)(name_end - line)); - if (id == 0) /* failed (out of memory) */ + // Find the group name in the table. If it does not exist yet, add it. + id = syn_check_group((const char_u *)line, (int)(name_end - line)); + if (id == 0) { // Failed (out of memory). return; - idx = id - 1; /* index is ID minus one */ + } + idx = id - 1; // Index is ID minus one. // Return if "default" was used and the group already has settings if (dodefault && hl_has_settings(idx, true)) { @@ -6303,19 +6446,21 @@ do_highlight(char_u *line, int forceit, int init) { is_normal_group = (STRCMP(HL_TABLE()[idx].sg_name_u, "NORMAL") == 0); - /* Clear the highlighting for ":hi clear {group}" and ":hi clear". */ + // Clear the highlighting for ":hi clear {group}" and ":hi clear". if (doclear || (forceit && init)) { highlight_clear(idx); if (!doclear) HL_TABLE()[idx].sg_set = 0; } + char *key = NULL; + char *arg = NULL; if (!doclear) { - while (!ends_excmd(*linep)) { + while (!ends_excmd((uint8_t)(*linep))) { key_start = linep; if (*linep == '=') { - EMSG2(_("E415: unexpected equal sign: %s"), key_start); - error = TRUE; + emsgf(_("E415: unexpected equal sign: %s"), key_start); + error = true; break; } @@ -6325,61 +6470,58 @@ do_highlight(char_u *line, int forceit, int init) { linep++; } xfree(key); - key = vim_strnsave_up(key_start, (int)(linep - key_start)); - linep = skipwhite(linep); + key = (char *)vim_strnsave_up((const char_u *)key_start, + (int)(linep - key_start)); + linep = (const char *)skipwhite((const char_u *)linep); - if (STRCMP(key, "NONE") == 0) { + if (strcmp(key, "NONE") == 0) { if (!init || HL_TABLE()[idx].sg_set == 0) { - if (!init) + if (!init) { HL_TABLE()[idx].sg_set |= SG_CTERM+SG_GUI; + } highlight_clear(idx); } continue; } - /* - * Check for the equal sign. - */ + // Check for the equal sign. if (*linep != '=') { - EMSG2(_("E416: missing equal sign: %s"), key_start); - error = TRUE; + emsgf(_("E416: missing equal sign: %s"), key_start); + error = true; break; } - ++linep; + linep++; - /* - * Isolate the argument. - */ - linep = skipwhite(linep); - if (*linep == '\'') { /* guifg='color name' */ + // Isolate the argument. + linep = (const char *)skipwhite((const char_u *)linep); + if (*linep == '\'') { // guifg='color name' arg_start = ++linep; - linep = vim_strchr(linep, '\''); + linep = strchr(linep, '\''); if (linep == NULL) { - EMSG2(_(e_invarg2), key_start); - error = TRUE; + emsgf(_(e_invarg2), key_start); + error = true; break; } } else { arg_start = linep; - linep = skiptowhite(linep); + linep = (const char *)skiptowhite((const char_u *)linep); } if (linep == arg_start) { - EMSG2(_("E417: missing argument: %s"), key_start); - error = TRUE; + emsgf(_("E417: missing argument: %s"), key_start); + error = true; break; } xfree(arg); - arg = vim_strnsave(arg_start, (int)(linep - arg_start)); + arg = xstrndup(arg_start, (size_t)(linep - arg_start)); - if (*linep == '\'') - ++linep; + if (*linep == '\'') { + linep++; + } - /* - * Store the argument. - */ - if ( STRCMP(key, "TERM") == 0 - || STRCMP(key, "CTERM") == 0 - || STRCMP(key, "GUI") == 0) { + // Store the argument. + if (strcmp(key, "TERM") == 0 + || strcmp(key, "CTERM") == 0 + || strcmp(key, "GUI") == 0) { attr = 0; off = 0; while (arg[off] != NUL) { @@ -6392,26 +6534,30 @@ do_highlight(char_u *line, int forceit, int init) { } } if (i < 0) { - EMSG2(_("E418: Illegal value: %s"), arg); - error = TRUE; + emsgf(_("E418: Illegal value: %s"), arg); + error = true; break; } - if (arg[off] == ',') /* another one follows */ - ++off; + if (arg[off] == ',') { // Another one follows. + off++; + } } - if (error) + if (error) { break; + } if (*key == 'C') { if (!init || !(HL_TABLE()[idx].sg_set & SG_CTERM)) { - if (!init) + if (!init) { HL_TABLE()[idx].sg_set |= SG_CTERM; + } HL_TABLE()[idx].sg_cterm = attr; HL_TABLE()[idx].sg_cterm_bold = FALSE; } } else if (*key == 'G') { if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) { - if (!init) + if (!init) { HL_TABLE()[idx].sg_set |= SG_GUI; + } HL_TABLE()[idx].sg_gui = attr; } } @@ -6430,14 +6576,14 @@ do_highlight(char_u *line, int forceit, int init) { HL_TABLE()[idx].sg_cterm_bold = FALSE; } - if (ascii_isdigit(*arg)) + if (ascii_isdigit(*arg)) { color = atoi((char *)arg); - else if (STRICMP(arg, "fg") == 0) { - if (cterm_normal_fg_color) + } else if (STRICMP(arg, "fg") == 0) { + if (cterm_normal_fg_color) { color = cterm_normal_fg_color - 1; - else { + } else { EMSG(_("E419: FG color unknown")); - error = TRUE; + error = true; break; } } else if (STRICMP(arg, "bg") == 0) { @@ -6445,70 +6591,85 @@ do_highlight(char_u *line, int forceit, int init) { color = cterm_normal_bg_color - 1; else { EMSG(_("E420: BG color unknown")); - error = TRUE; + error = true; break; } } else { - static char *(color_names[28]) = { + static const char *color_names[] = { "Black", "DarkBlue", "DarkGreen", "DarkCyan", "DarkRed", "DarkMagenta", "Brown", "DarkYellow", "Gray", "Grey", "LightGray", "LightGrey", "DarkGray", "DarkGrey", "Blue", "LightBlue", "Green", "LightGreen", "Cyan", "LightCyan", "Red", "LightRed", "Magenta", - "LightMagenta", "Yellow", "LightYellow", "White", "NONE" + "LightMagenta", "Yellow", "LightYellow", "White", + "NONE" + }; + static const int color_numbers_16[] = { + 0, 1, 2, 3, + 4, 5, 6, 6, + 7, 7, + 7, 7, 8, 8, + 9, 9, 10, 10, + 11, 11, 12, 12, 13, + 13, 14, 14, 15, + -1 + }; + // For xterm with 88 colors: + static int color_numbers_88[] = { + 0, 4, 2, 6, + 1, 5, 32, 72, + 84, 84, + 7, 7, 82, 82, + 12, 43, 10, 61, + 14, 63, 9, 74, 13, + 75, 11, 78, 15, + -1 + }; + // For xterm with 256 colors: + static int color_numbers_256[] = { + 0, 4, 2, 6, + 1, 5, 130, 130, + 248, 248, + 7, 7, 242, 242, + 12, 81, 10, 121, + 14, 159, 9, 224, 13, + 225, 11, 229, 15, + -1 }; - static int color_numbers_16[28] = {0, 1, 2, 3, - 4, 5, 6, 6, - 7, 7, - 7, 7, 8, 8, - 9, 9, 10, 10, - 11, 11, 12, 12, 13, - 13, 14, 14, 15, -1}; - /* for xterm with 88 colors... */ - static int color_numbers_88[28] = {0, 4, 2, 6, - 1, 5, 32, 72, - 84, 84, - 7, 7, 82, 82, - 12, 43, 10, 61, - 14, 63, 9, 74, 13, - 75, 11, 78, 15, -1}; - /* for xterm with 256 colors... */ - static int color_numbers_256[28] = {0, 4, 2, 6, - 1, 5, 130, 130, - 248, 248, - 7, 7, 242, 242, - 12, 81, 10, 121, - 14, 159, 9, 224, 13, - 225, 11, 229, 15, -1}; - /* for terminals with less than 16 colors... */ - static int color_numbers_8[28] = {0, 4, 2, 6, - 1, 5, 3, 3, - 7, 7, - 7, 7, 0+8, 0+8, - 4+8, 4+8, 2+8, 2+8, - 6+8, 6+8, 1+8, 1+8, 5+8, - 5+8, 3+8, 3+8, 7+8, -1}; - - /* reduce calls to STRICMP a bit, it can be slow */ + // For terminals with less than 16 colors: + static int color_numbers_8[28] = { + 0, 4, 2, 6, + 1, 5, 3, 3, + 7, 7, + 7, 7, 0+8, 0+8, + 4+8, 4+8, 2+8, 2+8, + 6+8, 6+8, 1+8, 1+8, 5+8, + 5+8, 3+8, 3+8, 7+8, + -1 + }; + + // Reduce calls to STRICMP a bit, it can be slow. off = TOUPPER_ASC(*arg); - for (i = ARRAY_SIZE(color_names); --i >= 0; ) + for (i = ARRAY_SIZE(color_names); --i >= 0; ) { if (off == color_names[i][0] - && STRICMP(arg + 1, color_names[i] + 1) == 0) + && STRICMP(arg + 1, color_names[i] + 1) == 0) { break; + } + } if (i < 0) { - EMSG2(_( + emsgf(_( "E421: Color name or number not recognized: %s"), key_start); - error = TRUE; + error = true; break; } - /* Use the _16 table to check if its a valid color name. */ + // Use the _16 table to check if its a valid color name. color = color_numbers_16[i]; if (color >= 0) { if (t_colors == 8) { - /* t_Co is 8: use the 8 colors table */ + // t_Co is 8: use the 8 colors table. color = color_numbers_8[i]; if (key[5] == 'F') { /* set/reset bold attribute to get light foreground @@ -6532,16 +6693,14 @@ do_highlight(char_u *line, int forceit, int init) { } } } - /* Add one to the argument, to avoid zero. Zero is used for - * "NONE", then "color" is -1. */ + // Add one to the argument, to avoid zero. Zero is used for + // "NONE", then "color" is -1. if (key[5] == 'F') { HL_TABLE()[idx].sg_cterm_fg = color + 1; if (is_normal_group) { cterm_normal_fg_color = color + 1; cterm_normal_fg_bold = (HL_TABLE()[idx].sg_cterm & HL_BOLD); - { - must_redraw = CLEAR; - } + must_redraw = CLEAR; } } else { HL_TABLE()[idx].sg_cterm_bg = color + 1; @@ -6565,15 +6724,15 @@ do_highlight(char_u *line, int forceit, int init) { } } } - } else if (STRCMP(key, "GUIFG") == 0) { + } else if (strcmp(key, "GUIFG") == 0) { if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) { if (!init) HL_TABLE()[idx].sg_set |= SG_GUI; xfree(HL_TABLE()[idx].sg_rgb_fg_name); - if (STRCMP(arg, "NONE")) { - HL_TABLE()[idx].sg_rgb_fg_name = (uint8_t *)xstrdup((char *)arg); - HL_TABLE()[idx].sg_rgb_fg = name_to_color(arg); + if (strcmp(arg, "NONE")) { + HL_TABLE()[idx].sg_rgb_fg_name = (char_u *)xstrdup((char *)arg); + HL_TABLE()[idx].sg_rgb_fg = name_to_color((const char_u *)arg); } else { HL_TABLE()[idx].sg_rgb_fg_name = NULL; HL_TABLE()[idx].sg_rgb_fg = -1; @@ -6590,8 +6749,8 @@ do_highlight(char_u *line, int forceit, int init) { xfree(HL_TABLE()[idx].sg_rgb_bg_name); if (STRCMP(arg, "NONE") != 0) { - HL_TABLE()[idx].sg_rgb_bg_name = (uint8_t *)xstrdup((char *)arg); - HL_TABLE()[idx].sg_rgb_bg = name_to_color(arg); + HL_TABLE()[idx].sg_rgb_bg_name = (char_u *)xstrdup((char *)arg); + HL_TABLE()[idx].sg_rgb_bg = name_to_color((const char_u *)arg); } else { HL_TABLE()[idx].sg_rgb_bg_name = NULL; HL_TABLE()[idx].sg_rgb_bg = -1; @@ -6601,15 +6760,15 @@ do_highlight(char_u *line, int forceit, int init) { if (is_normal_group) { normal_bg = HL_TABLE()[idx].sg_rgb_bg; } - } else if (STRCMP(key, "GUISP") == 0) { + } else if (strcmp(key, "GUISP") == 0) { if (!init || !(HL_TABLE()[idx].sg_set & SG_GUI)) { if (!init) HL_TABLE()[idx].sg_set |= SG_GUI; xfree(HL_TABLE()[idx].sg_rgb_sp_name); - if (STRCMP(arg, "NONE") != 0) { - HL_TABLE()[idx].sg_rgb_sp_name = (uint8_t *)xstrdup((char *)arg); - HL_TABLE()[idx].sg_rgb_sp = name_to_color(arg); + if (strcmp(arg, "NONE") != 0) { + HL_TABLE()[idx].sg_rgb_sp_name = (char_u *)xstrdup((char *)arg); + HL_TABLE()[idx].sg_rgb_sp = name_to_color((const char_u *)arg); } else { HL_TABLE()[idx].sg_rgb_sp_name = NULL; HL_TABLE()[idx].sg_rgb_sp = -1; @@ -6619,31 +6778,25 @@ do_highlight(char_u *line, int forceit, int init) { if (is_normal_group) { normal_sp = HL_TABLE()[idx].sg_rgb_sp; } - } else if (STRCMP(key, "START") == 0 || STRCMP(key, "STOP") == 0) { + } else if (strcmp(key, "START") == 0 || strcmp(key, "STOP") == 0) { // Ignored for now } else { - EMSG2(_("E423: Illegal argument: %s"), key_start); - error = TRUE; + emsgf(_("E423: Illegal argument: %s"), key_start); + error = true; break; } - /* - * When highlighting has been given for a group, don't link it. - */ + // When highlighting has been given for a group, don't link it. if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK)) { HL_TABLE()[idx].sg_link = 0; } - /* - * Continue with next argument. - */ - linep = skipwhite(linep); + // Continue with next argument. + linep = (const char *)skipwhite((const char_u *)linep); } } - /* - * If there is an error, and it's a new entry, remove it from the table. - */ + // If there is an error, and it's a new entry, remove it from the table. if (error && idx == highlight_ga.ga_len) { syn_unadd_group(); } else { @@ -7201,7 +7354,7 @@ char_u *syn_id2name(int id) /* * Like syn_name2id(), but take a pointer + length argument. */ -int syn_namen2id(char_u *linep, int len) +int syn_namen2id(const char_u *linep, int len) { char_u *name = vim_strnsave(linep, len); int id = syn_name2id(name); @@ -7217,7 +7370,7 @@ int syn_namen2id(char_u *linep, int len) /// @param len length of \p pp /// /// @return 0 for failure else the id of the group -int syn_check_group(char_u *pp, int len) +int syn_check_group(const char_u *pp, int len) { char_u *name = vim_strnsave(pp, len); int id = syn_name2id(name); @@ -8220,7 +8373,7 @@ color_name_table_T color_name_table[] = { /// /// @param[in] name string value to convert to RGB /// return the hex value or -1 if could not find a correct value -RgbValue name_to_color(const uint8_t *name) +RgbValue name_to_color(const char_u *name) { if (name[0] == '#' && isxdigit(name[1]) && isxdigit(name[2]) diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 4e8a9b8523..615a59573f 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -993,107 +993,6 @@ void viml_pexpr_free_ast(ExprAST ast) // > ># >? <= <=# <=? // < <# = >=# >=? // is is# is? isnot isnot# isnot? -// -// Used highlighting groups and assumed linkage: -// -// NVimInternalError -> highlight as fg:red/bg:red -// -// NVimInvalid -> Error -// NVimInvalidValue -> NVimInvalid -// NVimInvalidOperator -> NVimInvalid -// NVimInvalidDelimiter -> NVimInvalid -// -// NVimOperator -> Operator -// NVimUnaryOperator -> NVimOperator -// NVimBinaryOperator -> NVimOperator -// -// NVimComparisonOperator -> NVimBinaryOperator -// NVimComparisonOperatorModifier -> NVimComparisonOperator -// -// NVimTernary -> NVimOperator -// NVimTernaryColon -> NVimTernary -// -// NVimParenthesis -> Delimiter -// -// NVimColon -> Delimiter -// NVimComma -> Delimiter -// NVimArrow -> Delimiter -// -// NVimLambda -> Delimiter -// NVimDict -> Delimiter -// NVimCurly -> Delimiter -// -// NVimList -> Delimiter -// NVimSubscript -> Delimiter -// NVimSubscriptColon -> NVimSubscript -// -// NVimIdentifier -> Identifier -// NVimIdentifierScope -> NVimIdentifier -// NVimIdentifierScopeDelimiter -> NVimIdentifier -// -// NVimIdentifierKey -> Identifier -// -// NVimUnaryPlus -> NVimUnaryOperator -// NVimBinaryPlus -> NVimBinaryOperator -// NVimConcat -> NVimBinaryOperator -// NVimConcatOrSubscript -> NVimConcat -// -// NVimRegister -> SpecialChar -// NVimNumber -> Number -// NVimNumberPrefix -> SpecialChar -// NVimFloat -> NVimNumber -// -// NVimNestingParenthesis -> NVimParenthesis -// NVimCallingParenthesis -> NVimParenthesis -// -// NVimString -> String -// NVimStringSpecial -> SpecialChar -// NVimSingleQuote -> NVimString -// NVimSingleQuotedBody -> NVimString -// NVimSingleQuotedQuote -> NVimStringSpecial -// NVimDoubleQuote -> NVimString -// NVimDoubleQuotedBody -> NVimString -// NVimDoubleQuotedEscape -> NVimStringSpecial -// NVimDoubleQuotedUnknownEscape -> NVimInvalid -// -// " Note: NVimDoubleQuotedUnknownEscape is not actually invalid -// -// NVimInvalidComma -> NVimInvalidDelimiter -// NVimInvalidSpacing -> NVimInvalid -// NVimInvalidTernary -> NVimInvalidOperator -// NVimInvalidTernaryColon -> NVimInvalidTernary -// NVimInvalidRegister -> NVimInvalidValue -// NVimInvalidClosingBracket -> NVimInvalidDelimiter -// NVimInvalidSpacing -> NVimInvalid -// NVimInvalidArrow -> NVimInvalidDelimiter -// NVimInvalidLambda -> NVimInvalidDelimiter -// NVimInvalidDict -> NVimInvalidDelimiter -// NVimInvalidCurly -> NVimInvalidDelimiter -// NVimInvalidFigureBrace -> NVimInvalidDelimiter -// NVimInvalidIdentifier -> NVimInvalidValue -// NVimInvalidIdentifierScope -> NVimInvalidValue -// NVimInvalidIdentifierScopeDelimiter -> NVimInvalidValue -// NVimInvalidComparisonOperator -> NVimInvalidOperator -// NVimInvalidComparisonOperatorModifier -> NVimInvalidComparisonOperator -// NVimInvalidNumber -> NVimInvalidValue -// NVimInvalidFloat -> NVimInvalidValue -// NVimInvalidIdentifierKey -> NVimInvalidIdentifier -// NVimInvalidList -> NVimInvalidDelimiter -// NVimInvalidSubscript -> NVimInvalidDelimiter -// NVimInvalidSubscriptColon -> NVimInvalidSubscript -// NVimInvalidString -> NVimInvalidValue -// NVimInvalidStringSpecial -> NVimInvalidString -// NVimInvalidSingleQuote -> NVimInvalidString -// NVimInvalidSingleQuotedBody -> NVimInvalidString -// NVimInvalidSingleQuotedQuote -> NVimInvalidStringSpecial -// NVimInvalidDoubleQuote -> NVimInvalidString -// NVimInvalidDoubleQuotedBody -> NVimInvalidString -// NVimInvalidDoubleQuotedEscape -> NVimInvalidStringSpecial -// NVimInvalidDoubleQuotedUnknownEscape -> NVimInvalidDoubleQuotedEscape -// -// NVimFigureBrace -> NVimInternalError -// NVimInvalidSingleQuotedUnknownEscape -> NVimInternalError -// NVimSingleQuotedUnknownEscape -> NVimInternalError /// Allocate a new node and set some of the values /// @@ -2183,12 +2082,12 @@ viml_pexpr_parse_process_token: ADD_OP_NODE(cur_node); if (cur_token.data.cmp.ccs != kCCStrategyUseOption) { viml_parser_highlight(pstate, cur_token.start, cur_token.len - 1, - HL(ComparisonOperator)); + HL(Comparison)); viml_parser_highlight( pstate, shifted_pos(cur_token.start, cur_token.len - 1), 1, - HL(ComparisonOperatorModifier)); + HL(ComparisonModifier)); } else { - HL_CUR_TOKEN(ComparisonOperator); + HL_CUR_TOKEN(Comparison); } want_node = kENodeValue; break; @@ -2390,7 +2289,7 @@ viml_pexpr_parse_valid_colon: break; } case kExprNodeSubscript: { - HL_CUR_TOKEN(Subscript); + HL_CUR_TOKEN(SubscriptBracket); break; } default: { @@ -2418,7 +2317,7 @@ viml_pexpr_parse_bracket_closing_error: } NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeSubscript); ADD_OP_NODE(cur_node); - HL_CUR_TOKEN(Subscript); + HL_CUR_TOKEN(SubscriptBracket); } } break; @@ -2626,7 +2525,7 @@ viml_pexpr_parse_figure_brace_closing_error: cur_token.len - scope_shift, (node_is_key ? HL(IdentifierKey) - : HL(Identifier))); + : HL(IdentifierName))); } else { if (scope == kExprVarScopeMissing) { ADD_IDENT( @@ -2637,7 +2536,7 @@ viml_pexpr_parse_figure_brace_closing_error: cur_node->data.var.ident_len = cur_token.len; want_node = kENodeOperator; } while (0), - Identifier); + IdentifierName); } else { OP_MISSING; } -- cgit From b91cb18c3688a4a936c14484af57de05ca113641 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 29 Oct 2017 21:42:37 +0300 Subject: syntax: Adjust position and arguments of syn_init_cmdline_highlight This way it works both after `nvim -u NORC` and after that and `colorscheme wombat256mod`. Removed the comment because I do not actually know why it works here with these arguments and not in previous position with previous arguments. --- src/nvim/syntax.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index b418df77a4..f8a62423ce 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6248,11 +6248,8 @@ init_highlight(int both, int reset) (void)source_runtime((char_u *)"syntax/syncolor.vim", DIP_ALL); recursive--; } - // Without syncolor.vim it is going to screw everything over by defining - // cleared highlight groups by creating links to non-existent groups. This - // effectively prevents ":highlight default" from working properly. - syn_init_cmdline_highlight(reset, true); } + syn_init_cmdline_highlight(false, false); } /* -- cgit From 538af1c90a4ac9928f60e97338869e516def4956 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 29 Oct 2017 22:02:19 +0300 Subject: syntax,viml/parser/expressions: Add missing highlight groups Also adjusts some names. --- src/nvim/syntax.c | 39 ++++++++++++++++++++++++++++++++++++-- src/nvim/viml/parser/expressions.c | 12 ++++++------ 2 files changed, 43 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index f8a62423ce..d787790bc3 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6029,6 +6029,8 @@ static const char *highlight_init_cmdline[] = { "default link NVimUnaryOperator NVimOperator", "default link NVimUnaryPlus NVimUnaryOperator", + "default link NVimUnaryMinus NVimUnaryOperator", + "default link NVimNot NVimUnaryOperator", "default link NVimBinaryOperator NVimOperator", "default link NVimComparison NVimBinaryOperator", @@ -6036,6 +6038,11 @@ static const char *highlight_init_cmdline[] = { "default link NVimBinaryPlus NVimBinaryOperator", "default link NVimConcat NVimBinaryOperator", "default link NVimConcatOrSubscript NVimConcat", + "default link NVimOr NVimBinaryOperator", + "default link NVimAnd NVimBinaryOperator", + "default link NVimMultiplication NVimBinaryOperator", + "default link NVimDivision NVimBinaryOperator", + "default link NVimMod NVimBinaryOperator", "default link NVimTernary NVimOperator", "default link NVimTernaryColon NVimTernary", @@ -6068,7 +6075,15 @@ static const char *highlight_init_cmdline[] = { "default link NVimRegister SpecialChar", "default link NVimNumber Number", "default link NVimFloat NVimNumber", - "default link NVimNumberPrefix SpecialChar", + "default link NVimNumberPrefix Type", + + "default link NVimOptionSigil Type", + "default link NVimOptionName NVimIdentifier", + "default link NVimOptionScope NVimIdentifierScope", + "default link NVimOptionScopeDelimiter NVimIdentifierScopeDelimiter", + + "default link NVimEnvironmentSigil NVimOptionSigil", + "default link NVimEnvironmentName NVimIdentifier", "default link NVimString String", "default link NVimStringBody NVimString", @@ -6089,6 +6104,8 @@ static const char *highlight_init_cmdline[] = { "default link NVimFigureBrace NVimInternalError", "default link NVimSingleQuotedUnknownEscape NVimInternalError", + "default link NVimSpacing Normal", + // NVimInvalid groups: "default link NVimInvalidSingleQuotedUnknownEscape NVimInternalError", @@ -6099,6 +6116,8 @@ static const char *highlight_init_cmdline[] = { "default link NVimInvalidUnaryOperator NVimInvalidOperator", "default link NVimInvalidUnaryPlus NVimInvalidUnaryOperator", + "default link NVimInvalidUnaryMinus NVimInvalidUnaryOperator", + "default link NVimInvalidNot NVimInvalidUnaryOperator", "default link NVimInvalidBinaryOperator NVimInvalidOperator", "default link NVimInvalidComparison NVimInvalidBinaryOperator", @@ -6106,6 +6125,11 @@ static const char *highlight_init_cmdline[] = { "default link NVimInvalidBinaryPlus NVimInvalidBinaryOperator", "default link NVimInvalidConcat NVimInvalidBinaryOperator", "default link NVimInvalidConcatOrSubscript NVimInvalidConcat", + "default link NVimInvalidOr NVimInvalidBinaryOperator", + "default link NVimInvalidAnd NVimInvalidBinaryOperator", + "default link NVimInvalidMultiplication NVimInvalidBinaryOperator", + "default link NVimInvalidDivision NVimInvalidBinaryOperator", + "default link NVimInvalidMod NVimInvalidBinaryOperator", "default link NVimInvalidTernary NVimInvalidOperator", "default link NVimInvalidTernaryColon NVimInvalidTernary", @@ -6144,6 +6168,15 @@ static const char *highlight_init_cmdline[] = { "default link NVimInvalidFloat NVimInvalidNumber", "default link NVimInvalidNumberPrefix NVimInvalidNumber", + "default link NVimInvalidOptionSigil NVimInvalidIdentifier", + "default link NVimInvalidOptionName NVimInvalidIdentifier", + "default link NVimInvalidOptionScope NVimInvalidIdentifierScope", + "default link NVimInvalidOptionScopeDelimiter " + "NVimInvalidIdentifierScopeDelimiter", + + "default link NVimInvalidEnvironmentSigil NVimInvalidOptionSigil", + "default link NVimInvalidEnvironmentName NVimInvalidIdentifier", + // Invalid string bodies and specials are still highlighted as valid ones to // minimize the red area. "default link NVimInvalidString NVimInvalidValue", @@ -6160,7 +6193,9 @@ static const char *highlight_init_cmdline[] = { "default link NVimInvalidDoubleQuotedEscape NVimInvalidStringSpecial", "default link NVimInvalidDoubleQuotedUnknownEscape NVimInvalidValue", - "default link NVimInvalidFigureBrace NVimInternalError", + "default link NVimInvalidFigureBrace NVimInvalidDelimiter", + + "default link NVimInvalidSpacing ErrorMsg", }; /// Create default links for NVim* highlight groups used for cmdline coloring diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 615a59573f..f5bc547d54 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -1472,7 +1472,7 @@ static void parse_quoted_string(ParserState *const pstate, kvec_withinit_t(StringShift, 16) shifts; kvi_init(shifts); if (!is_double) { - viml_parser_highlight(pstate, token.start, 1, HL(SingleQuotedString)); + viml_parser_highlight(pstate, token.start, 1, HL(SingleQuote)); while (p < e) { const char *const chunk_e = memchr(p, '\'', (size_t)(e - p)); if (chunk_e == NULL) { @@ -1509,7 +1509,7 @@ static void parse_quoted_string(ParserState *const pstate, } } } else { - viml_parser_highlight(pstate, token.start, 1, HL(DoubleQuotedString)); + viml_parser_highlight(pstate, token.start, 1, HL(DoubleQuote)); for (p = s + 1; p < e; p++) { if (*p == '\\' && p + 1 < e) { p++; @@ -1741,10 +1741,10 @@ static void parse_quoted_string(ParserState *const pstate, if (token.data.str.closed) { if (is_double) { viml_parser_highlight(pstate, shifted_pos(token.start, token.len - 1), - 1, HL(DoubleQuotedString)); + 1, HL(DoubleQuote)); } else { viml_parser_highlight(pstate, shifted_pos(token.start, token.len - 1), - 1, HL(SingleQuotedString)); + 1, HL(SingleQuote)); } } kvi_destroy(shifts); @@ -2035,7 +2035,7 @@ viml_pexpr_parse_process_token: } viml_parser_highlight( pstate, shifted_pos(cur_token.start, scope_shift + 1), - cur_token.len - (scope_shift + 1), HL(Option)); + cur_token.len - (scope_shift + 1), HL(OptionName)); break; } case kExprLexEnv: { @@ -2053,7 +2053,7 @@ viml_pexpr_parse_process_token: want_node = kENodeOperator; viml_parser_highlight(pstate, cur_token.start, 1, HL(EnvironmentSigil)); viml_parser_highlight(pstate, shifted_pos(cur_token.start, 1), - cur_token.len - 1, HL(Environment)); + cur_token.len - 1, HL(EnvironmentName)); break; } case kExprLexNot: { -- cgit From a9b203d23fcc6ba8c4e298b8e082db990e1ec04f Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 30 Oct 2017 01:32:10 +0300 Subject: *: Fix linter errors Big function in expressions.c may be refactored, if I ever catch the idea how to split it right. --- src/nvim/edit.c | 2 +- src/nvim/keymap.c | 24 ++++++++++++------------ src/nvim/mbyte.c | 26 +++++++++++++++++--------- src/nvim/syntax.c | 25 ++++++++++++------------- src/nvim/viml/parser/expressions.c | 8 ++++---- src/nvim/viml/parser/expressions.h | 2 +- 6 files changed, 47 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 28722a4d10..859f98d2ad 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -6080,7 +6080,7 @@ char_u *add_char2buf(int c, char_u *s) { char_u temp[MB_MAXBYTES + 1]; const int len = utf_char2bytes(c, temp); - for (int i = 0; i < len; ++i) { + for (int i = 0; i < len; i++) { c = temp[i]; // Need to escape K_SPECIAL and CSI like in the typeahead buffer. if (c == K_SPECIAL) { diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index 6ed54464e8..0c8e47b02e 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -25,21 +25,21 @@ */ static const struct modmasktable { - short mod_mask; ///< Bit-mask for particular key modifier. - short mod_flag; ///< Bit(s) for particular key modifier. + uint16_t mod_mask; ///< Bit-mask for particular key modifier. + uint16_t mod_flag; ///< Bit(s) for particular key modifier. char_u name; ///< Single letter name of modifier. } mod_mask_table[] = { - {MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'M'}, - {MOD_MASK_META, MOD_MASK_META, (char_u)'T'}, - {MOD_MASK_CTRL, MOD_MASK_CTRL, (char_u)'C'}, - {MOD_MASK_SHIFT, MOD_MASK_SHIFT, (char_u)'S'}, - {MOD_MASK_MULTI_CLICK, MOD_MASK_2CLICK, (char_u)'2'}, - {MOD_MASK_MULTI_CLICK, MOD_MASK_3CLICK, (char_u)'3'}, - {MOD_MASK_MULTI_CLICK, MOD_MASK_4CLICK, (char_u)'4'}, - {MOD_MASK_CMD, MOD_MASK_CMD, (char_u)'D'}, + { MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'M' }, + { MOD_MASK_META, MOD_MASK_META, (char_u)'T' }, + { MOD_MASK_CTRL, MOD_MASK_CTRL, (char_u)'C' }, + { MOD_MASK_SHIFT, MOD_MASK_SHIFT, (char_u)'S' }, + { MOD_MASK_MULTI_CLICK, MOD_MASK_2CLICK, (char_u)'2' }, + { MOD_MASK_MULTI_CLICK, MOD_MASK_3CLICK, (char_u)'3' }, + { MOD_MASK_MULTI_CLICK, MOD_MASK_4CLICK, (char_u)'4' }, + { MOD_MASK_CMD, MOD_MASK_CMD, (char_u)'D' }, // 'A' must be the last one - {MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'A'}, - {0, 0, NUL} + { MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'A' }, + { 0, 0, NUL } }; /* diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 843007b97b..008bce6df6 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -98,15 +98,23 @@ const uint8_t utf8len_tab[] = { // Like utf8len_tab above, but using a zero for illegal lead bytes. const uint8_t utf8len_tab_zero[] = { - //1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0 - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 2 - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 4 - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 6 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 8 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // A - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // C - 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,0,0, // E + // ?1 ?2 ?3 ?4 ?5 ?6 ?7 ?8 ?9 ?A ?B ?C ?D ?E ?F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 2? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 3? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 4? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 5? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 6? + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 7? + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 8? + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 9? + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // A? + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // B? + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // C? + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // D? + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // E? + 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0, // F? }; /* diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index d787790bc3..e0bf74567d 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5930,7 +5930,8 @@ static void syntime_report(void) // When making changes here, also change runtime/colors/default.vim! static const char *highlight_init_both[] = { - "Conceal ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey", + "Conceal " + "ctermbg=DarkGrey ctermfg=LightGrey guibg=DarkGrey guifg=LightGrey", "Cursor guibg=fg guifg=bg", "lCursor guibg=fg guifg=bg", "DiffText cterm=bold ctermbg=Red gui=bold guibg=Red", @@ -6211,11 +6212,9 @@ void syn_init_cmdline_highlight(bool reset, bool init) /// /// @param both include groups where 'bg' doesn't matter /// @param reset clear groups first -void -init_highlight(int both, int reset) +void init_highlight(bool both, bool reset) { - int i; - static int had_both = FALSE; + static int had_both = false; // Try finding the color scheme file. Used when a color file was loaded // and 'background' or 't_Co' is changed. @@ -6235,9 +6234,9 @@ init_highlight(int both, int reset) * Didn't use a color file, use the compiled-in colors. */ if (both) { - had_both = TRUE; + had_both = true; const char *const *const pp = highlight_init_both; - for (i = 0; pp[i] != NULL; i++) { + for (size_t i = 0; pp[i] != NULL; i++) { do_highlight(pp[i], reset, true); } } else if (!had_both) { @@ -6250,7 +6249,7 @@ init_highlight(int both, int reset) const char *const *const pp = ((*p_bg == 'l') ? highlight_init_light : highlight_init_dark); - for (i = 0; pp[i] != NULL; i++) { + for (size_t i = 0; pp[i] != NULL; i++) { do_highlight(pp[i], reset, true); } @@ -6266,8 +6265,9 @@ init_highlight(int both, int reset) : "Visual cterm=NONE ctermbg=DarkGrey"), false, true); } else { do_highlight("Visual cterm=reverse ctermbg=NONE", false, true); - if (*p_bg == 'l') + if (*p_bg == 'l') { do_highlight("Search ctermfg=black", false, true); + } } /* @@ -6452,7 +6452,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) restore_cterm_colors(); // Clear all default highlight groups and load the defaults. - for (int idx = 0; idx < highlight_ga.ga_len; ++idx) { + for (int idx = 0; idx < highlight_ga.ga_len; idx++) { highlight_clear(idx); } init_highlight(true, true); @@ -6690,9 +6690,8 @@ void do_highlight(const char *line, const bool forceit, const bool init) } } if (i < 0) { - emsgf(_( - "E421: Color name or number not recognized: %s"), - key_start); + emsgf(_("E421: Color name or number not recognized: %s"), + key_start); error = true; break; } diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index f5bc547d54..fc184f56f5 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -1814,8 +1814,8 @@ ExprAST viml_pexpr_parse(ParserState *const pstate, const int flags) || ((*kv_Z(ast_stack, 1))->type != kExprNodeConcat && ((*kv_Z(ast_stack, 1))->type != kExprNodeConcatOrSubscript)))) - ? kELFlagAllowFloat - : 0)); + ? kELFlagAllowFloat + : 0)); LexExprToken cur_token = viml_pexpr_next_token( pstate, want_node_to_lexer_flags[want_node] | lexer_additional_flags); if (cur_token.type == kExprLexEOC) { @@ -1876,7 +1876,7 @@ viml_pexpr_parse_process_token: // time. // // Here example will always contain a concat with "a:2" sucking colon, - // making expression invalid both because there is no longer a spare colon + // making expression invalid both because there is no longer a spare colon // for ternary and because concatenating dictionary with anything is not // valid. There are more cases when this will make a difference though. const bool node_is_key = ( @@ -2853,7 +2853,7 @@ viml_pexpr_parse_end: } kvi_destroy(ast_stack); return ast; -} +} // NOLINT(readability/fn_size) #undef NEW_NODE #undef HL diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index d00d4855f3..668c2a4c84 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -189,7 +189,7 @@ typedef enum { kExprNodeCall, ///< Function call. /// Plain identifier: simple variable/function name /// - /// Looks like "string", "g:Foo", etc: consists from a single + /// Looks like "string", "g:Foo", etc: consists from a single /// kExprLexPlainIdentifier token. kExprNodePlainIdentifier, /// Plain dictionary key, for use with kExprNodeConcatOrSubscript -- cgit From 0356dbbb36ffa7934c35e9dbfc6667f9118c244f Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 30 Oct 2017 01:38:02 +0300 Subject: ex_getln: Fix variable name which is wrong after the merge --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 785038f5d6..f64efe08a1 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2500,7 +2500,7 @@ static bool color_cmdline(CmdlineInfo *colored_ccline) tl_ret = try_leave(&tstate, &err); can_free_cb = true; } else if (colored_ccline->cmdfirstc == '=') { - color_expr_cmdline(colored_ccline, ret_ccline_colors); + color_expr_cmdline(colored_ccline, ccline_colors); can_free_cb = false; } if (!tl_ret || !dgc_ret) { -- cgit From cc7285823cda56aeb1ce16e03990c3397e315a2e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 29 Oct 2017 20:03:17 +0100 Subject: eval_clear: free profile data Memory leak exposed by new test added in #7444. ==38771==ERROR: LeakSanitizer: detected memory leaks Direct leak of 2400 byte(s) in 1 object(s) allocated from: 0 0x51163d in realloc (/home/travis/build/neovim/neovim/build/bin/nvim+0x51163d) 1 0xfda51c in xrealloc /home/travis/build/neovim/neovim/src/nvim/memory.c:169:15 2 0xda6802 in ga_grow /home/travis/build/neovim/neovim/src/nvim/garray.c:98:14 3 0xb67ccd in script_line_start /home/travis/build/neovim/neovim/src/nvim/ex_cmds2.c:3286:11 4 0xb62885 in getsourceline /home/travis/build/neovim/neovim/src/nvim/ex_cmds2.c:3110:5 5 0xb5fbfd in do_source /home/travis/build/neovim/neovim/src/nvim/ex_cmds2.c:2951:15 6 0xb5c484 in cmd_source /home/travis/build/neovim/neovim/src/nvim/ex_cmds2.c:2710:14 7 0xb5c5b0 in ex_source /home/travis/build/neovim/neovim/src/nvim/ex_cmds2.c:2691:3 8 0xb950b9 in do_one_cmd /home/travis/build/neovim/neovim/src/nvim/ex_docmd.c:2242:5 9 0xb737e1 in do_cmdline /home/travis/build/neovim/neovim/src/nvim/ex_docmd.c:609:20 10 0xb79ac5 in do_cmdline_cmd /home/travis/build/neovim/neovim/src/nvim/ex_docmd.c:280:10 11 0xed8a7b in exe_commands /home/travis/build/neovim/neovim/src/nvim/main.c:1684:5 12 0xec6602 in main /home/travis/build/neovim/neovim/src/nvim/main.c:521:5 13 0x2ae968600f44 in __libc_start_main /build/eglibc-SvCtMH/eglibc-2.19/csu/libc-start.c:287 --- src/nvim/ex_cmds2.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 19e7f1bbc5..9b8e463aee 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1039,9 +1039,14 @@ static void profile_reset(void) uf->uf_tm_total = profile_zero(); uf->uf_tm_self = profile_zero(); uf->uf_tm_children = profile_zero(); + + xfree(uf->uf_tml_count); + xfree(uf->uf_tml_total); + xfree(uf->uf_tml_self); uf->uf_tml_count = NULL; uf->uf_tml_total = NULL; uf->uf_tml_self = NULL; + uf->uf_tml_start = profile_zero(); uf->uf_tml_children = profile_zero(); uf->uf_tml_wait = profile_zero(); @@ -3070,6 +3075,8 @@ char_u *get_scriptname(scid_T id) # if defined(EXITFREE) void free_scriptnames(void) { + profile_reset(); + # define FREE_SCRIPTNAME(item) xfree((item)->sn_name) GA_DEEP_CLEAR(&script_items, scriptitem_T, FREE_SCRIPTNAME); } -- cgit From 241fe704a52092aad7eff8c1cbf25262bfcf0195 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 30 Oct 2017 23:29:47 +0100 Subject: pvs/V575: false positive (#7462) ./src/nvim/ex_getln.c:2787:1: error: V575 The 'memcpy' function doesn't copy the whole string. Use 'strcpy / strcpy_s' function to preserve terminal null. We could instead "trick" PVS like this: diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e79476ab532a..295630693b27 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2782,9 +2782,10 @@ static void ui_ext_cmdline_show(CmdlineInfo *line) void ui_ext_cmdline_block_append(int indent, const char *line) { - char *buf = xmallocz(indent + strlen(line)); + size_t linelen = strlen(line); + char *buf = xmallocz(indent + linelen); memset(buf, ' ', indent); - memcpy(buf+indent, line, strlen(line)); + memcpy(buf + indent, line, linelen); Array item = ARRAY_DICT_INIT; ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT)); --- src/nvim/ex_getln.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e79476ab53..c9567145e4 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2784,7 +2784,7 @@ void ui_ext_cmdline_block_append(int indent, const char *line) { char *buf = xmallocz(indent + strlen(line)); memset(buf, ' ', indent); - memcpy(buf+indent, line, strlen(line)); + memcpy(buf + indent, line, strlen(line)); // -V575 Array item = ARRAY_DICT_INIT; ADD(item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT)); -- cgit From ff819d8ad72b6a7404d28707f1f9ef460c35c472 Mon Sep 17 00:00:00 2001 From: Lech Lorens Date: Sun, 1 Oct 2017 15:37:27 +0200 Subject: quickfix: fix location list updates. Fix quickfix performance optimization which prevented quickfix items from being updated when there were multiple windows with location lists but the buffer with errors only in one of the lists. --- src/nvim/mark.c | 14 ++++++++++---- src/nvim/quickfix.c | 14 +++++++------- 2 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 7889fabd45..1ba400972c 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -951,11 +951,17 @@ static void mark_adjust_internal(linenr_T line1, linenr_T line2, one_adjust_nodel(&(curbuf->b_visual.vi_start.lnum)); one_adjust_nodel(&(curbuf->b_visual.vi_end.lnum)); - /* quickfix marks */ - qf_mark_adjust(NULL, line1, line2, amount, amount_after); - /* location lists */ + // quickfix marks + if (!qf_mark_adjust(NULL, line1, line2, amount, amount_after)) { + curbuf->b_has_qf_entry &= ~BUF_HAS_QF_ENTRY; + } + // location lists + bool found_one = false; FOR_ALL_TAB_WINDOWS(tab, win) { - qf_mark_adjust(win, line1, line2, amount, amount_after); + found_one |= qf_mark_adjust(win, line1, line2, amount, amount_after); + } + if (!found_one) { + curbuf->b_has_qf_entry &= ~BUF_HAS_LL_ENTRY; } sign_mark_adjust(line1, line2, amount, amount_after); diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index e6b1e7b95a..b9228e15b9 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -2379,7 +2379,8 @@ static void qf_free(qf_info_T *qi, int idx) /* * qf_mark_adjust: adjust marks */ -void qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long amount_after) +bool qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, + long amount_after) { int i; qfline_T *qfp; @@ -2389,11 +2390,12 @@ void qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long int buf_has_flag = wp == NULL ? BUF_HAS_QF_ENTRY : BUF_HAS_LL_ENTRY; if (!(curbuf->b_has_qf_entry & buf_has_flag)) { - return; + return false; } if (wp != NULL) { - if (wp->w_llist == NULL) - return; + if (wp->w_llist == NULL) { + return false; + } qi = wp->w_llist; } @@ -2414,9 +2416,7 @@ void qf_mark_adjust(win_T *wp, linenr_T line1, linenr_T line2, long amount, long } } - if (!found_one) { - curbuf->b_has_qf_entry &= ~buf_has_flag; - } + return found_one; } /* -- cgit From 860ecd705588470b52094b7036c016b2af15f8c9 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 23 Oct 2017 01:50:26 +0200 Subject: vim-patch:8.0.0096: has('ttyin'), has('ttyout') Nvim note: intentionally did not include `--ttyfail` since its purpose is not clear. (And it isn't used in any Vim test files/scripts). --- Problem: When the input or output is not a tty Vim appears to hang. Solution: Add the --ttyfail argument. Also add the "ttyin" and "ttyout" features to be able to check in Vim script. https://github.com/vim/vim/commit/2cab0e191055a8145ccd46cd52869fbb9798b971 --- src/nvim/eval.c | 4 ++++ src/nvim/globals.h | 27 ++++++++++++++------------- src/nvim/main.c | 6 ++++-- 3 files changed, 22 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index c7cb51ac29..9752851d4e 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -10672,6 +10672,10 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr) n = has_nvim_version(name + 5); } else if (STRICMP(name, "vim_starting") == 0) { n = (starting != 0); + } else if (STRICMP(name, "ttyin") == 0) { + n = stdin_isatty; + } else if (STRICMP(name, "ttyout") == 0) { + n = stdout_isatty; } else if (STRICMP(name, "multi_byte_encoding") == 0) { n = has_mbyte != 0; #if defined(USE_ICONV) && defined(DYNAMIC_ICONV) diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 0f3e132bc0..8f804ff888 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -564,21 +564,22 @@ EXTERN int ru_col; /* column for ruler */ EXTERN int ru_wid; /* 'rulerfmt' width of ruler when non-zero */ EXTERN int sc_col; /* column for shown command */ -/* - * When starting or exiting some things are done differently (e.g. screen - * updating). - */ +// +// When starting or exiting some things are done differently (e.g. screen +// updating). +// + +// First NO_SCREEN, then NO_BUFFERS, then 0 when startup finished. EXTERN int starting INIT(= NO_SCREEN); -/* first NO_SCREEN, then NO_BUFFERS and then - * set to 0 when starting up finished */ -EXTERN int exiting INIT(= FALSE); -/* TRUE when planning to exit Vim. Might - * still keep on running if there is a changed - * buffer. */ -// volatile because it is used in signal handler deathtrap(). +// true when planning to exit. Might keep running if there is a changed buffer. +EXTERN int exiting INIT(= false); +// is stdin a terminal? +EXTERN int stdin_isatty INIT(= true); +// is stdout a terminal? +EXTERN int stdout_isatty INIT(= true); +// true when doing full-screen output, otherwise only writing some messages. +// volatile because it is used in a signal handler. EXTERN volatile int full_screen INIT(= false); -// TRUE when doing full-screen output -// otherwise only writing some messages EXTERN int restricted INIT(= FALSE); // TRUE when started in restricted mode (-Z) diff --git a/src/nvim/main.c b/src/nvim/main.c index ea7a58bda3..93afe11f3a 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1240,8 +1240,10 @@ static void init_startuptime(mparm_T *paramp) static void check_and_set_isatty(mparm_T *paramp) { - paramp->input_isatty = os_isatty(fileno(stdin)); - paramp->output_isatty = os_isatty(fileno(stdout)); + stdin_isatty + = paramp->input_isatty = os_isatty(fileno(stdin)); + stdout_isatty + = paramp->output_isatty = os_isatty(fileno(stdout)); paramp->err_isatty = os_isatty(fileno(stderr)); TIME_MSG("window checked"); } -- cgit From 04b3c327723587fa63f391884b8dfce44233cc77 Mon Sep 17 00:00:00 2001 From: KillTheMule Date: Sun, 5 Nov 2017 17:11:44 +0100 Subject: 'inccommand': Fix matches for zero-width (#7487) closes #7485 --- src/nvim/ex_cmds.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 112f53247c..39059a2c80 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -3478,6 +3478,10 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout) else ++matchcol; } + // match will be pushed to preview_lines, bring it into a proper state + current_match.start.col = matchcol; + current_match.end.lnum = sub_firstlnum; + current_match.end.col = matchcol; goto skip; } -- cgit From d98199de9c2969d430ba489187ffa02d8c489dea Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 2 Nov 2017 10:44:20 +0300 Subject: charset: Refactor vim_str2nr --- src/nvim/charset.c | 135 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 88 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/nvim/charset.c b/src/nvim/charset.c index c895d65eb7..5aebf90194 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1611,8 +1611,9 @@ bool vim_isblankline(char_u *lbuf) /// If maxlen > 0, check at a maximum maxlen chars. /// /// @param start -/// @param prep Returns type of number 0 = decimal, 'x' or 'X' is hex, -/// '0' = octal, 'b' or 'B' is bin +/// @param prep Returns guessed type of number 0 = decimal, 'x' or 'X' is +/// hexadecimal, '0' = octal, 'b' or 'B' is binary. When using +/// STR2NR_FORCE is always zero. /// @param len Returns the detected length of number. /// @param what Recognizes what number passed. /// @param nptr Returns the signed result. @@ -1627,55 +1628,84 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, #define STRING_ENDED(ptr) \ (!(maxlen == 0 || (int)((ptr) - (const char *)start) < maxlen)) int pre = 0; // default is decimal - bool negative = false; + const bool negative = (ptr[0] == '-'); + uvarnumber_T un = 0; - if (ptr[0] == '-') { - negative = true; + if (negative) { ptr++; } - // Recognize hex, octal and bin. - if ((what & (STR2NR_HEX|STR2NR_OCT|STR2NR_BIN)) - && !STRING_ENDED(ptr + 1) - && ptr[0] == '0' && ptr[1] != '8' && ptr[1] != '9') { + if (what & STR2NR_FORCE) { + // When forcing main consideration is skipping the prefix. Octal and decimal + // numbers have no prefixes to skip. pre is not set. + switch ((unsigned)what & (~(unsigned)STR2NR_FORCE)) { + case STR2NR_HEX: { + if (!STRING_ENDED(ptr + 2) + && ptr[0] == '0' + && (ptr[1] == 'x' || ptr[1] == 'X') + && ascii_isxdigit(ptr[2])) { + ptr += 2; + } + goto vim_str2nr_hex; + } + case STR2NR_BIN: { + if (!STRING_ENDED(ptr + 2) + && ptr[0] == '0' + && (ptr[1] == 'b' || ptr[1] == 'B') + && ascii_isbdigit(ptr[2])) { + ptr += 2; + } + goto vim_str2nr_bin; + } + case STR2NR_OCT: { + goto vim_str2nr_oct; + } + case 0: { + goto vim_str2nr_dec; + } + default: { + assert(false); + } + } + } else if ((what & (STR2NR_HEX|STR2NR_OCT|STR2NR_BIN)) + && !STRING_ENDED(ptr + 1) + && ptr[0] == '0' && ptr[1] != '8' && ptr[1] != '9') { pre = ptr[1]; - + // Detect hexadecimal: 0x or 0X follwed by hex digit if ((what & STR2NR_HEX) && !STRING_ENDED(ptr + 2) && (pre == 'X' || pre == 'x') && ascii_isxdigit(ptr[2])) { - // hexadecimal ptr += 2; - } else if ((what & STR2NR_BIN) - && !STRING_ENDED(ptr + 2) - && (pre == 'B' || pre == 'b') - && ascii_isbdigit(ptr[2])) { - // binary + goto vim_str2nr_hex; + } + // Detect binary: 0b or 0B follwed by 0 or 1 + if ((what & STR2NR_BIN) + && !STRING_ENDED(ptr + 2) + && (pre == 'B' || pre == 'b') + && ascii_isbdigit(ptr[2])) { ptr += 2; - } else { - // decimal or octal, default is decimal - pre = 0; - - if (what & STR2NR_OCT - && !STRING_ENDED(ptr + 1) - && ('0' <= ptr[1] && ptr[1] <= '7')) { - // Assume octal now: what we already know is that string starts with - // zero and some octal digit. - pre = '0'; - // Don’t interpret "0", "008" or "0129" as octal. - for (int i = 2; !STRING_ENDED(ptr + i) && ascii_isdigit(ptr[i]); i++) { - if (ptr[i] > '7') { - // Can’t be octal. - pre = 0; - break; - } - } + goto vim_str2nr_bin; + } + // Detect octal number: zero followed by octal digits without '8' or '9' + pre = 0; + if (!(what & STR2NR_OCT) + || !('0' <= ptr[1] && ptr[1] <= '7')) { + goto vim_str2nr_dec; + } + for (int i = 2; !STRING_ENDED(ptr + i) && ascii_isdigit(ptr[i]); i++) { + if (ptr[i] > '7') { + goto vim_str2nr_dec; } } + pre = '0'; + goto vim_str2nr_oct; + } else { + goto vim_str2nr_dec; } // Do the string-to-numeric conversion "manually" to avoid sscanf quirks. - uvarnumber_T un = 0; + assert(false); // Should’ve used goto earlier. #define PARSE_NUMBER(base, cond, conv) \ do { \ while (!STRING_ENDED(ptr) && (cond)) { \ @@ -1688,18 +1718,29 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, ptr++; \ } \ } while (0) - if (pre == 'B' || pre == 'b' || what == (STR2NR_BIN|STR2NR_FORCE)) { - // Binary number. - PARSE_NUMBER(2, (*ptr == '0' || *ptr == '1'), (*ptr - '0')); - } else if (pre == '0' || what == (STR2NR_OCT|STR2NR_FORCE)) { - // Octal number. - PARSE_NUMBER(8, ('0' <= *ptr && *ptr <= '7'), (*ptr - '0')); - } else if (pre == 'X' || pre == 'x' || what == (STR2NR_HEX|STR2NR_FORCE)) { - // Hexadecimal number. - PARSE_NUMBER(16, (ascii_isxdigit(*ptr)), (hex2nr(*ptr))); - } else { - // Decimal number. - PARSE_NUMBER(10, (ascii_isdigit(*ptr)), (*ptr - '0')); + switch (pre) { + case 'b': + case 'B': { +vim_str2nr_bin: + PARSE_NUMBER(2, (*ptr == '0' || *ptr == '1'), (*ptr - '0')); + break; + } + case '0': { +vim_str2nr_oct: + PARSE_NUMBER(8, ('0' <= *ptr && *ptr <= '7'), (*ptr - '0')); + break; + } + case 0: { +vim_str2nr_dec: + PARSE_NUMBER(10, (ascii_isdigit(*ptr)), (*ptr - '0')); + break; + } + case 'x': + case 'X': { +vim_str2nr_hex: + PARSE_NUMBER(16, (ascii_isxdigit(*ptr)), (hex2nr(*ptr))); + break; + } } #undef PARSE_NUMBER -- cgit From b9d5aea073521f3278bea257be306b7ac2b8d83c Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 3 Nov 2017 11:38:59 +0300 Subject: api/vim: Create part of nvim_parse_expression function --- src/nvim/api/vim.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 9daa2fb398..446a049897 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -33,6 +33,8 @@ #include "nvim/syntax.h" #include "nvim/getchar.h" #include "nvim/os/input.h" +#include "nvim/viml/parser/expressions.h" +#include "nvim/viml/parser/parser.h" #define LINE_BUFFER_SIZE 4096 @@ -897,6 +899,12 @@ theend: /// /// Use only "m" to parse like for "=", only "E" to /// parse like for ":echo", empty string for ":let". +/// @param[in] highlight If true, return value will also include "highlight" +/// key containing array of 4-tuples (arrays) (Integer, +/// Integer, Integer, String), where first three numbers +/// define the highlighted region and represent line, +/// starting column and ending column (latter exclusive: +/// one should highlight region [start_col, end_col)). /// /// @return AST: top-level dectionary holds keys /// @@ -946,9 +954,105 @@ theend: /// "fvalue": Float, floating-point value for "Float" nodes. /// "svalue": String, value for "SingleQuotedString" and /// "DoubleQuotedString" nodes. -Dictionary nvim_parse_expression(String expr, String flags, Error *err) +Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, + Error *err) FUNC_API_SINCE(4) { + int pflags = 0; + for (size_t i = 0 ; i < flags.size ; i++) { + switch (flags.data[i]) { + case 'm': { pflags |= kExprFlagsMulti; break; } + case 'E': { pflags |= kExprFlagsDisallowEOC; break; } + default: { + api_set_error(err, kErrorTypeValidation, "Invalid flag: '%c' (%u)", + flags.data[i], (unsigned)flags.data[i]); + return (Dictionary)ARRAY_DICT_INIT; + } + } + } + ParserLine plines[] = { + { + .data = expr.data, + .size = expr.size, + .allocated = false, + }, + { NULL, 0, false }, + }; + ParserLine *plines_p = plines; + ParserHighlight colors; + kvi_init(colors); + ParserHighlight *const colors_p = (highlight ? &colors : NULL); + ParserState pstate; + viml_parser_init( + &pstate, parser_simple_get_line, &plines_p, colors_p); + ExprAST east = viml_pexpr_parse(&pstate, pflags); + + const size_t dict_size = ( + 1 // "ast" + + (size_t)(east.err.arg != NULL) // "error" + + (size_t)highlight // "highlight" + ); + Dictionary ret = { + .items = xmalloc(dict_size * sizeof(ret.items[0])), + .size = 0, + .capacity = dict_size, + }; + ret.items[ret.size++] = (KeyValuePair) { + .key = STATIC_CSTR_AS_STRING("ast"), + .value = NIL, + }; + if (east.err.arg != NULL) { + Dictionary err_dict = { + .items = xmalloc(2 * sizeof(err_dict.items[0])), + .size = 2, + .capacity = 2, + }; + err_dict.items[0] = (KeyValuePair) { + .key = STATIC_CSTR_AS_STRING("message"), + .value = STRING_OBJ(cstr_to_string(east.err.arg)), + }; + err_dict.items[1] = (KeyValuePair) { + .key = STATIC_CSTR_AS_STRING("arg"), + .value = STRING_OBJ(((String) { + .data = xmemdup(east.err.arg, (size_t)east.err.arg_len), + .size = (size_t)east.err.arg_len, + })), + }; + ret.items[ret.size++] = (KeyValuePair) { + .key = STATIC_CSTR_AS_STRING("error"), + .value = DICTIONARY_OBJ(err_dict), + }; + } + if (highlight) { + Array hl = (Array) { + .items = xmalloc(kv_size(colors) * sizeof(hl.items[0])), + .capacity = kv_size(colors), + .size = kv_size(colors), + }; + for (size_t i = 0 ; i < kv_size(colors) ; i++) { + const ParserHighlightChunk chunk = kv_A(colors, i); + Array chunk_arr = (Array) { + .items = xmalloc(4), + .capacity = 4, + .size = 4, + }; + chunk_arr.items[0] = INTEGER_OBJ((Integer)chunk.start.line); + chunk_arr.items[1] = INTEGER_OBJ((Integer)chunk.start.col); + chunk_arr.items[2] = INTEGER_OBJ((Integer)chunk.end_col); + chunk_arr.items[3] = STRING_OBJ(cstr_to_string(chunk.group)); + hl.items[i] = ARRAY_OBJ(chunk_arr); + } + ret.items[ret.size++] = (KeyValuePair) { + .key = STATIC_CSTR_AS_STRING("highlight"), + .value = ARRAY_OBJ(hl), + }; + } + + // FIXME: populate AST + + assert(ret.size == ret.capacity); + viml_pexpr_free_ast(east); + viml_parser_destroy(&pstate); return (Dictionary)ARRAY_DICT_INIT; } -- cgit From 07ec709141886c6db4f944665e07a36ef7302eb4 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 5 Nov 2017 01:33:44 +0300 Subject: vim/api: Actually dump AST, fix some bugs in nvim_parse_expression --- src/nvim/api/vim.c | 264 ++++++++++++++++++++++++++++++++++--- src/nvim/viml/parser/expressions.c | 10 +- src/nvim/viml/parser/expressions.h | 9 ++ 3 files changed, 262 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 446a049897..1aab87010e 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -888,6 +888,13 @@ theend: return rv; } +typedef struct { + ExprASTNode **node_p; + Object *ret_node_p; +} ExprASTConvStackItem; + +typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack; + /// Parse a VimL expression /// /// @param[in] expr Expression to parse. Is always treated as a single line. @@ -915,7 +922,8 @@ theend: /// Must contain exactly one "%.*s". /// "arg": String, error message argument. /// -/// "ast": actual AST, a dictionary with the following keys: +/// "ast": actual AST, either nil or a dictionary with the following +/// keys: /// /// "type": node type, one of the value names from ExprASTNodeType /// stringified without "kExprNode" prefix. @@ -927,11 +935,9 @@ theend: /// debugging purposes primary (debugging parser and providing /// debug information). /// "children": a list of nodes described in top/"ast". There always -/// is zero, one or two children, key will contain an -/// empty array if node can have children, but has no and -/// will not be present at all if node can’t have any -/// children. Maximum number of children may be found in -/// node_maxchildren array. +/// is zero, one or two children, key will not be present +/// if node has no children. Maximum number of children +/// may be found in node_maxchildren array. /// /// Local values (present only for certain nodes): /// @@ -950,6 +956,8 @@ theend: /// value names from ExprCaseCompareStrategy, /// stringified without "kCCStrategy" prefix. Only /// present for "Comparison" nodes. +/// "invert": Boolean, true if result of comparison needs to be +/// inverted. Only present for "Comparison" nodes. /// "ivalue": Integer, integer value for "Integer" nodes. /// "fvalue": Float, floating-point value for "Float" nodes. /// "svalue": String, value for "SingleQuotedString" and @@ -998,7 +1006,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, .capacity = dict_size, }; ret.items[ret.size++] = (KeyValuePair) { - .key = STATIC_CSTR_AS_STRING("ast"), + .key = STATIC_CSTR_TO_STRING("ast"), .value = NIL, }; if (east.err.arg != NULL) { @@ -1008,18 +1016,18 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, .capacity = 2, }; err_dict.items[0] = (KeyValuePair) { - .key = STATIC_CSTR_AS_STRING("message"), + .key = STATIC_CSTR_TO_STRING("message"), .value = STRING_OBJ(cstr_to_string(east.err.arg)), }; err_dict.items[1] = (KeyValuePair) { - .key = STATIC_CSTR_AS_STRING("arg"), + .key = STATIC_CSTR_TO_STRING("arg"), .value = STRING_OBJ(((String) { - .data = xmemdup(east.err.arg, (size_t)east.err.arg_len), + .data = xmemdupz(east.err.arg, (size_t)east.err.arg_len), .size = (size_t)east.err.arg_len, })), }; ret.items[ret.size++] = (KeyValuePair) { - .key = STATIC_CSTR_AS_STRING("error"), + .key = STATIC_CSTR_TO_STRING("error"), .value = DICTIONARY_OBJ(err_dict), }; } @@ -1032,7 +1040,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, for (size_t i = 0 ; i < kv_size(colors) ; i++) { const ParserHighlightChunk chunk = kv_A(colors, i); Array chunk_arr = (Array) { - .items = xmalloc(4), + .items = xmalloc(4 * sizeof(chunk_arr.items[0])), .capacity = 4, .size = 4, }; @@ -1043,17 +1051,243 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, hl.items[i] = ARRAY_OBJ(chunk_arr); } ret.items[ret.size++] = (KeyValuePair) { - .key = STATIC_CSTR_AS_STRING("highlight"), + .key = STATIC_CSTR_TO_STRING("highlight"), .value = ARRAY_OBJ(hl), }; } - // FIXME: populate AST + // Walk over the AST, freeing nodes in process. + ExprASTConvStack ast_conv_stack; + kvi_init(ast_conv_stack); + kvi_push(ast_conv_stack, ((ExprASTConvStackItem) { + .node_p = &east.root, + .ret_node_p = &ret.items[0].value, + })); + while (kv_size(ast_conv_stack)) { + ExprASTConvStackItem cur_item = kv_last(ast_conv_stack); + if (*cur_item.node_p == NULL) { + assert(kv_size(ast_conv_stack) == 1); + kv_drop(ast_conv_stack, 1); + } else { + ExprASTNode *const node = *cur_item.node_p; + if (cur_item.ret_node_p->type == kObjectTypeNil) { + const size_t ret_node_items_size = (size_t)( + 3 // "type", "start" and "len" + + (node->children != NULL) // "children" + + (node->type == kExprNodeOption + || node->type == kExprNodePlainIdentifier) // "scope" + + (node->type == kExprNodeOption + || node->type == kExprNodePlainIdentifier + || node->type == kExprNodePlainKey + || node->type == kExprNodeEnvironment) // "ident" + + (node->type == kExprNodeRegister) // "name" + + (3 // "cmp_type", "ccs_strategy", "invert" + * (node->type == kExprNodeComparison)) + + (node->type == kExprNodeInteger) // "ivalue" + + (node->type == kExprNodeFloat) // "fvalue" + + (node->type == kExprNodeDoubleQuotedString + || node->type == kExprNodeSingleQuotedString) // "svalue" + + 0); + Dictionary ret_node = { + .items = xmalloc(ret_node_items_size * sizeof(ret_node.items[0])), + .capacity = ret_node_items_size, + .size = 0, + }; + *cur_item.ret_node_p = DICTIONARY_OBJ(ret_node); + } + Dictionary *ret_node = &cur_item.ret_node_p->data.dictionary; + if (node->children != NULL) { + const size_t num_children = 1 + (node->children->next != NULL); + Array children_array = { + .items = xmalloc(num_children * sizeof(children_array.items[0])), + .capacity = num_children, + .size = num_children, + }; + for (size_t i = 0; i < num_children; i++) { + children_array.items[i] = NIL; + } + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("children"), + .value = ARRAY_OBJ(children_array), + }; + kvi_push(ast_conv_stack, ((ExprASTConvStackItem) { + .node_p = &node->children, + .ret_node_p = &children_array.items[0], + })); + } else if (node->next != NULL) { + kvi_push(ast_conv_stack, ((ExprASTConvStackItem) { + .node_p = &node->children, + .ret_node_p = cur_item.ret_node_p + 1, + })); + } else if (node != NULL) { + kv_drop(ast_conv_stack, 1); + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("type"), + .value = STRING_OBJ(cstr_to_string(east_node_type_tab[node->type])), + }; + Array start_array = { + .items = xmalloc(2 * sizeof(start_array.items[0])), + .capacity = 2, + .size = 2, + }; + start_array.items[0] = INTEGER_OBJ((Integer)node->start.line); + start_array.items[1] = INTEGER_OBJ((Integer)node->start.col); + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("start"), + .value = ARRAY_OBJ(start_array), + }; + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("len"), + .value = INTEGER_OBJ((Integer)node->len), + }; + switch (node->type) { + case kExprNodeDoubleQuotedString: + case kExprNodeSingleQuotedString: { + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("svalue"), + .value = STRING_OBJ(cstr_as_string(node->data.str.value)), + }; + break; + } + case kExprNodeOption: { + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("scope"), + .value = INTEGER_OBJ(node->data.opt.scope), + }; + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("ident"), + .value = STRING_OBJ(((String) { + .data = xmemdupz(node->data.opt.ident, + node->data.opt.ident_len), + .size = node->data.opt.ident_len, + })), + }; + break; + } + case kExprNodePlainIdentifier: { + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("scope"), + .value = INTEGER_OBJ(node->data.var.scope), + }; + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("ident"), + .value = STRING_OBJ(((String) { + .data = xmemdupz(node->data.var.ident, + node->data.var.ident_len), + .size = node->data.var.ident_len, + })), + }; + break; + } + case kExprNodePlainKey: { + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("ident"), + .value = STRING_OBJ(((String) { + .data = xmemdupz(node->data.var.ident, + node->data.var.ident_len), + .size = node->data.var.ident_len, + })), + }; + break; + } + case kExprNodeEnvironment: { + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("ident"), + .value = STRING_OBJ(((String) { + .data = xmemdupz(node->data.env.ident, + node->data.env.ident_len), + .size = node->data.env.ident_len, + })), + }; + break; + } + case kExprNodeRegister: { + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("name"), + .value = INTEGER_OBJ(node->data.reg.name), + }; + break; + } + case kExprNodeComparison: { + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("cmp_type"), + .value = STRING_OBJ(cstr_to_string( + eltkn_cmp_type_tab[node->data.cmp.type])), + }; + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("ccs_strategy"), + .value = STRING_OBJ(cstr_to_string( + eltkn_cmp_type_tab[node->data.cmp.ccs])), + }; + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("invert"), + .value = BOOLEAN_OBJ(node->data.cmp.inv), + }; + break; + } + case kExprNodeFloat: { + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("fvalue"), + .value = FLOAT_OBJ(node->data.flt.value), + }; + break; + } + case kExprNodeInteger: { + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("ivalue"), + .value = INTEGER_OBJ((Integer)( + node->data.num.value > API_INTEGER_MAX + ? API_INTEGER_MAX + : (Integer)node->data.num.value)), + }; + break; + } + case kExprNodeMissing: + case kExprNodeOpMissing: + case kExprNodeTernary: + case kExprNodeTernaryValue: + case kExprNodeSubscript: + case kExprNodeListLiteral: + case kExprNodeUnaryPlus: + case kExprNodeBinaryPlus: + case kExprNodeNested: + case kExprNodeCall: + case kExprNodeComplexIdentifier: + case kExprNodeUnknownFigure: + case kExprNodeLambda: + case kExprNodeDictLiteral: + case kExprNodeCurlyBracesIdentifier: + case kExprNodeComma: + case kExprNodeColon: + case kExprNodeArrow: + case kExprNodeConcat: + case kExprNodeConcatOrSubscript: + case kExprNodeOr: + case kExprNodeAnd: + case kExprNodeUnaryMinus: + case kExprNodeBinaryMinus: + case kExprNodeNot: + case kExprNodeMultiplication: + case kExprNodeDivision: + case kExprNodeMod: { + break; + } + } + assert(cur_item.ret_node_p->data.dictionary.size + == cur_item.ret_node_p->data.dictionary.capacity); + xfree(*cur_item.node_p); + *cur_item.node_p = NULL; + } + } + } + kvi_destroy(ast_conv_stack); assert(ret.size == ret.capacity); + // Should be a no-op actually, leaving it in case non-nodes will need to be + // freed later. viml_pexpr_free_ast(east); viml_parser_destroy(&pstate); - return (Dictionary)ARRAY_DICT_INIT; + return ret; } diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index fc184f56f5..b19aab22af 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -616,7 +616,7 @@ static const char *const eltkn_type_tab[] = { [kExprLexArrow] = "Arrow", }; -static const char *const eltkn_cmp_type_tab[] = { +const char *const eltkn_cmp_type_tab[] = { [kExprCmpEqual] = "Equal", [kExprCmpMatches] = "Matches", [kExprCmpGreater] = "Greater", @@ -624,7 +624,7 @@ static const char *const eltkn_cmp_type_tab[] = { [kExprCmpIdentical] = "Identical", }; -static const char *const ccs_tab[] = { +const char *const ccs_tab[] = { [kCCStrategyUseOption] = "UseOption", [kCCStrategyMatchCase] = "MatchCase", [kCCStrategyIgnoreCase] = "IgnoreCase", @@ -725,8 +725,7 @@ viml_pexpr_repr_token_end: return ret; } -#ifdef UNIT_TESTING -static const char *const east_node_type_tab[] = { +const char *const east_node_type_tab[] = { [kExprNodeMissing] = "Missing", [kExprNodeOpMissing] = "OpMissing", [kExprNodeTernary] = "Ternary", @@ -766,7 +765,6 @@ static const char *const east_node_type_tab[] = { [kExprNodeOption] = "Option", [kExprNodeEnvironment] = "Environment", }; -#endif /// Represent `int` character as a string /// @@ -2148,10 +2146,10 @@ viml_pexpr_parse_invalid_comma: } #define EXP_VAL_COLON "E15: Expected value, got colon: %.*s" case kExprLexColon: { + bool is_ternary = false; if (kv_size(ast_stack) < 2) { goto viml_pexpr_parse_invalid_colon; } - bool is_ternary = false; bool can_be_ternary = true; bool is_subscript = false; for (size_t i = 1; i < kv_size(ast_stack); i++) { diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 668c2a4c84..648f8cbc1f 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -341,6 +341,15 @@ typedef struct { /// Array mapping ExprASTNodeType to maximum amount of children node may have extern const uint8_t node_maxchildren[]; +/// Array mapping ExprASTNodeType values to their stringified versions +extern const char *const east_node_type_tab[]; + +/// Array mapping ExprComparisonType values to their stringified versions +extern const char *const eltkn_cmp_type_tab[]; + +/// Array mapping ExprCaseCompareStrategy values to their stringified versions +extern const char *const ccs_tab[]; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "viml/parser/expressions.h.generated.h" #endif -- cgit From 7bc6de75263f58c6c4f999bc86a6454ae9f28b80 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 5 Nov 2017 02:41:44 +0300 Subject: api/vim,functests: Add tests for nvim_parse_expression, fix found bugs --- src/nvim/api/vim.c | 47 +++++++++++++++++++++++--------------- src/nvim/viml/parser/expressions.c | 2 +- 2 files changed, 30 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 1aab87010e..5f725acaf7 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -995,21 +995,21 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, &pstate, parser_simple_get_line, &plines_p, colors_p); ExprAST east = viml_pexpr_parse(&pstate, pflags); - const size_t dict_size = ( + const size_t ret_size = ( 1 // "ast" - + (size_t)(east.err.arg != NULL) // "error" + + (size_t)(east.err.msg != NULL) // "error" + (size_t)highlight // "highlight" ); Dictionary ret = { - .items = xmalloc(dict_size * sizeof(ret.items[0])), + .items = xmalloc(ret_size * sizeof(ret.items[0])), .size = 0, - .capacity = dict_size, + .capacity = ret_size, }; ret.items[ret.size++] = (KeyValuePair) { .key = STATIC_CSTR_TO_STRING("ast"), .value = NIL, }; - if (east.err.arg != NULL) { + if (east.err.msg != NULL) { Dictionary err_dict = { .items = xmalloc(2 * sizeof(err_dict.items[0])), .size = 2, @@ -1017,15 +1017,22 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, }; err_dict.items[0] = (KeyValuePair) { .key = STATIC_CSTR_TO_STRING("message"), - .value = STRING_OBJ(cstr_to_string(east.err.arg)), - }; - err_dict.items[1] = (KeyValuePair) { - .key = STATIC_CSTR_TO_STRING("arg"), - .value = STRING_OBJ(((String) { - .data = xmemdupz(east.err.arg, (size_t)east.err.arg_len), - .size = (size_t)east.err.arg_len, - })), + .value = STRING_OBJ(cstr_to_string(east.err.msg)), }; + if (east.err.arg == NULL) { + err_dict.items[1] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("arg"), + .value = STRING_OBJ(STRING_INIT), + }; + } else { + err_dict.items[1] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("arg"), + .value = STRING_OBJ(((String) { + .data = xmemdupz(east.err.arg, (size_t)east.err.arg_len), + .size = (size_t)east.err.arg_len, + })), + }; + } ret.items[ret.size++] = (KeyValuePair) { .key = STATIC_CSTR_TO_STRING("error"), .value = DICTIONARY_OBJ(err_dict), @@ -1055,6 +1062,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, .value = ARRAY_OBJ(hl), }; } + kvi_destroy(colors); // Walk over the AST, freeing nodes in process. ExprASTConvStack ast_conv_stack; @@ -1065,11 +1073,11 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, })); while (kv_size(ast_conv_stack)) { ExprASTConvStackItem cur_item = kv_last(ast_conv_stack); - if (*cur_item.node_p == NULL) { + ExprASTNode *const node = *cur_item.node_p; + if (node == NULL) { assert(kv_size(ast_conv_stack) == 1); kv_drop(ast_conv_stack, 1); } else { - ExprASTNode *const node = *cur_item.node_p; if (cur_item.ret_node_p->type == kObjectTypeNil) { const size_t ret_node_items_size = (size_t)( 3 // "type", "start" and "len" @@ -1116,7 +1124,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, })); } else if (node->next != NULL) { kvi_push(ast_conv_stack, ((ExprASTConvStackItem) { - .node_p = &node->children, + .node_p = &node->next, .ret_node_p = cur_item.ret_node_p + 1, })); } else if (node != NULL) { @@ -1145,7 +1153,10 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, case kExprNodeSingleQuotedString: { ret_node->items[ret_node->size++] = (KeyValuePair) { .key = STATIC_CSTR_TO_STRING("svalue"), - .value = STRING_OBJ(cstr_as_string(node->data.str.value)), + .value = STRING_OBJ(((String) { + .data = node->data.str.value, + .size = node->data.str.size, + })), }; break; } @@ -1217,7 +1228,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, ret_node->items[ret_node->size++] = (KeyValuePair) { .key = STATIC_CSTR_TO_STRING("ccs_strategy"), .value = STRING_OBJ(cstr_to_string( - eltkn_cmp_type_tab[node->data.cmp.ccs])), + ccs_tab[node->data.cmp.ccs])), }; ret_node->items[ret_node->size++] = (KeyValuePair) { .key = STATIC_CSTR_TO_STRING("invert"), diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index b19aab22af..b10952a8ac 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -1492,7 +1492,7 @@ static void parse_quoted_string(ParserState *const pstate, node->data.str.value = NULL; } else { char *v_p; - v_p = node->data.str.value = xmalloc(size); + v_p = node->data.str.value = xmallocz(size); p = s + 1; while (p < e) { const char *const chunk_e = memchr(p, '\'', (size_t)(e - p)); -- cgit From 7849070f998902bb6aae5d6f9147d4daf5421b36 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 5 Nov 2017 21:06:12 +0300 Subject: tests: Add missing test cases --- src/nvim/api/vim.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 5f725acaf7..b12c595cb5 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -971,6 +971,11 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, switch (flags.data[i]) { case 'm': { pflags |= kExprFlagsMulti; break; } case 'E': { pflags |= kExprFlagsDisallowEOC; break; } + case NUL: { + api_set_error(err, kErrorTypeValidation, "Invalid flag: '\\0' (%u)", + (unsigned)flags.data[i]); + return (Dictionary)ARRAY_DICT_INIT; + } default: { api_set_error(err, kErrorTypeValidation, "Invalid flag: '%c' (%u)", flags.data[i], (unsigned)flags.data[i]); @@ -995,6 +1000,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, &pstate, parser_simple_get_line, &plines_p, colors_p); ExprAST east = viml_pexpr_parse(&pstate, pflags); + // FIXME add parse_length key const size_t ret_size = ( 1 // "ast" + (size_t)(east.err.msg != NULL) // "error" -- cgit From ebb59778371784ba28d37fc615ae02a5338f365d Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 6 Nov 2017 01:15:18 +0300 Subject: api/vim: Add “len†dictionary key MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows determining where parsing ended which may be needed for e.g. parsing `:echo` with that API function. --- src/nvim/api/vim.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index b12c595cb5..8de37e2cf3 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -922,6 +922,12 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack; /// Must contain exactly one "%.*s". /// "arg": String, error message argument. /// +/// "len": Amount of bytes successfully parsed. With flags equal to "" +/// that should be equal to the length of expr string. +/// +/// @note: “Sucessfully parsed†here means “participated in AST +/// creationâ€, not “till the first errorâ€. +/// /// "ast": actual AST, either nil or a dictionary with the following /// keys: /// @@ -1000,9 +1006,8 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, &pstate, parser_simple_get_line, &plines_p, colors_p); ExprAST east = viml_pexpr_parse(&pstate, pflags); - // FIXME add parse_length key const size_t ret_size = ( - 1 // "ast" + 2 // "ast", "len" + (size_t)(east.err.msg != NULL) // "error" + (size_t)highlight // "highlight" ); @@ -1015,6 +1020,12 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, .key = STATIC_CSTR_TO_STRING("ast"), .value = NIL, }; + ret.items[ret.size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("len"), + .value = INTEGER_OBJ((Integer)(pstate.pos.line == 1 + ? plines[0].size + : pstate.pos.col)), + }; if (east.err.msg != NULL) { Dictionary err_dict = { .items = xmalloc(2 * sizeof(err_dict.items[0])), -- cgit From 05f775b5f248d922c9539432235738cc53e7edd7 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 6 Nov 2017 01:57:22 +0300 Subject: viml/parser/expressions: Briefly document some differences --- src/nvim/viml/parser/expressions.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index b10952a8ac..998edb1ed4 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -3,6 +3,44 @@ /// VimL expression parser +// Planned incompatibilities (to be included into vim_diff.txt when this parser +// will be an actual part of VimL evaluation process): +// +// 1. Expressions are first fully parsed and only then executed. This means +// that while ":echo [system('touch abc')" will create file "abc" in Vim and +// only then raise syntax error regarding missing comma in list in Neovim +// trying to execute that will immediately raise syntax error regarding +// missing list end without actually executing anything. +// 2. Expressions are first fully parsed, without considering any runtime +// information. This means things like that "d.a" does not change its +// meaning depending on type of "d" (or whether Vim is currently executing or +// skipping). For compatibility reasons the dot thus may either be “concat +// or subscript†operator or just “concat†operator. +// 3. Expressions parser is aware whether it is called for :echo or =. +// This means that while "=1 | 2" is equivalent to "=1" +// because "| 2" part is left to be treated as a command separator and then +// ignored in Neovim it is an error. +// 4. Expressions parser has generally better error reporting. But for +// compatibility reasons most errors have error code E15 while error messages +// are significantly different from Vim’s E15. Also some error codes were +// retired because of being harder to emulate or because of them being +// a result of differences in parsing process: e.g. with ":echo {a, b}" Vim +// will attempt to parse expression as lambda, fail, check whether it is +// a curly-braces-name, fail again, and evaluate that as a dictionary, giving +// error regarding undefined variable "a" (or about missing colon). Neovim +// will not try to evaluate anything here: comma right after an argument name +// means that expression may not be anything, but lambda, so the resulting +// error message will never be about missing variable or colon: it will be +// about missing arrow (or a continuation of argument list). +// 5. Failing to parse expression always gives exactly one error message: no +// more stack of error messages like > +// +// :echo [1, +// E697: Missing end of List ']': +// E15: Invalid expression: [1, +// +// < , just exactly one E697 message. + #include #include #include -- cgit From 842a54a1bbdd3724ba9283269b3f9899b3844e35 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 19 Aug 2017 14:13:14 +0200 Subject: doc --- src/nvim/api/vim.c | 5 ++++- src/nvim/lua/executor.c | 4 ++-- src/nvim/ops.c | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 98f4410347..86f4a9d008 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -166,7 +166,10 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_csi) /// On VimL error: Does not fail, but updates v:errmsg. /// /// Unlike `nvim_feedkeys`, this uses a lower-level input buffer and the call -/// is not deferred. This is the most reliable way to emulate real user input. +/// is not deferred. This is the most reliable way to send real user input. +/// +/// @note |keycodes| like are translated, so `<` is special. +/// To input a literal `<`, send ``. /// /// @param keys to be typed /// @return Number of bytes actually written (can be fewer than diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c index 16bb4169c4..8e7b8a1824 100644 --- a/src/nvim/lua/executor.c +++ b/src/nvim/lua/executor.c @@ -336,8 +336,8 @@ static lua_State *nlua_init(void) /// Calls nlua_init() if needed. Is responsible for pre-lua call initalization /// like updating `package.[c]path` with directories derived from &runtimepath. /// -/// @return Interprter instance to use. Will either be initialized now or taken -/// from previous initalization. +/// @return Interpreter instance to use. Will either be initialized now or +/// taken from previous initialization. static lua_State *nlua_enter(void) FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT { diff --git a/src/nvim/ops.c b/src/nvim/ops.c index c6df71ea46..432c9a8b47 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2735,7 +2735,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) // Autocommands may be executed when saving lines for undo, which may make // y_array invalid. Start undo now to avoid that. if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL) { - ELOG(_("Failed to save undo information")); + ELOG("Failed to save undo information"); return; } } -- cgit From 73fabf4f150e1f4e2da523b6c60b8b90797df4d2 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 23 Oct 2017 23:10:35 +0200 Subject: doc: nvim_buf_add_highlight(): zero-indexed lines --- src/nvim/api/buffer.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index c381e92dc7..f592f44f0e 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -739,29 +739,29 @@ ArrayOf(Integer, 2) nvim_buf_get_mark(Buffer buffer, String name, Error *err) /// Adds a highlight to buffer. /// -/// This can be used for plugins which dynamically generate highlights to a -/// buffer (like a semantic highlighter or linter). The function adds a single +/// Useful for plugins that dynamically generate highlights to a buffer +/// (like a semantic highlighter or linter). The function adds a single /// highlight to a buffer. Unlike matchaddpos() highlights follow changes to /// line numbering (as lines are inserted/removed above the highlighted line), /// like signs and marks do. /// -/// "src_id" is useful for batch deletion/updating of a set of highlights. When -/// called with src_id = 0, an unique source id is generated and returned. -/// Succesive calls can pass in it as "src_id" to add new highlights to the same -/// source group. All highlights in the same group can then be cleared with -/// nvim_buf_clear_highlight. If the highlight never will be manually deleted -/// pass in -1 for "src_id". +/// `src_id` is useful for batch deletion/updating of a set of highlights. When +/// called with `src_id = 0`, an unique source id is generated and returned. +/// Successive calls can pass that `src_id` to associate new highlights with +/// the same source group. All highlights in the same group can be cleared +/// with `nvim_buf_clear_highlight`. If the highlight never will be manually +/// deleted, pass `src_id = -1`. /// -/// If "hl_group" is the empty string no highlight is added, but a new src_id +/// If `hl_group` is the empty string no highlight is added, but a new `src_id` /// is still returned. This is useful for an external plugin to synchrounously -/// request an unique src_id at initialization, and later asynchronously add and -/// clear highlights in response to buffer changes. +/// request an unique `src_id` at initialization, and later asynchronously add +/// and clear highlights in response to buffer changes. /// /// @param buffer Buffer handle /// @param src_id Source group to use or 0 to use a new group, /// or -1 for ungrouped highlight /// @param hl_group Name of the highlight group to use -/// @param line Line to highlight +/// @param line Line to highlight (zero-indexed) /// @param col_start Start of range of columns to highlight /// @param col_end End of range of columns to highlight, /// or -1 to highlight to end of line -- cgit From 280943d9b938e95fcf77ef5290576630b84511fb Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 6 Nov 2017 02:00:39 +0100 Subject: doc: API (generated) --- src/nvim/api/buffer.c | 13 +++++++------ src/nvim/api/vim.c | 29 ++++++++++++++--------------- 2 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index f592f44f0e..4b6a88e5fa 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -439,6 +439,7 @@ Object nvim_buf_get_var(Buffer buffer, String name, Error *err) /// Gets a changed tick of a buffer /// /// @param[in] buffer Buffer handle. +/// @param[out] err Error details, if any /// /// @return `b:changedtick` value. Integer nvim_buf_get_changedtick(Buffer buffer, Error *err) @@ -453,14 +454,14 @@ Integer nvim_buf_get_changedtick(Buffer buffer, Error *err) return buf->b_changedtick; } -/// Get a list of dictionaries describing buffer-local mappings -/// Note that the buffer key in the dictionary will represent the buffer -/// handle where the mapping is present +/// Gets a list of dictionaries describing buffer-local mappings. +/// The "buffer" key in the returned dictionary reflects the buffer +/// handle where the mapping is present. /// -/// @param mode The abbreviation for the mode -/// @param buffer_id Buffer handle +/// @param mode Mode short-name ("n", "i", "v", ...) +/// @param buffer Buffer handle /// @param[out] err Error details, if any -/// @returns An array of maparg() like dictionaries describing mappings +/// @returns Array of maparg()-like dictionaries describing mappings ArrayOf(Dictionary) nvim_buf_get_keymap(Buffer buffer, String mode, Error *err) FUNC_API_SINCE(3) { diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 86f4a9d008..e5ec018795 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -168,8 +168,8 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_csi) /// Unlike `nvim_feedkeys`, this uses a lower-level input buffer and the call /// is not deferred. This is the most reliable way to send real user input. /// -/// @note |keycodes| like are translated, so `<` is special. -/// To input a literal `<`, send ``. +/// @note |keycodes| like are translated, so "<" is special. +/// To input a literal "<", send . /// /// @param keys to be typed /// @return Number of bytes actually written (can be fewer than @@ -323,15 +323,15 @@ Object nvim_execute_lua(String code, Array args, Error *err) /// @param text Some text /// @param[out] err Error details, if any /// @return Number of cells -Integer nvim_strwidth(String str, Error *err) +Integer nvim_strwidth(String text, Error *err) FUNC_API_SINCE(1) { - if (str.size > INT_MAX) { + if (text.size > INT_MAX) { api_set_error(err, kErrorTypeValidation, "String length is too high"); return 0; } - return (Integer) mb_string2cells((char_u *) str.data); + return (Integer)mb_string2cells((char_u *)text.data); } /// Gets the paths contained in 'runtimepath'. @@ -581,7 +581,7 @@ Buffer nvim_get_current_buf(void) /// Sets the current buffer /// -/// @param id Buffer handle +/// @param buffer Buffer handle /// @param[out] err Error details, if any void nvim_set_current_buf(Buffer buffer, Error *err) FUNC_API_SINCE(1) @@ -635,7 +635,7 @@ Window nvim_get_current_win(void) /// Sets the current window /// -/// @param handle Window handle +/// @param window Window handle void nvim_set_current_win(Window window, Error *err) FUNC_API_SINCE(1) { @@ -688,7 +688,7 @@ Tabpage nvim_get_current_tabpage(void) /// Sets the current tabpage /// -/// @param handle Tabpage handle +/// @param tabpage Tabpage handle /// @param[out] err Error details, if any void nvim_set_current_tabpage(Tabpage tabpage, Error *err) FUNC_API_SINCE(1) @@ -758,9 +758,8 @@ Dictionary nvim_get_color_map(void) } -/// Gets the current mode. -/// mode: Mode string. |mode()| -/// blocking: true if Nvim is waiting for input. +/// Gets the current mode. |mode()| +/// "blocking" is true if Nvim is waiting for input. /// /// @returns Dictionary { "mode": String, "blocking": Boolean } Dictionary nvim_get_mode(void) @@ -776,11 +775,11 @@ Dictionary nvim_get_mode(void) return rv; } -/// Get a list of dictionaries describing global (i.e. non-buffer) mappings -/// Note that the "buffer" key will be 0 to represent false. +/// Gets a list of dictionaries describing global (non-buffer) mappings. +/// The "buffer" key in the returned dictionary is always zero. /// -/// @param mode The abbreviation for the mode -/// @returns An array of maparg() like dictionaries describing mappings +/// @param mode Mode short-name ("n", "i", "v", ...) +/// @returns Array of maparg()-like dictionaries describing mappings ArrayOf(Dictionary) nvim_get_keymap(String mode) FUNC_API_SINCE(3) { -- cgit From 8f03014e8861df7f49bf4e1dbdfcc20e1611ce35 Mon Sep 17 00:00:00 2001 From: Adrian Neumann Date: Thu, 28 Sep 2017 10:19:57 +0200 Subject: eval/decode.c: Avoid NULL arg to memchr() #7332 Clang complains because memchr has undefined behavior if the ptr is NULL, even if len==0. Helped-by: Nikolai Aleksandrovich Pavlov --- src/nvim/eval/decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index 9c9c2c2dc8..0933b1bf9c 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -266,7 +266,7 @@ typval_T decode_string(const char *const s, const size_t len, { assert(s != NULL || len == 0); const bool really_hasnul = (hasnul == kNone - ? memchr(s, NUL, len) != NULL + ? ((s != NULL) && (memchr(s, NUL, len) != NULL)) : (bool)hasnul); if (really_hasnul) { list_T *const list = tv_list_alloc(); -- cgit From c85f485aa78352f31421d209176b2ed57b91b86e Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 6 Nov 2017 19:06:24 +0300 Subject: charset: Move vim_str2nr flags from vim.h to charset.h --- src/nvim/charset.c | 2 +- src/nvim/charset.h | 15 +++++++++++++++ src/nvim/vim.h | 7 ------- 3 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/charset.c b/src/nvim/charset.c index 5aebf90194..980b4ed426 100644 --- a/src/nvim/charset.c +++ b/src/nvim/charset.c @@ -1615,7 +1615,7 @@ bool vim_isblankline(char_u *lbuf) /// hexadecimal, '0' = octal, 'b' or 'B' is binary. When using /// STR2NR_FORCE is always zero. /// @param len Returns the detected length of number. -/// @param what Recognizes what number passed. +/// @param what Recognizes what number passed, @see ChStr2NrFlags. /// @param nptr Returns the signed result. /// @param unptr Returns the unsigned result. /// @param maxlen Max length of string to check. diff --git a/src/nvim/charset.h b/src/nvim/charset.h index c69582c4c6..7198c8d405 100644 --- a/src/nvim/charset.h +++ b/src/nvim/charset.h @@ -15,6 +15,21 @@ ?((int)(uint8_t)(c)) \ :((int)(c))) +/// Flags for vim_str2nr() +typedef enum { + STR2NR_DEC = 0, + STR2NR_BIN = (1 << 0), ///< Allow binary numbers. + STR2NR_OCT = (1 << 1), ///< Allow octal numbers. + STR2NR_HEX = (1 << 2), ///< Allow hexadecimal numbers. + /// Force one of the above variants. + /// + /// STR2NR_FORCE|STR2NR_DEC is actually not different from supplying zero + /// as flags, but still present for completeness. + STR2NR_FORCE = (1 << 3), + /// Recognize all formats vim_str2nr() can recognize. + STR2NR_ALL = STR2NR_BIN | STR2NR_OCT | STR2NR_HEX, +} ChStr2NrFlags; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "charset.h.generated.h" #endif diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 62ffc7433e..096c57450f 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -28,13 +28,6 @@ /// length of a buffer to store a number in ASCII (64 bits binary + NUL) enum { NUMBUFLEN = 65 }; -// flags for vim_str2nr() -#define STR2NR_BIN 1 -#define STR2NR_OCT 2 -#define STR2NR_HEX 4 -#define STR2NR_ALL (STR2NR_BIN + STR2NR_OCT + STR2NR_HEX) -#define STR2NR_FORCE 8 // only when ONE of the above is used - #define MAX_TYPENR 65535 #define ROOT_UID 0 -- cgit From f2660bee6aca35be3d0ddb1d225784476c13cd27 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 6 Nov 2017 20:20:31 +0300 Subject: *: Fix some typos found by oni-link --- src/nvim/ex_getln.c | 1 - src/nvim/generators/gen_declarations.lua | 6 +++--- src/nvim/keymap.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index f64efe08a1..3b751530e8 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2501,7 +2501,6 @@ static bool color_cmdline(CmdlineInfo *colored_ccline) can_free_cb = true; } else if (colored_ccline->cmdfirstc == '=') { color_expr_cmdline(colored_ccline, ccline_colors); - can_free_cb = false; } if (!tl_ret || !dgc_ret) { goto color_cmdline_error; diff --git a/src/nvim/generators/gen_declarations.lua b/src/nvim/generators/gen_declarations.lua index 0c73376ba0..065c043557 100755 --- a/src/nvim/generators/gen_declarations.lua +++ b/src/nvim/generators/gen_declarations.lua @@ -169,10 +169,10 @@ Usage: gendeclarations.lua definitions.c static.h non-static.h definitions.i -Generates declarations for a C file defitions.c, putting declarations for +Generates declarations for a C file definitions.c, putting declarations for static functions into static.h and declarations for non-static functions into non-static.h. File `definitions.i' should contain an already preprocessed -version of defintions.c and it is the only one which is actually parsed, +version of definitions.c and it is the only one which is actually parsed, definitions.c is needed only to determine functions from which file out of all functions found in definitions.i are needed. @@ -181,7 +181,7 @@ Additionally uses the following environment variables: NVIM_GEN_DECLARATIONS_LINE_NUMBERS: If set to 1 then all generated declarations receive a comment with file name and line number after the declaration. This may be useful for - debugging gen_declarations script, but not much beyound that with + debugging gen_declarations script, but not much beyond that with configured development environment (i.e. with ctags/cscope/finding definitions with clang/etc). diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index 0c8e47b02e..aca21c20a5 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -714,7 +714,7 @@ int find_special_key_in_table(int c) /// with "t_" the next two characters are interpreted as /// a termcap name. /// -/// @return Key code or 0 if ton found. +/// @return Key code or 0 if not found. int get_special_key_code(const char_u *name) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { -- cgit From 4aebd00a9eeeb2f56ff53dd4e383825e997ee7be Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 6 Nov 2017 20:28:37 +0300 Subject: *: Fix linter errors --- src/nvim/api/vim.c | 20 ++++++++++---------- src/nvim/viml/parser/expressions.c | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 0596c3ebd8..bac19ef363 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -930,7 +930,7 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack; /// @note: “Sucessfully parsed†here means “participated in AST /// creationâ€, not “till the first errorâ€. /// -/// "ast": actual AST, either nil or a dictionary with the following +/// "ast": actual AST, either nil or a dictionary with the following /// keys: /// /// "type": node type, one of the value names from ExprASTNodeType @@ -1009,10 +1009,10 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, ExprAST east = viml_pexpr_parse(&pstate, pflags); const size_t ret_size = ( - 2 // "ast", "len" - + (size_t)(east.err.msg != NULL) // "error" - + (size_t)highlight // "highlight" - ); + 2 // "ast", "len" + + (size_t)(east.err.msg != NULL) // "error" + + (size_t)highlight // "highlight" + + 0); Dictionary ret = { .items = xmalloc(ret_size * sizeof(ret.items[0])), .size = 0, @@ -1242,12 +1242,12 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, ret_node->items[ret_node->size++] = (KeyValuePair) { .key = STATIC_CSTR_TO_STRING("cmp_type"), .value = STRING_OBJ(cstr_to_string( - eltkn_cmp_type_tab[node->data.cmp.type])), + eltkn_cmp_type_tab[node->data.cmp.type])), }; ret_node->items[ret_node->size++] = (KeyValuePair) { .key = STATIC_CSTR_TO_STRING("ccs_strategy"), .value = STRING_OBJ(cstr_to_string( - ccs_tab[node->data.cmp.ccs])), + ccs_tab[node->data.cmp.ccs])), }; ret_node->items[ret_node->size++] = (KeyValuePair) { .key = STATIC_CSTR_TO_STRING("invert"), @@ -1266,9 +1266,9 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, ret_node->items[ret_node->size++] = (KeyValuePair) { .key = STATIC_CSTR_TO_STRING("ivalue"), .value = INTEGER_OBJ((Integer)( - node->data.num.value > API_INTEGER_MAX - ? API_INTEGER_MAX - : (Integer)node->data.num.value)), + node->data.num.value > API_INTEGER_MAX + ? API_INTEGER_MAX + : (Integer)node->data.num.value)), }; break; } diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 998edb1ed4..71eda2cdc1 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -22,7 +22,7 @@ // ignored in Neovim it is an error. // 4. Expressions parser has generally better error reporting. But for // compatibility reasons most errors have error code E15 while error messages -// are significantly different from Vim’s E15. Also some error codes were +// are significantly different from Vim’s E15. Also some error codes were // retired because of being harder to emulate or because of them being // a result of differences in parsing process: e.g. with ":echo {a, b}" Vim // will attempt to parse expression as lambda, fail, check whether it is -- cgit From c598c3ac770b4ae1bdcda06224fa18300eac1455 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 00:51:03 +0100 Subject: doc: deprecate 'highlight'; remove howto.txt (#7497) --- src/nvim/syntax.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 70bda42d83..913fd05482 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -79,7 +79,7 @@ struct hl_group { #define SG_LINK 8 // link has been set /// @} -// highlight groups for 'highlight' option +// builtin |highlight-groups| static garray_T highlight_ga = GA_EMPTY_INIT_VALUE; static inline struct hl_group * HL_TABLE(void) -- cgit From 599170de8304d74baa3e18df0929330e3773a14d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 01:29:14 +0100 Subject: vim-patch:6aa8cea46d41 Update runtime files. https://github.com/vim/vim/commit/6aa8cea46d4179b2617daae034063dd0d8054e35 --- src/nvim/po/it.po | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/po/it.po b/src/nvim/po/it.po index b8b119ade6..91b7b715f8 100644 --- a/src/nvim/po/it.po +++ b/src/nvim/po/it.po @@ -1402,6 +1402,31 @@ msgstr "com: %s" msgid "frame is zero" msgstr "al livello zero" +msgid "E901: gethostbyname() in channel_open()" +msgstr "E901: gethostbyname() in channel_open()" + +msgid "E898: socket() in channel_open()" +msgstr "E898: socket() in channel_open()" + +msgid "E903: received command with non-string argument" +msgstr "E903: il comando ricevuto non aveva come argomento una stringa" + +msgid "E904: last argument for expr/call must be a number" +msgstr "E904: l'ultimo argomento per espressione/chiamata dev'essere numerico" + +msgid "E904: third argument for call must be a list" +msgstr "E904: il terzo argomento della chiamata dev'essere una Lista" + +msgid "E905: received unknown command: %s" +msgstr "E905: recevuto comando non conosciuto: %s" + +#, c-format +msgid "E630: %s(): write while not connected" +msgstr "E630: %s(): scrittura in mancanza di connessione" + +msgid "E631: %s(): write failed" +msgstr "E631: %s(): scrittura non riuscita" + #, c-format msgid "frame at highest level: %d" msgstr "al livello più alto: %d" @@ -4812,10 +4837,16 @@ msgstr "" "\n" "Non posso impostare il contesto di sicurezza per " +msgid "E151: No match: %s" +msgstr "E151: Nessuna corrispondenza: %s" + #, c-format msgid "Could not set security context %s for %s" msgstr "Non posso impostare il contesto di sicurezza %s per %s" +msgid "E934: Cannot jump to a buffer that does not have a name" +msgstr "E934: Impossibile passare a un buffer che non ha un nome" + #, c-format msgid "Could not get security context %s for %s. Removing it!" msgstr "Non posso ottenere il contesto di sicurezza %s per %s. Lo rimuovo!" @@ -5353,8 +5384,24 @@ msgstr "E770: Sezione non supportata nel file ortografico" #: ../spell.c:3762 #, c-format -msgid "Warning: region %s not supported" -msgstr "Avviso: regione %s non supportata" +msgid "E778: This does not look like a .sug file: %s" +msgstr "E778: Questo non sembra un file .sug: %s" + +#, c-format +msgid "E779: Old .sug file, needs to be updated: %s" +msgstr "E779: File .sug obsoleto, è necessario aggiornarlo: %s" + +#, c-format +msgid "E780: .sug file is for newer version of Vim: %s" +msgstr "E780: Il file .sug è per versioni di Vim più recenti: %s" + +#, c-format +msgid "E781: .sug file doesn't match .spl file: %s" +msgstr "E781: Il file .sug non corrisponde al file .spl: %s" + +#, c-format +msgid "E782: error while reading .sug file: %s" +msgstr "E782: Errore leggendo il file .sug: %s" #: ../spell.c:4550 #, c-format -- cgit From a39bf019580d82f8ca5f9e8d99dd856418ffc491 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 01:34:28 +0100 Subject: vim-patch:3ec574f2b549 Update runtime files. Includes changing &sw to shiftwidth() for all indent scripts. https://github.com/vim/vim/commit/3ec574f2b549f456f664f689d6da36dc5719aeb9 --- src/nvim/po/it.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/po/it.po b/src/nvim/po/it.po index 91b7b715f8..4d9ce045ca 100644 --- a/src/nvim/po/it.po +++ b/src/nvim/po/it.po @@ -11,7 +11,7 @@ # msgid "" msgstr "" -"Project-Id-Version: vim 7.4\n" +"Project-Id-Version: vim 8.0\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2016-02-11 12:10+0100\n" "PO-Revision-Date: 2016-02-11 14:42+0200\n" -- cgit From 85cfc4c4f9fdbd25e0ece129840d654c049f85b6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 01:38:06 +0100 Subject: vim-patch:74675a666b51 Updated runtime files and translations. https://github.com/vim/vim/commit/74675a666b51edd61e0210132658d81a86c5102c --- src/nvim/po/de.po | 2 +- src/nvim/po/eo.po | 151 +++++++++++++++++++++++++--------------- src/nvim/po/fr.po | 110 +++++++++++++++++++---------- src/nvim/po/ga.po | 177 ++++++++++++++++++++++++++++++++++------------- src/nvim/po/ja.euc-jp.po | 147 +++++++++++++++++++++++++-------------- src/nvim/po/ja.po | 147 +++++++++++++++++++++++++-------------- src/nvim/po/ko.UTF-8.po | 75 ++++++++++++++++---- src/nvim/po/uk.po | 43 +++++++++++- 8 files changed, 591 insertions(+), 261 deletions(-) (limited to 'src') diff --git a/src/nvim/po/de.po b/src/nvim/po/de.po index f04d3be4b4..751e9aeb4c 100644 --- a/src/nvim/po/de.po +++ b/src/nvim/po/de.po @@ -12,7 +12,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2014-06-26 15:13+0200\n" "PO-Revision-Date: 2008-05-24 17:26+0200\n" -"Last-Translator: Georg Dahn \n" +"Last-Translator: was: Georg Dahn\n" "Language-Team: German \n" "Language: de\n" "MIME-Version: 1.0\n" diff --git a/src/nvim/po/eo.po b/src/nvim/po/eo.po index 3fb300c63f..188d86f478 100644 --- a/src/nvim/po/eo.po +++ b/src/nvim/po/eo.po @@ -13,18 +13,12 @@ # Komputeko: http://komputeko.net/index_eo.php # Komputada leksikono: http://bertilow.com/div/komputada_leksikono/ # -# Lasta versio: -# http://dominique.pelle.free.fr/vim-eo.php -# -# Ĉiu komento estas bonvenata... -# Every remark is welcome... -# msgid "" msgstr "" "Project-Id-Version: Vim(Esperanto)\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-01-16 00:30+0100\n" -"PO-Revision-Date: 2017-01-16 01:14+0100\n" +"POT-Creation-Date: 2017-07-11 23:10+0200\n" +"PO-Revision-Date: 2017-07-12 05:14+0200\n" "Last-Translator: Dominique PELLÉ \n" "Language-Team: \n" "Language: eo\n" @@ -442,6 +436,9 @@ msgstr "Analizas: %s" msgid "Scanning tags." msgstr "Analizas etikedojn." +msgid "match in file" +msgstr "kongruo en dosiero" + msgid " Adding" msgstr " Aldonanta" @@ -523,17 +520,23 @@ msgid "E711: List value has not enough items" msgstr "E711: Lista valoro ne havas sufiĉe da eroj" msgid "E690: Missing \"in\" after :for" -msgstr "E690: \"in\" mankas post \":for\"" +msgstr "E690: \"in\" mankas malantaÅ­ \":for\"" #, c-format msgid "E108: No such variable: \"%s\"" msgstr "E108: Ne estas tia variablo: \"%s\"" +#. For historic reasons this error is not given for a list or dict. +#. * E.g., the b: dict could be locked/unlocked. +#, c-format +msgid "E940: Cannot lock or unlock variable %s" +msgstr "E940: Ne eblas Ålosi aÅ­ malÅlosi variablon %s" + msgid "E743: variable nested too deep for (un)lock" -msgstr "E743: variablo ingita tro profunde por malÅlosi" +msgstr "E743: variablo ingita tro profunde por (mal)Ålosi" msgid "E109: Missing ':' after '?'" -msgstr "E109: Mankas ':' post '?'" +msgstr "E109: Mankas ':' malantaÅ­ '?'" msgid "E691: Can only compare List with List" msgstr "E691: Eblas nur kompari Liston kun Listo" @@ -705,12 +708,6 @@ msgstr "E785: complete() uzeblas nur en Enmeta reÄimo" msgid "&Ok" msgstr "&Bone" -#, c-format -msgid "+-%s%3ld line: " -msgid_plural "+-%s%3ld lines: " -msgstr[0] "+-%s%3ld linio: " -msgstr[1] "+-%s%3ld linioj: " - #, c-format msgid "E700: Unknown function: %s" msgstr "E700: Nekonata funkcio: %s" @@ -756,8 +753,8 @@ msgstr "E727: Komenco preter fino" msgid "" msgstr "" -msgid "E240: No connection to Vim server" -msgstr "E240: Neniu konekto al Vim-servilo" +msgid "E240: No connection to the X server" +msgstr "E240: Neniu konekto al X-servilo" #, c-format msgid "E241: Unable to send to %s" @@ -766,6 +763,12 @@ msgstr "E241: Ne eblas sendi al %s" msgid "E277: Unable to read a server reply" msgstr "E277: Ne eblas legi respondon de servilo" +msgid "E941: already started a server" +msgstr "E941: servilo jam lanĉita" + +msgid "E942: +clientserver feature not available" +msgstr "E942: la eblo +clientserver ne disponeblas" + msgid "remove() argument" msgstr "argumento de remove()" @@ -1002,8 +1005,9 @@ msgstr " en 1 linio" msgid " on %ld lines" msgstr " en %ld linioj" -msgid "E147: Cannot do :global recursive" -msgstr "E147: Ne eblas fari \":global\" rekursie" +#. will increment global_busy to break out of the loop +msgid "E147: Cannot do :global recursive with a range" +msgstr "E147: Ne eblas fari \":global\" rekursie kun amplekso" # DP: global estas por ":global" do mi ne tradukis Äin msgid "E148: Regular expression missing from global" @@ -1189,6 +1193,14 @@ msgstr "Serĉado de \"%s\"" msgid "not found in '%s': \"%s\"" msgstr "ne trovita en '%s: \"%s\"" +#, c-format +msgid "W20: Required python version 2.x not supported, ignoring file: %s" +msgstr "W20: Pitono versio 2.x bezonata sed nesubtenata, ignoro de dosiero: %s" + +#, c-format +msgid "W21: Required python version 3.x not supported, ignoring file: %s" +msgstr "W21: pitono versio 3.x bezonata sed nesubtenata, ignore de dosiero: %s" + msgid "Source Vim script" msgstr "Ruli Vim-skripton" @@ -1286,6 +1298,9 @@ msgstr "Inversa amplekso donita, permuteblas" msgid "E494: Use w or w>>" msgstr "E494: Uzu w aÅ­ w>>" +msgid "E943: Command table needs to be updated, run 'make cmdidxs'" +msgstr "E943: Tabulo de komandoj estas Äisdatigenda, lanĉu 'make cmdidx'" + msgid "E319: Sorry, the command is not available in this version" msgstr "E319: BedaÅ­rinde, tiu komando ne haveblas en tiu versio" @@ -1562,7 +1577,7 @@ msgid "E583: multiple :else" msgstr "E583: pluraj \":else\"" msgid "E584: :elseif after :else" -msgstr "E584: \":elseif\" post \":else\"" +msgstr "E584: \":elseif\" malantaÅ­ \":else\"" msgid "E585: :while/:for nesting too deep" msgstr "E585: \":while/:for\" ingita tro profunde" @@ -1588,7 +1603,7 @@ msgstr "E603: \":catch\" sen \":try\"" #. Give up for a ":catch" after ":finally" and ignore it. #. * Just parse. msgid "E604: :catch after :finally" -msgstr "E604: \":catch\" post \":finally\"" +msgstr "E604: \":catch\" malantaÅ­ \":finally\"" msgid "E606: :finally without :try" msgstr "E606: \":finally\" sen \":try\"" @@ -1986,7 +2001,7 @@ msgstr "W19: ForviÅo de augroup kiu estas ankoraÅ­ uzata" #, c-format msgid "E215: Illegal character after *: %s" -msgstr "E215: Nevalida signo post *: %s" +msgstr "E215: Nevalida signo malantaÅ­ *: %s" #, c-format msgid "E216: No such event: %s" @@ -2044,12 +2059,6 @@ msgstr "E350: Ne eblas krei faldon per la aktuala 'foldmethod'" msgid "E351: Cannot delete fold with current 'foldmethod'" msgstr "E351: Ne eblas forviÅi faldon per la aktuala 'foldmethod'" -#, c-format -msgid "+--%3ld line folded " -msgid_plural "+--%3ld lines folded " -msgstr[0] "+--%3ld linio faldita " -msgstr[1] "+--%3ld linioj falditaj " - msgid "E222: Add to read buffer" msgstr "E222: Aldoni al lega bufro" @@ -2859,10 +2868,10 @@ msgid "Too many edit arguments" msgstr "Tro da argumentoj de redakto" msgid "Argument missing after" -msgstr "Argumento mankas post" +msgstr "Argumento mankas malantaÅ­" msgid "Garbage after option argument" -msgstr "Forĵetindaĵo post argumento de opcio" +msgstr "Forĵetindaĵo malantaÅ­ argumento de opcio" msgid "Too many \"+command\", \"-c command\" or \"--cmd command\" arguments" msgstr "Tro da argumentoj \"+komando\", \"-c komando\" aÅ­ \"--cmd komando\"" @@ -2968,7 +2977,7 @@ msgstr "" "Argumentoj:\n" msgid "--\t\t\tOnly file names after this" -msgstr "--\t\t\tNur dosiernomoj post tio" +msgstr "--\t\t\tNur dosiernomoj malantaÅ­ tio" msgid "--literal\t\tDon't expand wildcards" msgstr "--literal\t\tNe malvolvi ĵokerojn" @@ -3069,8 +3078,7 @@ msgstr "" "--not-a-term\t\tPreterpasi averton por enigo/eligo, kiu ne estas terminalo" msgid "--ttyfail\t\tExit if input or output is not a terminal" -msgstr "" -"--ttyfail\t\tEliri se le eniro aÅ­ eliro ne estas terminalo" +msgstr "--ttyfail\t\tEliri se la eniro aÅ­ eliro ne estas terminalo" msgid "-u \t\tUse instead of any .vimrc" msgstr "-u \t\tUzi anstataÅ­ iun ajn .vimrc" @@ -4116,8 +4124,8 @@ msgstr "E662: Ĉe komenco de ÅanÄlisto" msgid "E663: At end of changelist" msgstr "E663: Ĉe fino de ÅanÄlisto" -msgid "Type :quit to exit Vim" -msgstr "Tajpu \":quit\" por eliri el Vim" +msgid "Type :qa! and press to abandon all changes and exit Vim" +msgstr "Tajpu :qa! kaj premu por forlasi ĉiujn ÅanÄojn kaj eliri el Vim" #, c-format msgid "1 line %sed 1 time" @@ -4262,7 +4270,7 @@ msgid "E846: Key code not set" msgstr "E846: Klavkodo ne agordita" msgid "E521: Number required after =" -msgstr "E521: Nombro bezonata post =" +msgstr "E521: Nombro bezonata malantaÅ­ =" msgid "E522: Not found in termcap" msgstr "E522: Netrovita en termcap" @@ -4304,7 +4312,7 @@ msgstr "E525: Ĉeno de nula longo" #, c-format msgid "E526: Missing number after <%s>" -msgstr "E526: Mankas nombro post <%s>" +msgstr "E526: Mankas nombro malantaÅ­ <%s>" msgid "E527: Missing comma" msgstr "E527: Mankas komo" @@ -4332,7 +4340,7 @@ msgstr "E534: Nevalida larÄa tiparo" #, c-format msgid "E535: Illegal character after <%c>" -msgstr "E535: Nevalida signo post <%c>" +msgstr "E535: Nevalida signo malantaÅ­ <%c>" msgid "E536: comma required" msgstr "E536: komo bezonata" @@ -4415,7 +4423,7 @@ msgstr "E357: 'langmap': Kongrua signo mankas por %s" #, c-format msgid "E358: 'langmap': Extra characters after semicolon: %s" -msgstr "E358: 'langmap': Ekstraj signoj post punktokomo: %s" +msgstr "E358: 'langmap': Ekstraj signoj malantaÅ­ punktokomo: %s" msgid "cannot open " msgstr "ne eblas malfermi " @@ -4736,7 +4744,13 @@ msgstr "E369: nevalida ano en %s%%[]" #, c-format msgid "E769: Missing ] after %s[" -msgstr "E769: Mankas ] post %s[" +msgstr "E769: Mankas ] malantaÅ­ %s[" + +msgid "E944: Reverse range in character class" +msgstr "E944: Inversa amplekso en klaso de signoj" + +msgid "E945: Range too large in character class" +msgstr "E945: tro larga amplekso de klaso de signoj" #, c-format msgid "E53: Unmatched %s%%(" @@ -4759,12 +4773,15 @@ msgstr "E67: \\z1 kaj aliaj estas nepermeseblaj tie" #, c-format msgid "E69: Missing ] after %s%%[" -msgstr "E69: Mankas ] post %s%%[" +msgstr "E69: Mankas ] malantaÅ­ %s%%[" #, c-format msgid "E70: Empty %s%%[]" msgstr "E70: Malplena %s%%[]" +msgid "E65: Illegal back reference" +msgstr "E65: Nevalida retro-referenco" + msgid "E339: Pattern too long" msgstr "E339: Åœablono tro longa" @@ -4780,7 +4797,7 @@ msgstr "E52: Neekvilibra \\z(" #, c-format msgid "E59: invalid character after %s@" -msgstr "E59: nevalida signo post %s@" +msgstr "E59: nevalida signo malantaÅ­ %s@" #, c-format msgid "E60: Too many complex %s{...}s" @@ -4801,19 +4818,16 @@ msgstr "E63: nevalida uzo de \\_" msgid "E64: %s%c follows nothing" msgstr "E64: %s%c sekvas nenion" -msgid "E65: Illegal back reference" -msgstr "E65: Nevalida retro-referenco" - msgid "E68: Invalid character after \\z" -msgstr "E68: Nevalida signo post \\z" +msgstr "E68: Nevalida signo malantaÅ­ \\z" #, c-format msgid "E678: Invalid character after %s%%[dxouU]" -msgstr "E678: Nevalida signo post %s%%[dxouU]" +msgstr "E678: Nevalida signo malantaÅ­ %s%%[dxouU]" #, c-format msgid "E71: Invalid character after %s%%" -msgstr "E71: Nevalida signo post %s%%" +msgstr "E71: Nevalida signo malantaÅ­ %s%%" #, c-format msgid "E554: Syntax error in %s{...}" @@ -4845,7 +4859,7 @@ msgstr "E866: (NFA-regulesprimo) Mispoziciigita %c" #, c-format msgid "E877: (NFA regexp) Invalid character class: %ld" -msgstr "E877: (NFA-regulesprimo) Nevalida klaso de signo: %ld" +msgstr "E877: (NFA-regulesprimo) Nevalida klaso de signoj: %ld" #, c-format msgid "E867: (NFA) Unknown operator '\\z%c'" @@ -4975,7 +4989,7 @@ msgid "E385: search hit BOTTOM without match for: %s" msgstr "E385: serĉo atingis SUBON sen trovi: %s" msgid "E386: Expected '?' or '/' after ';'" -msgstr "E386: Atendis '?' aÅ­ '/' post ';'" +msgstr "E386: Atendis '?' aÅ­ '/' malantaÅ­ ';'" msgid " (includes previously listed match)" msgstr " (enhavas antaÅ­e listigitajn kongruojn)" @@ -5406,10 +5420,31 @@ msgstr "E783: ripetita signo en rikordo MAP" msgid "No Syntax items defined for this buffer" msgstr "Neniu sintaksa elemento difinita por tiu bufro" +msgid "syntax conceal on" +msgstr "sintakso de conceal Åaltata" + +msgid "syntax conceal off" +msgstr "sintakso de conceal malÅaltita" + #, c-format msgid "E390: Illegal argument: %s" msgstr "E390: Nevalida argumento: %s" +msgid "syntax case ignore" +msgstr "sintakso ignoras usklecon" + +msgid "syntax case match" +msgstr "sintakso konsideras usklecon" + +msgid "syntax spell toplevel" +msgstr "literumado en teksto sen sintaksa grupo" + +msgid "syntax spell notoplevel" +msgstr "sen literumado en teksto sen sintaksa grupo" + +msgid "syntax spell default" +msgstr "literumado en teksto sen sintaksa grupo, nur se ne estas @Spell aÅ­ @NoSpell" + msgid "syntax iskeyword " msgstr "sintakso iskeyword " @@ -5491,7 +5526,7 @@ msgstr "E789: Mankas ']': %s" #, c-format msgid "E890: trailing char after ']': %s]%s" -msgstr "E890: vosta signo post ']': %s]%s" +msgstr "E890: vosta signo malantaÅ­ ']': %s]%s" #, c-format msgid "E398: Missing '=': %s" @@ -5513,7 +5548,7 @@ msgstr "E401: Disigilo de Åablono netrovita: %s" #, c-format msgid "E402: Garbage after pattern: %s" -msgstr "E402: Forĵetindaĵo post Åablono: %s" +msgstr "E402: Forĵetindaĵo malantaÅ­ Åablono: %s" msgid "E403: syntax sync: line continuations pattern specified twice" msgstr "E403: sintaksa sinkronigo: Åablono de linia daÅ­rigo specifita dufoje" @@ -5986,6 +6021,10 @@ msgstr "E932: Fermo-funkcio devus esti je la plej alta nivelo: %s" msgid "E126: Missing :endfunction" msgstr "E126: Mankas \":endfunction\"" +#, c-format +msgid "W22: Text found after :endfunction: %s" +msgstr "W22: Teksto trovita malantaÅ­ :endfunction: %s" + #, c-format msgid "E707: Function name conflicts with variable: %s" msgstr "E707: Nomo de funkcio konfliktas kun variablo: %s" @@ -6730,8 +6769,8 @@ msgstr "E592: 'winwidth' ne rajtas esti malpli ol 'winminwidth'" msgid "E80: Error while writing" msgstr "E80: Eraro dum skribado" -msgid "Zero count" -msgstr "Nul kvantoro" +msgid "E939: Positive count required" +msgstr "E939: Pozitiva kvantoro bezonata" msgid "E81: Using not in a script context" msgstr "E81: Uzo de ekster kunteksto de skripto" diff --git a/src/nvim/po/fr.po b/src/nvim/po/fr.po index c0df5f2170..435042ad05 100644 --- a/src/nvim/po/fr.po +++ b/src/nvim/po/fr.po @@ -4,20 +4,17 @@ # Do ":help uganda" in Vim to read copying and usage conditions. # Do ":help credits" in Vim to see a list of people who contributed. # -# FIRST AUTHOR DindinX 2000. -# SECOND AUTHOR Adrien Beau 2002, 2003. -# THIRD AUTHOR David Blanchet 2006, 2008. -# FOURTH AUTHOR Dominique Pellé 2008, 2017. -# -# Latest translation available at: -# http://dominique.pelle.free.fr/vim-fr.php +# FIRST AUTHOR DindinX 2000. +# SECOND AUTHOR Adrien Beau 2002, 2003. +# THIRD AUTHOR David Blanchet 2006, 2008. +# FOURTH AUTHOR Dominique Pellé 2008, 2017. # msgid "" msgstr "" "Project-Id-Version: Vim(Français)\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-01-16 00:30+0100\n" -"PO-Revision-Date: 2017-01-16 00:51+0100\n" +"POT-Creation-Date: 2017-07-11 23:10+0200\n" +"PO-Revision-Date: 2017-01-12 05:16+0200\n" "Last-Translator: Dominique Pellé \n" "Language-Team: \n" "Language: fr\n" @@ -481,6 +478,9 @@ msgstr "Examen : %s" msgid "Scanning tags." msgstr "Examen des marqueurs." +msgid "match in file" +msgstr "correspondance dans le fichier" + # AB - Cette chaîne de caractères est ajoutée en début de ligne lorsqu'une # opération de complétion est répétée (typiquement avec CTRL-X CTRL-N). # Que ce soit en anglais ou en français, il y a un problème de majuscules. @@ -584,6 +584,12 @@ msgstr "E690: \"in\" manquant apr msgid "E108: No such variable: \"%s\"" msgstr "E108: Variable inexistante : %s" +#. For historic reasons this error is not given for a list or dict. +#. * E.g., the b: dict could be locked/unlocked. +#, c-format +msgid "E940: Cannot lock or unlock variable %s" +msgstr "E940: Impossible de (dé)verrouiler la variable %s" + msgid "E743: variable nested too deep for (un)lock" msgstr "E743: variable trop imbriquée pour la (dé)verrouiller" @@ -773,12 +779,6 @@ msgstr "E785: complete() n'est utilisable que dans le mode Insertion" msgid "&Ok" msgstr "&Ok" -#, c-format -msgid "+-%s%3ld line: " -msgid_plural "+-%s%3ld lines: " -msgstr[0] "+-%s%3ld ligne : " -msgstr[1] "+-%s%3ld lignes : " - #, c-format msgid "E700: Unknown function: %s" msgstr "E700: Fonction inconnue : %s" @@ -827,9 +827,7 @@ msgstr "E727: D msgid "" msgstr "" -# AB - À mon avis, la version anglaise est erronée. -# DB : Vérifier -msgid "E240: No connection to Vim server" +msgid "E240: No connection to the X server" msgstr "E240: Pas de connexion au serveur X" # AB - La version française est meilleure que la version anglaise. @@ -840,6 +838,12 @@ msgstr "E241: L'envoi au serveur %s a msgid "E277: Unable to read a server reply" msgstr "E277: Impossible de lire la réponse du serveur" +msgid "E941: already started a server" +msgstr "E941: serveur déjà démarré" + +msgid "E942: +clientserver feature not available" +msgstr "E942: La fonctionnalité +clientserver n'est pas disponible" + msgid "remove() argument" msgstr "argument de remove()" @@ -1137,8 +1141,9 @@ msgstr " sur %ld lignes" # AB - Il faut respecter l'esprit plus que la lettre. # AB - Ce message devrait contenir une référence à :vglobal. -msgid "E147: Cannot do :global recursive" -msgstr "E147: :global ne peut pas exécuter :global" +#. will increment global_busy to break out of the loop +msgid "E147: Cannot do :global recursive with a range" +msgstr "E147: :global ne peut pas exécuter :global avec une plage" # AB - Ce message devrait contenir une référence à :vglobal. msgid "E148: Regular expression missing from global" @@ -1357,6 +1362,14 @@ msgstr "Recherche de \"%s\"" msgid "not found in '%s': \"%s\"" msgstr "introuvable dans '%s' : \"%s\"" +#, c-format +msgid "W20: Required python version 2.x not supported, ignoring file: %s" +msgstr "W20: Python version 2.x non supporté, fichier %s ignoré" + +#, c-format +msgid "W21: Required python version 3.x not supported, ignoring file: %s" +msgstr "W21: Python 3.x non supporté, fichier %s ignoré" + msgid "Source Vim script" msgstr "Sourcer un script - Vim" @@ -1457,6 +1470,9 @@ msgstr "La plage sp msgid "E494: Use w or w>>" msgstr "E494: Utilisez w ou w>>" +msgid "E943: Command table needs to be updated, run 'make cmdidxs'" +msgstr "E943: La table des commandes doit être mise à jour, lancez 'make cmdidxs'" + msgid "E319: Sorry, the command is not available in this version" msgstr "E319: Désolé, cette commande n'est pas disponible dans cette version" @@ -2233,12 +2249,6 @@ msgstr "E350: Impossible de cr msgid "E351: Cannot delete fold with current 'foldmethod'" msgstr "E351: Impossible de supprimer un repli avec la 'foldmethod'e actuelle" -#, c-format -msgid "+--%3ld line folded " -msgid_plural "+--%3ld lines folded " -msgstr[0] "+--%3ld ligne repliée " -msgstr[1] "+--%3ld lignes repliées " - msgid "E222: Add to read buffer" msgstr "E222: Ajout au tampon de lecture" @@ -3281,8 +3291,7 @@ msgstr "" "--no-a-term\t\tAucun avertissement si l'entrée/sortie n'est pas un terminal" msgid "--ttyfail\t\tExit if input or output is not a terminal" -msgstr "" -"--ttyfail\t\tQuitte si l'entrée ou la sortie ne sont pas un terminal" +msgstr "--ttyfail\t\tQuitte si l'entrée ou la sortie ne sont pas un terminal" msgid "-u \t\tUse instead of any .vimrc" msgstr "-u \tUtiliser au lieu du vimrc habituel" @@ -4338,8 +4347,8 @@ msgstr "E662: Au d msgid "E663: At end of changelist" msgstr "E663: À la fin de la liste des modifications" -msgid "Type :quit to exit Vim" -msgstr "tapez :q pour quitter Vim" +msgid "Type :qa! and press to abandon all changes and exit Vim" +msgstr "Tapez :qa! puis pour abandonner tous les changements et quitter Vim" #, c-format msgid "1 line %sed 1 time" @@ -4968,6 +4977,12 @@ msgstr "E369: msgid "E769: Missing ] after %s[" msgstr "E769: ']' manquant après %s[" +msgid "E944: Reverse range in character class" +msgstr "E944: Classe de caractères inversée" + +msgid "E945: Range too large in character class" +msgstr "E945: Plage de classe de caractères trop large" + #, c-format msgid "E53: Unmatched %s%%(" msgstr "E53: Pas de correspondance pour %s%%(" @@ -4994,6 +5009,9 @@ msgstr "E69: ']' manquant apr msgid "E70: Empty %s%%[]" msgstr "E70: %s%%[] vide" +msgid "E65: Illegal back reference" +msgstr "E65: post-référence invalide" + msgid "E339: Pattern too long" msgstr "E339: Motif trop long" @@ -5030,9 +5048,6 @@ msgstr "E63: utilisation invalide de \\_" msgid "E64: %s%c follows nothing" msgstr "E64: %s%c ne suit aucun atome" -msgid "E65: Illegal back reference" -msgstr "E65: post-référence invalide" - msgid "E68: Invalid character after \\z" msgstr "E68: Caractère invalide après \\z" @@ -5642,10 +5657,31 @@ msgstr "E783: caract msgid "No Syntax items defined for this buffer" msgstr "Aucun élément de syntaxe défini pour ce tampon" +msgid "syntax conceal on" +msgstr "\"syntax conceal\" activée" + +msgid "syntax conceal off" +msgstr "\"syntax conceal\" désactivée" + #, c-format msgid "E390: Illegal argument: %s" msgstr "E390: Argument invalide : %s" +msgid "syntax case ignore" +msgstr "syntaxe ignore la casse" + +msgid "syntax case match" +msgstr "syntaxe respecte la casse" + +msgid "syntax spell toplevel" +msgstr "contrôle orthographique dans le texte sans groupe syntaxique" + +msgid "syntax spell notoplevel" +msgstr "pas de contrôle orthographique dans le texte sans groupe syntaxique" + +msgid "syntax spell default" +msgstr "contrôle orthographique dans le texte sans groupe syntaxique, sauf si @Spell/@NoSpell" + msgid "syntax iskeyword " msgstr "syntaxe iskeyword " @@ -6248,6 +6284,10 @@ msgstr "" msgid "E126: Missing :endfunction" msgstr "E126: Il manque :endfunction" +#, c-format +msgid "W22: Text found after :endfunction: %s" +msgstr "W22: Texte trouvé après :endfunction: %s" + #, c-format msgid "E707: Function name conflicts with variable: %s" msgstr "E707: Le nom de fonction entre en conflit avec la variable : %s" @@ -6997,8 +7037,8 @@ msgstr "E592: 'winwidth' ne peut pas msgid "E80: Error while writing" msgstr "E80: Erreur lors de l'écriture" -msgid "Zero count" -msgstr "Le quantificateur est nul" +msgid "E939: Positive count required" +msgstr "E939: Quantificateur positif requis" msgid "E81: Using not in a script context" msgstr "E81: utilisé en dehors d'un script" diff --git a/src/nvim/po/ga.po b/src/nvim/po/ga.po index abb3565077..281af86ba9 100644 --- a/src/nvim/po/ga.po +++ b/src/nvim/po/ga.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: vim 7.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-10-25 09:31-0500\n" +"POT-Creation-Date: 2017-07-11 15:45-0500\n" "PO-Revision-Date: 2010-04-14 10:01-0500\n" "Last-Translator: Kevin Patrick Scannell \n" "Language-Team: Irish \n" @@ -239,7 +239,8 @@ msgid "E917: Cannot use a callback with %s()" msgstr "E917: Ní féidir aisghlaoch a úsáid le %s()" msgid "E912: cannot use ch_evalexpr()/ch_sendexpr() with a raw or nl channel" -msgstr "E912: ní féidir ch_evalexpr()/ch_sendexpr() a úsáid le cainéal raw nó nl" +msgstr "" +"E912: ní féidir ch_evalexpr()/ch_sendexpr() a úsáid le cainéal raw nó nl" msgid "E906: not an open channel" msgstr "E906: ní cainéal oscailte é" @@ -426,6 +427,9 @@ msgstr "%s msgid "Scanning tags." msgstr "Clibeanna á scanadh." +msgid "match in file" +msgstr "meaitseáil sa chomhad" + msgid " Adding" msgstr " Méadú" @@ -513,6 +517,12 @@ msgstr "E690: \"in\" ar iarraidh i ndiaidh :for" msgid "E108: No such variable: \"%s\"" msgstr "E108: Níl a leithéid d'athróg: \"%s\"" +#. For historic reasons this error is not given for a list or dict. +#. * E.g., the b: dict could be locked/unlocked. +#, c-format +msgid "E940: Cannot lock or unlock variable %s" +msgstr "E940: Ní féidir athróg %s a ghlasáil nó a dhíghlasáil" + msgid "E743: variable nested too deep for (un)lock" msgstr "E743: athróg neadaithe ródhomhain chun í a (dí)ghlasáil" @@ -690,15 +700,6 @@ msgstr "E785: is f msgid "&Ok" msgstr "&Ok" -#, c-format -msgid "+-%s%3ld line: " -msgid_plural "+-%s%3ld lines: " -msgstr[0] "+-%s%3ld líne: " -msgstr[1] "+-%s%3ld líne: " -msgstr[2] "+-%s%3ld líne: " -msgstr[3] "+-%s%3ld líne: " -msgstr[4] "+-%s%3ld líne: " - #, c-format msgid "E700: Unknown function: %s" msgstr "E700: Feidhm anaithnid: %s" @@ -707,7 +708,9 @@ msgid "E922: expected a dict" msgstr "E922: bhíothas ag súil le foclóir" msgid "E923: Second argument of function() must be a list or a dict" -msgstr "E923: Caithfidh an dara hargóint de function() a bheith ina liosta nó ina foclóir" +msgstr "" +"E923: Caithfidh an dara hargóint de function() a bheith ina liosta nó ina " +"foclóir" msgid "" "&OK\n" @@ -744,8 +747,8 @@ msgstr "E727: Tosach thar dheireadh" msgid "" msgstr "" -msgid "E240: No connection to Vim server" -msgstr "E240: Níl aon nasc le freastalaí Vim" +msgid "E240: No connection to the X server" +msgstr "E240: Níl aon cheangal leis an bhfreastalaí X" #, c-format msgid "E241: Unable to send to %s" @@ -754,6 +757,12 @@ msgstr "E241: N msgid "E277: Unable to read a server reply" msgstr "E277: Ní féidir freagra ón fhreastalaí a léamh" +msgid "E941: already started a server" +msgstr "E941: tosaíodh freastalaí cheana" + +msgid "E942: +clientserver feature not available" +msgstr "E942: níl an ghné +clientserver ar fáil" + msgid "remove() argument" msgstr "argóint remove()" @@ -993,8 +1002,9 @@ msgstr " ar l msgid " on %ld lines" msgstr " ar %ld líne" -msgid "E147: Cannot do :global recursive" -msgstr "E147: Ní cheadaítear :global go hathchúrsach" +#. will increment global_busy to break out of the loop +msgid "E147: Cannot do :global recursive with a range" +msgstr "E147: Ní cheadaítear :global athchúrsach le raon" # should have ":" msgid "E148: Regular expression missing from global" @@ -1179,6 +1189,14 @@ msgstr "Ag d msgid "not found in '%s': \"%s\"" msgstr "gan aimsiú in '%s': \"%s\"" +#, c-format +msgid "W20: Required python version 2.x not supported, ignoring file: %s" +msgstr "W20: Níl leagan 2.x de Python ar fáil; ag déanamh neamhaird de %s" + +#, c-format +msgid "W21: Required python version 3.x not supported, ignoring file: %s" +msgstr "W21: Níl leagan 3.x de Python ar fáil; ag déanamh neamhaird de %s" + msgid "Source Vim script" msgstr "Foinsigh script Vim" @@ -1278,6 +1296,9 @@ msgstr "Raon droim ar ais, babht msgid "E494: Use w or w>>" msgstr "E494: Bain úsáid as w nó w>>" +msgid "E943: Command table needs to be updated, run 'make cmdidxs'" +msgstr "E943: Caithfear tábla na n-orduithe a nuashonrú; rith 'make cmdidxs'" + msgid "E319: Sorry, the command is not available in this version" msgstr "E319: Tá brón orm, níl an t-ordú ar fáil sa leagan seo" @@ -1391,7 +1412,7 @@ msgid "No swap file" msgstr "Níl aon chomhad babhtála ann" msgid "Append File" -msgstr "Cuir Comhad i nDeireadh" +msgstr "Ceangail Comhad ag an Deireadh" msgid "E747: Cannot change directory, buffer is modified (add ! to override)" msgstr "" @@ -1412,10 +1433,10 @@ msgid "Window position: X %d, Y %d" msgstr "Ionad na fuinneoige: X %d, Y %d" msgid "E188: Obtaining window position not implemented for this platform" -msgstr "E188: Ní féidir ionad na fuinneoige a fháil amach ar an chóras seo" +msgstr "E188: Ní féidir ionad na fuinneoige a fháil amach ar an gcóras seo" msgid "E466: :winpos requires two number arguments" -msgstr "E466: ní foláir dhá argóint uimhriúla le :winpos" +msgstr "E466: dhá argóint uimhriúla de dhíth le :winpos" msgid "E930: Cannot use :redir inside execute()" msgstr "E930: Ní féidir :redir a úsáid laistigh de execute()" @@ -2045,15 +2066,6 @@ msgstr "E350: N msgid "E351: Cannot delete fold with current 'foldmethod'" msgstr "E351: Ní féidir filleadh a scriosadh leis an 'foldmethod' reatha" -#, c-format -msgid "+--%3ld line folded " -msgid_plural "+--%3ld lines folded " -msgstr[0] "+--%3ld líne fillte " -msgstr[1] "+--%3ld líne fillte " -msgstr[2] "+--%3ld líne fillte " -msgstr[3] "+--%3ld líne fillte " -msgstr[4] "+--%3ld líne fillte " - msgid "E222: Add to read buffer" msgstr "E222: Cuir leis an maolán léite" @@ -2652,8 +2664,8 @@ msgid "" "E895: Sorry, this command is disabled, the MzScheme's racket/base module " "could not be loaded." msgstr "" -"E895: Ár leithscéal, tá an t-ordú seo díchumasaithe; níorbh fhéidir " -"modúl racket/base MzScheme a luchtú." +"E895: Ár leithscéal, tá an t-ordú seo díchumasaithe; níorbh fhéidir modúl " +"racket/base MzScheme a luchtú." msgid "invalid expression" msgstr "slonn neamhbhailí" @@ -2845,6 +2857,10 @@ msgstr "E573: Aitheantas neamhbhail msgid "E251: VIM instance registry property is badly formed. Deleted!" msgstr "E251: Airí míchumtha sa chlárlann áisc VIM. Scriosta!" +#, c-format +msgid "E938: Duplicate key in JSON: \"%s\"" +msgstr "E938: Eochair dhúblach in JSON: \"%s\"" + #, c-format msgid "E696: Missing comma in List: %s" msgstr "E696: Camóg ar iarraidh i Liosta: %s" @@ -2898,7 +2914,8 @@ msgid "Vim: Error: Failure to start gvim from NetBeans\n" msgstr "Vim: Earráid: Theip ar thosú gvim ó NetBeans\n" msgid "Vim: Error: This version of Vim does not run in a Cygwin terminal\n" -msgstr "Vim: Earráid: Ní féidir an leagan seo de Vim a rith i dteirminéal Cygwin\n" +msgstr "" +"Vim: Earráid: Ní féidir an leagan seo de Vim a rith i dteirminéal Cygwin\n" msgid "Vim: Warning: Output is not to a terminal\n" msgstr "Vim: Rabhadh: Níl an t-aschur ag dul chuig teirminéal\n" @@ -3067,7 +3084,12 @@ msgid "-T \tSet terminal type to " msgstr "-T \tSocraigh cineál teirminéal" msgid "--not-a-term\t\tSkip warning for input/output not being a terminal" -msgstr "--not-a-term\t\tNá bac le rabhadh faoi ionchur/aschur gan a bheith ón teirminéal" +msgstr "" +"--not-a-term\t\tNá bac le rabhadh faoi ionchur/aschur gan a bheith ón " +"teirminéal" + +msgid "--ttyfail\t\tExit if input or output is not a terminal" +msgstr "--ttyfail\t\tScoir mura bhfuil ionchur agus aschur ina dteirminéil" msgid "-u \t\tUse instead of any .vimrc" msgstr "-u \t\tÚsáid in ionad aon .vimrc" @@ -4122,8 +4144,8 @@ msgstr "E662: Ag tosach liosta na n-athruithe" msgid "E663: At end of changelist" msgstr "E663: Ag deireadh liosta na n-athruithe" -msgid "Type :quit to exit Vim" -msgstr "Clóscríobh :quit chun Vim a scor" +msgid "Type :qa! and press to abandon all changes and exit Vim" +msgstr "Clóscríobh :qa! agus brúigh le fágáil ó Vim gan athruithe a shábháil" # ouch - English -ed ? #, c-format @@ -4234,7 +4256,8 @@ msgid "" "Selected %s%ld of %ld Lines; %lld of %lld Words; %lld of %lld Chars; %lld of " "%lld Bytes" msgstr "" -"Roghnaíodh %s%ld as %ld Líne; %lld as %lld Focal; %lld as %lld Carachtar; %lld as %lld Beart" +"Roghnaíodh %s%ld as %ld Líne; %lld as %lld Focal; %lld as %lld Carachtar; " +"%lld as %lld Beart" #, c-format msgid "Col %s of %s; Line %ld of %ld; Word %lld of %lld; Byte %lld of %lld" @@ -4245,7 +4268,8 @@ msgid "" "Col %s of %s; Line %ld of %ld; Word %lld of %lld; Char %lld of %lld; Byte " "%lld of %lld" msgstr "" -"Col %s as %s; Líne %ld as %ld; Focal %lld as %lld; Carachtar %lld as %lld; Beart %lld as %lld" +"Col %s as %s; Líne %ld as %ld; Focal %lld as %lld; Carachtar %lld as %lld; " +"Beart %lld as %lld" #, c-format msgid "(+%ld for BOM)" @@ -4507,8 +4531,7 @@ msgstr "" #, c-format msgid "E244: Illegal quality name \"%s\" in font name \"%s\"" -msgstr "" -"E244: Ainm neamhcheadaithe ar cháilíocht \"%s\" in ainm cló \"%s\"" +msgstr "E244: Ainm neamhcheadaithe ar cháilíocht \"%s\" in ainm cló \"%s\"" #, c-format msgid "E245: Illegal char '%c' in font name \"%s\"" @@ -4551,7 +4574,8 @@ msgstr "N #, c-format msgid "Could not get security context %s for %s. Removing it!" -msgstr "Níorbh fhéidir comhthéacs slándála %s a fháil le haghaidh %s. Á bhaint!" +msgstr "" +"Níorbh fhéidir comhthéacs slándála %s a fháil le haghaidh %s. Á bhaint!" msgid "" "\n" @@ -4752,6 +4776,12 @@ msgstr "E369: m msgid "E769: Missing ] after %s[" msgstr "E769: ] ar iarraidh i ndiaidh %s[" +msgid "E944: Reverse range in character class" +msgstr "E944: Raon aisiompaithe in aicme carachtar" + +msgid "E945: Range too large in character class" +msgstr "E945: Raon rómhór in aicme carachtar" + #, c-format msgid "E53: Unmatched %s%%(" msgstr "E53: %s%%( corr" @@ -4778,6 +4808,9 @@ msgstr "E69: ] ar iarraidh i ndiaidh %s%%[" msgid "E70: Empty %s%%[]" msgstr "E70: %s%%[] folamh" +msgid "E65: Illegal back reference" +msgstr "E65: Cúltagairt neamhbhailí" + msgid "E339: Pattern too long" msgstr "E339: Slonn rófhada" @@ -4814,9 +4847,6 @@ msgstr "E63: msgid "E64: %s%c follows nothing" msgstr "E64: níl aon rud roimh %s%c" -msgid "E65: Illegal back reference" -msgstr "E65: Cúltagairt neamhbhailí" - msgid "E68: Invalid character after \\z" msgstr "E68: Carachtar neamhbhailí i ndiaidh \\z" @@ -5424,12 +5454,33 @@ msgstr "E783: carachtar d msgid "No Syntax items defined for this buffer" msgstr "Níl aon mhír chomhréire sainmhínithe le haghaidh an mhaoláin seo" +msgid "syntax conceal on" +msgstr "syntax conceal on" + +msgid "syntax conceal off" +msgstr "syntax conceal off" + #, c-format msgid "E390: Illegal argument: %s" msgstr "E390: Argóint neamhcheadaithe: %s" +msgid "syntax case ignore" +msgstr "syntax case ignore" + +msgid "syntax case match" +msgstr "syntax case match" + +msgid "syntax spell toplevel" +msgstr "syntax spell toplevel" + +msgid "syntax spell notoplevel" +msgstr "syntax spell notoplevel" + +msgid "syntax spell default" +msgstr "syntax spell default" + msgid "syntax iskeyword " -msgstr "comhréir iskeyword " +msgstr "syntax iskeyword " #, c-format msgid "E391: No such syntax cluster: %s" @@ -6005,6 +6056,10 @@ msgstr "E932: N msgid "E126: Missing :endfunction" msgstr "E126: :endfunction ar iarraidh" +#, c-format +msgid "W22: Text found after :endfunction: %s" +msgstr "W22: Aimsíodh téacs tar éis :endfunction: %s" + #, c-format msgid "E707: Function name conflicts with variable: %s" msgstr "E707: Tagann ainm na feidhme salach ar athróg: %s" @@ -6475,6 +6530,10 @@ msgstr "E236: N msgid "E473: Internal error" msgstr "E473: Earráid inmheánach" +#, c-format +msgid "E685: Internal error: %s" +msgstr "E685: Earráid inmheánach: %s" + msgid "Interrupted" msgstr "Idirbhriste" @@ -6635,7 +6694,7 @@ msgid "E486: Pattern not found: %s" msgstr "E486: Patrún gan aimsiú: %s" msgid "E487: Argument must be positive" -msgstr "E487: Ní foláir argóint dheimhneach" +msgstr "E487: Argóint dheimhneach de dhíth" msgid "E459: Cannot go back to previous directory" msgstr "E459: Ní féidir a fhilleadh ar an chomhadlann roimhe seo" @@ -6745,8 +6804,8 @@ msgstr "E592: n msgid "E80: Error while writing" msgstr "E80: Earráid agus á scríobh" -msgid "Zero count" -msgstr "Nialas" +msgid "E939: Positive count required" +msgstr "E939: Uimhir dheimhneach de dhíth" msgid "E81: Using not in a script context" msgstr "E81: á úsáid nach i gcomhthéacs scripte" @@ -6760,10 +6819,6 @@ msgstr "E463: R msgid "E744: NetBeans does not allow changes in read-only files" msgstr "E744: Ní cheadaíonn NetBeans aon athrú i gcomhaid inléite amháin" -#, c-format -msgid "E685: Internal error: %s" -msgstr "E685: Earráid inmheánach: %s" - msgid "E363: pattern uses more memory than 'maxmempattern'" msgstr "E363: úsáideann an patrún níos mó cuimhne ná 'maxmempattern'" @@ -7062,6 +7117,28 @@ msgstr "" "Níorbh fhéidir an chonair a shocrú: ní liosta é sys.path\n" "Ba chóir duit vim.VIM_SPECIAL_PATH a cheangal le deireadh sys.path" +#~ msgid "+-%s%3ld line: " +#~ msgid_plural "+-%s%3ld lines: " +#~ msgstr[0] "+-%s%3ld líne: " +#~ msgstr[1] "+-%s%3ld líne: " +#~ msgstr[2] "+-%s%3ld líne: " +#~ msgstr[3] "+-%s%3ld líne: " +#~ msgstr[4] "+-%s%3ld líne: " + +#~ msgid "+--%3ld line folded " +#~ msgid_plural "+--%3ld lines folded " +#~ msgstr[0] "+--%3ld líne fillte " +#~ msgstr[1] "+--%3ld líne fillte " +#~ msgstr[2] "+--%3ld líne fillte " +#~ msgstr[3] "+--%3ld líne fillte " +#~ msgstr[4] "+--%3ld líne fillte " + +#~ msgid "Type :quit to exit Vim" +#~ msgstr "Clóscríobh :quit chun Vim a scor" + +#~ msgid "Zero count" +#~ msgstr "Nialas" + #~ msgid "E693: Can only compare Funcref with Funcref" #~ msgstr "E693: Is féidir Funcref a chur i gcomparáid le Funcref eile amháin" diff --git a/src/nvim/po/ja.euc-jp.po b/src/nvim/po/ja.euc-jp.po index 4b32096f1a..10d7342430 100644 --- a/src/nvim/po/ja.euc-jp.po +++ b/src/nvim/po/ja.euc-jp.po @@ -13,10 +13,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Vim 7.4\n" +"Project-Id-Version: Vim 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-10 21:10+0900\n" -"PO-Revision-Date: 2016-09-10 21:20+0900\n" +"POT-Creation-Date: 2017-07-03 23:05+0900\n" +"PO-Revision-Date: 2017-07-12 20:45+0900\n" "Last-Translator: MURAOKA Taro \n" "Language-Team: vim-jp (https://github.com/vim-jp/lang-ja)\n" "Language: Japanese\n" @@ -245,7 +245,8 @@ msgid "E917: Cannot use a callback with %s()" msgstr "E917: %s() ¤Ë¥³¡¼¥ë¥Ð¥Ã¥¯¤Ï»È¤¨¤Þ¤»¤ó" msgid "E912: cannot use ch_evalexpr()/ch_sendexpr() with a raw or nl channel" -msgstr "E912: À¸¤ä nl ¥Á¥ã¥ó¥Í¥ë¤Ë ch_evalexpr()/ch_sendexpr ¤Ï»È¤¨¤Þ¤»¤ó" +msgstr "" +"E912: raw ¤ä nl ¥â¡¼¥É¤Î¥Á¥ã¥ó¥Í¥ë¤Ë ch_evalexpr()/ch_sendexpr() ¤Ï»È¤¨¤Þ¤»¤ó" msgid "E906: not an open channel" msgstr "E906: ³«¤¤¤Æ¤¤¤Ê¤¤¥Á¥ã¥ó¥Í¥ë¤Ç¤¹" @@ -431,6 +432,9 @@ msgstr " msgid "Scanning tags." msgstr "¥¿¥°¤ò¥¹¥­¥ã¥óÃæ." +msgid "match in file" +msgstr "¥Õ¥¡¥¤¥ëÆâ¤Î¥Þ¥Ã¥Á" + msgid " Adding" msgstr " ÄɲÃÃæ" @@ -519,6 +523,12 @@ msgstr "E690: :for msgid "E108: No such variable: \"%s\"" msgstr "E108: ¤½¤ÎÊÑ¿ô¤Ï¤¢¤ê¤Þ¤»¤ó: \"%s\"" +#. For historic reasons this error is not given for a list or dict. +#. * E.g., the b: dict could be locked/unlocked. +#, c-format +msgid "E940: Cannot lock or unlock variable %s" +msgstr "E940: ÊÑ¿ô %s ¤Ï¥í¥Ã¥¯¤Þ¤¿¤Ï¥¢¥ó¥í¥Ã¥¯¤Ç¤­¤Þ¤»¤ó" + msgid "E743: variable nested too deep for (un)lock" msgstr "E743: (¥¢¥ó)¥í¥Ã¥¯¤¹¤ë¤Ë¤ÏÊÑ¿ô¤ÎÆþ¤ì»Ò¤¬¿¼²á¤®¤Þ¤¹" @@ -696,11 +706,6 @@ msgstr "E785: complete() msgid "&Ok" msgstr "&Ok" -#, c-format -msgid "+-%s%3ld line: " -msgid_plural "+-%s%3ld lines: " -msgstr[0] "+-%s%3ld ¹Ô: " - #, c-format msgid "E700: Unknown function: %s" msgstr "E700: ̤ÃΤδؿô¤Ç¤¹: %s" @@ -746,8 +751,8 @@ msgstr "E727: msgid "" msgstr "<¶õ>" -msgid "E240: No connection to Vim server" -msgstr "E240: Vim ¥µ¡¼¥Ð¡¼¤Ø¤ÎÀܳ¤¬¤¢¤ê¤Þ¤»¤ó" +msgid "E240: No connection to the X server" +msgstr "E240: X ¥µ¡¼¥Ð¡¼¤Ø¤ÎÀܳ¤¬¤¢¤ê¤Þ¤»¤ó" #, c-format msgid "E241: Unable to send to %s" @@ -756,6 +761,12 @@ msgstr "E241: %s msgid "E277: Unable to read a server reply" msgstr "E277: ¥µ¡¼¥Ð¡¼¤Î±þÅú¤¬¤¢¤ê¤Þ¤»¤ó" +msgid "E941: already started a server" +msgstr "E941: ¥µ¡¼¥Ð¡¼¤Ï¤¹¤Ç¤Ë³«»Ï¤·¤Æ¤¤¤Þ¤¹" + +msgid "E942: +clientserver feature not available" +msgstr "E942: +clientserver µ¡Ç½¤¬Ìµ¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹" + msgid "remove() argument" msgstr "remove() ¤Î°ú¿ô" @@ -993,8 +1004,9 @@ msgstr " ( msgid " on %ld lines" msgstr " (·× %ld ¹ÔÆâ)" -msgid "E147: Cannot do :global recursive" -msgstr "E147: :global ¤òºÆµ¢Åª¤Ë¤Ï»È¤¨¤Þ¤»¤ó" +#. will increment global_busy to break out of the loop +msgid "E147: Cannot do :global recursive with a range" +msgstr "E147: :global ¤òÈϰÏÉÕ¤­¤ÇºÆµ¢Åª¤Ë¤Ï»È¤¨¤Þ¤»¤ó" msgid "E148: Regular expression missing from global" msgstr "E148: global¥³¥Þ¥ó¥É¤ËÀµµ¬É½¸½¤¬»ØÄꤵ¤ì¤Æ¤¤¤Þ¤»¤ó" @@ -1180,6 +1192,14 @@ msgstr "\"%s\" msgid "not found in '%s': \"%s\"" msgstr "'%s' ¤ÎÃæ¤Ë¤Ï¤¢¤ê¤Þ¤»¤ó: \"%s\"" +#, c-format +msgid "W20: Required python version 2.x not supported, ignoring file: %s" +msgstr "W20: Í׵ᤵ¤ì¤¿python 2.x¤ÏÂбþ¤·¤Æ¤¤¤Þ¤»¤ó¡¢¥Õ¥¡¥¤¥ë¤ò̵»ë¤·¤Þ¤¹: %s" + +#, c-format +msgid "W21: Required python version 3.x not supported, ignoring file: %s" +msgstr "W21: Í׵ᤵ¤ì¤¿python 3.x¤ÏÂбþ¤·¤Æ¤¤¤Þ¤»¤ó¡¢¥Õ¥¡¥¤¥ë¤ò̵»ë¤·¤Þ¤¹: %s" + msgid "Source Vim script" msgstr "Vim¥¹¥¯¥ê¥×¥È¤Î¼è¹þ¤ß" @@ -1278,6 +1298,11 @@ msgstr " msgid "E494: Use w or w>>" msgstr "E494: w ¤â¤·¤¯¤Ï w>> ¤ò»ÈÍѤ·¤Æ¤¯¤À¤µ¤¤" +msgid "E943: Command table needs to be updated, run 'make cmdidxs'" +msgstr "" +"E943: ¥³¥Þ¥ó¥É¥Æ¡¼¥Ö¥ë¤ò¹¹¿·¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡¢'make cmdidxs' ¤ò¼Â¹Ô¤·¤Æ¤¯¤À" +"¤µ¤¤" + msgid "E319: Sorry, the command is not available in this version" msgstr "E319: ¤³¤Î¥Ð¡¼¥¸¥ç¥ó¤Ç¤Ï¤³¤Î¥³¥Þ¥ó¥É¤ÏÍøÍѤǤ­¤Þ¤»¤ó, ¤´¤á¤ó¤Ê¤µ¤¤" @@ -2030,11 +2055,6 @@ msgstr "E350: msgid "E351: Cannot delete fold with current 'foldmethod'" msgstr "E351: ¸½ºß¤Î 'foldmethod' ¤Ç¤ÏÀÞ¾ö¤ß¤òºï½ü¤Ç¤­¤Þ¤»¤ó" -#, c-format -msgid "+--%3ld line folded " -msgid_plural "+--%3ld lines folded " -msgstr[0] "+--%3ld ¹Ô¤¬ÀÞ¾ö¤Þ¤ì¤Þ¤·¤¿ " - msgid "E222: Add to read buffer" msgstr "E222: ÆÉ¹þ¥Ð¥Ã¥Õ¥¡¤ØÄɲÃ" @@ -2818,6 +2838,10 @@ msgstr "E573: ̵ msgid "E251: VIM instance registry property is badly formed. Deleted!" msgstr "E251: VIM ¼ÂÂΤÎÅÐÏ¿¥×¥í¥Ñ¥Æ¥£¤¬ÉÔÀµ¤Ç¤¹. ¾Ãµî¤·¤Þ¤·¤¿!" +#, c-format +msgid "E938: Duplicate key in JSON: \"%s\"" +msgstr "E938: JSON¤Ë½ÅÊ£¥­¡¼¤¬¤¢¤ê¤Þ¤¹: \"%s\"" + #, c-format msgid "E696: Missing comma in List: %s" msgstr "E696: ¥ê¥¹¥È·¿¤Ë¥«¥ó¥Þ¤¬¤¢¤ê¤Þ¤»¤ó: %s" @@ -2858,7 +2882,7 @@ msgid "This Vim was not compiled with the diff feature." msgstr "¤³¤ÎVim¤Ë¤Ïdiffµ¡Ç½¤¬¤¢¤ê¤Þ¤»¤ó(¥³¥ó¥Ñ¥¤¥ë»þÀßÄê)." msgid "Attempt to open script file again: \"" -msgstr "¥¹¥¯¥ê¥×¥È¥Õ¥¡¥¤¥ë¤òºÆ¤Ó³«¤¤¤Æ¤ß¤Þ¤¹: \"" +msgstr "¥¹¥¯¥ê¥×¥È¥Õ¥¡¥¤¥ë¤òºÆ¤Ó³«¤³¤¦¤È¤·¤Þ¤·¤¿: \"" msgid "Cannot open for reading: \"" msgstr "ÆÉ¹þÍѤȤ·¤Æ³«¤±¤Þ¤»¤ó" @@ -3039,6 +3063,9 @@ msgstr "-T \tü msgid "--not-a-term\t\tSkip warning for input/output not being a terminal" msgstr "--not-a-term\t\tÆþ½ÐÎϤ¬Ã¼Ëö¤Ç¤Ê¤¤¤È¤Î·Ù¹ð¤ò¥¹¥­¥Ã¥×¤¹¤ë" +msgid "--ttyfail\t\tExit if input or output is not a terminal" +msgstr "--ttyfail\t\tÆþ½ÐÎϤ¬Ã¼Ëö¤Ç¤Ê¤±¤ì¤Ð½ªÎ»¤¹¤ë" + msgid "-u \t\tUse instead of any .vimrc" msgstr "-u \t\t.vimrc¤ÎÂå¤ï¤ê¤Ë ¤ò»È¤¦" @@ -3906,7 +3933,7 @@ msgid "E766: Insufficient arguments for printf()" msgstr "E766: printf() ¤Î°ú¿ô¤¬ÉÔ½½Ê¬¤Ç¤¹" msgid "E807: Expected Float argument for printf()" -msgstr "E807: printf() ¤Î°ú¿ô¤Ë¤ÏÉâÆ°¾¯¿ôÅÀ¿ô¤¬´üÂÔ¤µ¤ì¤Æ¤¤¤Þ¤¹" +msgstr "E807: printf() ¤Î°ú¿ô¤Ë¤ÏÉâÆ°¾®¿ôÅÀ¿ô¤¬´üÂÔ¤µ¤ì¤Æ¤¤¤Þ¤¹" msgid "E767: Too many arguments to printf()" msgstr "E767: printf() ¤Î°ú¿ô¤¬Â¿²á¤®¤Þ¤¹" @@ -4063,8 +4090,10 @@ msgstr "E662: msgid "E663: At end of changelist" msgstr "E663: Êѹ¹¥ê¥¹¥È¤ÎËöÈø" -msgid "Type :quit to exit Vim" -msgstr "Vim¤ò½ªÎ»¤¹¤ë¤Ë¤Ï :quit ¤ÈÆþÎϤ·¤Æ¤¯¤À¤µ¤¤" +msgid "Type :qa! and press to abandon all changes and exit Vim" +msgstr "" +"¤¹¤Ù¤Æ¤ÎÊѹ¹¤òÇË´þ¤·¡¢Vim¤ò½ªÎ»¤¹¤ë¤Ë¤Ï :qa! ¤ÈÆþÎϤ· ¤ò²¡¤·¤Æ¤¯¤À" +"¤µ¤¤" #, c-format msgid "1 line %sed 1 time" @@ -4413,9 +4442,6 @@ msgstr " msgid "Message" msgstr "¥á¥Ã¥»¡¼¥¸" -msgid "'columns' is not 80, cannot execute external commands" -msgstr "'columns' ¤¬ 80 ¤Ç¤Ï¤Ê¤¤¤¿¤á¡¢³°Éô¥³¥Þ¥ó¥É¤ò¼Â¹Ô¤Ç¤­¤Þ¤»¤ó" - msgid "E237: Printer selection failed" msgstr "E237: ¥×¥ê¥ó¥¿¤ÎÁªÂò¤Ë¼ºÇÔ¤·¤Þ¤·¤¿" @@ -4685,6 +4711,12 @@ msgstr "E369: ̵ msgid "E769: Missing ] after %s[" msgstr "E769: %s[ ¤Î¸å¤Ë ] ¤¬¤¢¤ê¤Þ¤»¤ó" +msgid "E944: Reverse range in character class" +msgstr "E944: ʸ»ú¥¯¥é¥¹¤ÎÈϰϤ¬µÕ¤Ç¤¹" + +msgid "E945: Range too large in character class" +msgstr "E945: ʸ»ú¥¯¥é¥¹¤ÎÈϰϤ¬Â礭¤¹¤®¤Þ¤¹" + #, c-format msgid "E53: Unmatched %s%%(" msgstr "E53: %s%%( ¤¬Äà¤ê¹ç¤Ã¤Æ¤¤¤Þ¤»¤ó" @@ -4714,6 +4746,10 @@ msgstr "E69: %s%%[ msgid "E70: Empty %s%%[]" msgstr "E70: %s%%[] ¤¬¶õ¤Ç¤¹" +# +msgid "E65: Illegal back reference" +msgstr "E65: ÉÔÀµ¤Ê¸åÊý»²¾È¤Ç¤¹" + msgid "E339: Pattern too long" msgstr "E339: ¥Ñ¥¿¡¼¥ó¤¬Ä¹²á¤®¤Þ¤¹" @@ -4751,10 +4787,6 @@ msgstr "E63: \\_ msgid "E64: %s%c follows nothing" msgstr "E64:%s%c ¤Î¸å¤Ë¤Ê¤Ë¤â¤¢¤ê¤Þ¤»¤ó" -# -msgid "E65: Illegal back reference" -msgstr "E65: ÉÔÀµ¤Ê¸åÊý»²¾È¤Ç¤¹" - # msgid "E68: Invalid character after \\z" msgstr "E68: \\z ¤Î¸å¤ËÉÔÀµ¤Êʸ»ú¤¬¤¢¤ê¤Þ¤·¤¿" @@ -5363,12 +5395,33 @@ msgstr "E783: MAP msgid "No Syntax items defined for this buffer" msgstr "¤³¤Î¥Ð¥Ã¥Õ¥¡¤ËÄêµÁ¤µ¤ì¤¿¹½Ê¸Í×ÁǤϤ¢¤ê¤Þ¤»¤ó" +msgid "syntax conceal on" +msgstr "¹½Ê¸¤Î conceal ¤Ï¸½ºß on ¤Ç¤¹" + +msgid "syntax conceal off" +msgstr "¹½Ê¸¤Î conceal ¤Ï¸½ºß off ¤Ç¤¹" + #, c-format msgid "E390: Illegal argument: %s" msgstr "E390: ÉÔÀµ¤Ê°ú¿ô¤Ç¤¹: %s" +msgid "syntax case ignore" +msgstr "¹½Ê¸¤ÎÂçʸ»ú¾®Ê¸»ú¤Ï¸½ºß ignore ¤Ç¤¹" + +msgid "syntax case match" +msgstr "¹½Ê¸¤ÎÂçʸ»ú¾®Ê¸»ú¤Ï¸½ºß match ¤Ç¤¹" + +msgid "syntax spell toplevel" +msgstr "¹½Ê¸¤Î spell ¤Ï¸½ºß toplevel ¤Ç¤¹" + +msgid "syntax spell notoplevel" +msgstr "¹½Ê¸¤Î spell ¤Ï¸½ºß notoplevel ¤Ç¤¹" + +msgid "syntax spell default" +msgstr "¹½Ê¸¤Î spell ¤Ï¸½ºß default ¤Ç¤¹" + msgid "syntax iskeyword " -msgstr "¥·¥ó¥¿¥Ã¥¯¥¹ÍÑ iskeyword " +msgstr "¹½Ê¸ÍÑ iskeyword " #, c-format msgid "E391: No such syntax cluster: %s" @@ -5579,7 +5632,7 @@ msgid "E556: at top of tag stack" msgstr "E556: ¥¿¥°¥¹¥¿¥Ã¥¯¤ÎÀèÆ¬¤Ç¤¹" msgid "E425: Cannot go before first matching tag" -msgstr "E425: ºÇ½é¤Î³ºÅö¥¿¥°¤òͤ¨¤ÆÌá¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó" +msgstr "E425: ºÇ½é¤Î³ºÅö¥¿¥°¤ò±Û¤¨¤ÆÌá¤ë¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó" #, c-format msgid "E426: tag not found: %s" @@ -5595,7 +5648,7 @@ msgid "E427: There is only one matching tag" msgstr "E427: ³ºÅö¥¿¥°¤¬1¤Ä¤À¤±¤·¤«¤¢¤ê¤Þ¤»¤ó" msgid "E428: Cannot go beyond last matching tag" -msgstr "E428: ºÇ¸å¤Ë³ºÅö¤¹¤ë¥¿¥°¤òͤ¨¤Æ¿Ê¤à¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó" +msgstr "E428: ºÇ¸å¤Î³ºÅö¥¿¥°¤ò±Û¤¨¤Æ¿Ê¤à¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó" #, c-format msgid "File \"%s\" does not exist" @@ -5942,6 +5995,10 @@ msgstr "E932: msgid "E126: Missing :endfunction" msgstr "E126: :endfunction ¤¬¤¢¤ê¤Þ¤»¤ó" +#, c-format +msgid "W22: Text found after :endfunction: %s" +msgstr "W22: :endfunction ¤Î¸å¤Ëʸ»ú¤¬¤¢¤ê¤Þ¤¹: %s" + #, c-format msgid "E707: Function name conflicts with variable: %s" msgstr "E707: ´Ø¿ô̾¤¬ÊÑ¿ô̾¤È¾×ÆÍ¤·¤Þ¤¹: %s" @@ -5965,14 +6022,6 @@ msgstr "E133: msgid "E107: Missing parentheses: %s" msgstr "E107: ¥«¥Ã¥³ '(' ¤¬¤¢¤ê¤Þ¤»¤ó: %s" -#. Only MS VC 4.1 and earlier can do Win32s -msgid "" -"\n" -"MS-Windows 16/32-bit GUI version" -msgstr "" -"\n" -"MS-Windows 16/32 ¥Ó¥Ã¥È GUI ÈÇ" - msgid "" "\n" "MS-Windows 64-bit GUI version" @@ -6256,12 +6305,6 @@ msgstr " msgid "menu Help->Sponsor/Register for information " msgstr "¾ÜºÙ¤Ï¥á¥Ë¥å¡¼¤Î ¥Ø¥ë¥×->¥¹¥Ý¥ó¥µ¡¼/ÅÐÏ¿ ¤ò»²¾È¤·¤Æ²¼¤µ¤¤" -msgid "WARNING: Windows 95/98/ME detected" -msgstr "·Ù¹ð: Windows 95/98/ME ¤ò¸¡½Ð¤·¤Þ¤·¤¿" - -msgid "type :help windows95 for info on this" -msgstr "¾ÜºÙ¤Ê¾ðÊó¤Ï :help windows95" - msgid "Already only one window" msgstr "´û¤Ë¥¦¥£¥ó¥É¥¦¤Ï1¤Ä¤·¤«¤¢¤ê¤Þ¤»¤ó" @@ -6415,6 +6458,10 @@ msgstr "E236: msgid "E473: Internal error" msgstr "E473: ÆâÉô¥¨¥é¡¼¤Ç¤¹" +#, c-format +msgid "E685: Internal error: %s" +msgstr "E685: ÆâÉô¥¨¥é¡¼¤Ç¤¹: %s" + msgid "Interrupted" msgstr "³ä¹þ¤Þ¤ì¤Þ¤·¤¿" @@ -6680,8 +6727,8 @@ msgstr "E592: 'winwidth' msgid "E80: Error while writing" msgstr "E80: ½ñ¹þ¤ßÃæ¤Î¥¨¥é¡¼" -msgid "Zero count" -msgstr "¥¼¥í¥«¥¦¥ó¥È" +msgid "E939: Positive count required" +msgstr "E939: Àµ¤Î¥«¥¦¥ó¥È¤¬É¬ÍפǤ¹" msgid "E81: Using not in a script context" msgstr "E81: ¥¹¥¯¥ê¥×¥È°Ê³°¤Ç¤¬»È¤ï¤ì¤Þ¤·¤¿" @@ -6695,10 +6742,6 @@ msgstr "E463: msgid "E744: NetBeans does not allow changes in read-only files" msgstr "E744: NetBeans ¤ÏÆÉ¹þÀìÍÑ¥Õ¥¡¥¤¥ë¤òÊѹ¹¤¹¤ë¤³¤È¤òµö¤·¤Þ¤»¤ó" -#, c-format -msgid "E685: Internal error: %s" -msgstr "E685: ÆâÉô¥¨¥é¡¼¤Ç¤¹: %s" - msgid "E363: pattern uses more memory than 'maxmempattern'" msgstr "E363: ¥Ñ¥¿¡¼¥ó¤¬ 'maxmempattern' °Ê¾å¤Î¥á¥â¥ê¤ò»ÈÍѤ·¤Þ¤¹" diff --git a/src/nvim/po/ja.po b/src/nvim/po/ja.po index 5cb789c93e..39b4a89517 100644 --- a/src/nvim/po/ja.po +++ b/src/nvim/po/ja.po @@ -13,10 +13,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Vim 7.4\n" +"Project-Id-Version: Vim 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-10 21:10+0900\n" -"PO-Revision-Date: 2016-09-10 21:20+0900\n" +"POT-Creation-Date: 2017-07-03 23:05+0900\n" +"PO-Revision-Date: 2017-07-12 20:45+0900\n" "Last-Translator: MURAOKA Taro \n" "Language-Team: vim-jp (https://github.com/vim-jp/lang-ja)\n" "Language: Japanese\n" @@ -245,7 +245,8 @@ msgid "E917: Cannot use a callback with %s()" msgstr "E917: %s() ã«ã‚³ãƒ¼ãƒ«ãƒãƒƒã‚¯ã¯ä½¿ãˆã¾ã›ã‚“" msgid "E912: cannot use ch_evalexpr()/ch_sendexpr() with a raw or nl channel" -msgstr "E912: 生や nl ãƒãƒ£ãƒ³ãƒãƒ«ã« ch_evalexpr()/ch_sendexpr ã¯ä½¿ãˆã¾ã›ã‚“" +msgstr "" +"E912: raw ã‚„ nl モードã®ãƒãƒ£ãƒ³ãƒãƒ«ã« ch_evalexpr()/ch_sendexpr() ã¯ä½¿ãˆã¾ã›ã‚“" msgid "E906: not an open channel" msgstr "E906: é–‹ã„ã¦ã„ãªã„ãƒãƒ£ãƒ³ãƒãƒ«ã§ã™" @@ -431,6 +432,9 @@ msgstr "スキャン中: %s" msgid "Scanning tags." msgstr "タグをスキャン中." +msgid "match in file" +msgstr "ファイル内ã®ãƒžãƒƒãƒ" + msgid " Adding" msgstr " 追加中" @@ -519,6 +523,12 @@ msgstr "E690: :for ã®å¾Œã« \"in\" ãŒã‚りã¾ã›ã‚“" msgid "E108: No such variable: \"%s\"" msgstr "E108: ãã®å¤‰æ•°ã¯ã‚りã¾ã›ã‚“: \"%s\"" +#. For historic reasons this error is not given for a list or dict. +#. * E.g., the b: dict could be locked/unlocked. +#, c-format +msgid "E940: Cannot lock or unlock variable %s" +msgstr "E940: 変数 %s ã¯ãƒ­ãƒƒã‚¯ã¾ãŸã¯ã‚¢ãƒ³ãƒ­ãƒƒã‚¯ã§ãã¾ã›ã‚“" + msgid "E743: variable nested too deep for (un)lock" msgstr "E743: (アン)ロックã™ã‚‹ã«ã¯å¤‰æ•°ã®å…¥ã‚Œå­ãŒæ·±éŽãŽã¾ã™" @@ -696,11 +706,6 @@ msgstr "E785: complete() ã¯æŒ¿å…¥ãƒ¢ãƒ¼ãƒ‰ã§ã—ã‹åˆ©ç”¨ã§ãã¾ã›ã‚“" msgid "&Ok" msgstr "&Ok" -#, c-format -msgid "+-%s%3ld line: " -msgid_plural "+-%s%3ld lines: " -msgstr[0] "+-%s%3ld 行: " - #, c-format msgid "E700: Unknown function: %s" msgstr "E700: 未知ã®é–¢æ•°ã§ã™: %s" @@ -746,8 +751,8 @@ msgstr "E727: é–‹å§‹ä½ç½®ãŒçµ‚了ä½ç½®ã‚’è¶Šãˆã¾ã—ãŸ" msgid "" msgstr "<空>" -msgid "E240: No connection to Vim server" -msgstr "E240: Vim サーãƒãƒ¼ã¸ã®æŽ¥ç¶šãŒã‚りã¾ã›ã‚“" +msgid "E240: No connection to the X server" +msgstr "E240: X サーãƒãƒ¼ã¸ã®æŽ¥ç¶šãŒã‚りã¾ã›ã‚“" #, c-format msgid "E241: Unable to send to %s" @@ -756,6 +761,12 @@ msgstr "E241: %s ã¸é€ã‚‹ã“ã¨ãŒã§ãã¾ã›ã‚“" msgid "E277: Unable to read a server reply" msgstr "E277: サーãƒãƒ¼ã®å¿œç­”ãŒã‚りã¾ã›ã‚“" +msgid "E941: already started a server" +msgstr "E941: サーãƒãƒ¼ã¯ã™ã§ã«é–‹å§‹ã—ã¦ã„ã¾ã™" + +msgid "E942: +clientserver feature not available" +msgstr "E942: +clientserver 機能ãŒç„¡åйã«ãªã£ã¦ã„ã¾ã™" + msgid "remove() argument" msgstr "remove() ã®å¼•æ•°" @@ -993,8 +1004,9 @@ msgstr " (計 1 行内)" msgid " on %ld lines" msgstr " (計 %ld 行内)" -msgid "E147: Cannot do :global recursive" -msgstr "E147: :global ã‚’å†å¸°çš„ã«ã¯ä½¿ãˆã¾ã›ã‚“" +#. will increment global_busy to break out of the loop +msgid "E147: Cannot do :global recursive with a range" +msgstr "E147: :global を範囲付ãã§å†å¸°çš„ã«ã¯ä½¿ãˆã¾ã›ã‚“" msgid "E148: Regular expression missing from global" msgstr "E148: globalã‚³ãƒžãƒ³ãƒ‰ã«æ­£è¦è¡¨ç¾ãŒæŒ‡å®šã•れã¦ã„ã¾ã›ã‚“" @@ -1180,6 +1192,14 @@ msgstr "\"%s\" を検索中" msgid "not found in '%s': \"%s\"" msgstr "'%s' ã®ä¸­ã«ã¯ã‚りã¾ã›ã‚“: \"%s\"" +#, c-format +msgid "W20: Required python version 2.x not supported, ignoring file: %s" +msgstr "W20: è¦æ±‚ã•れãŸpython 2.xã¯å¯¾å¿œã—ã¦ã„ã¾ã›ã‚“ã€ãƒ•ァイルを無視ã—ã¾ã™: %s" + +#, c-format +msgid "W21: Required python version 3.x not supported, ignoring file: %s" +msgstr "W21: è¦æ±‚ã•れãŸpython 3.xã¯å¯¾å¿œã—ã¦ã„ã¾ã›ã‚“ã€ãƒ•ァイルを無視ã—ã¾ã™: %s" + msgid "Source Vim script" msgstr "Vimスクリプトã®å–è¾¼ã¿" @@ -1278,6 +1298,11 @@ msgstr "逆ã•ã¾ã®ç¯„å›²ãŒæŒ‡å®šã•れã¾ã—ãŸ, 入替ãˆã¾ã™ã‹?" msgid "E494: Use w or w>>" msgstr "E494: w ã‚‚ã—ã㯠w>> を使用ã—ã¦ãã ã•ã„" +msgid "E943: Command table needs to be updated, run 'make cmdidxs'" +msgstr "" +"E943: コマンドテーブルを更新ã™ã‚‹å¿…è¦ãŒã‚りã¾ã™ã€'make cmdidxs' を実行ã—ã¦ãã " +"ã•ã„" + msgid "E319: Sorry, the command is not available in this version" msgstr "E319: ã“ã®ãƒãƒ¼ã‚¸ãƒ§ãƒ³ã§ã¯ã“ã®ã‚³ãƒžãƒ³ãƒ‰ã¯åˆ©ç”¨ã§ãã¾ã›ã‚“, ã”ã‚ã‚“ãªã•ã„" @@ -2030,11 +2055,6 @@ msgstr "E350: ç¾åœ¨ã® 'foldmethod' ã§ã¯æŠ˜ç•³ã¿ã‚’作æˆã§ãã¾ã›ã‚“" msgid "E351: Cannot delete fold with current 'foldmethod'" msgstr "E351: ç¾åœ¨ã® 'foldmethod' ã§ã¯æŠ˜ç•³ã¿ã‚’削除ã§ãã¾ã›ã‚“" -#, c-format -msgid "+--%3ld line folded " -msgid_plural "+--%3ld lines folded " -msgstr[0] "+--%3ld è¡ŒãŒæŠ˜ç•³ã¾ã‚Œã¾ã—㟠" - msgid "E222: Add to read buffer" msgstr "E222: 読込ãƒãƒƒãƒ•ã‚¡ã¸è¿½åŠ " @@ -2818,6 +2838,10 @@ msgstr "E573: 無効ãªã‚µãƒ¼ãƒãƒ¼IDãŒä½¿ã‚れã¾ã—ãŸ: %s" msgid "E251: VIM instance registry property is badly formed. Deleted!" msgstr "E251: VIM 実体ã®ç™»éŒ²ãƒ—ロパティãŒä¸æ­£ã§ã™. 消去ã—ã¾ã—ãŸ!" +#, c-format +msgid "E938: Duplicate key in JSON: \"%s\"" +msgstr "E938: JSONã«é‡è¤‡ã‚­ãƒ¼ãŒã‚りã¾ã™: \"%s\"" + #, c-format msgid "E696: Missing comma in List: %s" msgstr "E696: リスト型ã«ã‚«ãƒ³ãƒžãŒã‚りã¾ã›ã‚“: %s" @@ -2858,7 +2882,7 @@ msgid "This Vim was not compiled with the diff feature." msgstr "ã“ã®Vimã«ã¯diff機能ãŒã‚りã¾ã›ã‚“(コンパイル時設定)." msgid "Attempt to open script file again: \"" -msgstr "スクリプトファイルをå†ã³é–‹ã„ã¦ã¿ã¾ã™: \"" +msgstr "スクリプトファイルをå†ã³é–‹ã“ã†ã¨ã—ã¾ã—ãŸ: \"" msgid "Cannot open for reading: \"" msgstr "読込用ã¨ã—ã¦é–‹ã‘ã¾ã›ã‚“" @@ -3039,6 +3063,9 @@ msgstr "-T \t端末を ã«è¨­å®šã™ã‚‹" msgid "--not-a-term\t\tSkip warning for input/output not being a terminal" msgstr "--not-a-term\t\t入出力ãŒç«¯æœ«ã§ãªã„ã¨ã®è­¦å‘Šã‚’スキップã™ã‚‹" +msgid "--ttyfail\t\tExit if input or output is not a terminal" +msgstr "--ttyfail\t\t入出力ãŒç«¯æœ«ã§ãªã‘れã°çµ‚了ã™ã‚‹" + msgid "-u \t\tUse instead of any .vimrc" msgstr "-u \t\t.vimrcã®ä»£ã‚り㫠を使ã†" @@ -3906,7 +3933,7 @@ msgid "E766: Insufficient arguments for printf()" msgstr "E766: printf() ã®å¼•æ•°ãŒä¸å分ã§ã™" msgid "E807: Expected Float argument for printf()" -msgstr "E807: printf() ã®å¼•æ•°ã«ã¯æµ®å‹•å°‘æ•°ç‚¹æ•°ãŒæœŸå¾…ã•れã¦ã„ã¾ã™" +msgstr "E807: printf() ã®å¼•æ•°ã«ã¯æµ®å‹•å°æ•°ç‚¹æ•°ãŒæœŸå¾…ã•れã¦ã„ã¾ã™" msgid "E767: Too many arguments to printf()" msgstr "E767: printf() ã®å¼•æ•°ãŒå¤šéŽãŽã¾ã™" @@ -4063,8 +4090,10 @@ msgstr "E662: 変更リストã®å…ˆé ­" msgid "E663: At end of changelist" msgstr "E663: å¤‰æ›´ãƒªã‚¹ãƒˆã®æœ«å°¾" -msgid "Type :quit to exit Vim" -msgstr "Vimを終了ã™ã‚‹ã«ã¯ :quit ã¨å…¥åŠ›ã—ã¦ãã ã•ã„" +msgid "Type :qa! and press to abandon all changes and exit Vim" +msgstr "" +"ã™ã¹ã¦ã®å¤‰æ›´ã‚’破棄ã—ã€Vimを終了ã™ã‚‹ã«ã¯ :qa! ã¨å…¥åŠ›ã— ã‚’æŠ¼ã—ã¦ãã " +"ã•ã„" #, c-format msgid "1 line %sed 1 time" @@ -4413,9 +4442,6 @@ msgstr "入出力エラー" msgid "Message" msgstr "メッセージ" -msgid "'columns' is not 80, cannot execute external commands" -msgstr "'columns' ㌠80 ã§ã¯ãªã„ãŸã‚ã€å¤–部コマンドを実行ã§ãã¾ã›ã‚“" - msgid "E237: Printer selection failed" msgstr "E237: プリンタã®é¸æŠžã«å¤±æ•—ã—ã¾ã—ãŸ" @@ -4685,6 +4711,12 @@ msgstr "E369: 無効ãªé …ç›®ã§ã™: %s%%[]" msgid "E769: Missing ] after %s[" msgstr "E769: %s[ ã®å¾Œã« ] ãŒã‚りã¾ã›ã‚“" +msgid "E944: Reverse range in character class" +msgstr "E944: 文字クラスã®ç¯„囲ãŒé€†ã§ã™" + +msgid "E945: Range too large in character class" +msgstr "E945: 文字クラスã®ç¯„囲ãŒå¤§ãã™ãŽã¾ã™" + #, c-format msgid "E53: Unmatched %s%%(" msgstr "E53: %s%%( ãŒé‡£ã‚Šåˆã£ã¦ã„ã¾ã›ã‚“" @@ -4714,6 +4746,10 @@ msgstr "E69: %s%%[ ã®å¾Œã« ] ãŒã‚りã¾ã›ã‚“" msgid "E70: Empty %s%%[]" msgstr "E70: %s%%[] ãŒç©ºã§ã™" +# +msgid "E65: Illegal back reference" +msgstr "E65: 䏿­£ãªå¾Œæ–¹å‚ç…§ã§ã™" + msgid "E339: Pattern too long" msgstr "E339: パターンãŒé•·éŽãŽã¾ã™" @@ -4751,10 +4787,6 @@ msgstr "E63: \\_ ã®ç„¡åйãªä½¿ç”¨æ–¹æ³•ã§ã™" msgid "E64: %s%c follows nothing" msgstr "E64:%s%c ã®å¾Œã«ãªã«ã‚‚ã‚りã¾ã›ã‚“" -# -msgid "E65: Illegal back reference" -msgstr "E65: 䏿­£ãªå¾Œæ–¹å‚ç…§ã§ã™" - # msgid "E68: Invalid character after \\z" msgstr "E68: \\z ã®å¾Œã«ä¸æ­£ãªæ–‡å­—ãŒã‚りã¾ã—ãŸ" @@ -5363,12 +5395,33 @@ msgstr "E783: MAP エントリã«é‡è¤‡æ–‡å­—ãŒå­˜åœ¨ã—ã¾ã™" msgid "No Syntax items defined for this buffer" msgstr "ã“ã®ãƒãƒƒãƒ•ã‚¡ã«å®šç¾©ã•ã‚ŒãŸæ§‹æ–‡è¦ç´ ã¯ã‚りã¾ã›ã‚“" +msgid "syntax conceal on" +msgstr "構文㮠conceal ã¯ç¾åœ¨ on ã§ã™" + +msgid "syntax conceal off" +msgstr "構文㮠conceal ã¯ç¾åœ¨ off ã§ã™" + #, c-format msgid "E390: Illegal argument: %s" msgstr "E390: 䏿­£ãªå¼•æ•°ã§ã™: %s" +msgid "syntax case ignore" +msgstr "æ§‹æ–‡ã®å¤§æ–‡å­—å°æ–‡å­—ã¯ç¾åœ¨ ignore ã§ã™" + +msgid "syntax case match" +msgstr "æ§‹æ–‡ã®å¤§æ–‡å­—å°æ–‡å­—ã¯ç¾åœ¨ match ã§ã™" + +msgid "syntax spell toplevel" +msgstr "構文㮠spell ã¯ç¾åœ¨ toplevel ã§ã™" + +msgid "syntax spell notoplevel" +msgstr "構文㮠spell ã¯ç¾åœ¨ notoplevel ã§ã™" + +msgid "syntax spell default" +msgstr "構文㮠spell ã¯ç¾åœ¨ default ã§ã™" + msgid "syntax iskeyword " -msgstr "シンタックス用 iskeyword " +msgstr "構文用 iskeyword " #, c-format msgid "E391: No such syntax cluster: %s" @@ -5579,7 +5632,7 @@ msgid "E556: at top of tag stack" msgstr "E556: タグスタックã®å…ˆé ­ã§ã™" msgid "E425: Cannot go before first matching tag" -msgstr "E425: 最åˆã®è©²å½“ã‚¿ã‚°ã‚’è¶…ãˆã¦æˆ»ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“" +msgstr "E425: 最åˆã®è©²å½“ã‚¿ã‚°ã‚’è¶Šãˆã¦æˆ»ã‚‹ã“ã¨ã¯ã§ãã¾ã›ã‚“" #, c-format msgid "E426: tag not found: %s" @@ -5595,7 +5648,7 @@ msgid "E427: There is only one matching tag" msgstr "E427: 該当タグãŒ1ã¤ã ã‘ã—ã‹ã‚りã¾ã›ã‚“" msgid "E428: Cannot go beyond last matching tag" -msgstr "E428: 最後ã«è©²å½“ã™ã‚‹ã‚¿ã‚°ã‚’è¶…ãˆã¦é€²ã‚€ã“ã¨ã¯ã§ãã¾ã›ã‚“" +msgstr "E428: 最後ã®è©²å½“ã‚¿ã‚°ã‚’è¶Šãˆã¦é€²ã‚€ã“ã¨ã¯ã§ãã¾ã›ã‚“" #, c-format msgid "File \"%s\" does not exist" @@ -5942,6 +5995,10 @@ msgstr "E932: クロージャー関数ã¯ãƒˆãƒƒãƒ—レベルã«è¨˜è¿°ã§ãã¾ã› msgid "E126: Missing :endfunction" msgstr "E126: :endfunction ãŒã‚りã¾ã›ã‚“" +#, c-format +msgid "W22: Text found after :endfunction: %s" +msgstr "W22: :endfunction ã®å¾Œã«æ–‡å­—ãŒã‚りã¾ã™: %s" + #, c-format msgid "E707: Function name conflicts with variable: %s" msgstr "E707: 関数åãŒå¤‰æ•°åã¨è¡çªã—ã¾ã™: %s" @@ -5965,14 +6022,6 @@ msgstr "E133: 関数外㫠:return ãŒã‚りã¾ã—ãŸ" msgid "E107: Missing parentheses: %s" msgstr "E107: カッコ '(' ãŒã‚りã¾ã›ã‚“: %s" -#. Only MS VC 4.1 and earlier can do Win32s -msgid "" -"\n" -"MS-Windows 16/32-bit GUI version" -msgstr "" -"\n" -"MS-Windows 16/32 ビット GUI 版" - msgid "" "\n" "MS-Windows 64-bit GUI version" @@ -6256,12 +6305,6 @@ msgstr "è©³ç´°ãªæƒ…報㯠:help register " msgid "menu Help->Sponsor/Register for information " msgstr "詳細ã¯ãƒ¡ãƒ‹ãƒ¥ãƒ¼ã® ヘルプ->スãƒãƒ³ã‚µãƒ¼/登録 ã‚’å‚ç…§ã—ã¦ä¸‹ã•ã„" -msgid "WARNING: Windows 95/98/ME detected" -msgstr "警告: Windows 95/98/ME を検出ã—ã¾ã—ãŸ" - -msgid "type :help windows95 for info on this" -msgstr "è©³ç´°ãªæƒ…報㯠:help windows95" - msgid "Already only one window" msgstr "æ—¢ã«ã‚¦ã‚£ãƒ³ãƒ‰ã‚¦ã¯1ã¤ã—ã‹ã‚りã¾ã›ã‚“" @@ -6415,6 +6458,10 @@ msgstr "E236: フォント \"%s\" ã¯å›ºå®šå¹…ã§ã¯ã‚りã¾ã›ã‚“" msgid "E473: Internal error" msgstr "E473: 内部エラーã§ã™" +#, c-format +msgid "E685: Internal error: %s" +msgstr "E685: 内部エラーã§ã™: %s" + msgid "Interrupted" msgstr "割込ã¾ã‚Œã¾ã—ãŸ" @@ -6680,8 +6727,8 @@ msgstr "E592: 'winwidth' 㯠'winminwidth' よりå°ã•ãã§ãã¾ã›ã‚“" msgid "E80: Error while writing" msgstr "E80: 書込ã¿ä¸­ã®ã‚¨ãƒ©ãƒ¼" -msgid "Zero count" -msgstr "ゼロカウント" +msgid "E939: Positive count required" +msgstr "E939: æ­£ã®ã‚«ã‚¦ãƒ³ãƒˆãŒå¿…è¦ã§ã™" msgid "E81: Using not in a script context" msgstr "E81: スクリプト以外ã§ãŒä½¿ã‚れã¾ã—ãŸ" @@ -6695,10 +6742,6 @@ msgstr "E463: 領域ãŒä¿è­·ã•れã¦ã„ã‚‹ã®ã§, 変更ã§ãã¾ã›ã‚“" msgid "E744: NetBeans does not allow changes in read-only files" msgstr "E744: NetBeans ã¯èª­è¾¼å°‚用ファイルを変更ã™ã‚‹ã“ã¨ã‚’許ã—ã¾ã›ã‚“" -#, c-format -msgid "E685: Internal error: %s" -msgstr "E685: 内部エラーã§ã™: %s" - msgid "E363: pattern uses more memory than 'maxmempattern'" msgstr "E363: パターン㌠'maxmempattern' 以上ã®ãƒ¡ãƒ¢ãƒªã‚’使用ã—ã¾ã™" diff --git a/src/nvim/po/ko.UTF-8.po b/src/nvim/po/ko.UTF-8.po index 7afa507edb..89d6a57655 100644 --- a/src/nvim/po/ko.UTF-8.po +++ b/src/nvim/po/ko.UTF-8.po @@ -1110,6 +1110,10 @@ msgid "E137: Viminfo file is not writable: %s" msgstr "E137: Viminfo 파ì¼ì˜ 쓰기 ê¶Œí•œì´ ì—†ìŠµë‹ˆë‹¤: %s" #: ../ex_cmds.c:1626 +#, c-format +msgid "E929: Too many viminfo temp files, like %s!" +msgstr "E929: 너무 ë§Žì€ viminfo 임시 파ì¼ë“¤, 가령 %s!" + #, c-format msgid "E138: Can't write viminfo file %s!" msgstr "E138: Viminfo íŒŒì¼ %sì„(를) 쓸 수 없습니다!" @@ -1119,6 +1123,10 @@ msgstr "E138: Viminfo íŒŒì¼ %sì„(를) 쓸 수 없습니다!" msgid "Writing viminfo file \"%s\"" msgstr "Viminfo íŒŒì¼ \"%s\"ì„(를) 쓰는 중" +#, c-format +msgid "E886: Can't rename viminfo file to %s!" +msgstr "E886: viminfo 파ì¼ëª…ì„ %s(으)로 변경할 수 없습니다!" + #. Write the info: #: ../ex_cmds.c:1720 #, c-format @@ -1300,8 +1308,8 @@ msgstr "미안합니다, ë„ì›€ë§ íŒŒì¼ \"%s\"ì„(를) ì°¾ì„ ìˆ˜ 없습니다 #: ../ex_cmds.c:5323 #, c-format -msgid "E150: Not a directory: %s" -msgstr "E150: 디렉토리가 아님: %s" +msgid "E151: No match: %s" +msgstr "E151: ë§žì§€ 않ìŒ: %s" #: ../ex_cmds.c:5446 #, c-format @@ -1324,6 +1332,10 @@ msgid "E154: Duplicate tag \"%s\" in file %s/%s" msgstr "E154: \"%s\" 태그가 %s/%s 파ì¼ì—서 중복ë˜ì—ˆìŠµë‹ˆë‹¤" #: ../ex_cmds.c:5687 +#, c-format +msgid "E150: Not a directory: %s" +msgstr "E150: 디렉토리가 아님: %s" + #, c-format msgid "E160: Unknown sign command: %s" msgstr "E160: 모르는 sign 명령: %s" @@ -1452,8 +1464,16 @@ msgstr "\"%s\"ì„(를) 찾는 중" #: ../ex_cmds2.c:2307 #, c-format -msgid "not found in 'runtimepath': \"%s\"" -msgstr "'runtimepath'ì—서 ì°¾ì„ ìˆ˜ ì—†ìŒ: \"%s\"" +msgid "not found in '%s': \"%s\"" +msgstr "'%s'ì—서 ì°¾ì„ ìˆ˜ ì—†ìŒ: \"%s\"" + +#, c-format +msgid "W20: Required python version 2.x not supported, ignoring file: %s" +msgstr "W20: 요구ë˜ëŠ” 파ì´ì„  버젼 2.x는 ì§€ì›ë˜ì§€ 않ìŒ, 파ì¼ì„ 무시: %s" + +#, c-format +msgid "W21: Required python version 3.x not supported, ignoring file: %s" +msgstr "W21: 요구ë˜ëŠ” 파ì´ì„  버젼 3.x는 ì§€ì›ë˜ì§€ 않ìŒ, 파ì¼ì„ 무시: %s" #: ../ex_cmds2.c:2472 #, c-format @@ -1609,10 +1629,10 @@ msgstr "E174: ëª…ë ¹ì´ ì´ë¯¸ 존재합니다: 바꾸려면 !ì„ ë”하세요" #: ../ex_docmd.c:4432 msgid "" "\n" -" Name Args Range Complete Definition" +" Name Args Address Complete Definition" msgstr "" "\n" -" ì´ë¦„ ì¸ìž 범위 완성 ì •ì˜" +" ì´ë¦„ ì¸ìž 주소 완성 ì •ì˜" #: ../ex_docmd.c:4516 msgid "No user-defined commands found" @@ -1661,6 +1681,10 @@ msgid "E184: No such user-defined command: %s" msgstr "E184: 그런 ì‚¬ìš©ìž ì •ì˜ ëª…ë ¹ ì—†ìŒ: %s" #: ../ex_docmd.c:5219 +#, c-format +msgid "E180: Invalid address type value: %s" +msgstr "E180: ìž˜ëª»ëœ ì£¼ì†Œ í˜•ì‹ ê°’: %s" + #, c-format msgid "E180: Invalid complete value: %s" msgstr "E180: ìž˜ëª»ëœ ë내기 ê°’: %s" @@ -1953,7 +1977,7 @@ msgstr "" #: ../ex_getln.c:5047 msgid "Command Line" -msgstr "명령 줄" +msgstr "명령 í–‰" #: ../ex_getln.c:5048 msgid "Search String" @@ -1965,7 +1989,10 @@ msgstr "표현" #: ../ex_getln.c:5050 msgid "Input Line" -msgstr "ìž…ë ¥ 줄" +msgstr "ìž…ë ¥ í–‰" + +msgid "Debug Line" +msgstr "디버그 í–‰" #: ../ex_getln.c:5117 msgid "E198: cmd_pchar beyond the command length" @@ -3190,6 +3217,7 @@ msgstr "%-5s: %s%*s (사용법: %s)" #: ../if_cscope.c:1155 msgid "" "\n" +" a: Find assignments to this symbol\n" " c: Find functions calling this function\n" " d: Find functions called by this function\n" " e: Find this egrep pattern\n" @@ -3200,13 +3228,14 @@ msgid "" " t: Find this text string\n" msgstr "" "\n" +" a: ì´ ê¸°í˜¸ì— ëŒ€í•œ 할당 찾기\n" " c: ì´ í•¨ìˆ˜ë¥¼ 부르는 함수들 찾기\n" " d: ì´ í•¨ìˆ˜ì— ì˜í•´ 불려지는 함수들 찾기\n" " e: ì´ egrep 패턴 찾기\n" " f: ì´ íŒŒì¼ ì°¾ê¸°\n" " g: ì´ ì •ì˜ ì°¾ê¸°\n" -" i: ì´ íŒŒì¼ì„ í¬í•¨í•˜ëŠ” 파ì¼ë“¤ 찾기\n" -" s: ì´ C 심볼 찾기\n" +" i: ì´ íŒŒì¼ì„ #include하는 파ì¼ë“¤ 찾기\n" +" s: ì´ C 기호 찾기\n" " t: ì´ ë¬¸ìžì—´ 찾기\n" #: ../if_cscope.c:1226 @@ -4739,6 +4768,10 @@ msgid "E447: Can't find file \"%s\" in path" msgstr "E447: pathì—서 \"%s\" 파ì¼ì„ ì°¾ì„ ìˆ˜ 없습니다" #: ../quickfix.c:359 +#, c-format +msgid "shell returned %d" +msgstr "ì‰˜ì´ %dì„(를) ëŒë ¤ì£¼ì—ˆìŠµë‹ˆë‹¤" + #, c-format msgid "E372: Too many %%%c in format string" msgstr "E372: í˜•ì‹ ë¬¸ìžì—´ì— %%%cì´(ê°€) 너무 많습니다" @@ -5249,8 +5282,24 @@ msgstr "E770: spell 파ì¼ì— ì§€ì›ë˜ì§€ 않는 섹션" #: ../spell.c:3762 #, c-format -msgid "Warning: region %s not supported" -msgstr "경고: %s ì˜ì—­ì€ ì§€ì›ë˜ì§€ 않습니다" +msgid "E778: This does not look like a .sug file: %s" +msgstr "E778: .sug 파ì¼ì´ 아닌 것 ê°™ìŒ: %s" + +#, c-format +msgid "E779: Old .sug file, needs to be updated: %s" +msgstr "E779: ì˜¤ëž˜ëœ .sug 파ì¼, 갱신 í•„ìš”: %s" + +#, c-format +msgid "E780: .sug file is for newer version of Vim: %s" +msgstr "E780: .sug 파ì¼ì´ 새 ë²„ì ¼ì˜ Vim용임: %s" + +#, c-format +msgid "E781: .sug file doesn't match .spl file: %s" +msgstr "E781: .sug 파ì¼ì´ .spl 파ì¼ê³¼ ë§žì§€ 않ìŒ: %s" + +#, c-format +msgid "E782: error while reading .sug file: %s" +msgstr "E782: .sug íŒŒì¼ ì½ê¸° ì—러: %s" #: ../spell.c:4550 #, c-format @@ -6312,7 +6361,7 @@ msgstr "by Bram Moolenaar et al." #: ../version.c:774 msgid "Vim is open source and freely distributable" -msgstr "ë¹”ì€ ì†ŒìŠ¤ê°€ ì—´ë ¤ 있고 공짜로 ë°°í¬ë©ë‹ˆë‹¤" +msgstr "ë¹”ì€ ëˆ„êµ¬ë‚˜ 소스를 ë³¼ 수 있고 공짜로 ë°°í¬ë©ë‹ˆë‹¤" #: ../version.c:776 msgid "Help poor children in Uganda!" diff --git a/src/nvim/po/uk.po b/src/nvim/po/uk.po index 2c203f808f..c66cb2973c 100644 --- a/src/nvim/po/uk.po +++ b/src/nvim/po/uk.po @@ -1,6 +1,8 @@ # # Ukrainian Vim translation [uk] # +# Original translations +# # Copyright (C) 2001 Bohdan Vlasyuk # Bohdan donated this work to be distributed with Vim under the Vim license. # @@ -510,6 +512,9 @@ msgstr "Пошук у: %s" msgid "Scanning tags." msgstr "Пошук Ñеред теґів." +msgid "match in file" +msgstr "збіг у файлі" + msgid " Adding" msgstr " ДодаєтьÑÑ" @@ -642,6 +647,12 @@ msgstr "E107: Пропущено дужки: %s" msgid "E108: No such variable: \"%s\"" msgstr "E108: Змінної немає: «%s»" +#. For historic reasons this error is not given for a list or dict. +#. * E.g., the b: dict could be locked/unlocked. +#, c-format +msgid "E940: Cannot lock or unlock variable %s" +msgstr "E940: Ðеможливо заблокувати чи розблокувати змінну %s" + msgid "E743: variable nested too deep for (un)lock" msgstr "E743: Змінна має забагато вкладень щоб бути за-/відкритою." @@ -1392,8 +1403,9 @@ msgstr " в одному Ñ€Ñдку" msgid " on % lines" msgstr " в % Ñ€Ñдках" -msgid "E147: Cannot do :global recursive" -msgstr "E147: :global не можна вживати рекурÑивно" +#. will increment global_busy to break out of the loop +msgid "E147: Cannot do :global recursive with a range" +msgstr "E147: :global не можна вживати рекурÑивно з діапазоном" msgid "E148: Regular expression missing from global" msgstr "E148: У global бракує зразка" @@ -4130,6 +4142,12 @@ msgstr "E369: Ðекоректний елемент у %s%%[]" msgid "E769: Missing ] after %s[" msgstr "E769: Бракує ] піÑÐ»Ñ %s[" +msgid "E944: Reverse range in character class" +msgstr "E944: Зворотній діапазон у клаÑÑ– Ñимволів" + +msgid "E945: Range too large in character class" +msgstr "E945: Завеликий діапазон у клаÑÑ– Ñимволів" + #, c-format msgid "E53: Unmatched %s%%(" msgstr "E53: Ðемає пари %s%%(" @@ -4888,10 +4906,31 @@ msgstr "E783: Повторено Ñимвол у елементі MAP" msgid "No Syntax items defined for this buffer" msgstr "Ð”Ð»Ñ Ð±ÑƒÑ„ÐµÑ€Ð° не визначено елементів ÑинтакÑиÑу" +msgid "syntax conceal on" +msgstr "маÑÐºÑƒÐ²Ð°Ð½Ð½Ñ ÑинтакÑиÑу увімк" + +msgid "syntax conceal off" +msgstr "маÑÐºÑƒÐ²Ð°Ð½Ð½Ñ ÑинтакÑиÑу вимк" + #, c-format msgid "E390: Illegal argument: %s" msgstr "E390: Ðеправильний аргумент: %s" +msgid "syntax case ignore" +msgstr "ÑинтакÑÐ¸Ñ Ñ–Ð³Ð½Ð¾Ñ€ÑƒÐ²Ð°Ñ‚Ð¸ регіÑтр" + +msgid "syntax case match" +msgstr "ÑинтакÑÐ¸Ñ Ð´Ð¾Ñ‚Ñ€Ð¸Ð¼ÑƒÐ²Ð°Ñ‚Ð¸ÑÑ Ñ€ÐµÐ³Ñ–Ñтру" + +msgid "syntax spell toplevel" +msgstr "ÑинтакÑÐ¸Ñ Ð¿ÐµÑ€ÐµÐ²Ñ–Ñ€Ñти вÑюди" + +msgid "syntax spell notoplevel" +msgstr "ÑинтакÑÐ¸Ñ Ð½Ðµ перевірÑти" + +msgid "syntax spell default" +msgstr "ÑинтакÑÐ¸Ñ Ð¿Ð¾Ñ‡Ð°Ñ‚ÐºÐ¾Ð²Ð¾" + msgid "syntax iskeyword " msgstr "ÑинтакÑÐ¸Ñ iskeyword " -- cgit From 20e317e22abeef20891eb70a18435559f7b09212 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 02:25:46 +0100 Subject: po: remove duplicate definitions --- src/nvim/po/it.po | 22 ---------------------- src/nvim/po/ko.UTF-8.po | 24 ------------------------ 2 files changed, 46 deletions(-) (limited to 'src') diff --git a/src/nvim/po/it.po b/src/nvim/po/it.po index 4d9ce045ca..91a68cf1e6 100644 --- a/src/nvim/po/it.po +++ b/src/nvim/po/it.po @@ -5382,27 +5382,10 @@ msgstr "E772: Il file ortografico msgid "E770: Unsupported section in spell file" msgstr "E770: Sezione non supportata nel file ortografico" -#: ../spell.c:3762 -#, c-format -msgid "E778: This does not look like a .sug file: %s" -msgstr "E778: Questo non sembra un file .sug: %s" - #, c-format msgid "E779: Old .sug file, needs to be updated: %s" msgstr "E779: File .sug obsoleto, è necessario aggiornarlo: %s" -#, c-format -msgid "E780: .sug file is for newer version of Vim: %s" -msgstr "E780: Il file .sug è per versioni di Vim più recenti: %s" - -#, c-format -msgid "E781: .sug file doesn't match .spl file: %s" -msgstr "E781: Il file .sug non corrisponde al file .spl: %s" - -#, c-format -msgid "E782: error while reading .sug file: %s" -msgstr "E782: Errore leggendo il file .sug: %s" - #: ../spell.c:4550 #, c-format msgid "Reading affix file %s ..." @@ -5761,11 +5744,6 @@ msgstr "E753: Non trovato: %s" msgid "E778: This does not look like a .sug file: %s" msgstr "E778: Questo non sembra un file .sug: %s" -#: ../spell.c:9282 -#, c-format -msgid "E779: Old .sug file, needs to be updated: %s" -msgstr "E779: File .sug obsoleto, è necessario aggiornarlo: %s" - #: ../spell.c:9286 #, c-format msgid "E780: .sug file is for newer version of Vim: %s" diff --git a/src/nvim/po/ko.UTF-8.po b/src/nvim/po/ko.UTF-8.po index 89d6a57655..6173283135 100644 --- a/src/nvim/po/ko.UTF-8.po +++ b/src/nvim/po/ko.UTF-8.po @@ -5280,27 +5280,6 @@ msgstr "E772: Spell 파ì¼ì´ 새 ë²„ì ¼ì˜ Vim용입니다" msgid "E770: Unsupported section in spell file" msgstr "E770: spell 파ì¼ì— ì§€ì›ë˜ì§€ 않는 섹션" -#: ../spell.c:3762 -#, c-format -msgid "E778: This does not look like a .sug file: %s" -msgstr "E778: .sug 파ì¼ì´ 아닌 것 ê°™ìŒ: %s" - -#, c-format -msgid "E779: Old .sug file, needs to be updated: %s" -msgstr "E779: ì˜¤ëž˜ëœ .sug 파ì¼, 갱신 í•„ìš”: %s" - -#, c-format -msgid "E780: .sug file is for newer version of Vim: %s" -msgstr "E780: .sug 파ì¼ì´ 새 ë²„ì ¼ì˜ Vim용임: %s" - -#, c-format -msgid "E781: .sug file doesn't match .spl file: %s" -msgstr "E781: .sug 파ì¼ì´ .spl 파ì¼ê³¼ ë§žì§€ 않ìŒ: %s" - -#, c-format -msgid "E782: error while reading .sug file: %s" -msgstr "E782: .sug íŒŒì¼ ì½ê¸° ì—러: %s" - #: ../spell.c:4550 #, c-format msgid "Reading affix file %s ..." @@ -7527,9 +7506,6 @@ msgstr "E446: 커서 ë°‘ì— íŒŒì¼ ì´ë¦„ì´ ì—†ìŠµë‹ˆë‹¤" #~ msgid "Could not fix up function pointers to the DLL!" #~ msgstr "함수 í¬ì¸í„°ë¥¼ DLL로 바꿀 수 없습니다!" -#~ msgid "shell returned %d" -#~ msgstr "ì‰˜ì´ %dì„(를) ëŒë ¤ì£¼ì—ˆìŠµë‹ˆë‹¤" - #~ msgid "Vim: Caught %s event\n" #~ msgstr "ë¹”: %s ì´ë²¤íŠ¸ë¥¼ 잡았습니다\n" -- cgit From bd17fa487d9e0bab8a23c80ed64f4b02a0e3b849 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 02:37:17 +0100 Subject: vim-patch:bf92e3a3719f Update translations. https://github.com/vim/vim/commit/bf92e3a3719f255dbb30102ceb618e0eac7c9497 --- src/nvim/po/de.po | 10 ++++------ src/nvim/po/es.po | 31 ++++++++++++++----------------- src/nvim/po/ga.po | 2 +- src/nvim/po/pl.UTF-8.po | 2 +- src/nvim/po/pt_BR.po | 4 ++-- src/nvim/po/ru.po | 8 +++----- src/nvim/po/sk.cp1250.po | 1 + src/nvim/po/sk.po | 1 + src/nvim/po/uk.po | 1 - 9 files changed, 27 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/nvim/po/de.po b/src/nvim/po/de.po index 751e9aeb4c..b900e19e62 100644 --- a/src/nvim/po/de.po +++ b/src/nvim/po/de.po @@ -377,7 +377,7 @@ msgstr " Definitions-Erg #: ../edit.c:92 msgid " Dictionary completion (^K^N^P)" -msgstr " Wörterbuch-Ergänzung (^K^N^P) " +msgstr " Dictionary-Ergänzung (^K^N^P) " #: ../edit.c:93 msgid " Thesaurus completion (^T^N^P)" @@ -633,6 +633,9 @@ msgstr "" #: ../ex_cmds.c:2433 #, c-format +msgid "Pattern not found: %s" +msgstr "Muster nicht gefunden: %s" + msgid "" "File permissions of \"%s\" are read-only.\n" "It may still be possible to write it.\n" @@ -713,11 +716,6 @@ msgstr "E148: Regul msgid "Pattern found in every line: %s" msgstr "Muster in jeder Zeile gefunden: %s" -#: ../ex_cmds.c:4504 -#, c-format -msgid "Pattern not found: %s" -msgstr "Muster nicht gefunden: %s" - #: ../ex_cmds.c:4581 msgid "" "\n" diff --git a/src/nvim/po/es.po b/src/nvim/po/es.po index ed96e4de94..10b661a5d2 100644 --- a/src/nvim/po/es.po +++ b/src/nvim/po/es.po @@ -1197,7 +1197,7 @@ msgstr "E141: No existe un nombre de archivo para el búfer %" #: ../ex_cmds.c:2412 msgid "E142: File not written: Writing is disabled by 'write' option" msgstr "" -"E142: No se ha escrito el archivo: escritura desactivada por \n" +"E142: No se ha escrito el archivo: escritura desactivada por " "la opción 'write'" #: ../ex_cmds.c:2434 @@ -2209,7 +2209,7 @@ msgstr "es de solo lectura (añada ! para sobreescribir)" #: ../fileio.c:2886 msgid "E506: Can't write to backup file (add ! to override)" msgstr "" -"E506: No se pudo escribir en el archivo de recuperación\n" +"E506: No se pudo escribir en el archivo de recuperación " "(añada ! para forzar la orden)" #: ../fileio.c:2898 @@ -3136,7 +3136,7 @@ msgstr "" #: ../hardcopy.c:2254 msgid "E675: No default font specified for multi-byte printing." msgstr "" -"E675: No se ha definido un tipo de letra predeterminado para impresión\n" +"E675: No se ha definido un tipo de letra predeterminado para impresión " "multi-byte" #: ../hardcopy.c:2426 @@ -3393,7 +3393,7 @@ msgstr "Basura después de la opción" #: ../main.c:152 msgid "Too many \"+command\", \"-c command\" or \"--cmd command\" arguments" msgstr "" -"Demasiados argumentos tales como: \"+orden\", \"-c orden\" \n" +"Demasiados argumentos tales como: \"+orden\", \"-c orden\" " "o \"--cmd orden\"" #: ../main.c:154 @@ -3797,7 +3797,7 @@ msgstr "E302: No pude cambiar el nombre del archivo de intercambio" #, c-format msgid "E303: Unable to open swap file for \"%s\", recovery impossible" msgstr "" -"E303: Incapaz de abrir el archivo de intercambio para %s,\n" +"E303: Incapaz de abrir el archivo de intercambio para %s, " "recuperación imposible" #: ../memline.c:666 @@ -3916,7 +3916,7 @@ msgstr "??? desde aquí hasta ???FIN las líneas pueden estar desordenadas" #: ../memline.c:1164 msgid "??? from here until ???END lines may have been inserted/deleted" msgstr "" -"??? desde aquí hasta ???FIN las líneas pueden haber sido\n" +"??? desde aquí hasta ???FIN las líneas pueden haber sido " "insertadas/borradas" #: ../memline.c:1181 @@ -3931,7 +3931,7 @@ msgstr "E311: Recuperación interrumpida" msgid "" "E312: Errors detected while recovering; look for lines starting with ???" msgstr "" -"E312: Se han detectado errores al recuperar; busque líneas que\n" +"E312: Se han detectado errores al recuperar; busque líneas que " "empiecen con ???" #: ../memline.c:1245 @@ -5382,7 +5382,7 @@ msgstr "E756: La corrección ortográfica está desactivada" #, c-format msgid "Warning: Cannot find word list \"%s.%s.spl\" or \"%s.ascii.spl\"" msgstr "" -"Advertencia: No se pudo hallar la lista de palabras \"%s.%s.spl\" \n" +"Advertencia: No se pudo hallar la lista de palabras \"%s.%s.spl\" " "or \"%s.ascii.spl\"" #: ../spell.c:2473 @@ -5443,8 +5443,7 @@ msgid "" "%d" msgstr "" "Definir COMPOUNDFORBIDFLAG después de un elemento PFX puede dar resultados " -"erróneos\n" -"en %s línea %d" +"erróneos en %s línea %d" #: ../spell.c:4731 #, c-format @@ -5453,8 +5452,7 @@ msgid "" "%d" msgstr "" "Definir COMPOUNDPERMITFLAG después de un ítem PFX puede dar resultados " -"erróneos\n" -"en %s línea %d" +"erróneos en %s línea %d" #: ../spell.c:4747 #, c-format @@ -5485,7 +5483,7 @@ msgstr "Valor equivocado de CHECKCOMPOUNDPATTERN en %s línea %d: %s" #, c-format msgid "Different combining flag in continued affix block in %s line %d: %s" msgstr "" -"Marca de combinación diferente en el bloque de afijos continuo\n" +"Marca de combinación diferente en el bloque de afijos continuo " "en %s línea %d: %s" #: ../spell.c:4850 @@ -5500,8 +5498,7 @@ msgid "" "line %d: %s" msgstr "" "Afijo usado también para BAD/RARE/KEEPCASE/NEEDAFFIX/NEEDCOMPOUND/NOSUGGEST " -"en\n" -"%s línea %d: %s" +"en %s línea %d: %s" #: ../spell.c:4893 #, c-format @@ -5942,7 +5939,7 @@ msgstr "E402: Basura después del patrón: %s" #: ../syntax.c:5120 msgid "E403: syntax sync: line continuations pattern specified twice" msgstr "" -"E403: Sincronización de sintaxis: Se especificó dos veces un\n" +"E403: Sincronización de sintaxis: Se especificó dos veces un " "patrón de continuación de línea" #: ../syntax.c:5169 @@ -6569,7 +6566,7 @@ msgstr "E813: No se puede cerrar la ventana de autocmd" #: ../window.c:1814 msgid "E814: Cannot close window, only autocmd window would remain" msgstr "" -"E814: No se pudo cerrar la última ventana, solo quedará\n" +"E814: No se pudo cerrar la última ventana, solo quedará " "la ventana de autocmd" #: ../window.c:2717 diff --git a/src/nvim/po/ga.po b/src/nvim/po/ga.po index 281af86ba9..d409560f6b 100644 --- a/src/nvim/po/ga.po +++ b/src/nvim/po/ga.po @@ -3457,7 +3457,7 @@ msgid "" "Maybe no changes were made or Vim did not update the swap file." msgstr "" "\n" -"B'fhéidir nach raibh aon athrú á dhéanamh, nó tá an comhad\n" +"B'fhéidir nach raibh aon athrú á dhéanamh, nó tá an comhad " "babhtála as dáta." msgid " cannot be used with this version of Vim.\n" diff --git a/src/nvim/po/pl.UTF-8.po b/src/nvim/po/pl.UTF-8.po index 0757afd3ae..c65602344e 100644 --- a/src/nvim/po/pl.UTF-8.po +++ b/src/nvim/po/pl.UTF-8.po @@ -3550,7 +3550,7 @@ msgstr "" #: ../main.c:2240 msgid "--startuptime \tWrite startup timing messages to " msgstr "" -"--startuptime \n" +"--startuptime " "Zapisz wiadomoÅ›ci o dÅ‚ugoÅ›ci startu do " #: ../main.c:2242 diff --git a/src/nvim/po/pt_BR.po b/src/nvim/po/pt_BR.po index 05986cf097..37942704e7 100644 --- a/src/nvim/po/pt_BR.po +++ b/src/nvim/po/pt_BR.po @@ -6341,8 +6341,8 @@ msgstr "" #: ../main.c:2213 msgid "-S \t\tSource file after loading the first file" msgstr "" -"-S \t\tExecutar o arquivo depois de carregar o\n" -"\t\t\tprimeiro arquivo" +"-S \t\tExecutar o arquivo depois de carregar o " +"primeiro arquivo" #: ../main.c:2214 msgid "-s \tRead Normal mode commands from file " diff --git a/src/nvim/po/ru.po b/src/nvim/po/ru.po index a4668743ba..12022d02c8 100644 --- a/src/nvim/po/ru.po +++ b/src/nvim/po/ru.po @@ -3376,8 +3376,7 @@ msgstr "-t метка редактирование файла Ñ ÑƒÐºÐ°Ð·Ð°Ð½ #: ../main.c:2181 msgid "-q [errorfile] edit file with first error" msgstr "" -"-q [файл-ошибок]\n" -"\t\t\t\t редактирование файла Ñ Ð¿ÐµÑ€Ð²Ð¾Ð¹ ошибкой" +"-q [файл-ошибок] редактирование файла Ñ Ð¿ÐµÑ€Ð²Ð¾Ð¹ ошибкой" #: ../main.c:2187 msgid "" @@ -3479,8 +3478,8 @@ msgstr "-N\t\t\tРежим неполной ÑовмеÑтимоÑти Ñ Vi: 'n #: ../main.c:2215 msgid "-V[N][fname]\t\tBe verbose [level N] [log messages to fname]" msgstr "" -"-V[N][файл]\t\tВыводить дополнительные ÑообщениÑ\n" -"\t\t\t\t[уровень N] [запиÑывать в файл]" +"-V[N][файл]\t\tВыводить дополнительные ÑÐ¾Ð¾Ð±Ñ‰ÐµÐ½Ð¸Ñ " +"[уровень N] [запиÑывать в файл]" #: ../main.c:2216 msgid "-D\t\t\tDebugging mode" @@ -4105,7 +4104,6 @@ msgstr "" #: ../memline.c:3245 msgid " Quit, or continue with caution.\n" msgstr "" -" \n" " Завершите работу или продолжайте Ñ Ð¾ÑторожноÑтью.\n" #: ../memline.c:3246 diff --git a/src/nvim/po/sk.cp1250.po b/src/nvim/po/sk.cp1250.po index 4b1e64bd02..bf205938fa 100644 --- a/src/nvim/po/sk.cp1250.po +++ b/src/nvim/po/sk.cp1250.po @@ -3870,6 +3870,7 @@ msgid "" "You may want to delete the .swp file now.\n" "\n" msgstr "Potom vymažte odkladací súbor s príponou .swp.\n" +"\n" #. use msg() to start the scrolling properly #: ../memline.c:1327 diff --git a/src/nvim/po/sk.po b/src/nvim/po/sk.po index e48a5de927..3c92ec3c34 100644 --- a/src/nvim/po/sk.po +++ b/src/nvim/po/sk.po @@ -3870,6 +3870,7 @@ msgid "" "You may want to delete the .swp file now.\n" "\n" msgstr "Potom vyma¾te odkladací súbor s príponou .swp.\n" +"\n" #. use msg() to start the scrolling properly #: ../memline.c:1327 diff --git a/src/nvim/po/uk.po b/src/nvim/po/uk.po index c66cb2973c..68425073c7 100644 --- a/src/nvim/po/uk.po +++ b/src/nvim/po/uk.po @@ -3528,7 +3528,6 @@ msgid "" msgstr "" "»,\n" " щоб позбутиÑÑ Ñ†ÑŒÐ¾Ð³Ð¾ повідомленнÑ.\n" -"\n" msgid "Swap file \"" msgstr "Файл обміну «" -- cgit From 39fa2782168f0858504e5a13be0a4eaa9bf15b03 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 03:08:41 +0100 Subject: vim-patch:f55e4c867f77 Updated runtime files https://github.com/vim/vim/commit/f55e4c867f774d1f27973d06b07b97c0a4d6b968 --- src/nvim/po/ca.po | 88 ++++++++++++++++++++++++++++++++++--------------------- src/nvim/po/de.po | 6 ++-- 2 files changed, 57 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/nvim/po/ca.po b/src/nvim/po/ca.po index 7d32db9f97..b485b61491 100644 --- a/src/nvim/po/ca.po +++ b/src/nvim/po/ca.po @@ -299,7 +299,7 @@ msgstr "E100: No hi ha cap altre buffer en mode diff" #: ../diff.c:2112 msgid "E101: More than two buffers in diff mode, don't know which one to use" -msgstr "E101: Hi ha més de 2 buffers en mode diff, no se sap quin usar" +msgstr "E101: Hi ha més de 2 buffers en mode diff" #: ../diff.c:2141 #, c-format @@ -1095,7 +1095,7 @@ msgstr "% l #: ../ex_cmds.c:1194 msgid "E135: *Filter* Autocommands must not change current buffer" -msgstr "E135: Les auto-ordres *Filter* no poden canviar el buffer actual" +msgstr "E135: Les ordres automàtiques *Filter* han de no modificar el buffer" #: ../ex_cmds.c:1244 msgid "[No write since last change]\n" @@ -1582,7 +1582,7 @@ msgstr "E605: No s'ha interceptat l'excepci #: ../ex_docmd.c:1085 msgid "End of sourced file" -msgstr "Final del fitxer interpretat" +msgstr "Final de l'script" #: ../ex_docmd.c:1086 msgid "End of function" @@ -1881,7 +1881,7 @@ msgstr "%s s'ha descartat" #: ../ex_eval.c:708 msgid "Exception" -msgstr "Exepció" +msgstr "Excepció" #: ../ex_eval.c:713 msgid "Error and interrupt" @@ -2162,7 +2162,7 @@ msgstr "[ERRORS DE LECTURA]" #: ../fileio.c:2104 msgid "Can't find temp file for conversion" -msgstr "No s'ha trobat el fitxer temporal per la conversió" +msgstr "No s'ha trobat el fitxer temporal per a fer la conversió" #: ../fileio.c:2110 msgid "Conversion with 'charconvert' failed" @@ -2298,7 +2298,7 @@ msgstr "E205: patchmode: no s'ha pogut desar el fitxer original" #: ../fileio.c:3602 msgid "E206: patchmode: can't touch empty original file" -msgstr "E206: patchmode: no s'ha pogut tocar el fitxer original buit" +msgstr "E206: patchmode: no s'ha pogut fer un toc al fitxer original buit" #: ../fileio.c:3616 msgid "E207: Can't delete backup file" @@ -2308,9 +2308,7 @@ msgstr "E207: No s'ha pogut eliminar la c msgid "" "\n" "WARNING: Original file may be lost or damaged\n" -msgstr "" -"\n" -"ATENCIÓ: El fitxer original es pot haver fet malbé\n" +msgstr "\nATENCIÓ: El fitxer original es pot haver perdut o fet malbé\n" #: ../fileio.c:3675 msgid "don't quit the editor until the file is successfully written!" @@ -2460,7 +2458,7 @@ msgstr "" #: ../fileio.c:5065 #, c-format msgid "E462: Could not prepare for reloading \"%s\"" -msgstr "E462: No s'han pogut fer les preparacions per rellegir \"%s\"" +msgstr "E462: No s'han pogut fer les preparacions per a rellegir \"%s\"" #: ../fileio.c:5078 #, c-format @@ -2536,7 +2534,7 @@ msgstr "Executant %s" #: ../fileio.c:7211 #, c-format msgid "autocommand %s" -msgstr "auto-ordre %s" +msgstr "ordre automàtica %s" #: ../fileio.c:7795 msgid "E219: Missing {." @@ -3043,7 +3041,7 @@ msgstr "No hi ha text per imprimir" #: ../hardcopy.c:668 #, c-format msgid "Printing page %d (%d%%)" -msgstr "S'està imprimint la pàgina %d (%d%%)" +msgstr "Imprimint la pàgina %d (%d%%)" #: ../hardcopy.c:680 #, c-format @@ -3057,7 +3055,7 @@ msgstr "S'ha impr #: ../hardcopy.c:740 msgid "Printing aborted" -msgstr "S'ha avortat l'impressió" +msgstr "S'ha avortat la impressió" #: ../hardcopy.c:1365 msgid "E455: Error writing to PostScript output file" @@ -3314,7 +3312,7 @@ msgstr "E609: Error de cscope: %s" #: ../if_cscope.c:2053 msgid "All cscope databases reset" -msgstr "S'han reiniciat totes les bases de dades cscope" +msgstr "S'han restablert totes les bases de dades cscope" #: ../if_cscope.c:2123 msgid "no cscope connections\n" @@ -3517,7 +3515,7 @@ msgstr "-n\t\t\tNo usa fitxers d'intercanvi, nom #: ../main.c:2218 msgid "-r\t\t\tList swap files and exit" -msgstr "-r\t\t\tLlista els fitxers d'intercanvi i surt" +msgstr "-r\t\t\tLlistat dels fitxers d'intercanvi" #: ../main.c:2219 msgid "-r (with file name)\tRecover crashed session" @@ -3549,7 +3547,7 @@ msgstr "-u \t\tUsa en lloc de qualsevol altre .vimrc" #: ../main.c:2226 msgid "--noplugin\t\tDon't load plugin scripts" -msgstr "--noplugin\t\tNo carrega cap plugin" +msgstr "--noplugin\t\tNo carrega plugins" #: ../main.c:2227 msgid "-p[N]\t\tOpen N tab pages (default: one for each file)" @@ -3561,7 +3559,7 @@ msgstr "-o[N]\t\tObre N finestres (per omissi #: ../main.c:2229 msgid "-O[N]\t\tLike -o but split vertically" -msgstr "-O[N]\t\tCom -o però amb divisions verticals" +msgstr "-O[N]\t\tCom -o però amb divisió vertical" #: ../main.c:2230 msgid "+\t\t\tStart at end of file" @@ -3739,7 +3737,7 @@ msgstr "E305: No s'ha trobat el fitxer d'intercanvi de %s" #: ../memline.c:839 msgid "Enter number of swap file to use (0 to quit): " -msgstr "Entreu el número del fitxer d'intercanvi a utilitzar (0 per sortir): " +msgstr "Entreu el número del fitxer .swp a utilitzar (0 per a sortir): " #: ../memline.c:879 #, c-format @@ -3806,6 +3804,30 @@ msgid "E308: Warning: Original file may have been changed" msgstr "E308: Atenció: El fitxer original pot haver canviat" #: ../memline.c:1061 +#, c-format +msgid "Swap file is encrypted: \"%s\"" +msgstr "El fitxer d'intercanvi està xifrat: \"%s\"" + +msgid "" +"\n" +"If you entered a new crypt key but did not write the text file," +msgstr "\nSi vau entrar una nova clau de xifrat però no vau desar el fitxer," + +msgid "" +"\n" +"enter the new crypt key." +msgstr "\nentreu la nova clau." + +msgid "" +"\n" +"If you wrote the text file after changing the crypt key press enter" +msgstr "\nSi vau desar el fitxer després de canviar la clau, premeu Entrar per a" + +msgid "" +"\n" +"to use the same key for text file and swap file" +msgstr "\nusar la mateixa clau per al fitxer de text i per al fitxer d'intercanvi." + #, c-format msgid "E309: Unable to read block 1 from %s" msgstr "E309: No s'ha pogut llegir el bloc 1 de %s" @@ -3931,7 +3953,7 @@ msgstr " [del Vim versi #: ../memline.c:1550 msgid " [does not look like a Vim swap file]" -msgstr " [no sembla un fitxer d'intercanvi de Vim]" +msgstr " [no sembla un fitxer .swp de Vim]" #: ../memline.c:1552 msgid " file name: " @@ -4003,7 +4025,7 @@ msgstr " [no es pot obrir]" #: ../memline.c:1698 msgid "E313: Cannot preserve, there is no swap file" -msgstr "E313: No s'ha pogut preservar, no hi ha fitxer d'intercanvi" +msgstr "E313: No s'ha pogut preservar, no existeix cap fitxer d'intercanvi" #: ../memline.c:1747 msgid "File preserved" @@ -4025,7 +4047,7 @@ msgstr "E316: ml_get: no s'ha trobat la l #: ../memline.c:2236 msgid "E317: pointer block id wrong 3" -msgstr "E317: Punter a la id d'un bloc incorrecte 3" +msgstr "E317: punter a id de bloc incorrecte 3" #: ../memline.c:2311 msgid "stack_idx should be 0" @@ -4037,7 +4059,7 @@ msgstr "E318: S'han actualitzat massa blocs?" #: ../memline.c:2511 msgid "E317: pointer block id wrong 4" -msgstr "E317: Punter a la id d'un bloc incorrecte 4" +msgstr "E317: Punter a id de bloc incorrecte 4" #: ../memline.c:2536 msgid "deleted block 1?" @@ -4087,9 +4109,7 @@ msgstr "E325: ATENCI msgid "" "\n" "Found a swap file by the name \"" -msgstr "" -"\n" -"S'ha trobat un fitxer d'intercanvi de nom \"" +msgstr "\nS'ha trobat un fitxer d'intercanvi amb nom \"" #: ../memline.c:3226 msgid "While opening file \"" @@ -4134,7 +4154,7 @@ msgid "" " to recover the changes (see \":help recovery\").\n" msgstr "" "\"\n" -" per recuperar els canvis (vegeu \":help recovery\").\n" +" per a recuperar els canvis (vegeu \":help recovery\").\n" #: ../memline.c:3250 msgid " If you did this already, delete the swap file \"" @@ -4146,7 +4166,7 @@ msgid "" " to avoid this message.\n" msgstr "" "\"\n" -" per evitar aquest missatge.\n" +" per a evitar aquest missatge.\n" #: ../memline.c:3450 ../memline.c:3452 msgid "Swap file \"" @@ -4172,7 +4192,7 @@ msgid "" "&Quit\n" "&Abort" msgstr "" -"&Obrir només-lectura\n" +"&Obrir amb només lectura\n" "&Editar igualment\n" "&Recuperar\n" "&Sortir\n" @@ -4840,7 +4860,7 @@ msgstr "E377: %%%c no v #. nothing found #: ../quickfix.c:477 msgid "E378: 'errorformat' contains no pattern" -msgstr "E378: L'opció 'errorformat' no conté cap patró" +msgstr "E378: 'errorformat' no conté cap patró" #: ../quickfix.c:695 msgid "E379: Missing or empty directory name" @@ -5234,7 +5254,7 @@ msgstr "S'han trobat tots els fitxers inclosos" #: ../search.c:4519 msgid "No included files" -msgstr "No hi han fitxers inclosos" +msgstr "No hi ha fitxers inclosos" #: ../search.c:4527 msgid "E388: Couldn't find definition" @@ -5605,7 +5625,7 @@ msgstr "Escrivint el fitxer de suggeriments %s ..." #: ../spell.c:7707 ../spell.c:7927 #, c-format msgid "Estimated runtime memory use: %d bytes" -msgstr "Ús estimat de memòria en funcionament: %d octets" +msgstr "Ús estimat de memòria durant l'execució: %d octets" #: ../spell.c:7820 msgid "E751: Output file name must not have region name" @@ -5622,7 +5642,7 @@ msgstr "E755: Regi #: ../spell.c:7907 msgid "Warning: both compounding and NOBREAK specified" -msgstr "Atenció: heu especificat composició i NOBREAK alhora" +msgstr "Atenció: s'ha especificat composició i NOBREAK alhora" #: ../spell.c:7920 #, c-format @@ -6373,7 +6393,7 @@ msgstr " alternativa per a $VIM: \"" # 29 caràcters fins el ":" (inclòs) #: ../version.c:705 msgid " f-b for $VIMRUNTIME: \"" -msgstr " alt per a $VIMRUNTIME: \"" +msgstr " altern. per a $VIMRUNTIME: \"" #: ../version.c:709 msgid "Compilation: " @@ -6401,7 +6421,7 @@ msgstr "per Bram Moolenaar et al." #: ../version.c:774 msgid "Vim is open source and freely distributable" -msgstr "Vim és un programa obert i lliure distribució" +msgstr "Vim és un programa obert i de lliure distribució" #: ../version.c:776 msgid "Help poor children in Uganda!" diff --git a/src/nvim/po/de.po b/src/nvim/po/de.po index b900e19e62..3986a796d8 100644 --- a/src/nvim/po/de.po +++ b/src/nvim/po/de.po @@ -401,7 +401,7 @@ msgstr " Vorschlag der Rechtschreibpr #: ../edit.c:98 msgid " Keyword Local completion (^N^P)" -msgstr " Lokale Schlüsselwort-Ergänzung(^N^P)" +msgstr " Lokale Stichwort-Ergänzung(^N^P)" #: ../edit.c:101 msgid "Hit end of paragraph" @@ -443,7 +443,7 @@ msgstr "Durchsuche: %s" #: ../edit.c:3513 msgid "Scanning tags." -msgstr "Durchsuchen von Tags." +msgstr "Durchsuche Tags" #: ../edit.c:4418 msgid " Adding" @@ -6486,7 +6486,7 @@ msgid "" "\tLast set from " msgstr "" "\n" -"\tZuletzt gesetzt von " +"\tZuletzt gesetzt in " #: ../eval.c:18682 msgid "No old files" -- cgit From 06fd32b8ffc437d596a2d82a986220add4315869 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 7 Nov 2017 18:53:42 +0100 Subject: ui: remove ext_cmdline noise (#7486) Only send cmdline contents once per ui_flush. Don't send extra redraws due to 'arshape', it makes no difference to external ui. --- src/nvim/ex_getln.c | 51 ++++++++++++++++++++++++++++++++++++++++++++------- src/nvim/ui.c | 2 ++ 2 files changed, 46 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 27883997e4..43e7cf457d 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -91,6 +91,13 @@ typedef struct { CmdlineColors colors; ///< Last colors. } ColoredCmdline; +/// Keeps track how much state must be sent to external ui. +typedef enum { + kCmdRedrawNone, + kCmdRedrawPos, + kCmdRedrawAll, +} CmdRedraw; + /* * Variables shared between getcmdline(), redrawcmdline() and others. * These need to be saved when using CTRL-R |, that's why they are in a @@ -120,6 +127,7 @@ struct cmdline_info { struct cmdline_info *prev_ccline; ///< pointer to saved cmdline state char special_char; ///< last putcmdline char (used for redraws) bool special_shift; ///< shift of last putcmdline char + CmdRedraw redraw_state; ///< needed redraw for external cmdline }; /// Last value of prompt_id, incremented when doing new prompt static unsigned last_prompt_id = 0; @@ -423,6 +431,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) ccline.cmdbuff = NULL; if (ui_is_external(kUICmdline)) { + ccline.redraw_state = kCmdRedrawNone; ui_call_cmdline_hide(ccline.level); } ccline.level--; @@ -1816,7 +1825,8 @@ static int command_line_changed(CommandLineState *s) // right-left typing. Not efficient, but it works. // Do it only when there are no characters left to read // to avoid useless intermediate redraws. - if (vpeekc() == NUL) { + // if cmdline is external the ui handles shaping, no redraw needed. + if (!ui_is_external(kUICmdline) && vpeekc() == NUL) { redrawcmd(); } } @@ -2614,7 +2624,7 @@ static void draw_cmdline(int start, int len) if (ui_is_external(kUICmdline)) { ccline.special_char = NUL; - ui_ext_cmdline_show(&ccline); + ccline.redraw_state = kCmdRedrawAll; return; } @@ -2826,7 +2836,7 @@ void cmdline_screen_cleared(void) if (prev_ccline->level == prev_level) { // don't redraw a cmdline already shown in the cmdline window if (prev_level != cmdwin_level) { - ui_ext_cmdline_show(prev_ccline); + prev_ccline->redraw_state = kCmdRedrawAll; } prev_level--; } @@ -2834,6 +2844,28 @@ void cmdline_screen_cleared(void) } } +/// called by ui_flush, do what redraws neccessary to keep cmdline updated. +void cmdline_ui_flush(void) +{ + if (!ui_is_external(kUICmdline)) { + return; + } + int level = ccline.level; + CmdlineInfo *line = &ccline; + while (level > 0 && line) { + if (line->level == level) { + if (line->redraw_state == kCmdRedrawAll) { + ui_ext_cmdline_show(line); + } else if (line->redraw_state == kCmdRedrawPos) { + ui_call_cmdline_pos(line->cmdpos, line->level); + } + line->redraw_state = kCmdRedrawNone; + level--; + } + line = line->prev_ccline; + } +} + /* * Put a character on the command line. Shifts the following text to the * right when "shift" is TRUE. Used for CTRL-V, CTRL-K, etc. @@ -2854,8 +2886,10 @@ void putcmdline(int c, int shift) } else { ccline.special_char = c; ccline.special_shift = shift; - ui_call_cmdline_special_char(cchar_to_string((char)(c)), shift, - ccline.level); + if (ccline.redraw_state != kCmdRedrawAll) { + ui_call_cmdline_special_char(cchar_to_string((char)(c)), shift, + ccline.level); + } } cursorcmd(); ui_cursor_shape(); @@ -3196,7 +3230,7 @@ static void redrawcmdprompt(void) if (cmd_silent) return; if (ui_is_external(kUICmdline)) { - ui_ext_cmdline_show(&ccline); + ccline.redraw_state = kCmdRedrawAll; return; } if (ccline.cmdfirstc != NUL) { @@ -3273,7 +3307,9 @@ static void cursorcmd(void) return; if (ui_is_external(kUICmdline)) { - ui_call_cmdline_pos(ccline.cmdpos, ccline.level); + if (ccline.redraw_state < kCmdRedrawPos) { + ccline.redraw_state = kCmdRedrawPos; + } return; } @@ -5867,6 +5903,7 @@ static int ex_window(void) changed_line_abv_curs(); invalidate_botline(); if (ui_is_external(kUICmdline)) { + ccline.redraw_state = kCmdRedrawNone; ui_call_cmdline_hide(ccline.level); } redraw_later(SOME_VALID); diff --git a/src/nvim/ui.c b/src/nvim/ui.c index afe7a51d43..3b8b3ac9a7 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -14,6 +14,7 @@ #include "nvim/cursor.h" #include "nvim/diff.h" #include "nvim/ex_cmds2.h" +#include "nvim/ex_getln.h" #include "nvim/fold.h" #include "nvim/main.h" #include "nvim/ascii.h" @@ -484,6 +485,7 @@ int ui_current_col(void) void ui_flush(void) { + cmdline_ui_flush(); ui_call_flush(); } -- cgit From 10e5040b61ece408db268e830953047001951a15 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 20:12:44 +0100 Subject: vim-patch:24a98a0eb772 Update runtime files https://github.com/vim/vim/commit/24a98a0eb77245adc50facad8b735b20bfd31a7e --- src/nvim/po/it.po | 9 +++++++++ src/nvim/po/pt_BR.po | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/po/it.po b/src/nvim/po/it.po index 91a68cf1e6..c95faf1dce 100644 --- a/src/nvim/po/it.po +++ b/src/nvim/po/it.po @@ -1417,6 +1417,7 @@ msgstr "E904: l'ultimo argomento per espressione/chiamata dev'essere numerico" msgid "E904: third argument for call must be a list" msgstr "E904: il terzo argomento della chiamata dev'essere una Lista" +#, c-format msgid "E905: received unknown command: %s" msgstr "E905: recevuto comando non conosciuto: %s" @@ -1424,6 +1425,7 @@ msgstr "E905: recevuto comando non conosciuto: %s" msgid "E630: %s(): write while not connected" msgstr "E630: %s(): scrittura in mancanza di connessione" +#, c-format msgid "E631: %s(): write failed" msgstr "E631: %s(): scrittura non riuscita" @@ -4837,6 +4839,7 @@ msgstr "" "\n" "Non posso impostare il contesto di sicurezza per " +#, c-format msgid "E151: No match: %s" msgstr "E151: Nessuna corrispondenza: %s" @@ -5382,6 +5385,12 @@ msgstr "E772: Il file ortografico msgid "E770: Unsupported section in spell file" msgstr "E770: Sezione non supportata nel file ortografico" +msgid "E944: Reverse range in character class" +msgstr "E944: Intervallo invertito nella classe di caratteri" + +msgid "E945: Range too large in character class" +msgstr "E945: Intervallo troppo ampio nella classe di caratteri" + #, c-format msgid "E779: Old .sug file, needs to be updated: %s" msgstr "E779: File .sug obsoleto, è necessario aggiornarlo: %s" diff --git a/src/nvim/po/pt_BR.po b/src/nvim/po/pt_BR.po index 37942704e7..f8d6ac3011 100644 --- a/src/nvim/po/pt_BR.po +++ b/src/nvim/po/pt_BR.po @@ -24,7 +24,7 @@ msgstr "[Ajuda]" #: ../screen.c:4815 ../buffer.c:3244 msgid "[Preview]" -msgstr "[Visualização]" +msgstr "[Visualização]" #: ../screen.c:4823 ../fileio.c:1855 ../buffer.c:2496 ../buffer.c:3207 msgid "[RO]" @@ -4859,7 +4859,7 @@ msgstr " tipo arquivo\n" #: ../ex_getln.c:4762 msgid "'history' option is zero" -msgstr "opção 'history' vale zero" +msgstr "opção 'history' vale zero" #: ../ex_getln.c:5008 #, c-format @@ -6203,7 +6203,7 @@ msgstr "--\t\t\tApenas nomes de arquivo depois daqui" #: ../main.c:2177 msgid "--literal\t\tDon't expand wildcards" -msgstr "--literal\t\tNão expandir caracteres-curinga" +msgstr "--literal\t\tNão expandir caracteres-curinga" #: ../main.c:2179 msgid "-v\t\t\tVi mode (like \"vi\")" @@ -6227,7 +6227,7 @@ msgstr "-d\t\t\tModo diff (como \"vimdiff\")" #: ../main.c:2184 msgid "-y\t\t\tEasy mode (like \"evim\", modeless)" -msgstr "-y\t\t\tModo fácil (como \"evim\", o Vim não modal)" +msgstr "-y\t\t\tModo fácil (como \"evim\", o Vim não modal)" #: ../main.c:2185 msgid "-R\t\t\tReadonly mode (like \"view\")" -- cgit From 4175dfac9a91e30d01e5aec6b45ed81e0288aaf9 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 20:43:11 +0100 Subject: vim-patch:01164a6546b4 Long overdue runtime update. https://github.com/vim/vim/commit/01164a6546b4c635daf96a1f17d1cb2d07f32a66 --- src/nvim/po/eo.po | 188 +++++++++++++++++--------------------------- src/nvim/po/fi.po | 227 ++++++++++++++++++++++++++++++++++++++++++++---------- src/nvim/po/fr.po | 192 +++++++++++++++++---------------------------- 3 files changed, 329 insertions(+), 278 deletions(-) (limited to 'src') diff --git a/src/nvim/po/eo.po b/src/nvim/po/eo.po index 188d86f478..cc0893de3a 100644 --- a/src/nvim/po/eo.po +++ b/src/nvim/po/eo.po @@ -17,8 +17,8 @@ msgid "" msgstr "" "Project-Id-Version: Vim(Esperanto)\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-07-11 23:10+0200\n" -"PO-Revision-Date: 2017-07-12 05:14+0200\n" +"POT-Creation-Date: 2017-10-02 22:42+0200\n" +"PO-Revision-Date: 2017-10-02 22:57+0200\n" "Last-Translator: Dominique PELLÉ \n" "Language-Team: \n" "Language: eo\n" @@ -99,7 +99,6 @@ msgstr "E90: Ne eblas malÅargi la lastan bufron" msgid "E84: No modified buffer found" msgstr "E84: Neniu modifita bufro trovita" -#. back where we started, didn't find anything. msgid "E85: There is no listed buffer" msgstr "E85: Estas neniu listigita bufro" @@ -115,6 +114,18 @@ msgstr "" "E89: Neniu skribo de post la lasta ÅanÄo de la bufro %ld (aldonu ! por " "transpasi)" +msgid "E948: Job still running (add ! to end the job)" +msgstr "E948: Tasko akoraÅ­ aktiva (aldonu ! por fini la taskon)" + +msgid "E37: No write since last change (add ! to override)" +msgstr "E37: Neniu skribo de post lasta ÅanÄo (aldonu ! por transpasi)" + +msgid "E948: Job still running" +msgstr "E948: Tasko ankoraÅ­ aktiva" + +msgid "E37: No write since last change" +msgstr "E37: Neniu skribo de post lasta ÅanÄo" + msgid "W14: Warning: List of file names overflow" msgstr "W14: Averto: Listo de dosiernomoj troas" @@ -170,7 +181,6 @@ msgstr "linio %ld de %ld --%d%%-- kol " msgid "[No Name]" msgstr "[Neniu nomo]" -#. must be a help buffer msgid "help" msgstr "helpo" @@ -196,6 +206,9 @@ msgstr "" "\n" "# Listo de bufroj:\n" +msgid "E382: Cannot write, 'buftype' option is set" +msgstr "E382: Ne eblas skribi, opcio 'buftype' estas Åaltita" + msgid "[Scratch]" msgstr "[Malneto]" @@ -363,7 +376,6 @@ msgstr "E791: Malplena rikordo en klavmapo" msgid " Keyword completion (^N^P)" msgstr " Kompletigo de Ålosilvorto (^N^P)" -#. ctrl_x_mode == 0, ^P/^N compl. msgid " ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)" msgstr " ReÄimo ^X (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)" @@ -442,10 +454,6 @@ msgstr "kongruo en dosiero" msgid " Adding" msgstr " Aldonanta" -#. showmode might reset the internal line pointers, so it must -#. * be called before line = ml_get(), or when this address is no -#. * longer needed. -- Acevedo. -#. msgid "-- Searching..." msgstr "-- Serĉanta..." @@ -466,7 +474,6 @@ msgstr "kongruo %d de %d" msgid "match %d" msgstr "kongruo %d" -#. maximum nesting of lists and dicts msgid "E18: Unexpected characters in :let" msgstr "E18: Neatenditaj signoj en \":let\"" @@ -526,8 +533,6 @@ msgstr "E690: \"in\" mankas malantaÅ­ \":for\"" msgid "E108: No such variable: \"%s\"" msgstr "E108: Ne estas tia variablo: \"%s\"" -#. For historic reasons this error is not given for a list or dict. -#. * E.g., the b: dict could be locked/unlocked. #, c-format msgid "E940: Cannot lock or unlock variable %s" msgstr "E940: Ne eblas Ålosi aÅ­ malÅlosi variablon %s" @@ -700,11 +705,6 @@ msgstr "argumento de add()" msgid "E785: complete() can only be used in Insert mode" msgstr "E785: complete() uzeblas nur en Enmeta reÄimo" -#. -#. * Yes this is ugly, I don't particularly like it either. But doing it -#. * this way has the compelling advantage that translations need not to -#. * be touched at all. See below what 'ok' and 'ync' are used for. -#. msgid "&Ok" msgstr "&Bone" @@ -865,7 +865,6 @@ msgstr " malnovaj dosieroj" msgid " FAILED" msgstr " MALSUKCESIS" -#. avoid a wait_return for this message, it's annoying #, c-format msgid "E137: Viminfo file is not writable: %s" msgstr "E137: Dosiero viminfo ne skribeblas: %s" @@ -886,7 +885,6 @@ msgstr "Skribas dosieron viminfo \"%s\"" msgid "E886: Can't rename viminfo file to %s!" msgstr "E886: Ne eblas renomi dosieron viminfo al %s!" -#. Write the info: #, c-format msgid "# This viminfo file was generated by Vim %s.\n" msgstr "# Tiu dosiero viminfo estis kreita de Vim %s.\n" @@ -1005,7 +1003,6 @@ msgstr " en 1 linio" msgid " on %ld lines" msgstr " en %ld linioj" -#. will increment global_busy to break out of the loop msgid "E147: Cannot do :global recursive with a range" msgstr "E147: Ne eblas fari \":global\" rekursie kun amplekso" @@ -1158,8 +1155,9 @@ msgstr "E750: Uzu unue \":profile start {dosiernomo}\"" msgid "Save changes to \"%s\"?" msgstr "Ĉu konservi ÅanÄojn al \"%s\"?" -msgid "Untitled" -msgstr "Sen titolo" +#, c-format +msgid "E947: Job still running in buffer \"%s\"" +msgstr "E947: Tasko ankoraÅ­ aktiva en la bufro \"%s\"" #, c-format msgid "E162: No write since last change for buffer \"%s\"" @@ -1199,7 +1197,7 @@ msgstr "W20: Pitono versio 2.x bezonata sed nesubtenata, ignoro de dosiero: %s" #, c-format msgid "W21: Required python version 3.x not supported, ignoring file: %s" -msgstr "W21: pitono versio 3.x bezonata sed nesubtenata, ignore de dosiero: %s" +msgstr "W21: pitono versio 3.x bezonata sed nesubtenata, ignoro de dosiero: %s" msgid "Source Vim script" msgstr "Ruli Vim-skripton" @@ -1466,7 +1464,6 @@ msgstr "E189: \"%s\" ekzistas (aldonu ! por transpasi)" msgid "E190: Cannot open \"%s\" for writing" msgstr "E190: Ne eblas malfermi \"%s\" por skribi" -#. set mark msgid "E191: Argument must be a letter or forward/backward quote" msgstr "E191: Argumento devas esti litero, citilo aÅ­ retrocitilo" @@ -1508,13 +1505,15 @@ msgstr "E500: Liveras malplenan ĉenon" msgid "E195: Cannot open viminfo file for reading" msgstr "E195: Ne eblas malfermi dosieron viminfo en lega reÄimo" +msgid "Untitled" +msgstr "Sen titolo" + msgid "E196: No digraphs in this version" msgstr "E196: Neniu duliteraĵo en tiu versio" msgid "E608: Cannot :throw exceptions with 'Vim' prefix" msgstr "E608: Ne eblas lanĉi (:throw) escepton kun prefikso 'Vim'" -#. always scroll up, don't overwrite #, c-format msgid "Exception thrown: %s" msgstr "Escepto lanĉita: %s" @@ -1531,7 +1530,6 @@ msgstr "Escepto ne konservita: %s" msgid "%s, line %ld" msgstr "%s, linio %ld" -#. always scroll up, don't overwrite #, c-format msgid "Exception caught: %s" msgstr "Kaptis escepton: %s" @@ -1557,7 +1555,6 @@ msgstr "Eraro kaj interrompo" msgid "Error" msgstr "Eraro" -#. if (pending & CSTP_INTERRUPT) msgid "Interrupt" msgstr "Interrompo" @@ -1600,15 +1597,12 @@ msgstr "E601: \":try\" ingita tro profunde" msgid "E603: :catch without :try" msgstr "E603: \":catch\" sen \":try\"" -#. Give up for a ":catch" after ":finally" and ignore it. -#. * Just parse. msgid "E604: :catch after :finally" msgstr "E604: \":catch\" malantaÅ­ \":finally\"" msgid "E606: :finally without :try" msgstr "E606: \":finally\" sen \":try\"" -#. Give up for a multiple ":finally" and ignore it. msgid "E607: multiple :finally" msgstr "E607: pluraj \":finally\"" @@ -1701,7 +1695,6 @@ msgstr "Vim: Legado el stdin...\n" msgid "Reading from stdin..." msgstr "Legado el stdin..." -#. Re-opening the original file failed! msgid "E202: Conversion made file unreadable!" msgstr "E202: Konverto igis la dosieron nelegebla!" @@ -1907,9 +1900,6 @@ msgstr "[sen EOL]" msgid "[Incomplete last line]" msgstr "[Nekompleta lasta linio]" -#. don't overwrite messages here -#. must give this prompt -#. don't use emsg() here, don't want to flush the buffers msgid "WARNING: The file has been changed since reading it!!!" msgstr "AVERTO: La dosiero estas ÅanÄita de post kiam Äi estis legita!!!" @@ -1988,7 +1978,6 @@ msgstr "--ForviÅita--" msgid "auto-removing autocommand: %s " msgstr "aÅ­to-forviÅas aÅ­tokomandon: %s " -#. the group doesn't exist #, c-format msgid "E367: No such group: \"%s\"" msgstr "E367: Ne ekzistas tia grupo: \"%s\"" @@ -2011,7 +2000,6 @@ msgstr "E216: Ne estas tia evento: %s" msgid "E216: No such group or event: %s" msgstr "E216: Ne ekzistas tia grupo aÅ­ evento: %s" -#. Highlight title msgid "" "\n" "--- Auto-Commands ---" @@ -2195,18 +2183,15 @@ msgstr "Serĉi kion:" msgid "Replace with:" msgstr "AnstataÅ­igi per:" -#. whole word only button msgid "Match whole word only" msgstr "Kongrui kun nur plena vorto" -#. match case button msgid "Match case" msgstr "Uskleca kongruo" msgid "Direction" msgstr "Direkto" -#. 'Up' and 'Down' buttons msgid "Up" msgstr "Supren" @@ -2285,8 +2270,6 @@ msgstr "Trovi ĉenon (uzu '\\\\' por trovi '\\')" msgid "Find & Replace (use '\\\\' to find a '\\')" msgstr "Trovi kaj anstataÅ­igi (uzu '\\\\' por trovi '\\')" -#. We fake this: Use a filter that doesn't select anything and a default -#. * file name that won't be used. msgid "Not Used" msgstr "Ne uzata" @@ -2360,7 +2343,6 @@ msgstr "Vim - Elektilo de tiparo" msgid "Name:" msgstr "Nomo:" -#. create toggle button msgid "Show size in Points" msgstr "Montri grandon en punktoj" @@ -2606,7 +2588,6 @@ msgstr "E261: konekto cscope %s netrovita" msgid "cscope connection %s closed" msgstr "konekto cscope %s fermita" -#. should not reach here msgid "E570: fatal error in cs_manage_matches" msgstr "E570: neriparebla eraro en cs_manage_matches" @@ -2768,7 +2749,6 @@ msgstr "nevalida numero de bufro" msgid "not implemented yet" msgstr "ankoraÅ­ ne realigita" -#. ??? msgid "cannot set line(s)" msgstr "ne eblas meti la linio(j)n" @@ -2809,7 +2789,6 @@ msgid "" msgstr "" "ne eblas registri postalvokan komandon: bufro/fenestro estas jam forviÅiÄanta" -#. This should never happen. Famous last word? msgid "" "E280: TCL FATAL ERROR: reflist corrupt!? Please report this to vim-dev@vim." "org" @@ -2913,7 +2892,6 @@ msgstr "Vim: Averto: Eligo ne estas al terminalo\n" msgid "Vim: Warning: Input is not from a terminal\n" msgstr "Vim: Averto: Enigo ne estas el terminalo\n" -#. just in case.. msgid "pre-vimrc command line" msgstr "komanda linio pre-vimrc" @@ -3179,6 +3157,9 @@ msgstr "" msgid "-i \t\tUse instead of .viminfo" msgstr "-i \t\tUzi anstataÅ­ .viminfo" +msgid "--clean\t\t'nocompatible', Vim defaults, no plugins, no viminfo" +msgstr "--clean\t\t'nocompatible', defaÅ­ltaj agordoj de Vim, neniu viminfo" + msgid "-h or --help\tPrint Help (this message) and exit" msgstr "-h aÅ­ --help\tAfiÅi Helpon (tiun mesaÄon) kaj eliri" @@ -3279,11 +3260,9 @@ msgstr "--windowid \tMalfermi Vim en alia win32 fenestraĵo" msgid "No display" msgstr "Neniu ekrano" -#. Failed to send, abort. msgid ": Send failed.\n" msgstr ": Sendo malsukcesis.\n" -#. Let vim start normally. msgid ": Send failed. Trying to execute locally\n" msgstr ": Sendo malsukcesis. Provo de loka plenumo\n" @@ -3304,7 +3283,6 @@ msgstr "Neniu marko" msgid "E283: No marks matching \"%s\"" msgstr "E283: Neniu marko kongruas kun \"%s\"" -#. Highlight title msgid "" "\n" "mark line col file/text" @@ -3312,7 +3290,6 @@ msgstr "" "\n" "mark linio kol dosiero/teksto" -#. Highlight title msgid "" "\n" " jump line col file/text" @@ -3320,7 +3297,6 @@ msgstr "" "\n" " salt linio kol dosiero/teksto" -#. Highlight title msgid "" "\n" "change line col text" @@ -3335,7 +3311,6 @@ msgstr "" "\n" "# Markoj de dosiero:\n" -#. Write the jumplist with -' msgid "" "\n" "# Jumplist (newest first):\n" @@ -3405,7 +3380,6 @@ msgstr "E298: Ĉu ne akiris blokon n-ro 2?" msgid "E843: Error while updating swap file crypt" msgstr "E843: Eraro dum Äisdatigo de ĉifrada permutodosiero .swp" -#. could not (re)open the swap file, what can we do???? msgid "E301: Oops, lost the swap file!!!" msgstr "E301: Ve, perdis la permutodosieron .swp!!!" @@ -3589,7 +3563,6 @@ msgid "Using crypt key from swap file for the text file.\n" msgstr "" "Uzas Ålosilon de ĉifrado el permuto dosiero .swp por la teksta dosiero.\n" -#. use msg() to start the scrolling properly msgid "Swap files found:" msgstr "Permutodosiero .swp trovita:" @@ -3759,8 +3732,6 @@ msgstr "Dum malfermo de dosiero \"" msgid " NEWER than swap file!\n" msgstr " PLI NOVA ol permutodosiero .swp!\n" -#. Some of these messages are long to allow translation to -#. * other languages. msgid "" "\n" "(1) Another program may be editing the same file. If this is the case,\n" @@ -3850,7 +3821,6 @@ msgstr "E328: Menuo nur ekzistas en alia reÄimo" msgid "E329: No menu \"%s\"" msgstr "E329: Neniu menuo \"%s\"" -#. Only a mnemonic or accelerator is not valid. msgid "E792: Empty menu name" msgstr "E792: Malplena nomo de menuo" @@ -3863,8 +3833,6 @@ msgstr "E331: Aldono de menueroj direkte al menuzono estas malpermesita" msgid "E332: Separator cannot be part of a menu path" msgstr "E332: Disigilo ne rajtas esti ero de vojo de menuo" -#. Now we have found the matching menu, and we list the mappings -#. Highlight title msgid "" "\n" "--- Menus ---" @@ -3875,6 +3843,10 @@ msgstr "" msgid "Tear off this menu" msgstr "Disigi tiun menuon" +#, c-format +msgid "E335: Menu not defined for %s mode" +msgstr "E335: Menuo ne estas difinita por reÄimo %s" + msgid "E333: Menu path must lead to a menu item" msgstr "E333: Vojo de menuo devas konduki al menuero" @@ -3882,10 +3854,6 @@ msgstr "E333: Vojo de menuo devas konduki al menuero" msgid "E334: Menu not found: %s" msgstr "E334: Menuo netrovita: %s" -#, c-format -msgid "E335: Menu not defined for %s mode" -msgstr "E335: Menuo ne estas difinita por reÄimo %s" - msgid "E336: Menu path must lead to a sub-menu" msgstr "E336: Vojo de menuo devas konduki al sub-menuo" @@ -3957,7 +3925,6 @@ msgstr "Dialogujo de dosiera konservo" msgid "Open File dialog" msgstr "Dialogujo de dosiera malfermo" -#. TODO: non-GUI file selector here msgid "E338: Sorry, no file browser in console mode" msgstr "E338: BedaÅ­rinde ne estas dosierfoliumilo en konzola reÄimo" @@ -4125,7 +4092,9 @@ msgid "E663: At end of changelist" msgstr "E663: Ĉe fino de ÅanÄlisto" msgid "Type :qa! and press to abandon all changes and exit Vim" -msgstr "Tajpu :qa! kaj premu por forlasi ĉiujn ÅanÄojn kaj eliri el Vim" +msgstr "" +"Tajpu :qa! kaj premu por forlasi ĉiujn ÅanÄojn kaj eliri el " +"Vim" #, c-format msgid "1 line %sed 1 time" @@ -4157,7 +4126,6 @@ msgstr "%ld linioj krommarÄenitaj " msgid "E748: No previously used register" msgstr "E748: Neniu reÄistro antaÅ­e uzata" -#. must display the prompt msgid "cannot yank; delete anyway" msgstr "ne eblas kopii; tamen forviÅi" @@ -4172,25 +4140,30 @@ msgstr "%ld linioj ÅanÄitaj" msgid "freeing %ld lines" msgstr "malokupas %ld liniojn" -msgid "block of 1 line yanked" -msgstr "bloko de 1 linio kopiita" +#, c-format +msgid " into \"%c" +msgstr " en \"%c" + +#, c-format +msgid "block of 1 line yanked%s" +msgstr "bloko de 1 linio kopiita%s" -msgid "1 line yanked" -msgstr "1 linio kopiita" +#, c-format +msgid "1 line yanked%s" +msgstr "1 linio kopiita%s" #, c-format -msgid "block of %ld lines yanked" -msgstr "bloko de %ld linioj kopiita" +msgid "block of %ld lines yanked%s" +msgstr "bloko de %ld linioj kopiita%s" #, c-format -msgid "%ld lines yanked" -msgstr "%ld linioj kopiitaj" +msgid "%ld lines yanked%s" +msgstr "%ld linioj kopiitaj%s" #, c-format msgid "E353: Nothing in register %s" msgstr "E353: Nenio en reÄistro %s" -#. Highlight title msgid "" "\n" "--- Registers ---" @@ -4251,9 +4224,6 @@ msgstr "" msgid "(+%ld for BOM)" msgstr "(+%ld por BOM)" -msgid "%<%f%h%m%=Page %N" -msgstr "%<%f%h%m%=Folio %N" - msgid "Thanks for flying Vim" msgstr "Dankon pro flugi per Vim" @@ -4361,6 +4331,9 @@ msgstr "E541: tro da elementoj" msgid "E542: unbalanced groups" msgstr "E542: misekvilibraj grupoj" +msgid "E946: Cannot make a terminal with running job modifiable" +msgstr "E946: Ne eblas igi modifebla terminalon kun aktiva tasko" + msgid "E590: A preview window already exists" msgstr "E590: AntaÅ­vida fenestro jam ekzistas" @@ -4379,9 +4352,6 @@ msgstr "E594: Bezonas almenaÅ­ %d kolumnojn" msgid "E355: Unknown option: %s" msgstr "E355: Nekonata opcio: %s" -#. There's another character after zeros or the string -#. * is empty. In both cases, we are trying to set a -#. * num option using a string. #, c-format msgid "E521: Number required: &%s = '%s'" msgstr "E521: Nombro bezonata: &%s = '%s'" @@ -4454,7 +4424,6 @@ msgstr "ne eblas ÅanÄi reÄimon de konzolo?!\n" msgid "mch_get_shellsize: not a console??\n" msgstr "mch_get_shellsize: ne estas konzolo??\n" -#. if Vim opened a window: Executing a shell may cause crashes msgid "E360: Cannot execute shell with -f option" msgstr "E360: Ne eblas plenumi Åelon kun opcio -f" @@ -4680,7 +4649,6 @@ msgstr "E376: Nevalida %%%c en prefikso de formata ĉeno" msgid "E377: Invalid %%%c in format string" msgstr "E377: Nevalida %%%c en formata ĉeno" -#. nothing found msgid "E378: 'errorformat' contains no pattern" msgstr "E378: 'errorformat' enhavas neniun Åablonon" @@ -4719,9 +4687,6 @@ msgstr "E381: Ĉe la supro de stako de rapidriparo" msgid "No entries" msgstr "Neniu ano" -msgid "E382: Cannot write, 'buftype' option is set" -msgstr "E382: Ne eblas skribi, opcio 'buftype' estas Åaltita" - msgid "Error file" msgstr "Erara Dosiero" @@ -4869,7 +4834,6 @@ msgstr "E867: (NFA) Nekonata operatoro '\\z%c'" msgid "E867: (NFA) Unknown operator '\\%%%c'" msgstr "E867: (NFA) Nekonata operatoro '\\%%%c'" -#. should never happen msgid "E868: Error building NFA with equivalence class!" msgstr "E868: Eraro dum prekomputado de NFA kun ekvivalentoklaso!" @@ -4880,13 +4844,11 @@ msgstr "E869: (NFA) Nekonata operatoro '\\@%c'" msgid "E870: (NFA regexp) Error reading repetition limits" msgstr "E870: (NFS-regulesprimo) Eraro dum legado de limoj de ripeto" -#. Can't have a multi follow a multi. msgid "E871: (NFA regexp) Can't have a multi follow a multi !" msgstr "" "E871: (NFA-regulesprimo) Ne povas havi mult-selekton tuj post alia mult-" "selekto!" -#. Too many `(' msgid "E872: (NFA regexp) Too many '('" msgstr "E872: (NFA-regulesprimo) tro da '('" @@ -4907,7 +4869,7 @@ msgstr "" "statoj en la staplo" msgid "E876: (NFA regexp) Not enough space to store the whole NFA " -msgstr "E876: (NFA-regulesprimo) ne sufiĉa spaco por enmomorigi la tutan NFA " +msgstr "E876: (NFA-regulesprimo) ne sufiĉa spaco por enmemorigi la tutan NFA " msgid "E878: (NFA) Could not allocate memory for branch traversal!" msgstr "E878: (NFA) Ne povis asigni memoron por traigi branĉojn!" @@ -4994,7 +4956,6 @@ msgstr "E386: Atendis '?' aÅ­ '/' malantaÅ­ ';'" msgid " (includes previously listed match)" msgstr " (enhavas antaÅ­e listigitajn kongruojn)" -#. cursor at status line msgid "--- Included files " msgstr "--- Inkluzivitaj dosieroj " @@ -5071,8 +5032,6 @@ msgstr "BedaÅ­rinde ne estas sugestoj" msgid "Sorry, only %ld suggestions" msgstr "BedaÅ­rinde estas nur %ld sugestoj" -#. for when 'cmdheight' > 1 -#. avoid more prompt #, c-format msgid "Change \"%.*s\" to:" msgstr "AnstataÅ­igi \"%.*s\" per:" @@ -5354,10 +5313,6 @@ msgstr "Densigis %d de %d nodoj; %d (%d%%) restantaj" msgid "Reading back spell file..." msgstr "Relegas la dosieron de literumo..." -#. -#. * Go through the trie of good words, soundfold each word and add it to -#. * the soundfold trie. -#. msgid "Performing soundfolding..." msgstr "Fonetika analizado..." @@ -5412,8 +5367,6 @@ msgstr "Vorto '%.*s' aldonita al %s" msgid "E763: Word characters differ between spell files" msgstr "E763: Signoj de vorto malsamas tra literumaj dosieroj" -#. This should have been checked when generating the .spl -#. * file. msgid "E783: duplicate char in MAP entry" msgstr "E783: ripetita signo en rikordo MAP" @@ -5443,7 +5396,8 @@ msgid "syntax spell notoplevel" msgstr "sen literumado en teksto sen sintaksa grupo" msgid "syntax spell default" -msgstr "literumado en teksto sen sintaksa grupo, nur se ne estas @Spell aÅ­ @NoSpell" +msgstr "" +"literumado en teksto sen sintaksa grupo, nur se ne estas @Spell aÅ­ @NoSpell" msgid "syntax iskeyword " msgstr "sintakso iskeyword " @@ -5680,7 +5634,6 @@ msgstr "E428: Ne eblas iri preter lastan kongruan etikedon" msgid "File \"%s\" does not exist" msgstr "La dosiero \"%s\" ne ekzistas" -#. Give an indication of the number of matching tags #, c-format msgid "tag %d of %d%s" msgstr "etikedo %d de %d%s" @@ -5695,7 +5648,6 @@ msgstr " Uzo de etikedo kun malsama uskleco!" msgid "E429: File \"%s\" does not exist" msgstr "E429: Dosiero \"%s\" ne ekzistas" -#. Highlight title msgid "" "\n" " # TO tag FROM line in file/text" @@ -5726,7 +5678,6 @@ msgstr "AntaÅ­ bajto %ld" msgid "E432: Tags file not sorted: %s" msgstr "E432: Etikeda dosiero ne estas ordigita: %s" -#. never opened any tags file msgid "E433: No tags file" msgstr "E433: Neniu etikeda dosiero" @@ -5762,7 +5713,6 @@ msgstr "E436: Neniu rikordo \"%s\" en termcap" msgid "E437: terminal capability \"cm\" required" msgstr "E437: kapablo de terminalo \"cm\" bezonata" -#. Highlight title msgid "" "\n" "--- Terminal keys ---" @@ -5773,6 +5723,21 @@ msgstr "" msgid "Cannot open $VIMRUNTIME/rgb.txt" msgstr "Ne povas malfermi $VIMRUNTIME/rgb.txt" +msgid "Terminal" +msgstr "Terminalo" + +msgid "Terminal-finished" +msgstr "Terminalo-finiÄis" + +msgid "active" +msgstr "aktiva" + +msgid "running" +msgstr "ruliÄas" + +msgid "finished" +msgstr "finiÄis" + msgid "new shell started\n" msgstr "nova Åelo lanĉita\n" @@ -5782,12 +5747,9 @@ msgstr "Vim: Eraro dum legado de eniro, elironta...\n" msgid "Used CUT_BUFFER0 instead of empty selection" msgstr "Uzis CUT_BUFFER0 anstataÅ­ malplenan apartigon" -#. This happens when the FileChangedRO autocommand changes the -#. * file in a way it becomes shorter. msgid "E881: Line count changed unexpectedly" msgstr "E881: Nombro de linioj ÅanÄiÄis neatendite" -#. must display the prompt msgid "No undo possible; continue anyway" msgstr "Malfaro neebla; tamen daÅ­rigi" @@ -6421,7 +6383,6 @@ msgstr "Kompari per Vim" msgid "Edit with &Vim" msgstr "Redakti per &Vim" -#. Now concatenate msgid "Edit with existing Vim - " msgstr "Redakti per ekzistanta Vim - " @@ -6440,10 +6401,6 @@ msgstr "Serĉvojo estas tro longa!" msgid "--No lines in buffer--" msgstr "--Neniu linio en bufro--" -#. -#. * The error messages that can be shared are included here. -#. * Excluded are errors that are only used once and debugging messages. -#. msgid "E470: Command aborted" msgstr "E470: komando ĉesigita" @@ -6629,12 +6586,6 @@ msgstr "E484: Ne eblas malfermi dosieron %s" msgid "E485: Can't read file %s" msgstr "E485: Ne eblas legi dosieron %s" -msgid "E37: No write since last change (add ! to override)" -msgstr "E37: Neniu skribo de post lasta ÅanÄo (aldonu ! por transpasi)" - -msgid "E37: No write since last change" -msgstr "E37: Neniu skribo de post lasta ÅanÄo" - msgid "E38: Null argument" msgstr "E38: Nula argumento" @@ -6914,7 +6865,6 @@ msgstr "konstruilo de listo ne akceptas Ålosilvortajn argumentojn" msgid "list index out of range" msgstr "indekso de listo ekster limoj" -#. No more suitable format specifications in python-2.3 #, c-format msgid "internal error: failed to get vim list item %d" msgstr "interna eraro: obteno de vim-a listero %d malsukcesis" diff --git a/src/nvim/po/fi.po b/src/nvim/po/fi.po index 3551c07ff2..ce15cf076c 100644 --- a/src/nvim/po/fi.po +++ b/src/nvim/po/fi.po @@ -1,6 +1,6 @@ # Finnish translation for Vim. # Copyright (C) 2003-2006 Free Software Foundation, Inc. -# 2007-2016, Flammie Pirinen +# 2007-2018, Flammie Pirinen # # Jargonia ei ole yritetty suotta kotoperäistää missä teknisempi lainasanasto # tulee paremmin kyseeseen. @@ -277,6 +277,9 @@ msgstr "E83: Puskuria ei voitu varata, käytetään toista..." #~ msgid "E937: Attempt to delete a buffer that is in use" #~ msgstr "E934: Ei voida hypätä puskuriin jolla ei ole nimeä" +msgid "E937: Attempt to delete a buffer that is in use" +msgstr "E937: Ei voida poistaa puskuria joka on käytössä" + msgid "E515: No buffers were unloaded" msgstr "E515: Puskureita ei vapautettu" @@ -313,7 +316,6 @@ msgstr "E90: Ei voi vapauttaa viimeistä puskuria" msgid "E84: No modified buffer found" msgstr "E84: Ei muokattuja puskureita" -#. back where we started, didn't find anything. msgid "E85: There is no listed buffer" msgstr "E85: Luetteloitua puskuria ei ole" @@ -390,7 +392,6 @@ msgstr "1 rivi --%d %%--" msgid "[No Name]" msgstr "[Nimetön]" -#. must be a help buffer msgid "help" msgstr "ohje" @@ -411,6 +412,9 @@ msgstr "Loppu" msgid "Top" msgstr "Alku" +msgid "E382: Cannot write, 'buftype' option is set" +msgstr "E382: Ei voi kirjoittaa, buftype asetettu" + msgid "[Scratch]" msgstr "[Raapust]" @@ -495,7 +499,6 @@ msgstr "E791: Tyhjä keymap-kenttä" msgid " Keyword completion (^N^P)" msgstr " Avainsanatäydennys (^N^P)" -#. ctrl_x_mode == 0, ^P/^N compl. msgid " ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)" msgstr " ^X-tila (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)" @@ -567,13 +570,12 @@ msgstr "Luetaan: %s" msgid "Scanning tags." msgstr "Luetaan tägejä." +msgid "match in file" +msgstr "täsmäys tiedostossa" + msgid " Adding" msgstr " Lisätään" -#. showmode might reset the internal line pointers, so it must -#. * be called before line = ml_get(), or when this address is no -#. * longer needed. -- Acevedo. -#. msgid "-- Searching..." msgstr "-- Haetaan..." @@ -1346,6 +1348,10 @@ msgstr "E737: Avain on jo olemassa: %s" #~ msgid "tv_clear() argument" #~ msgstr "filter()-argumentti" +#, c-format +msgid "E940: Cannot lock or unlock variable %s" +msgstr "E940: Muuttujaa %s ei voi lukita tai avata" + msgid "E743: variable nested too deep for (un)lock" msgstr "E743: muuttujassa liian monta tasoa lukituksen käsittelyyn" @@ -1418,6 +1424,156 @@ msgstr "E907: Käytettiin erikoisarvoa Floattina" msgid "E808: Number or Float required" msgstr "E808: Number tai Float vaaditaan" +msgid "Entering Debug mode. Type \"cont\" to continue." +msgstr "Siirrytään vianetsintätilaan, kirjoita cont jatkaaksesi." + +#, c-format +msgid "line %ld: %s" +msgstr "rivi %ld: %s" + +#, c-format +msgid "cmd: %s" +msgstr "kmnt: %s" + +msgid "frame is zero" +msgstr "kehys on nolla" + +#, c-format +msgid "frame at highest level: %d" +msgstr "kehys ylimmällä tasolla: %d" + +#, c-format +msgid "Breakpoint in \"%s%s\" line %ld" +msgstr "Katkaisukohta %s%s rivillä %ld" + +#, c-format +msgid "E161: Breakpoint not found: %s" +msgstr "E161: Katkaisukohta puuttuu: %s" + +msgid "No breakpoints defined" +msgstr "Ei katkaisukohtia" + +#, c-format +msgid "%3d %s %s line %ld" +msgstr "%3d %s %s rivi %ld" + +msgid "E750: First use \":profile start {fname}\"" +msgstr "E750: Aloita käskyllä :profile start {fname}" + +msgid "Save As" +msgstr "Tallenna nimellä" + +#, c-format +msgid "Save changes to \"%s\"?" +msgstr "Tallennetaanko muutokset tiedostoon %s?" + +#, c-format +msgid "E947: Job still running in buffer \"%s\"" +msgstr "E947: Komento on vielä käynnissä puskurissa \"%s\"" + +#, c-format +msgid "E162: No write since last change for buffer \"%s\"" +msgstr "E162: Muutoksia ei ole kirjoitettu puskurin %s viime muutoksen jälkeen" + +msgid "Warning: Entered other buffer unexpectedly (check autocommands)" +msgstr "Varoitus: Puskuri vaihtui odottamatta (tarkista autocommands)" + +msgid "E163: There is only one file to edit" +msgstr "E163: Vain yksi tiedosto muokattavana" + +msgid "E164: Cannot go before first file" +msgstr "E164: Ensimmäisen tiedoston ohi ei voi mennä" + +msgid "E165: Cannot go beyond last file" +msgstr "E165: Viimeisen tiedoston ohi ei voi mennä" + +#, c-format +msgid "E666: compiler not supported: %s" +msgstr "E666: kääntäjää ei tueta: %s" + +#, c-format +msgid "Searching for \"%s\" in \"%s\"" +msgstr "Etsitään ilmausta %s kohteesta %s" + +#, c-format +msgid "Searching for \"%s\"" +msgstr "Etsitään ilmausta %s" + +#, c-format +msgid "not found in '%s': \"%s\"" +msgstr "'%s' ei löydy kohteesta: %s" + +#, c-format +msgid "W20: Required python version 2.x not supported, ignoring file: %s" +msgstr "W20: Vaadittu python-versio 2.x ei ole tuettu. Ohitetaan: %s" + +#, c-format +msgid "W21: Required python version 3.x not supported, ignoring file: %s" +msgstr "W21: Vaadittu python-versio 3.x ei ole tuettu. Ohitetaan: %s" + +msgid "Source Vim script" +msgstr "Lataa vim-skripti" + +#, c-format +msgid "Cannot source a directory: \"%s\"" +msgstr "Hakemistoa ei voi ladata: %s" + +#, c-format +msgid "could not source \"%s\"" +msgstr "ei voitu ladata %s" + +#, c-format +msgid "line %ld: could not source \"%s\"" +msgstr "rivi %ld: ei voitu ladata %s" + +#, c-format +msgid "sourcing \"%s\"" +msgstr "ladataan %s" + +#, c-format +msgid "line %ld: sourcing \"%s\"" +msgstr "rivi %ld: ladataan %s" + +#, c-format +msgid "finished sourcing %s" +msgstr "ladattu %s" + +#, c-format +msgid "continuing in %s" +msgstr "jatkaa kohdassa %s" + +msgid "modeline" +msgstr "mode-rivi" + +msgid "--cmd argument" +msgstr "--cmd-argumentti" + +msgid "-c argument" +msgstr "-c-argumentti" + +msgid "environment variable" +msgstr "ympäristömuuttuja" + +msgid "error handler" +msgstr "virhekäsittelin" + +msgid "W15: Warning: Wrong line separator, ^M may be missing" +msgstr "W15: Varoitus: Väärä rivierotin, ^M saattaa puuttua" + +msgid "E167: :scriptencoding used outside of a sourced file" +msgstr "E167: :scriptencoding ladatun tiedoston ulkopuolella" + +msgid "E168: :finish used outside of a sourced file" +msgstr "E168: :finish ladatun tiedoston ulkopuolella" + +#, c-format +msgid "Current %slanguage: \"%s\"" +msgstr "Käytössä oleva %skieli: %s" + +#, c-format +msgid "E197: Cannot set language to \"%s\"" +msgstr "E197: Kieleksi ei voitu asettaa kieltä %s" + # puhutaan merkin ulkoasusta snprintf(..., c, c, c, c) #, c-format msgid "<%s>%s%s %d, Hex %02x, Octal %03o" @@ -1545,7 +1701,7 @@ msgstr " 1 rivillä" #~ msgid " on % lines" #~ msgstr " %ld rivillä" -msgid "E147: Cannot do :global recursive" +msgid "E147: Cannot do :global recursive with a range" msgstr "E147: :globalia ei voi suorittaa rekursiivisesti" msgid "E148: Regular expression missing from global" @@ -1574,6 +1730,10 @@ msgstr "E149: ei löydy ohjetta kohteelle %s" msgid "Sorry, help file \"%s\" not found" msgstr "ohjetiedostoa %s ei löydy" +#, c-format +msgid "E151: No match: %s" +msgstr "E151: Ei täsmää: %s" + #, c-format msgid "E152: Cannot open %s for writing" msgstr "E152: Ei voi avata tiedostoa %s kirjoittamista varten" @@ -1926,7 +2086,6 @@ msgstr "E189: %s on jo olemassa (lisää komentoon ! ohittaaksesi)" msgid "E190: Cannot open \"%s\" for writing" msgstr "E190: Tiedostoa %s ei voitu avata kirjoittamista varten" -#. set mark msgid "E191: Argument must be a letter or forward/backward quote" msgstr "E191: Argumentin eteen- tai taaksepäin lainaukseen pitää olla kirjain" @@ -1979,7 +2138,6 @@ msgstr "Poikkeus poistettu: %s" #~ msgid "%s, line %" #~ msgstr "%s, rivi %ld" -#. always scroll up, don't overwrite #, c-format msgid "Exception caught: %s" msgstr "Poikkeus otettu kiinni: %s" @@ -2005,7 +2163,6 @@ msgstr "Virhe ja keskeytys" msgid "Error" msgstr "Virhe" -#. if (pending & CSTP_INTERRUPT) msgid "Interrupt" msgstr "Keskeytys" @@ -2048,15 +2205,12 @@ msgstr "E601: liian monta tasoa :try-komennossa" msgid "E603: :catch without :try" msgstr "E603: :catch ilman komentoa :try" -#. Give up for a ":catch" after ":finally" and ignore it. -#. * Just parse. msgid "E604: :catch after :finally" msgstr "E604: :catch ilman komentoa :finally" msgid "E606: :finally without :try" msgstr "E606: :finally ilman komentoa :try" -#. Give up for a multiple ":finally" and ignore it. msgid "E607: multiple :finally" msgstr "E607: :finally monta kertaa" @@ -2147,7 +2301,6 @@ msgstr "" msgid "E201: *ReadPre autocommands must not change current buffer" msgstr "E201: *ReadPre-autocommand-komennot eivät saa muuttaa puskuria" -#. Re-opening the original file failed! msgid "E202: Conversion made file unreadable!" msgstr "E202: Muunnos teki tiedostosta lukukelvottoman." @@ -2469,7 +2622,6 @@ msgstr "E216: Eventtiä ei ole: %s" msgid "E216: No such group or event: %s" msgstr "E216: Ryhmää tai eventtiä ei ole: %s" -#. Highlight title msgid "" "\n" "--- Auto-Commands ---" @@ -3113,7 +3265,6 @@ msgstr "E261: cscope-yhteys %s puuttuu" msgid "cscope connection %s closed" msgstr "cscope-yhteys %s on katkaistu" -#. should not reach here msgid "E570: fatal error in cs_manage_matches" msgstr "E570: kriittinen virhe cs_manage_matches-funktiossa" @@ -3176,7 +3327,6 @@ msgstr "Vim: Varoitus: Tuloste ei mene terminaalille\n" msgid "Vim: Warning: Input is not from a terminal\n" msgstr "Vim: Varoitus: Syöte ei tule terminaalilta\n" -#. just in case.. msgid "pre-vimrc command line" msgstr "esi-vimrc-komentorivi" @@ -3394,7 +3544,6 @@ msgstr "Ei asetettuja merkkejä" msgid "E283: No marks matching \"%s\"" msgstr "E283: Mikään merkki ei täsmää ilmaukseen \"%s\"" -#. Highlight title msgid "" "\n" "mark line col file/text" @@ -3402,7 +3551,6 @@ msgstr "" "\n" "merkki rivi sarake tiedosto/teksti" -#. Highlight title msgid "" "\n" " jump line col file/text" @@ -3410,7 +3558,6 @@ msgstr "" "\n" "hyppy rivi sarake tiedosto/teksti" -#. Highlight title msgid "" "\n" "change line col text" @@ -3445,7 +3592,6 @@ msgstr "E298: Lohko 1:tä ei saatu?" msgid "E298: Didn't get block nr 2?" msgstr "E298: Lohko 2:ta ei saatu?" -#. could not (re)open the swap file, what can we do???? msgid "E301: Oops, lost the swap file!!!" msgstr "E301: Hups, swap-tiedosto hävisi!" @@ -3585,7 +3731,6 @@ msgstr "" "Voit poistaa .swp-tiedosto nyt.\n" "\n" -#. use msg() to start the scrolling properly msgid "Swap files found:" msgstr "Swap-tiedostoja löytyi:" @@ -3751,8 +3896,6 @@ msgstr "Avattaessa tiedostoa " msgid " NEWER than swap file!\n" msgstr " joka on UUDEMPI kuin swap-tiedosto!\n" -#. Some of these messages are long to allow translation to -#. * other languages. msgid "" "\n" "(1) Another program may be editing the same file. If this is the case,\n" @@ -3859,7 +4002,6 @@ msgstr "E328: Valikko on olemassa vain toisessa tilassa" msgid "E329: No menu \"%s\"" msgstr "E329: Ei valikkoa %s" -#. Only a mnemonic or accelerator is not valid. msgid "E792: Empty menu name" msgstr "E792: tyhjä valikkonimi" @@ -3872,8 +4014,6 @@ msgstr "E331: Valikkokohtia ei saa lisätä suoraan valikkopalkkiin" msgid "E332: Separator cannot be part of a menu path" msgstr "E332: Erotin ei voi olla valikkopolun osa" -#. Now we have found the matching menu, and we list the mappings -#. Highlight title msgid "" "\n" "--- Menus ---" @@ -3881,6 +4021,10 @@ msgstr "" "\n" "--- Valikot ---" +#, c-format +msgid "E335: Menu not defined for %s mode" +msgstr "E335: Valikkoa ei ole määritelty %s-tilassa" + msgid "E333: Menu path must lead to a menu item" msgstr "E333: Valikkopolun on johdettava valikkokohtaan" @@ -4223,6 +4367,9 @@ msgstr "E541: liikaa kohteita" msgid "E542: unbalanced groups" msgstr "E542: epätasapainoisia ryhmiä" +msgid "E946: Cannot make a terminal with running job modifiable" +msgstr "E946: Terminaalia jossa suoritetaan komentoa ei voi tehdä muokattavaksi" + msgid "E590: A preview window already exists" msgstr "E590: Esikatseluikkuna on jo olemassa" @@ -4354,7 +4501,6 @@ msgstr "E376: Virheellinen %%%c muotoilumerkkijonon alussa" msgid "E377: Invalid %%%c in format string" msgstr "E377: Virheellinen %%%c muotoilumerkkijonossa" -#. nothing found msgid "E378: 'errorformat' contains no pattern" msgstr "E378: errorformatissa ei ole kuvioita" @@ -4417,6 +4563,12 @@ msgstr "E369: virheellinen olio kohdassa %s%%[]" msgid "E769: Missing ] after %s[" msgstr "E769: ] puuttuu merkinnän %s[ jäljestä" +msgid "E944: Reverse range in character class" +msgstr "E944: Merkiluokan arvoalua on takaperin" + +msgid "E945: Range too large in character class" +msgstr "E945: Liian laaja valikoima merkkiluokassa" + #, c-format msgid "E53: Unmatched %s%%(" msgstr "E53: Pariton %s%%(" @@ -4443,6 +4595,9 @@ msgstr "E69: ] puuttuu merkinnän %s%%[ jäljestä" msgid "E70: Empty %s%%[]" msgstr "E70: Tyhjä %s%%[]" +msgid "E65: Illegal back reference" +msgstr "E65: Virheellinen täsmäysviittaus" + msgid "E339: Pattern too long" msgstr "E339: Liian pitkä kuvio" @@ -4479,9 +4634,6 @@ msgstr "E63: väärinkäytetty \\_" msgid "E64: %s%c follows nothing" msgstr "E64: %s%c jälkeen ei minkään" -msgid "E65: Illegal back reference" -msgstr "E65: Virheellinen täsmäysviittaus" - msgid "E68: Invalid character after \\z" msgstr "E68: Virheellinen merkki ilmauksen \\z jälkeen" @@ -4587,7 +4739,6 @@ msgstr "E386: ;:n jälkeen pitää olla ? tai /" msgid " (includes previously listed match)" msgstr " (sisältää viimeksi luetellun täsmäyksen)" -#. cursor at status line msgid "--- Included files " msgstr "--- Sisällytetyt tiedostot " @@ -4663,6 +4814,9 @@ msgstr " vanhaatiedostoa" msgid " FAILED" msgstr " EPÄONNISTUI" +msgid "E797: SpellFileMissing autocommand deleted buffer" +msgstr "E797: SpellFileMissing autocommand poisti puskurin" + #, c-format #~ msgid "System error while opening ShaDa file %s for reading: %s" #~ msgstr "" @@ -4841,8 +4995,6 @@ msgstr "ei ehdotuksia" #~ msgid "Sorry, only % suggestions" #~ msgstr "vain %ld ehdotusta" -#. for when 'cmdheight' > 1 -#. avoid more prompt #, c-format msgid "Change \"%.*s\" to:" msgstr "Muuta %.*s:" @@ -5430,7 +5582,6 @@ msgstr "E428: Ei voida edetä viimeisen täsmäävän tägin ohi" msgid "File \"%s\" does not exist" msgstr "Tiedostoa %s ei ole" -#. Give an indication of the number of matching tags #, c-format msgid "tag %d of %d%s" msgstr "tägi %d/%d%s" @@ -5445,7 +5596,6 @@ msgstr " Tägissä eri kirjaintaso" msgid "E429: File \"%s\" does not exist" msgstr "E429: Tiedostoa %s ei ole" -#. Highlight title msgid "" "\n" " # TO tag FROM line in file/text" @@ -5472,7 +5622,6 @@ msgstr "E431: Muotovirh tägitiedostossa %s" msgid "E432: Tags file not sorted: %s" msgstr "E432: Tägitiedosto ei ole järjestetty: %s" -#. never opened any tags file msgid "E433: No tags file" msgstr "E433: Ei tägitiedostoja" diff --git a/src/nvim/po/fr.po b/src/nvim/po/fr.po index 435042ad05..4fa4ef8f8f 100644 --- a/src/nvim/po/fr.po +++ b/src/nvim/po/fr.po @@ -13,8 +13,8 @@ msgid "" msgstr "" "Project-Id-Version: Vim(Français)\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-07-11 23:10+0200\n" -"PO-Revision-Date: 2017-01-12 05:16+0200\n" +"POT-Creation-Date: 2017-10-04 23:32+0200\n" +"PO-Revision-Date: 2017-10-04 23:44+0200\n" "Last-Translator: Dominique Pellé \n" "Language-Team: \n" "Language: fr\n" @@ -101,7 +101,6 @@ msgstr "E90: Impossible de d msgid "E84: No modified buffer found" msgstr "E84: Aucun tampon n'est modifié" -#. back where we started, didn't find anything. msgid "E85: There is no listed buffer" msgstr "E85: Aucun tampon n'est listé" @@ -118,6 +117,18 @@ msgid "E89: No write since last change for buffer %ld (add ! to override)" msgstr "" "E89: Le tampon %ld n'a pas été enregistré (ajoutez ! pour passer outre)" +msgid "E948: Job still running (add ! to end the job)" +msgstr "E948: Tâche en cours d'exécution (ajouter ! pour terminer la tâche)" + +msgid "E37: No write since last change (add ! to override)" +msgstr "E37: Modifications non enregistrées (ajoutez ! pour passer outre)" + +msgid "E948: Job still running" +msgstr "E948: Tâche en cours d'exécution" + +msgid "E37: No write since last change" +msgstr "E37: Modifications non enregistrées" + msgid "W14: Warning: List of file names overflow" msgstr "W14: Alerte : La liste des noms de fichier déborde" @@ -184,7 +195,6 @@ msgstr "ligne %ld sur %ld --%d%%-- col " msgid "[No Name]" msgstr "[Aucun nom]" -#. must be a help buffer msgid "help" msgstr "aide" @@ -215,6 +225,9 @@ msgstr "" "\n" "# Liste des tampons :\n" +msgid "E382: Cannot write, 'buftype' option is set" +msgstr "E382: Écriture impossible, l'option 'buftype' est activée" + msgid "[Scratch]" msgstr "[Brouillon]" @@ -393,7 +406,6 @@ msgid " Keyword completion (^N^P)" msgstr " Complètement de mot-clé (^N^P)" # DB - todo : Faut-il une majuscule à "mode" ? -#. ctrl_x_mode == 0, ^P/^N compl. msgid " ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)" msgstr " mode ^X (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)" @@ -488,10 +500,6 @@ msgstr "correspondance dans le fichier" msgid " Adding" msgstr " Ajout" -#. showmode might reset the internal line pointers, so it must -#. * be called before line = ml_get(), or when this address is no -#. * longer needed. -- Acevedo. -#. msgid "-- Searching..." msgstr "-- Recherche en cours..." @@ -522,7 +530,6 @@ msgstr "Correspondance %d sur %d" msgid "match %d" msgstr "Correspondance %d" -#. maximum nesting of lists and dicts msgid "E18: Unexpected characters in :let" msgstr "E18: Caractères inattendus avant '='" @@ -584,8 +591,6 @@ msgstr "E690: \"in\" manquant apr msgid "E108: No such variable: \"%s\"" msgstr "E108: Variable inexistante : %s" -#. For historic reasons this error is not given for a list or dict. -#. * E.g., the b: dict could be locked/unlocked. #, c-format msgid "E940: Cannot lock or unlock variable %s" msgstr "E940: Impossible de (dé)verrouiler la variable %s" @@ -771,11 +776,6 @@ msgstr "E785: complete() n'est utilisable que dans le mode Insertion" # AB - Texte par défaut du bouton de la boîte de dialogue affichée par la # fonction confirm(). -#. -#. * Yes this is ugly, I don't particularly like it either. But doing it -#. * this way has the compelling advantage that translations need not to -#. * be touched at all. See below what 'ok' and 'ync' are used for. -#. msgid "&Ok" msgstr "&Ok" @@ -969,7 +969,6 @@ msgstr " # ses droits d'accès. # AB - Le mot "viminfo" a été retiré pour que le message ne dépasse pas 80 # caractères dans le cas courant où %s = /home/12345678/.viminfo -#. avoid a wait_return for this message, it's annoying #, c-format msgid "E137: Viminfo file is not writable: %s" msgstr "E137: L'écriture dans le fichier %s est interdite" @@ -994,7 +993,6 @@ msgstr " msgid "E886: Can't rename viminfo file to %s!" msgstr "E886: Impossible de renommer viminfo en %s" -#. Write the info: #, c-format msgid "# This viminfo file was generated by Vim %s.\n" msgstr "# Ce fichier viminfo a été généré par Vim %s.\n" @@ -1141,7 +1139,6 @@ msgstr " sur %ld lignes" # AB - Il faut respecter l'esprit plus que la lettre. # AB - Ce message devrait contenir une référence à :vglobal. -#. will increment global_busy to break out of the loop msgid "E147: Cannot do :global recursive with a range" msgstr "E147: :global ne peut pas exécuter :global avec une plage" @@ -1322,10 +1319,9 @@ msgstr "E750: Utilisez d'abord \":profile start {nomfichier}\"" msgid "Save changes to \"%s\"?" msgstr "Enregistrer \"%s\" ?" -# AB - Si les parenthèses posent problème, il faudra remettre les guillemets -# ci-dessus. -msgid "Untitled" -msgstr "(sans titre)" +#, c-format +msgid "E947: Job still running in buffer \"%s\"" +msgstr "E947: Tâche en cours d'exécution dans le buffer \"%s\"" # AB - Il faut respecter l'esprit plus que la lettre. # AB - Ce message est similaire au message E89. @@ -1471,7 +1467,8 @@ msgid "E494: Use w or w>>" msgstr "E494: Utilisez w ou w>>" msgid "E943: Command table needs to be updated, run 'make cmdidxs'" -msgstr "E943: La table des commandes doit être mise à jour, lancez 'make cmdidxs'" +msgstr "" +"E943: La table des commandes doit être mise à jour, lancez 'make cmdidxs'" msgid "E319: Sorry, the command is not available in this version" msgstr "E319: Désolé, cette commande n'est pas disponible dans cette version" @@ -1638,7 +1635,6 @@ msgstr "E189: \"%s\" existe (ajoutez ! pour passer outre)" msgid "E190: Cannot open \"%s\" for writing" msgstr "E190: Impossible d'ouvrir \"%s\" pour y écrire" -#. set mark msgid "E191: Argument must be a letter or forward/backward quote" msgstr "E191: L'argument doit être une lettre ou une (contre-)apostrophe" @@ -1676,13 +1672,17 @@ msgstr "E500: msgid "E195: Cannot open viminfo file for reading" msgstr "E195: Impossible d'ouvrir le viminfo en lecture" +# AB - Si les parenthèses posent problème, il faudra remettre les guillemets +# ci-dessus. +msgid "Untitled" +msgstr "(sans titre)" + msgid "E196: No digraphs in this version" msgstr "E196: Pas de digraphes dans cette version" msgid "E608: Cannot :throw exceptions with 'Vim' prefix" msgstr "E608: Impossible d'émettre des exceptions avec 'Vim' comme préfixe" -#. always scroll up, don't overwrite #, c-format msgid "Exception thrown: %s" msgstr "Exception émise : %s" @@ -1699,7 +1699,6 @@ msgstr "Exception msgid "%s, line %ld" msgstr "%s, ligne %ld" -#. always scroll up, don't overwrite #, c-format msgid "Exception caught: %s" msgstr "Exception interceptée : %s" @@ -1726,7 +1725,6 @@ msgstr "Erreur et interruption" msgid "Error" msgstr "Erreur" -#. if (pending & CSTP_INTERRUPT) msgid "Interrupt" msgstr "Interruption" @@ -1769,15 +1767,12 @@ msgstr "E601: Imbrication de :try trop importante" msgid "E603: :catch without :try" msgstr "E603: :catch sans :try" -#. Give up for a ":catch" after ":finally" and ignore it. -#. * Just parse. msgid "E604: :catch after :finally" msgstr "E604: :catch après :finally" msgid "E606: :finally without :try" msgstr "E606: :finally sans :try" -#. Give up for a multiple ":finally" and ignore it. msgid "E607: multiple :finally" msgstr "E607: Il ne peut y avoir qu'un seul :finally" @@ -1878,7 +1873,6 @@ msgstr "Vim : Lecture de stdin...\n" msgid "Reading from stdin..." msgstr "Lecture de stdin..." -#. Re-opening the original file failed! msgid "E202: Conversion made file unreadable!" msgstr "E202: La conversion a rendu le fichier illisible !" @@ -2093,9 +2087,6 @@ msgstr "[noeol]" msgid "[Incomplete last line]" msgstr "[Dernière ligne incomplète]" -#. don't overwrite messages here -#. must give this prompt -#. don't use emsg() here, don't want to flush the buffers msgid "WARNING: The file has been changed since reading it!!!" msgstr "ALERTE : Le fichier a été modifié depuis que Vim l'a lu !" @@ -2177,7 +2168,6 @@ msgstr "--Effac msgid "auto-removing autocommand: %s " msgstr "Autocommandes marquées pour auto-suppression : %s " -#. the group doesn't exist #, c-format msgid "E367: No such group: \"%s\"" msgstr "E367: Aucun groupe \"%s\"" @@ -2200,7 +2190,6 @@ msgstr "E216: Aucun msgid "E216: No such group or event: %s" msgstr "E216: Aucun événement ou groupe %s" -#. Highlight title msgid "" "\n" "--- Auto-Commands ---" @@ -2387,18 +2376,15 @@ msgstr "Rechercher :" msgid "Replace with:" msgstr "Remplacer par :" -#. whole word only button msgid "Match whole word only" msgstr "Mots entiers seulement" -#. match case button msgid "Match case" msgstr "Respecter la casse" msgid "Direction" msgstr "Direction" -#. 'Up' and 'Down' buttons msgid "Up" msgstr "Haut" @@ -2482,8 +2468,6 @@ msgstr "Chercher et remplacer (utilisez '\\\\' pour trouver un '\\')" # DB - Traduction non indispensable puisque le code indique qu'il s'agit d'un # paramétrage bidon afin de sélectionner un répertoire plutôt qu'un # fichier. -#. We fake this: Use a filter that doesn't select anything and a default -#. * file name that won't be used. msgid "Not Used" msgstr "Non utilisé" @@ -2564,7 +2548,6 @@ msgstr "Choisir une police - Vim" msgid "Name:" msgstr "Nom :" -#. create toggle button msgid "Show size in Points" msgstr "Afficher la taille en Points" @@ -2815,7 +2798,6 @@ msgstr "E261: Connexion cscope %s introuvable" msgid "cscope connection %s closed" msgstr "connexion cscope %s fermée" -#. should not reach here msgid "E570: fatal error in cs_manage_matches" msgstr "E570: erreur fatale dans cs_manage_matches" @@ -2980,7 +2962,6 @@ msgid "not implemented yet" msgstr "pas encore implémenté" # DB - TODO : le contexte est celui d'une annulation. -#. ??? msgid "cannot set line(s)" msgstr "Impossible de remettre la/les ligne(s)" @@ -3021,7 +3002,6 @@ msgid "" msgstr "" "Impossible d'inscrire la commande de rappel : tampon/fenêtre en effacement" -#. This should never happen. Famous last word? msgid "" "E280: TCL FATAL ERROR: reflist corrupt!? Please report this to vim-dev@vim." "org" @@ -3124,7 +3104,6 @@ msgstr "Vim : Alerte : La sortie ne s'effectue pas sur un terminal\n" msgid "Vim: Warning: Input is not from a terminal\n" msgstr "Vim : Alerte : L'entrée ne se fait pas sur un terminal\n" -#. just in case.. msgid "pre-vimrc command line" msgstr "ligne de commande pre-vimrc" @@ -3391,6 +3370,9 @@ msgstr "" msgid "-i \t\tUse instead of .viminfo" msgstr "-i \t\tUtiliser au lieu du viminfo habituel" +msgid "--clean\t\t'nocompatible', Vim defaults, no plugins, no viminfo" +msgstr "--clean\t\t'nocompatible', réglages par défaut, aucun greffon ni viminfo" + msgid "-h or --help\tPrint Help (this message) and exit" msgstr "-h ou --help\t\tAfficher l'aide (ce message) puis quitter" @@ -3493,11 +3475,9 @@ msgstr "--windowid \tOuvrir Vim dans un autre widget win32" msgid "No display" msgstr "Aucun display" -#. Failed to send, abort. msgid ": Send failed.\n" msgstr " : L'envoi a échoué.\n" -#. Let vim start normally. msgid ": Send failed. Trying to execute locally\n" msgstr " : L'envoi a échoué. Tentative d'exécution locale\n" @@ -3518,7 +3498,6 @@ msgstr "Aucune marque positionn msgid "E283: No marks matching \"%s\"" msgstr "E283: Aucune marque ne correspond à \"%s\"" -#. Highlight title msgid "" "\n" "mark line col file/text" @@ -3526,7 +3505,6 @@ msgstr "" "\n" "marq ligne col fichier/texte" -#. Highlight title msgid "" "\n" " jump line col file/text" @@ -3534,7 +3512,6 @@ msgstr "" "\n" " saut ligne col fichier/texte" -#. Highlight title msgid "" "\n" "change line col text" @@ -3549,7 +3526,6 @@ msgstr "" "\n" "# Marques dans le fichier :\n" -#. Write the jumplist with -' msgid "" "\n" "# Jumplist (newest first):\n" @@ -3621,7 +3597,6 @@ msgstr "E298: Bloc n msgid "E843: Error while updating swap file crypt" msgstr "E843: Erreur lors de la mise à jour du fichier d'échange crypté" -#. could not (re)open the swap file, what can we do???? msgid "E301: Oops, lost the swap file!!!" msgstr "E301: Oups, le fichier d'échange a disparu !" @@ -3810,7 +3785,6 @@ msgstr "" "Utilisation de la clé de chiffrement du fichier d'échange pour le fichier " "texte.\n" -#. use msg() to start the scrolling properly msgid "Swap files found:" msgstr "Fichiers d'échange trouvés :" @@ -3980,8 +3954,6 @@ msgstr "Lors de l'ouverture du fichier \"" msgid " NEWER than swap file!\n" msgstr " PLUS RÉCENT que le fichier d'échange !\n" -#. Some of these messages are long to allow translation to -#. * other languages. msgid "" "\n" "(1) Another program may be editing the same file. If this is the case,\n" @@ -4072,7 +4044,6 @@ msgstr "E328: Le menu n'existe que dans un autre mode" msgid "E329: No menu \"%s\"" msgstr "E329: Aucun menu \"%s\"" -#. Only a mnemonic or accelerator is not valid. msgid "E792: Empty menu name" msgstr "E792: Nom de menu vide" @@ -4085,8 +4056,6 @@ msgstr "E331: Ajout d' msgid "E332: Separator cannot be part of a menu path" msgstr "E332: Un séparateur ne peut faire partie d'un chemin de menu" -#. Now we have found the matching menu, and we list the mappings -#. Highlight title msgid "" "\n" "--- Menus ---" @@ -4097,6 +4066,10 @@ msgstr "" msgid "Tear off this menu" msgstr "Détacher ce menu" +#, c-format +msgid "E335: Menu not defined for %s mode" +msgstr "E335: Le menu n'est pas défini pour le mode %s" + msgid "E333: Menu path must lead to a menu item" msgstr "E333: Le chemin du menu doit conduire à un élément de menu" @@ -4104,10 +4077,6 @@ msgstr "E333: Le chemin du menu doit conduire msgid "E334: Menu not found: %s" msgstr "E334: Menu introuvable : %s" -#, c-format -msgid "E335: Menu not defined for %s mode" -msgstr "E335: Le menu n'est pas défini pour le mode %s" - msgid "E336: Menu path must lead to a sub-menu" msgstr "E336: Le chemin du menu doit conduire à un sous-menu" @@ -4181,7 +4150,6 @@ msgstr "Enregistrer un fichier" msgid "Open File dialog" msgstr "Ouvrir un fichier" -#. TODO: non-GUI file selector here msgid "E338: Sorry, no file browser in console mode" msgstr "E338: Désolé, pas de sélecteur de fichiers en mode console" @@ -4348,7 +4316,9 @@ msgid "E663: At end of changelist" msgstr "E663: À la fin de la liste des modifications" msgid "Type :qa! and press to abandon all changes and exit Vim" -msgstr "Tapez :qa! puis pour abandonner tous les changements et quitter Vim" +msgstr "" +"Tapez :qa! puis pour abandonner tous les changements et quitter " +"Vim" #, c-format msgid "1 line %sed 1 time" @@ -4381,7 +4351,6 @@ msgid "E748: No previously used register" msgstr "E748: Aucun registre n'a été précédemment utilisé" # DB - Question O/N. -#. must display the prompt msgid "cannot yank; delete anyway" msgstr "impossible de réaliser une copie ; effacer tout de même" @@ -4396,25 +4365,30 @@ msgstr "%ld lignes modifi msgid "freeing %ld lines" msgstr "libération de %ld lignes" -msgid "block of 1 line yanked" -msgstr "bloc de 1 ligne copié" +#, c-format +msgid " into \"%c" +msgstr " dans \"%c" -msgid "1 line yanked" -msgstr "1 ligne copiée" +#, c-format +msgid "block of 1 line yanked%s" +msgstr "bloc de 1 ligne copié%s" #, c-format -msgid "block of %ld lines yanked" -msgstr "bloc de %ld lignes copié" +msgid "1 line yanked%s" +msgstr "1 ligne copiée%s" #, c-format -msgid "%ld lines yanked" -msgstr "%ld lignes copiées" +msgid "block of %ld lines yanked%s" +msgstr "bloc de %ld lignes copié%s" + +#, c-format +msgid "%ld lines yanked%s" +msgstr "%ld lignes copiées%s" #, c-format msgid "E353: Nothing in register %s" msgstr "E353: Le registre %s est vide" -#. Highlight title msgid "" "\n" "--- Registers ---" @@ -4478,9 +4452,6 @@ msgstr "" msgid "(+%ld for BOM)" msgstr "(+%ld pour le BOM)" -msgid "%<%f%h%m%=Page %N" -msgstr "%<%f%h%m%=Page %N" - msgid "Thanks for flying Vim" msgstr "Merci d'avoir choisi Vim" @@ -4591,6 +4562,9 @@ msgstr "E541: trop d' msgid "E542: unbalanced groups" msgstr "E542: parenthèses non équilibrées" +msgid "E946: Cannot make a terminal with running job modifiable" +msgstr "E946: terminal avec tâche en cours d'exécution ne peut pas être modifiable" + msgid "E590: A preview window already exists" msgstr "E590: Il existe déjà une fenêtre de prévisualisation" @@ -4609,9 +4583,6 @@ msgstr "E594: Au moins %d colonnes sont n msgid "E355: Unknown option: %s" msgstr "E355: Option inconnue : %s" -#. There's another character after zeros or the string -#. * is empty. In both cases, we are trying to set a -#. * num option using a string. #, c-format msgid "E521: Number required: &%s = '%s'" msgstr "E521: Nombre requis : &%s = '%s'" @@ -4684,7 +4655,6 @@ msgstr "Impossible de modifier le mode de la console ?!\n" msgid "mch_get_shellsize: not a console??\n" msgstr "mch_get_shellsize : pas une console ?!\n" -#. if Vim opened a window: Executing a shell may cause crashes msgid "E360: Cannot execute shell with -f option" msgstr "E360: Impossible d'exécuter un shell avec l'option -f" @@ -4911,7 +4881,6 @@ msgstr "E376: %%%c invalide dans le pr msgid "E377: Invalid %%%c in format string" msgstr "E377: %%%c invalide dans la chaîne de format" -#. nothing found msgid "E378: 'errorformat' contains no pattern" msgstr "E378: 'errorformat' ne contient aucun motif" @@ -4950,9 +4919,6 @@ msgstr "E381: Au sommet de la pile quickfix" msgid "No entries" msgstr "Aucune entrée" -msgid "E382: Cannot write, 'buftype' option is set" -msgstr "E382: Écriture impossible, l'option 'buftype' est activée" - msgid "Error file" msgstr "Fichier d'erreurs" @@ -5099,7 +5065,6 @@ msgstr "E867: (NFA) Op msgid "E867: (NFA) Unknown operator '\\%%%c'" msgstr "E867: (NFA) Opérateur inconnu '\\%%%c'" -#. should never happen msgid "E868: Error building NFA with equivalence class!" msgstr "E868: Erreur lors de la construction du NFA avec classe d'équivalence" @@ -5110,11 +5075,9 @@ msgstr "E869: (NFA) Op msgid "E870: (NFA regexp) Error reading repetition limits" msgstr "E870: (regexp NFA) Erreur à la lecture des limites de répétition" -#. Can't have a multi follow a multi. msgid "E871: (NFA regexp) Can't have a multi follow a multi !" msgstr "E871: (regexp NFA) Un multi ne peut pas suivre un multi !" -#. Too many `(' msgid "E872: (NFA regexp) Too many '('" msgstr "E872: (regexp NFA) Trop de '('" @@ -5224,7 +5187,6 @@ msgstr "E386: '?' ou '/' attendu apr msgid " (includes previously listed match)" msgstr " (inclut des correspondances listées précédemment)" -#. cursor at status line msgid "--- Included files " msgstr "--- Fichiers inclus " @@ -5301,8 +5263,6 @@ msgstr "D msgid "Sorry, only %ld suggestions" msgstr "Désolé, seulement %ld suggestions" -#. for when 'cmdheight' > 1 -#. avoid more prompt #, c-format msgid "Change \"%.*s\" to:" msgstr "Remplacer \"%.*s\" par :" @@ -5589,10 +5549,6 @@ msgstr "%d noeuds compress msgid "Reading back spell file..." msgstr "Relecture du fichier orthographique" -#. -#. * Go through the trie of good words, soundfold each word and add it to -#. * the soundfold trie. -#. msgid "Performing soundfolding..." msgstr "Analyse phonétique en cours..." @@ -5649,8 +5605,6 @@ msgid "E763: Word characters differ between spell files" msgstr "" "E763: Les caractères de mots diffèrent entre les fichiers orthographiques" -#. This should have been checked when generating the .spl -#. * file. msgid "E783: duplicate char in MAP entry" msgstr "E783: caractère dupliqué dans l'entrée MAP" @@ -5680,7 +5634,9 @@ msgid "syntax spell notoplevel" msgstr "pas de contrôle orthographique dans le texte sans groupe syntaxique" msgid "syntax spell default" -msgstr "contrôle orthographique dans le texte sans groupe syntaxique, sauf si @Spell/@NoSpell" +msgstr "" +"contrôle orthographique dans le texte sans groupe syntaxique, sauf si @Spell/" +"@NoSpell" msgid "syntax iskeyword " msgstr "syntaxe iskeyword " @@ -5921,7 +5877,6 @@ msgstr "E428: Impossible d'aller au-del msgid "File \"%s\" does not exist" msgstr "Le fichier \"%s\" n'existe pas" -#. Give an indication of the number of matching tags #, c-format msgid "tag %d of %d%s" msgstr "marqueur %d sur %d%s" @@ -5936,7 +5891,6 @@ msgstr " Utilisation d'un marqueur avec une casse diff msgid "E429: File \"%s\" does not exist" msgstr "E429: Le fichier \"%s\" n'existe pas" -#. Highlight title msgid "" "\n" " # TO tag FROM line in file/text" @@ -5967,7 +5921,6 @@ msgstr "Avant l'octet %ld" msgid "E432: Tags file not sorted: %s" msgstr "E432: Le fichier de marqueurs %s n'est pas ordonné" -#. never opened any tags file msgid "E433: No tags file" msgstr "E433: Aucun fichier de marqueurs" @@ -6004,7 +5957,6 @@ msgstr "E436: Aucune entr msgid "E437: terminal capability \"cm\" required" msgstr "E437: capacité de terminal \"cm\" requise" -#. Highlight title msgid "" "\n" "--- Terminal keys ---" @@ -6015,6 +5967,21 @@ msgstr "" msgid "Cannot open $VIMRUNTIME/rgb.txt" msgstr "Impossible d'ouvrir $VIMRUNTIME/rgb.txt" +msgid "Terminal" +msgstr "Terminal" + +msgid "Terminal-finished" +msgstr "Terminal-fini" + +msgid "active" +msgstr "actif" + +msgid "running" +msgstr "en cours" + +msgid "finished" +msgstr "fini" + msgid "new shell started\n" msgstr "nouveau shell démarré\n" @@ -6025,13 +5992,10 @@ msgstr "Vim : Erreur lors de la lecture de l'entr msgid "Used CUT_BUFFER0 instead of empty selection" msgstr "CUT_BUFFER0 utilisé plutôt qu'une sélection vide" -#. This happens when the FileChangedRO autocommand changes the -#. * file in a way it becomes shorter. msgid "E881: Line count changed unexpectedly" msgstr "E881: Le nombre de lignes a été changé inopinément" # DB - Question O/N. -#. must display the prompt msgid "No undo possible; continue anyway" msgstr "Annulation impossible ; continuer" @@ -6680,7 +6644,6 @@ msgstr "&Comparer avec Vim" msgid "Edit with &Vim" msgstr "Éditer dans &Vim" -#. Now concatenate msgid "Edit with existing Vim - " msgstr "Éditer dans le Vim existant - " @@ -6704,10 +6667,6 @@ msgstr "Le chemin est trop long !" msgid "--No lines in buffer--" msgstr "--Le tampon est vide--" -#. -#. * The error messages that can be shared are included here. -#. * Excluded are errors that are only used once and debugging messages. -#. msgid "E470: Command aborted" msgstr "E470: Commande annulée" @@ -6894,12 +6853,6 @@ msgstr "E484: Impossible d'ouvrir le fichier \"%s\"" msgid "E485: Can't read file %s" msgstr "E485: Impossible de lire le fichier %s" -msgid "E37: No write since last change (add ! to override)" -msgstr "E37: Modifications non enregistrées (ajoutez ! pour passer outre)" - -msgid "E37: No write since last change" -msgstr "E37: Modifications non enregistrées" - msgid "E38: Null argument" msgstr "E38: Argument null" @@ -7191,7 +7144,6 @@ msgstr "le constructeur de liste n'accepte pas les arguments nomm msgid "list index out of range" msgstr "index de liste hors limites" -#. No more suitable format specifications in python-2.3 #, c-format msgid "internal error: failed to get vim list item %d" msgstr "erreur interne : accès à un élément %d de liste a échoué" -- cgit From 2ca59638ba04d11c397496d4f12f4d24e3461f0e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 7 Nov 2017 20:51:49 +0100 Subject: vim-patch:b0d45e7f5354 Update runtime files. https://github.com/vim/vim/commit/b0d45e7f5354375edd02afafde3bd37dac1515ff --- src/nvim/po/af.po | 7250 +++++++++++++++++++++++++---------------------------- src/nvim/po/fi.po | 170 -- 2 files changed, 3391 insertions(+), 4029 deletions(-) (limited to 'src') diff --git a/src/nvim/po/af.po b/src/nvim/po/af.po index eb6be42688..27bb2d3a80 100644 --- a/src/nvim/po/af.po +++ b/src/nvim/po/af.po @@ -26,7 +26,7 @@ msgid "" msgstr "" "Project-Id-Version: Vim 6.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-05-26 14:21+0200\n" +"POT-Creation-Date: 2017-11-07 20:04+0100\n" "PO-Revision-Date: Wed Oct 31 13:41 SAST 2001\n" "Last-Translator: Danie Roux \n" "Language-Team: Danie Roux \n" @@ -35,101 +35,74 @@ msgstr "" "Content-Type: text/plain; charset=ISO_8859-1\n" "Content-Transfer-Encoding: 8-bit\n" -#: ../api/private/helpers.c:201 -#, fuzzy -msgid "Unable to get option value" -msgstr "E258: Kan nie na kliënt stuur nie" - -#: ../api/private/helpers.c:204 -msgid "internal error: unknown option type" -msgstr "" - -#: ../buffer.c:92 -msgid "[Location List]" -msgstr "" +#~ msgid "[Location List]" +#~ msgstr "" -#: ../buffer.c:93 -msgid "[Quickfix List]" -msgstr "" +#~ msgid "[Quickfix List]" +#~ msgstr "" -#: ../buffer.c:94 -msgid "E855: Autocommands caused command to abort" -msgstr "" +#~ msgid "E855: Autocommands caused command to abort" +#~ msgstr "" -#: ../buffer.c:135 msgid "E82: Cannot allocate any buffer, exiting..." msgstr "E82: Kan nie buffer toeken nie, program sluit..." -#: ../buffer.c:138 msgid "E83: Cannot allocate buffer, using other one..." msgstr "E83: Kan nie buffer toeken nie, gaan ander een gebruik..." -#: ../buffer.c:763 +#~ msgid "E937: Attempt to delete a buffer that is in use" +#~ msgstr "" + msgid "E515: No buffers were unloaded" msgstr "E515: Geen buffers is uitgelaai nie" -#: ../buffer.c:765 msgid "E516: No buffers were deleted" msgstr "E516: Geen buffers is geskrap nie" -#: ../buffer.c:767 msgid "E517: No buffers were wiped out" msgstr "E517: Geen buffers is geskrap nie" -#: ../buffer.c:772 msgid "1 buffer unloaded" msgstr "1 buffer uitgelaai" -#: ../buffer.c:774 #, c-format msgid "%d buffers unloaded" msgstr "%d buffers uitgelaai" -#: ../buffer.c:777 msgid "1 buffer deleted" msgstr "1 buffer geskrap" -#: ../buffer.c:779 #, c-format msgid "%d buffers deleted" msgstr "%d buffers geskrap" -#: ../buffer.c:782 msgid "1 buffer wiped out" msgstr "1 buffer geskrap" -#: ../buffer.c:784 #, c-format msgid "%d buffers wiped out" msgstr "%d buffers geskrap" -#: ../buffer.c:806 msgid "E90: Cannot unload last buffer" msgstr "E90: Kan nie laaste buffer uitlaai nie" -#: ../buffer.c:874 msgid "E84: No modified buffer found" msgstr "E84: Geen veranderde buffer gevind nie" #. back where we started, didn't find anything. -#: ../buffer.c:903 msgid "E85: There is no listed buffer" msgstr "E85: Daar is geen gelyste buffer nie" -#: ../buffer.c:913 -#, c-format -msgid "E86: Buffer % does not exist" -msgstr "E86: Buffer % bestaan nie" - -#: ../buffer.c:915 msgid "E87: Cannot go beyond last buffer" msgstr "E87: Kan nie verby laaste buffer gaan nie" -#: ../buffer.c:917 msgid "E88: Cannot go before first buffer" msgstr "E88: Kan nie vóór eerste buffer gaan nie" -#: ../buffer.c:945 +#, fuzzy, c-format +#~ msgid "E89: %s will be killed(add ! to override)" +#~ msgstr "E189: \"%s\" bestaan (gebruik ! om te dwing)" + #, c-format msgid "" "E89: No write since last change for buffer % (add ! to override)" @@ -138,117 +111,85 @@ msgstr "" "dwing)" #. wrap around (may cause duplicates) -#: ../buffer.c:1423 msgid "W14: Warning: List of file names overflow" msgstr "W14: Waarskuwing: Lêerlys loop oor" -#: ../buffer.c:1555 ../quickfix.c:3361 #, c-format msgid "E92: Buffer % not found" msgstr "E92: buffer % kon nie gevind word nie" -#: ../buffer.c:1798 #, c-format msgid "E93: More than one match for %s" msgstr "E93: Meer as een treffer vir %s" -#: ../buffer.c:1800 #, c-format msgid "E94: No matching buffer for %s" msgstr "E94: Geen buffer wat by %s pas nie" -#: ../buffer.c:2161 #, c-format msgid "line %" msgstr "reël %" -#: ../buffer.c:2233 msgid "E95: Buffer with this name already exists" msgstr "E95: Buffer met hierdie naam bestaan alreeds" -#: ../buffer.c:2498 msgid " [Modified]" msgstr " [Gewysig]" -#: ../buffer.c:2501 msgid "[Not edited]" msgstr "[Ongewysig]" -#: ../buffer.c:2504 msgid "[New file]" msgstr "[Nuwe lêer]" -#: ../buffer.c:2505 msgid "[Read errors]" msgstr "[Leesfoute]" -#: ../buffer.c:2506 ../buffer.c:3217 ../fileio.c:1807 ../screen.c:4895 msgid "[RO]" msgstr "[RO]" -#: ../buffer.c:2507 ../fileio.c:1807 msgid "[readonly]" msgstr "[lees alleen]" -#: ../buffer.c:2524 #, c-format msgid "1 line --%d%%--" msgstr "1 reël --%d%%--" -#: ../buffer.c:2526 #, c-format msgid "% lines --%d%%--" msgstr "% reëls --%d%%--" -#: ../buffer.c:2530 #, c-format msgid "line % of % --%d%%-- col " msgstr "reël % van % --%d%%-- kolom " -#: ../buffer.c:2632 ../buffer.c:4292 ../memline.c:1554 #, fuzzy -msgid "[No Name]" -msgstr "[Geen lêer]" +#~ msgid "[No Name]" +#~ msgstr "[Geen lêer]" #. must be a help buffer -#: ../buffer.c:2667 msgid "help" msgstr "help" -#: ../buffer.c:3225 ../screen.c:4883 #, fuzzy -msgid "[Help]" -msgstr "[help]" +#~ msgid "[Help]" +#~ msgstr "[help]" -#: ../buffer.c:3254 ../screen.c:4887 msgid "[Preview]" msgstr "[Voorskou]" -#: ../buffer.c:3528 msgid "All" msgstr "Alles" -#: ../buffer.c:3528 msgid "Bot" msgstr "Ond" -#: ../buffer.c:3531 msgid "Top" msgstr "Bo" -#: ../buffer.c:4244 -msgid "" -"\n" -"# Buffer list:\n" -msgstr "" -"\n" -"# Buffer lys:\n" - -#: ../buffer.c:4289 -msgid "[Scratch]" -msgstr "" +#~ msgid "[Scratch]" +#~ msgstr "" -#: ../buffer.c:4529 msgid "" "\n" "--- Signs ---" @@ -256,208 +197,161 @@ msgstr "" "\n" "--- Tekens ---" -#: ../buffer.c:4538 #, c-format msgid "Signs for %s:" msgstr "Tekens vir %s:" -#: ../buffer.c:4543 #, c-format msgid " line=% id=%d name=%s" msgstr " reël=% id=%d naam=%s" -#: ../cursor_shape.c:68 msgid "E545: Missing colon" msgstr "E545: Ontbrekende dubbelpunt" -#: ../cursor_shape.c:70 ../cursor_shape.c:94 msgid "E546: Illegal mode" msgstr "E546: Ongeldige modus" -#: ../cursor_shape.c:134 msgid "E548: digit expected" msgstr "E548: syfer verwag" -#: ../cursor_shape.c:138 msgid "E549: Illegal percentage" msgstr "E549: Ongeldige persentasie" -#: ../diff.c:146 -#, c-format -msgid "E96: Can not diff more than % buffers" -msgstr "E96: Kan nie meer as % buffers 'diff' nie" +#, fuzzy, c-format +#~ msgid "E96: Cannot diff more than % buffers" +#~ msgstr "E96: Kan nie meer as % buffers 'diff' nie" -#: ../diff.c:753 #, fuzzy -msgid "E810: Cannot read or write temp files" -msgstr "E557: Kan nie 'termcap'-lêer oopmaak nie" +#~ msgid "E810: Cannot read or write temp files" +#~ msgstr "E557: Kan nie 'termcap'-lêer oopmaak nie" -#: ../diff.c:755 msgid "E97: Cannot create diffs" msgstr "E97: Kan nie 'diffs' skep nie " -#: ../diff.c:966 #, fuzzy -msgid "E816: Cannot read patch output" -msgstr "E98: Kan nie 'diff' afvoer lees nie" +#~ msgid "E816: Cannot read patch output" +#~ msgstr "E98: Kan nie 'diff' afvoer lees nie" -#: ../diff.c:1220 msgid "E98: Cannot read diff output" msgstr "E98: Kan nie 'diff' afvoer lees nie" -#: ../diff.c:2081 msgid "E99: Current buffer is not in diff mode" msgstr "E99: Huidige buffer is nie in 'diff' modus nie" -#: ../diff.c:2100 #, fuzzy -msgid "E793: No other buffer in diff mode is modifiable" -msgstr "E100: Geen ander buffer in 'diff' modus nie" +#~ msgid "E793: No other buffer in diff mode is modifiable" +#~ msgstr "E100: Geen ander buffer in 'diff' modus nie" -#: ../diff.c:2102 msgid "E100: No other buffer in diff mode" msgstr "E100: Geen ander buffer in 'diff' modus nie" -#: ../diff.c:2112 msgid "E101: More than two buffers in diff mode, don't know which one to use" msgstr "" "E101: Meer as twee buffers in 'diff' modus, weet nie watter een om te " "gebruik nie" -#: ../diff.c:2141 #, c-format msgid "E102: Can't find buffer \"%s\"" msgstr "E102: Kan buffer %s nie vind nie" -#: ../diff.c:2152 #, c-format msgid "E103: Buffer \"%s\" is not in diff mode" msgstr "E103: Buffer \"%s\" is nie in 'diff' modus nie" -#: ../diff.c:2193 -msgid "E787: Buffer changed unexpectedly" -msgstr "" +#~ msgid "E787: Buffer changed unexpectedly" +#~ msgstr "" -#: ../digraph.c:1598 msgid "E104: Escape not allowed in digraph" msgstr "E104: 'Escape' nie toegelaat in digraaf nie" -#: ../digraph.c:1760 msgid "E544: Keymap file not found" msgstr "E544: Sleutelbindinglêer nie gevind nie" -#: ../digraph.c:1785 msgid "E105: Using :loadkeymap not in a sourced file" msgstr "E105: :loadkeymap word buite 'n uitvoerlêer gebruik" -#: ../digraph.c:1821 -msgid "E791: Empty keymap entry" -msgstr "" +#~ msgid "E791: Empty keymap entry" +#~ msgstr "" -#: ../edit.c:82 msgid " Keyword completion (^N^P)" msgstr " Sleutelwoord voltooiing (^N^P)" #. ctrl_x_mode == 0, ^P/^N compl. -#: ../edit.c:83 #, fuzzy -msgid " ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)" -msgstr " ^X modus (^E^Y^L^]^F^I^K^D^V^N^P)" +#~ msgid " ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)" +#~ msgstr " ^X modus (^E^Y^L^]^F^I^K^D^V^N^P)" -#: ../edit.c:85 msgid " Whole line completion (^L^N^P)" msgstr " Hele-reël voltooiing (^L^N^P)" -#: ../edit.c:86 msgid " File name completion (^F^N^P)" msgstr " Lêernaam voltooiing (^F^N^P)" -#: ../edit.c:87 msgid " Tag completion (^]^N^P)" msgstr " Etiketvoltooiing (^]^N^P)" -#: ../edit.c:88 msgid " Path pattern completion (^N^P)" msgstr " Gidspatroon voltooiing (^N^P)" -#: ../edit.c:89 msgid " Definition completion (^D^N^P)" msgstr " Definisievoltooiing (^D^N^P)" -#: ../edit.c:91 msgid " Dictionary completion (^K^N^P)" msgstr " Woordeboekvoltooiing (^K^N^P)" -#: ../edit.c:92 msgid " Thesaurus completion (^T^N^P)" msgstr " Tesourusvoltooiing (^T^N^P)" -#: ../edit.c:93 msgid " Command-line completion (^V^N^P)" msgstr " Bevelreëlvoltooiing (^V^N^P)" -#: ../edit.c:94 #, fuzzy -msgid " User defined completion (^U^N^P)" -msgstr " Hele-reël voltooiing (^L^N^P)" +#~ msgid " User defined completion (^U^N^P)" +#~ msgstr " Hele-reël voltooiing (^L^N^P)" -#: ../edit.c:95 #, fuzzy -msgid " Omni completion (^O^N^P)" -msgstr " Etiketvoltooiing (^]^N^P)" +#~ msgid " Omni completion (^O^N^P)" +#~ msgstr " Etiketvoltooiing (^]^N^P)" -#: ../edit.c:96 #, fuzzy -msgid " Spelling suggestion (s^N^P)" -msgstr " Hele-reël voltooiing (^L^N^P)" +#~ msgid " Spelling suggestion (s^N^P)" +#~ msgstr " Hele-reël voltooiing (^L^N^P)" -#: ../edit.c:97 msgid " Keyword Local completion (^N^P)" msgstr " Sleutelwoord Lokale voltooiing (^N^P)" -#: ../edit.c:100 msgid "Hit end of paragraph" msgstr "Het einde van paragraaf getref" -#: ../edit.c:101 -msgid "E839: Completion function changed window" -msgstr "" +#~ msgid "E839: Completion function changed window" +#~ msgstr "" -#: ../edit.c:102 -msgid "E840: Completion function deleted text" -msgstr "" +#~ msgid "E840: Completion function deleted text" +#~ msgstr "" -#: ../edit.c:1847 msgid "'dictionary' option is empty" msgstr "'dictionary' opsie is leeg" -#: ../edit.c:1848 msgid "'thesaurus' option is empty" msgstr "'thesaurus' opsie is leeg" -#: ../edit.c:2655 #, c-format msgid "Scanning dictionary: %s" msgstr "Deursoek woordeboek: %s" -#: ../edit.c:3079 msgid " (insert) Scroll (^E/^Y)" msgstr " (invoeg) Rol (^E/^Y)" -#: ../edit.c:3081 msgid " (replace) Scroll (^E/^Y)" msgstr " (vervang) Rol (^E/^Y)" -#: ../edit.c:3587 #, c-format msgid "Scanning: %s" msgstr "Soek vir: %s" -#: ../edit.c:3614 msgid "Scanning tags." msgstr "Deursoek etikette." -#: ../edit.c:4519 msgid " Adding" msgstr " Word bygevoeg" @@ -465,605 +359,550 @@ msgstr " Word bygevoeg" #. * be called before line = ml_get(), or when this address is no #. * longer needed. -- Acevedo. #. -#: ../edit.c:4562 msgid "-- Searching..." msgstr "-- Soekend..." -#: ../edit.c:4618 msgid "Back at original" msgstr "Terug by oorspronklike" -#: ../edit.c:4621 msgid "Word from other line" msgstr "Woord van ander reël" -#: ../edit.c:4624 msgid "The only match" msgstr "Die enigste treffer" -#: ../edit.c:4680 #, c-format msgid "match %d of %d" msgstr "treffer %d van %d" -#: ../edit.c:4684 #, c-format msgid "match %d" msgstr "treffer %d" -#: ../eval.c:137 #, fuzzy -msgid "E18: Unexpected characters in :let" -msgstr "E18: Onverwagte karakters voor '='" - -#: ../eval.c:138 -#, fuzzy, c-format -msgid "E684: list index out of range: %" -msgstr "E322: reëlnommer buite perke: % verby die einde" +#~ msgid "E18: Unexpected characters in :let" +#~ msgstr "E18: Onverwagte karakters voor '='" -#: ../eval.c:139 -#, c-format -msgid "E121: Undefined variable: %s" -msgstr "E121: Ongedefinieerde veranderlike: %s" - -#: ../eval.c:140 msgid "E111: Missing ']'" msgstr "E111: Ontbrekende ']'" -#: ../eval.c:141 #, fuzzy, c-format -msgid "E686: Argument of %s must be a List" -msgstr "E487: Parameter moet positief wees" +#~ msgid "E686: Argument of %s must be a List" +#~ msgstr "E487: Parameter moet positief wees" -#: ../eval.c:143 #, fuzzy, c-format -msgid "E712: Argument of %s must be a List or Dictionary" -msgstr "E487: Parameter moet positief wees" +#~ msgid "E712: Argument of %s must be a List or Dictionary" +#~ msgstr "E487: Parameter moet positief wees" -#: ../eval.c:144 #, fuzzy -msgid "E713: Cannot use empty key for Dictionary" -msgstr "E214: Kan nie tydelike lêer vind vir skryf nie" +#~ msgid "E714: List required" +#~ msgstr "E471: Parameter benodig" -#: ../eval.c:145 #, fuzzy -msgid "E714: List required" -msgstr "E471: Parameter benodig" +#~ msgid "E715: Dictionary required" +#~ msgstr "E129: Funksienaam vereis" -#: ../eval.c:146 #, fuzzy -msgid "E715: Dictionary required" -msgstr "E129: Funksienaam vereis" +#~ msgid "E928: String required" +#~ msgstr "E397: Lêernaam benodig" -#: ../eval.c:147 #, c-format msgid "E118: Too many arguments for function: %s" msgstr "E118: Te veel parameters vir funksie: %s" -#: ../eval.c:148 #, c-format -msgid "E716: Key not present in Dictionary: %s" -msgstr "" +#~ msgid "E716: Key not present in Dictionary: %s" +#~ msgstr "" -#: ../eval.c:150 #, c-format msgid "E122: Function %s already exists, add ! to replace it" msgstr "E122: Funksie %s bestaan alreeds, gebruik ! om te vervang" -#: ../eval.c:151 #, fuzzy -msgid "E717: Dictionary entry already exists" -msgstr "E95: Buffer met hierdie naam bestaan alreeds" +#~ msgid "E717: Dictionary entry already exists" +#~ msgstr "E95: Buffer met hierdie naam bestaan alreeds" -#: ../eval.c:152 #, fuzzy -msgid "E718: Funcref required" -msgstr "E129: Funksienaam vereis" +#~ msgid "E718: Funcref required" +#~ msgstr "E129: Funksienaam vereis" -#: ../eval.c:153 #, fuzzy -msgid "E719: Cannot use [:] with a Dictionary" -msgstr "E360: Kan nie dop met -f opsie uitvoer nie" - -#: ../eval.c:154 -#, c-format -msgid "E734: Wrong variable type for %s=" -msgstr "" +#~ msgid "E719: Cannot use [:] with a Dictionary" +#~ msgstr "E360: Kan nie dop met -f opsie uitvoer nie" -#: ../eval.c:155 #, fuzzy, c-format -msgid "E130: Unknown function: %s" -msgstr "E117: Onbekende funksie: %s" +#~ msgid "E130: Unknown function: %s" +#~ msgstr "E117: Onbekende funksie: %s" -#: ../eval.c:156 #, c-format msgid "E461: Illegal variable name: %s" msgstr "E461: Ongeldige veranderlikenaam: %s" -#: ../eval.c:157 -msgid "E806: using Float as a String" -msgstr "" +#, fuzzy, c-format +#~ msgid "E46: Cannot change read-only variable \"%.*s\"" +#~ msgstr "E46: Kan nie lees-alleen veranderlike stel nie \"%s\"" -#: ../eval.c:1830 -msgid "E687: Less targets than List items" -msgstr "" +#. TODO(ZyX-I): move to eval/executor +#, c-format +#~ msgid "E734: Wrong variable type for %s=" +#~ msgstr "" -#: ../eval.c:1834 -msgid "E688: More targets than List items" -msgstr "" +#~ msgid "E687: Less targets than List items" +#~ msgstr "" -#: ../eval.c:1906 -msgid "Double ; in list of variables" -msgstr "" +#~ msgid "E688: More targets than List items" +#~ msgstr "" + +#~ msgid "Double ; in list of variables" +#~ msgstr "" -#: ../eval.c:2078 #, fuzzy, c-format -msgid "E738: Can't list variables for %s" -msgstr "E138: Kan nie viminfo lêer %s stoor nie!" +#~ msgid "E738: Can't list variables for %s" +#~ msgstr "E138: Kan nie viminfo lêer %s stoor nie!" -#: ../eval.c:2391 -msgid "E689: Can only index a List or Dictionary" -msgstr "" +#, fuzzy, c-format +#~ msgid "E121: Undefined variable: %.*s" +#~ msgstr "E121: Ongedefinieerde veranderlike: %s" -#: ../eval.c:2396 -msgid "E708: [:] must come last" -msgstr "" +#~ msgid "E689: Can only index a List or Dictionary" +#~ msgstr "" -#: ../eval.c:2439 -msgid "E709: [:] requires a List value" -msgstr "" +#~ msgid "E708: [:] must come last" +#~ msgstr "" -#: ../eval.c:2674 -msgid "E710: List value has more items than target" -msgstr "" +#, fuzzy +#~ msgid "E713: Cannot use empty key after ." +#~ msgstr "E214: Kan nie tydelike lêer vind vir skryf nie" -#: ../eval.c:2678 -msgid "E711: List value has not enough items" -msgstr "" +#~ msgid "E709: [:] requires a List value" +#~ msgstr "" + +#~ msgid "E710: List value has more items than target" +#~ msgstr "" + +#~ msgid "E711: List value has not enough items" +#~ msgstr "" -#: ../eval.c:2867 #, fuzzy -msgid "E690: Missing \"in\" after :for" -msgstr "E69: Ontbrekende ] na %s%%[" +#~ msgid "E690: Missing \"in\" after :for" +#~ msgstr "E69: Ontbrekende ] na %s%%[" -#: ../eval.c:3063 #, c-format msgid "E107: Missing parentheses: %s" msgstr "E107: Ontbrekende hakies: %s" -#: ../eval.c:3263 #, c-format msgid "E108: No such variable: \"%s\"" msgstr "E108: Geen veranderlike: \"%s\"" -#: ../eval.c:3333 -msgid "E743: variable nested too deep for (un)lock" -msgstr "" +#. For historical reasons this error is not given for Lists and +#. Dictionaries. E.g. b: dictionary may be locked/unlocked. +#, fuzzy, c-format +#~ msgid "E940: Cannot lock or unlock variable %s" +#~ msgstr "E46: Kan nie lees-alleen veranderlike stel nie \"%s\"" -#: ../eval.c:3630 msgid "E109: Missing ':' after '?'" msgstr "E109: Ontbrekende ':' na '?'" -#: ../eval.c:3893 -msgid "E691: Can only compare List with List" -msgstr "" +#~ msgid "E691: Can only compare List with List" +#~ msgstr "" -#: ../eval.c:3895 #, fuzzy -msgid "E692: Invalid operation for Lists" -msgstr "E449: Ongeldige uitdrukking ontvang" +#~ msgid "E692: Invalid operation for List" +#~ msgstr "E449: Ongeldige uitdrukking ontvang" -#: ../eval.c:3915 -msgid "E735: Can only compare Dictionary with Dictionary" -msgstr "" +#~ msgid "E735: Can only compare Dictionary with Dictionary" +#~ msgstr "" -#: ../eval.c:3917 #, fuzzy -msgid "E736: Invalid operation for Dictionary" -msgstr "E116: Ongeldige parameters vir funksie %s" +#~ msgid "E736: Invalid operation for Dictionary" +#~ msgstr "E116: Ongeldige parameters vir funksie %s" -#: ../eval.c:3932 -msgid "E693: Can only compare Funcref with Funcref" -msgstr "" - -#: ../eval.c:3934 #, fuzzy -msgid "E694: Invalid operation for Funcrefs" -msgstr "E116: Ongeldige parameters vir funksie %s" +#~ msgid "E694: Invalid operation for Funcrefs" +#~ msgstr "E116: Ongeldige parameters vir funksie %s" -#: ../eval.c:4277 #, fuzzy -msgid "E804: Cannot use '%' with Float" -msgstr "E360: Kan nie dop met -f opsie uitvoer nie" +#~ msgid "E804: Cannot use '%' with Float" +#~ msgstr "E360: Kan nie dop met -f opsie uitvoer nie" -#: ../eval.c:4478 msgid "E110: Missing ')'" msgstr "E110: Ontbrekende ')'" -#: ../eval.c:4609 #, fuzzy -msgid "E695: Cannot index a Funcref" -msgstr "E90: Kan nie laaste buffer uitlaai nie" +#~ msgid "E695: Cannot index a Funcref" +#~ msgstr "E90: Kan nie laaste buffer uitlaai nie" + +#, fuzzy +#~ msgid "E909: Cannot index a special variable" +#~ msgstr "E90: Kan nie laaste buffer uitlaai nie" -#: ../eval.c:4839 #, c-format msgid "E112: Option name missing: %s" msgstr "E112: Opsienaam ontbreek: %s" -#: ../eval.c:4855 #, c-format msgid "E113: Unknown option: %s" msgstr "E113: Onbekende opsie: %s" -#: ../eval.c:4904 #, c-format msgid "E114: Missing quote: %s" msgstr "E114: Ontbrekende aanhalingsteken: %s" -#: ../eval.c:5020 #, c-format msgid "E115: Missing quote: %s" msgstr "E115: Ontbrekende aanhalingsteken: %s" -#: ../eval.c:5084 #, fuzzy, c-format -msgid "E696: Missing comma in List: %s" -msgstr "E405: Ontbrekende gelykaanteken: %s" +#~ msgid "E696: Missing comma in List: %s" +#~ msgstr "E405: Ontbrekende gelykaanteken: %s" -#: ../eval.c:5091 #, fuzzy, c-format -msgid "E697: Missing end of List ']': %s" -msgstr "E398: Ontbrekende '=': %s" +#~ msgid "E697: Missing end of List ']': %s" +#~ msgstr "E398: Ontbrekende '=': %s" + +#~ msgid "Not enough memory to set references, garbage collection aborted!" +#~ msgstr "" -#: ../eval.c:6475 #, fuzzy, c-format -msgid "E720: Missing colon in Dictionary: %s" -msgstr "E242: Ontbrekende kleur: %s" +#~ msgid "E720: Missing colon in Dictionary: %s" +#~ msgstr "E242: Ontbrekende kleur: %s" -#: ../eval.c:6499 #, c-format -msgid "E721: Duplicate key in Dictionary: \"%s\"" -msgstr "" +#~ msgid "E721: Duplicate key in Dictionary: \"%s\"" +#~ msgstr "" -#: ../eval.c:6517 #, fuzzy, c-format -msgid "E722: Missing comma in Dictionary: %s" -msgstr "E242: Ontbrekende kleur: %s" +#~ msgid "E722: Missing comma in Dictionary: %s" +#~ msgstr "E242: Ontbrekende kleur: %s" -#: ../eval.c:6524 #, fuzzy, c-format -msgid "E723: Missing end of Dictionary '}': %s" -msgstr "E126: Ontbrekende ':endfunction'" +#~ msgid "E723: Missing end of Dictionary '}': %s" +#~ msgstr "E126: Ontbrekende ':endfunction'" -#: ../eval.c:6555 -#, fuzzy -msgid "E724: variable nested too deep for displaying" -msgstr "E22: Skripte te diep ge-nes" +#, c-format +msgid "E125: Illegal argument: %s" +msgstr "E125: Ongeldige parameter: %s" -#: ../eval.c:7188 #, fuzzy, c-format -msgid "E740: Too many arguments for function %s" -msgstr "E118: Te veel parameters vir funksie: %s" +#~ msgid "E853: Duplicate argument name: %s" +#~ msgstr "E125: Ongeldige parameter: %s" + +#, fuzzy, c-format +#~ msgid "E740: Too many arguments for function %s" +#~ msgstr "E118: Te veel parameters vir funksie: %s" -#: ../eval.c:7190 #, c-format msgid "E116: Invalid arguments for function %s" msgstr "E116: Ongeldige parameters vir funksie %s" -#: ../eval.c:7377 #, c-format msgid "E117: Unknown function: %s" msgstr "E117: Onbekende funksie: %s" -#: ../eval.c:7383 +#, fuzzy, c-format +#~ msgid "E933: Function was deleted: %s" +#~ msgstr "E129: Funksienaam vereis" + #, c-format msgid "E119: Not enough arguments for function: %s" msgstr "E119: Te min parameters vir funksie: %s" -#: ../eval.c:7387 #, c-format msgid "E120: Using not in a script context: %s" msgstr "E120: word buite skripkonteks gebruik: %s" -#: ../eval.c:7391 #, c-format -msgid "E725: Calling dict function without Dictionary: %s" -msgstr "" +#~ msgid "E725: Calling dict function without Dictionary: %s" +#~ msgstr "" + +#, c-format +#~ msgid "Error converting the call result: %s" +#~ msgstr "" -#: ../eval.c:7453 #, fuzzy -msgid "E808: Number or Float required" -msgstr "E521: Nommer vereis na =" +#~ msgid "E699: Too many arguments" +#~ msgstr "Te veel redigeer-parameters" -#: ../eval.c:7503 #, fuzzy -msgid "add() argument" -msgstr "Ongeldige parameter vir" +#~ msgid "E785: complete() can only be used in Insert mode" +#~ msgstr "E328: Kieslys bestaan slegs in 'n ander modus" + +msgid "&Ok" +msgstr "&Ok" -#: ../eval.c:7907 #, fuzzy -msgid "E699: Too many arguments" -msgstr "Te veel redigeer-parameters" +#~ msgid "dictwatcheradd() argument" +#~ msgstr "Ongeldige parameter vir" + +#~ msgid "extend() argument" +#~ msgstr "" -#: ../eval.c:8073 #, fuzzy -msgid "E785: complete() can only be used in Insert mode" -msgstr "E328: Kieslys bestaan slegs in 'n ander modus" +#~ msgid "map() argument" +#~ msgstr " vim [parameters] " -#: ../eval.c:8156 -msgid "&Ok" -msgstr "&Ok" +#~ msgid "filter() argument" +#~ msgstr "" -#: ../eval.c:8676 #, fuzzy, c-format -msgid "E737: Key already exists: %s" -msgstr "E227: binding bestaan alreeds vir %s" +#~ msgid "+-%s%3ld line: " +#~ msgid_plural "+-%s%3ld lines: " +#~ msgstr[0] "+-%s%3ld reëls: " +#~ msgstr[1] "+-%s%3ld reëls: " -#: ../eval.c:8692 -msgid "extend() argument" -msgstr "" +#, fuzzy, c-format +#~ msgid "E700: Unknown function: %s" +#~ msgstr "E117: Onbekende funksie: %s" + +#~ msgid "E922: expected a dict" +#~ msgstr "" -#: ../eval.c:8915 #, fuzzy -msgid "map() argument" -msgstr " vim [parameters] " +#~ msgid "E923: Second argument of function() must be a list or a dict" +#~ msgstr "E487: Parameter moet positief wees" -#: ../eval.c:8916 -msgid "filter() argument" -msgstr "" +#, fuzzy +#~ msgid "E5000: Cannot find tab number." +#~ msgstr "E90: Kan nie laaste buffer uitlaai nie" -#: ../eval.c:9229 -#, c-format -msgid "+-%s%3ld lines: " -msgstr "+-%s%3ld reëls: " +#~ msgid "E5001: Higher scope cannot be -1 if lower scope is >= 0." +#~ msgstr "" -#: ../eval.c:9291 -#, fuzzy, c-format -msgid "E700: Unknown function: %s" -msgstr "E117: Onbekende funksie: %s" +#, fuzzy +#~ msgid "E5002: Cannot find window number." +#~ msgstr "E671: Kan nie venster titel vind nie \"%s\"" + +#~ msgid "E5050: {opts} must be the only argument" +#~ msgstr "" -#: ../eval.c:10729 msgid "called inputrestore() more often than inputsave()" msgstr "inputrestore() is meer gereeld as inputsave() geroep" -#: ../eval.c:10771 #, fuzzy -msgid "insert() argument" -msgstr "Te veel redigeer-parameters" +#~ msgid "insert() argument" +#~ msgstr "Te veel redigeer-parameters" -#: ../eval.c:10841 #, fuzzy -msgid "E786: Range not allowed" -msgstr "E481: Geen omvang toegelaat nie" +#~ msgid "E786: Range not allowed" +#~ msgstr "E481: Geen omvang toegelaat nie" + +#~ msgid "Invalid stream on rpc job, use jobclose(id, 'rpc')" +#~ msgstr "" + +#~ msgid "Invalid job stream: Not an rpc job" +#~ msgstr "" + +#, c-format +#~ msgid "Invalid job stream \"%s\"" +#~ msgstr "" + +#~ msgid "Can't send data to the job: stdin is closed" +#~ msgstr "" + +#~ msgid "Can't send raw data to rpc channel" +#~ msgstr "" + +#~ msgid "E474: Failed to convert list to string" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "E474: Failed to parse %.*s" +#~ msgstr "E241: Kan nie na %s stuur nie" -#: ../eval.c:11140 #, fuzzy -msgid "E701: Invalid type for len()" -msgstr "E596: Ongeldige font(e)" +#~ msgid "E701: Invalid type for len()" +#~ msgstr "E596: Ongeldige font(e)" -#: ../eval.c:11980 -msgid "E726: Stride is zero" -msgstr "" +#, c-format +#~ msgid "E798: ID is reserved for \":match\": %" +#~ msgstr "" -#: ../eval.c:11982 -msgid "E727: Start past end" -msgstr "" +#, c-format +#~ msgid "E798: ID is reserved for \"match\": %" +#~ msgstr "" -#: ../eval.c:12024 ../eval.c:15297 -msgid "" -msgstr "" +#, fuzzy, c-format +#~ msgid "msgpackdump() argument, index %i" +#~ msgstr " vim [parameters] " -#: ../eval.c:12282 -msgid "remove() argument" -msgstr "" +#~ msgid "E5070: Character number must not be less than zero" +#~ msgstr "" + +#, c-format +#~ msgid "E5071: Character number must not be greater than INT_MAX (%i)" +#~ msgstr "" + +#~ msgid "E726: Stride is zero" +#~ msgstr "" + +#~ msgid "E727: Start past end" +#~ msgstr "" + +#~ msgid "" +#~ msgstr "" + +#~ msgid "remove() argument" +#~ msgstr "" -#: ../eval.c:12466 msgid "E655: Too many symbolic links (cycle?)" msgstr "E655: Te veel simboliese skakels (siklus?)" -#: ../eval.c:12593 -msgid "reverse() argument" -msgstr "" +#~ msgid "reverse() argument" +#~ msgstr "" -#: ../eval.c:13721 -msgid "sort() argument" -msgstr "" +#, fuzzy, c-format +#~ msgid "E927: Invalid action: '%s'" +#~ msgstr "E383: Ongeldige soekstring: %s" + +#, fuzzy, c-format +#~ msgid "connection failed: %s" +#~ msgstr "XSMP 'SmcOpenConnection' het gefaal: %s" + +#~ msgid "sort() argument" +#~ msgstr "" -#: ../eval.c:13721 #, fuzzy -msgid "uniq() argument" -msgstr "Ongeldige parameter vir" +#~ msgid "uniq() argument" +#~ msgstr "Ongeldige parameter vir" -#: ../eval.c:13776 #, fuzzy -msgid "E702: Sort compare function failed" -msgstr "E237: Drukker-seleksie het gefaal" +#~ msgid "E702: Sort compare function failed" +#~ msgstr "E237: Drukker-seleksie het gefaal" -#: ../eval.c:13806 -msgid "E882: Uniq compare function failed" -msgstr "" +#~ msgid "E882: Uniq compare function failed" +#~ msgstr "" -#: ../eval.c:14085 msgid "(Invalid)" msgstr "(Ongeldig)" -#: ../eval.c:14590 -#, fuzzy -msgid "E677: Error writing temp file" -msgstr "E208: Kan nie skryf na \"%s\"" - -#: ../eval.c:16159 -msgid "E805: Using a Float as a Number" -msgstr "" +#, fuzzy, c-format +#~ msgid "E935: invalid submatch number: %d" +#~ msgstr "E354: Ongeldige registernaam: '%s'" -#: ../eval.c:16162 -msgid "E703: Using a Funcref as a Number" -msgstr "" +#~ msgid "Can only call this function in an unmodified buffer" +#~ msgstr "" -#: ../eval.c:16170 -msgid "E745: Using a List as a Number" -msgstr "" +#, fuzzy +#~ msgid "E921: Invalid callback argument" +#~ msgstr "E474: Ongeldige parameter" -#: ../eval.c:16173 -msgid "E728: Using a Dictionary as a Number" -msgstr "" +#, fuzzy, c-format +#~ msgid "E80: Error while writing: %s" +#~ msgstr "E80: Fout tydens skryfoperasie" -#: ../eval.c:16259 -msgid "E729: using Funcref as a String" -msgstr "" +#. Using %s, p and not %c, *p to preserve multibyte characters +#, fuzzy, c-format +#~ msgid "E5060: Unknown flag: %s" +#~ msgstr "E235: Onbekende font: %s" -#: ../eval.c:16262 #, fuzzy -msgid "E730: using List as a String" -msgstr "E374: Ontbrekende ] in formaatstring" +#~ msgid "E482: Can't open file with an empty name" +#~ msgstr "E212: Kan lêer nie oopmaak vir skryf nie" -#: ../eval.c:16265 -msgid "E731: using Dictionary as a String" -msgstr "" +#, fuzzy, c-format +#~ msgid "E482: Can't open file %s for writing: %s" +#~ msgstr "E212: Kan lêer nie oopmaak vir skryf nie" -#: ../eval.c:16619 #, fuzzy, c-format -msgid "E706: Variable type mismatch for: %s" -msgstr "E93: Meer as een treffer vir %s" +#~ msgid "E80: Error when closing file %s: %s" +#~ msgstr "E209: Kan \"%s\" nie sluit nie" -#: ../eval.c:16705 #, fuzzy, c-format -msgid "E795: Cannot delete variable %s" -msgstr "E46: Kan nie lees-alleen veranderlike stel nie \"%s\"" +#~ msgid "E794: Cannot set variable in the sandbox: \"%.*s\"" +#~ msgstr "E46: Kan nie lees-alleen veranderlike stel nie \"%s\"" -#: ../eval.c:16724 #, fuzzy, c-format -msgid "E704: Funcref variable name must start with a capital: %s" -msgstr "E128: Funksienaam moet met 'n hoofletter begin: %s" +#~ msgid "E795: Cannot delete variable %.*s" +#~ msgstr "E46: Kan nie lees-alleen veranderlike stel nie \"%s\"" -#: ../eval.c:16732 -#, c-format -msgid "E705: Variable name conflicts with existing function: %s" -msgstr "" +#, fuzzy, c-format +#~ msgid "E704: Funcref variable name must start with a capital: %s" +#~ msgstr "E128: Funksienaam moet met 'n hoofletter begin: %s" -#: ../eval.c:16763 #, c-format -msgid "E741: Value is locked: %s" -msgstr "" - -#: ../eval.c:16764 ../eval.c:16769 ../message.c:1839 -msgid "Unknown" -msgstr "Onbekend" - -#: ../eval.c:16768 -#, fuzzy, c-format -msgid "E742: Cannot change value of %s" -msgstr "E284: Kan nie IC waardes stel nie" +#~ msgid "E705: Variable name conflicts with existing function: %s" +#~ msgstr "" -#: ../eval.c:16838 -msgid "E698: variable nested too deep for making a copy" -msgstr "" +#~ msgid "E698: variable nested too deep for making a copy" +#~ msgstr "" -#: ../eval.c:17249 #, c-format msgid "E123: Undefined function: %s" msgstr "E123: Ongedefinieerde funksie: %s" -#: ../eval.c:17260 #, c-format msgid "E124: Missing '(': %s" msgstr "E124: Ontbrekende '(': %s" -#: ../eval.c:17293 #, fuzzy -msgid "E862: Cannot use g: here" -msgstr "E284: Kan nie IC waardes stel nie" +#~ msgid "E862: Cannot use g: here" +#~ msgstr "E284: Kan nie IC waardes stel nie" -#: ../eval.c:17312 #, c-format -msgid "E125: Illegal argument: %s" -msgstr "E125: Ongeldige parameter: %s" - -#: ../eval.c:17323 -#, fuzzy, c-format -msgid "E853: Duplicate argument name: %s" -msgstr "E125: Ongeldige parameter: %s" +#~ msgid "E932: Closure function should not be at top level: %s" +#~ msgstr "" -#: ../eval.c:17416 msgid "E126: Missing :endfunction" msgstr "E126: Ontbrekende ':endfunction'" -#: ../eval.c:17537 #, fuzzy, c-format -msgid "E707: Function name conflicts with variable: %s" -msgstr "E128: Funksienaam moet met 'n hoofletter begin: %s" +#~ msgid "E707: Function name conflicts with variable: %s" +#~ msgstr "E128: Funksienaam moet met 'n hoofletter begin: %s" -#: ../eval.c:17549 #, c-format msgid "E127: Cannot redefine function %s: It is in use" msgstr "E127: Kan funksie %s nie herdefinieer nie: Dit is in gebruik" -#: ../eval.c:17604 #, fuzzy, c-format -msgid "E746: Function name does not match script file name: %s" -msgstr "E128: Funksienaam moet met 'n hoofletter begin: %s" +#~ msgid "E746: Function name does not match script file name: %s" +#~ msgstr "E128: Funksienaam moet met 'n hoofletter begin: %s" -#: ../eval.c:17716 msgid "E129: Function name required" msgstr "E129: Funksienaam vereis" -#: ../eval.c:17824 #, fuzzy, c-format -msgid "E128: Function name must start with a capital or \"s:\": %s" -msgstr "E128: Funksienaam moet met 'n hoofletter begin: %s" +#~ msgid "E128: Function name must start with a capital or \"s:\": %s" +#~ msgstr "E128: Funksienaam moet met 'n hoofletter begin: %s" -#: ../eval.c:17833 #, fuzzy, c-format -msgid "E884: Function name cannot contain a colon: %s" -msgstr "E128: Funksienaam moet met 'n hoofletter begin: %s" +#~ msgid "E884: Function name cannot contain a colon: %s" +#~ msgstr "E128: Funksienaam moet met 'n hoofletter begin: %s" -#: ../eval.c:18336 #, c-format msgid "E131: Cannot delete function %s: It is in use" msgstr "E131: Kan funksie %s nie verwyder nie: Dit is in gebruik" -#: ../eval.c:18441 +#, fuzzy, c-format +#~ msgid "Cannot delete function %s: It is being used internally" +#~ msgstr "E131: Kan funksie %s nie verwyder nie: Dit is in gebruik" + msgid "E132: Function call depth is higher than 'maxfuncdepth'" msgstr "E132: Funksieroepdiepte is groter as 'maxfuncdepth'" -#: ../eval.c:18568 #, c-format msgid "calling %s" msgstr "roep %s" -#: ../eval.c:18651 #, c-format msgid "%s aborted" msgstr "%s gekanselleer" -#: ../eval.c:18653 #, c-format msgid "%s returning #%" msgstr "%s lewer #% op" -#: ../eval.c:18670 #, fuzzy, c-format -msgid "%s returning %s" -msgstr "%s lewer \"%s\" op" +#~ msgid "%s returning %s" +#~ msgstr "%s lewer \"%s\" op" -#: ../eval.c:18691 ../ex_cmds2.c:2695 #, c-format msgid "continuing in %s" msgstr "vervolg in %s" -#: ../eval.c:18795 msgid "E133: :return not inside a function" msgstr "E133: ':return' buite funksie" -#: ../eval.c:19159 -msgid "" -"\n" -"# global variables:\n" -msgstr "" -"\n" -"# globale veranderlikes:\n" - -#: ../eval.c:19254 msgid "" "\n" "\tLast set from " @@ -1071,154 +910,418 @@ msgstr "" "\n" "\tLaas gestel vanaf " -#: ../eval.c:19272 -#, fuzzy -msgid "No old files" -msgstr "Geen ingeslote lêers nie" +#~ msgid "E5009: $VIMRUNTIME is empty or unset" +#~ msgstr "" -#: ../ex_cmds.c:122 #, c-format -msgid "<%s>%s%s %d, Hex %02x, Octal %03o" -msgstr "<%s>%s%s %d, Hex %02x, Oktaal %03o" +#~ msgid "E5009: Invalid $VIMRUNTIME: %s" +#~ msgstr "" -#: ../ex_cmds.c:145 #, c-format -msgid "> %d, Hex %04x, Octal %o" -msgstr "> %d, Hex %04x, Oktaal %o" +#~ msgid "E474: Expected comma before list item: %s" +#~ msgstr "" -#: ../ex_cmds.c:146 #, c-format -msgid "> %d, Hex %08x, Octal %o" -msgstr "> %d, Hex %08x, Oktaal %o" +#~ msgid "E474: Expected colon before dictionary value: %s" +#~ msgstr "" -#: ../ex_cmds.c:684 -msgid "E134: Move lines into themselves" -msgstr "E134: Skuif reëls in hulself in" +#, fuzzy, c-format +#~ msgid "E474: Expected string key: %s" +#~ msgstr "E415: onverwagte gelykaanteken: %s" -#: ../ex_cmds.c:747 -msgid "1 line moved" -msgstr "1 reël geskuif" +#, fuzzy, c-format +#~ msgid "E474: Expected comma before dictionary key: %s" +#~ msgstr "E242: Ontbrekende kleur: %s" + +#, fuzzy, c-format +#~ msgid "E474: Unfinished escape sequence: %.*s" +#~ msgstr "E540: Onvoltooide uitdrukkingreeks" -#: ../ex_cmds.c:749 #, c-format -msgid "% lines moved" -msgstr "% reëls geskuif" +#~ msgid "E474: Unfinished unicode escape sequence: %.*s" +#~ msgstr "" -#: ../ex_cmds.c:1175 #, c-format -msgid "% lines filtered" -msgstr "% reëls filtreer" +#~ msgid "E474: Expected four hex digits after \\u: %.*s" +#~ msgstr "" -#: ../ex_cmds.c:1194 -msgid "E135: *Filter* Autocommands must not change current buffer" -msgstr "E135: *Filter* Outobevele mag nie die huidige buffer verander nie" +#, fuzzy, c-format +#~ msgid "E474: Unknown escape sequence: %.*s" +#~ msgstr "E409: Onbekende groepnaam: %s" -#: ../ex_cmds.c:1244 -msgid "[No write since last change]\n" -msgstr "[Ongestoor sedert vorige verandering]\n" +#, c-format +#~ msgid "E474: ASCII control characters cannot be present inside string: %.*s" +#~ msgstr "" + +#, c-format +#~ msgid "E474: Only UTF-8 strings allowed: %.*s" +#~ msgstr "" + +#, c-format +#~ msgid "" +#~ "E474: Only UTF-8 code points up to U+10FFFF are allowed to appear unescaped: " +#~ "%.*s" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "E474: Expected string end: %.*s" +#~ msgstr "E415: onverwagte gelykaanteken: %s" + +#, fuzzy, c-format +#~ msgid "E474: Leading zeroes are not allowed: %.*s" +#~ msgstr "E481: Geen omvang toegelaat nie" + +#, fuzzy, c-format +#~ msgid "E474: Missing number after minus sign: %.*s" +#~ msgstr "E526: Ontbrekende nommer na <%s>" + +#, fuzzy, c-format +#~ msgid "E474: Missing number after decimal dot: %.*s" +#~ msgstr "E526: Ontbrekende nommer na <%s>" + +#, fuzzy, c-format +#~ msgid "E474: Missing exponent: %.*s" +#~ msgstr "E114: Ontbrekende aanhalingsteken: %s" + +#, c-format +#~ msgid "" +#~ "E685: internal error: while converting number \"%.*s\" to float string2float " +#~ "consumed %zu bytes in place of %zu" +#~ msgstr "" -#: ../ex_cmds.c:1424 #, c-format -msgid "%sviminfo: %s in line: " -msgstr "%sviminfo: %s in reël: " +#~ msgid "" +#~ "E685: internal error: while converting number \"%.*s\" to integer vim_str2nr " +#~ "consumed %i bytes in place of %zu" +#~ msgstr "" -#: ../ex_cmds.c:1431 -msgid "E136: viminfo: Too many errors, skipping rest of file" -msgstr "E136: viminfo: Te veel foute, slaan die res van die lêer oor" +#~ msgid "E474: Attempt to decode a blank string" +#~ msgstr "" -#: ../ex_cmds.c:1458 #, c-format -msgid "Reading viminfo file \"%s\"%s%s%s" -msgstr "Besig om viminfo lêer \"%s\"%s%s%s te lees" +#~ msgid "E474: No container to close: %.*s" +#~ msgstr "" -#: ../ex_cmds.c:1460 -msgid " info" -msgstr " inligting" +#, c-format +#~ msgid "E474: Closing list with curly bracket: %.*s" +#~ msgstr "" -#: ../ex_cmds.c:1461 -msgid " marks" -msgstr " merkers" +#, c-format +#~ msgid "E474: Closing dictionary with square bracket: %.*s" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "E474: Trailing comma: %.*s" +#~ msgstr "E488: Oorbodige karakters" + +#, c-format +#~ msgid "E474: Expected value after colon: %.*s" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "E474: Expected value: %.*s" +#~ msgstr "E415: onverwagte gelykaanteken: %s" + +#, fuzzy, c-format +#~ msgid "E474: Comma not inside container: %.*s" +#~ msgstr "E242: Kleurnaam is onbekend: %s" + +#, fuzzy, c-format +#~ msgid "E474: Duplicate comma: %.*s" +#~ msgstr "E125: Ongeldige parameter: %s" + +#, fuzzy, c-format +#~ msgid "E474: Comma after colon: %.*s" +#~ msgstr "E254: Kan nie kleur %s toeken nie" + +#, fuzzy, c-format +#~ msgid "E474: Using comma in place of colon: %.*s" +#~ msgstr "E242: Ontbrekende kleur: %s" + +#, c-format +#~ msgid "E474: Leading comma: %.*s" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "E474: Colon not inside container: %.*s" +#~ msgstr "E242: Kleurnaam is onbekend: %s" + +#, fuzzy, c-format +#~ msgid "E474: Using colon not in dictionary: %.*s" +#~ msgstr "E242: Ontbrekende kleur: %s" + +#, fuzzy, c-format +#~ msgid "E474: Unexpected colon: %.*s" +#~ msgstr "E415: onverwagte gelykaanteken: %s" + +#, c-format +#~ msgid "E474: Colon after comma: %.*s" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "E474: Duplicate colon: %.*s" +#~ msgstr "gelaaide fontnaam: %s" + +#, fuzzy, c-format +#~ msgid "E474: Expected null: %.*s" +#~ msgstr "E415: onverwagte gelykaanteken: %s" + +#, fuzzy, c-format +#~ msgid "E474: Expected true: %.*s" +#~ msgstr "E415: onverwagte gelykaanteken: %s" + +#, fuzzy, c-format +#~ msgid "E474: Expected false: %.*s" +#~ msgstr "E415: onverwagte gelykaanteken: %s" + +#, fuzzy, c-format +#~ msgid "E474: Unidentified byte: %.*s" +#~ msgstr "E121: Ongedefinieerde veranderlike: %s" + +#, fuzzy, c-format +#~ msgid "E474: Trailing characters: %.*s" +#~ msgstr "E488: Oorbodige karakters" + +#, fuzzy, c-format +#~ msgid "E474: Unexpected end of input: %.*s" +#~ msgstr "E415: onverwagte gelykaanteken: %s" + +#, c-format +#~ msgid "key %s" +#~ msgstr "" + +#, c-format +#~ msgid "key %s at index %i from special map" +#~ msgstr "" + +#, c-format +#~ msgid "index %i" +#~ msgstr "" + +#~ msgid "partial" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "argument %i" +#~ msgstr " vim [parameters] " + +#~ msgid "partial self dictionary" +#~ msgstr "" + +#~ msgid "itself" +#~ msgstr "" + +#. Only give this message once for a recursive call to avoid +#. flooding the user with errors. +#~ msgid "E724: unable to correctly dump variable with self-referencing container" +#~ msgstr "" + +#~ msgid "E474: Unable to represent NaN value in JSON" +#~ msgstr "" + +#~ msgid "E474: Unable to represent infinity in JSON" +#~ msgstr "" + +#, c-format +#~ msgid "" +#~ "E474: String \"%.*s\" contains byte that does not start any UTF-8 character" +#~ msgstr "" + +#, c-format +#~ msgid "" +#~ "E474: UTF-8 string contains code point which belongs to a surrogate pair: " +#~ "%.*s" +#~ msgstr "" -#: ../ex_cmds.c:1462 #, fuzzy -msgid " oldfiles" -msgstr "Geen ingeslote lêers nie" +#~ msgid "E474: Unable to convert EXT string to JSON" +#~ msgstr "E620: Kon nie van wye-greep na \"%s\" enkodering verander nie" -#: ../ex_cmds.c:1463 -msgid " FAILED" -msgstr " GEFAAL" +#, c-format +#~ msgid "E474: Error while dumping %s, %s: attempt to dump function reference" +#~ msgstr "" + +#, fuzzy +#~ msgid "E474: Invalid key in special dictionary" +#~ msgstr "E116: Ongeldige parameters vir funksie %s" + +#, fuzzy +#~ msgid "encode_tv2string() argument" +#~ msgstr "Te veel redigeer-parameters" + +#, fuzzy +#~ msgid ":echo argument" +#~ msgstr " vim [parameters] " + +#, fuzzy +#~ msgid "encode_tv2json() argument" +#~ msgstr "Te veel redigeer-parameters" + +#, c-format +#~ msgid "E5004: Error while dumping %s, %s: attempt to dump function reference" +#~ msgstr "" + +#, c-format +#~ msgid "E5005: Unable to dump %s: container references itself in %s" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "E684: list index out of range: %" +#~ msgstr "E322: reëlnommer buite perke: % verby die einde" + +#~ msgid "E6000: Argument is not a function or function name" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "E737: Key already exists: %s" +#~ msgstr "E227: binding bestaan alreeds vir %s" + +#~ msgid "E743: variable nested too deep for (un)lock" +#~ msgstr "" + +#, c-format +#~ msgid "E741: Value is locked: %.*s" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "E742: Cannot change value of %.*s" +#~ msgstr "E284: Kan nie IC waardes stel nie" + +msgid "Unknown" +msgstr "Onbekend" + +#~ msgid "E805: Expected a Number or a String, Float found" +#~ msgstr "" + +#~ msgid "E703: Expected a Number or a String, Funcref found" +#~ msgstr "" + +#~ msgid "E745: Expected a Number or a String, List found" +#~ msgstr "" + +#~ msgid "E728: Expected a Number or a String, Dictionary found" +#~ msgstr "" + +#, fuzzy +#~ msgid "E5300: Expected a Number or a String" +#~ msgstr "E373: Onverwagte %%%c in formaatstring" + +#~ msgid "E745: Using a List as a Number" +#~ msgstr "" + +#~ msgid "E728: Using a Dictionary as a Number" +#~ msgstr "" + +#~ msgid "E805: Using a Float as a Number" +#~ msgstr "" + +#, fuzzy +#~ msgid "E685: using an invalid value as a Number" +#~ msgstr "E19: Merker het ongeldige reëlnommer" + +#, fuzzy +#~ msgid "E730: using List as a String" +#~ msgstr "E374: Ontbrekende ] in formaatstring" + +#~ msgid "E731: using Dictionary as a String" +#~ msgstr "" + +#, fuzzy +#~ msgid "E908: using an invalid value as a String" +#~ msgstr "E374: Ontbrekende ] in formaatstring" + +#~ msgid "E891: Using a Funcref as a Float" +#~ msgstr "" + +#~ msgid "E892: Using a String as a Float" +#~ msgstr "" + +#, fuzzy +#~ msgid "E893: Using a List as a Float" +#~ msgstr "E374: Ontbrekende ] in formaatstring" + +#, fuzzy +#~ msgid "E894: Using a Dictionary as a Float" +#~ msgstr "E242: Ontbrekende kleur: %s" + +#~ msgid "E907: Using a special value as a Float" +#~ msgstr "" + +#, fuzzy +#~ msgid "E808: Number or Float required" +#~ msgstr "E521: Nommer vereis na =" + +#~ msgid "tcp address must be host:port" +#~ msgstr "" + +#~ msgid "failed to lookup host or port" +#~ msgstr "" + +#, fuzzy +#~ msgid "connection refused" +#~ msgstr "'cscope' verbinding gesluit" + +#, c-format +msgid "<%s>%s%s %d, Hex %02x, Octal %03o" +msgstr "<%s>%s%s %d, Hex %02x, Oktaal %03o" -#. avoid a wait_return for this message, it's annoying -#: ../ex_cmds.c:1541 #, c-format -msgid "E137: Viminfo file is not writable: %s" -msgstr "E137: Viminfo lêer is nie skryfbaar nie: %s" +msgid "> %d, Hex %04x, Octal %o" +msgstr "> %d, Hex %04x, Oktaal %o" -#: ../ex_cmds.c:1626 #, c-format -msgid "E138: Can't write viminfo file %s!" -msgstr "E138: Kan nie viminfo lêer %s stoor nie!" +msgid "> %d, Hex %08x, Octal %o" +msgstr "> %d, Hex %08x, Oktaal %o" + +msgid "E134: Move lines into themselves" +msgstr "E134: Skuif reëls in hulself in" + +msgid "1 line moved" +msgstr "1 reël geskuif" -#: ../ex_cmds.c:1635 #, c-format -msgid "Writing viminfo file \"%s\"" -msgstr "Besig om viminfo lêer \"%s\" te stoor" +msgid "% lines moved" +msgstr "% reëls geskuif" -#. Write the info: -#: ../ex_cmds.c:1720 #, c-format -msgid "# This viminfo file was generated by Vim %s.\n" -msgstr "# Hierdie viminfo lêer is gegenereer deur Vim %s.\n" +msgid "E482: Can't create file %s" +msgstr "E482: Kan nie lêer %s skep nie" -#: ../ex_cmds.c:1722 -msgid "" -"# You may edit it if you're careful!\n" -"\n" -msgstr "" -"# Jy mag dit wysig as jy versigtig is!\n" -"\n" +#, c-format +msgid "% lines filtered" +msgstr "% reëls filtreer" -#: ../ex_cmds.c:1723 -msgid "# Value of 'encoding' when this file was written\n" -msgstr "# Waarde van 'encoding' toe hierdie lêer gestoor is\n" +msgid "E135: *Filter* Autocommands must not change current buffer" +msgstr "E135: *Filter* Outobevele mag nie die huidige buffer verander nie" -#: ../ex_cmds.c:1800 -msgid "Illegal starting char" -msgstr "Ongeldige beginkarakter" +msgid "[No write since last change]\n" +msgstr "[Ongestoor sedert vorige verandering]\n" -#: ../ex_cmds.c:2162 msgid "Write partial file?" msgstr "Skryf gedeeltelike lêer?" -#: ../ex_cmds.c:2166 msgid "E140: Use ! to write partial buffer" msgstr "E140: Gebruik ! om gedeeltelike buffer te skryf" -#: ../ex_cmds.c:2281 #, fuzzy, c-format -msgid "Overwrite existing file \"%s\"?" -msgstr "Oorskryf bestaande lêer \"%.*s\"?" +#~ msgid "Overwrite existing file \"%s\"?" +#~ msgstr "Oorskryf bestaande lêer \"%.*s\"?" -#: ../ex_cmds.c:2317 #, c-format -msgid "Swap file \"%s\" exists, overwrite anyway?" -msgstr "" +#~ msgid "Swap file \"%s\" exists, overwrite anyway?" +#~ msgstr "" -#: ../ex_cmds.c:2326 #, fuzzy, c-format -msgid "E768: Swap file exists: %s (:silent! overrides)" -msgstr "E13: Lêer bestaan (gebruik ! om te dwing)" +#~ msgid "E768: Swap file exists: %s (:silent! overrides)" +#~ msgstr "E13: Lêer bestaan (gebruik ! om te dwing)" -#: ../ex_cmds.c:2381 #, c-format msgid "E141: No file name for buffer %" msgstr "E141: Geen lêernaam vir buffer % nie" -#: ../ex_cmds.c:2412 msgid "E142: File not written: Writing is disabled by 'write' option" msgstr "E142: Lêer nie gestoor nie: Stoor is afgeskakel deur die 'write' opsie" -#: ../ex_cmds.c:2434 #, fuzzy, c-format msgid "" "'readonly' option is set for \"%s\".\n" @@ -1227,823 +1330,667 @@ msgstr "" "'readonly' opsie is aan vir \"%.*s\".\n" "Wil jy dit forseer?" -#: ../ex_cmds.c:2439 #, c-format -msgid "" -"File permissions of \"%s\" are read-only.\n" -"It may still be possible to write it.\n" -"Do you wish to try?" -msgstr "" +#~ msgid "" +#~ "File permissions of \"%s\" are read-only.\n" +#~ "It may still be possible to write it.\n" +#~ "Do you wish to try?" +#~ msgstr "" -#: ../ex_cmds.c:2451 #, fuzzy, c-format -msgid "E505: \"%s\" is read-only (add ! to override)" -msgstr "is lees-alleen (gebruik ! om te dwing)" +#~ msgid "E505: \"%s\" is read-only (add ! to override)" +#~ msgstr "is lees-alleen (gebruik ! om te dwing)" -#: ../ex_cmds.c:3120 #, c-format msgid "E143: Autocommands unexpectedly deleted new buffer %s" msgstr "E143: Outobevele het nuwe buffer %s onverwags geskrap" -#: ../ex_cmds.c:3313 msgid "E144: non-numeric argument to :z" msgstr "E144: nie-numeriese parameter vir :z" -#: ../ex_cmds.c:3404 -msgid "E145: Shell commands not allowed in rvim" -msgstr "E145: Dop bevele nie toegelaat in rvim" +#, fuzzy +#~ msgid "E145: Shell commands not allowed in restricted mode" +#~ msgstr "E145: Dop bevele nie toegelaat in rvim" -#: ../ex_cmds.c:3498 msgid "E146: Regular expressions can't be delimited by letters" msgstr "E146: Patrone kan nie deur letters afgebaken word nie" -#: ../ex_cmds.c:3964 #, c-format msgid "replace with %s (y/n/a/q/l/^E/^Y)?" msgstr "vervang met %s (y/n/a/q/l/^E/^Y)?" -#: ../ex_cmds.c:4379 msgid "(Interrupted) " msgstr "(Onderbreek) " -#: ../ex_cmds.c:4384 #, fuzzy -msgid "1 match" -msgstr "; treffer " +#~ msgid "1 match" +#~ msgstr "; treffer " -#: ../ex_cmds.c:4384 msgid "1 substitution" msgstr "1 vervanging" -#: ../ex_cmds.c:4387 #, fuzzy, c-format -msgid "% matches" -msgstr "% veranderinge" +#~ msgid "% matches" +#~ msgstr "% veranderinge" -#: ../ex_cmds.c:4388 #, c-format msgid "% substitutions" msgstr "% vervangings" -#: ../ex_cmds.c:4392 msgid " on 1 line" msgstr " op 1 reël" -#: ../ex_cmds.c:4395 #, c-format msgid " on % lines" msgstr " op % reëls" -#: ../ex_cmds.c:4438 msgid "E147: Cannot do :global recursive" msgstr "E147: Kan nie :global rekursief doen nie " -#: ../ex_cmds.c:4467 msgid "E148: Regular expression missing from global" msgstr "E148: Patroon ontbreek uit globaal" -#: ../ex_cmds.c:4508 #, c-format msgid "Pattern found in every line: %s" msgstr "Patroon gevind in elke reël: %s" -#: ../ex_cmds.c:4510 #, fuzzy, c-format -msgid "Pattern not found: %s" -msgstr "Patroon nie gevind nie" - -#: ../ex_cmds.c:4587 -msgid "" -"\n" -"# Last Substitute String:\n" -"$" -msgstr "" -"\n" -"# Vorige Vervangstring:\n" -"$" +#~ msgid "Pattern not found: %s" +#~ msgstr "Patroon nie gevind nie" -#: ../ex_cmds.c:4679 msgid "E478: Don't panic!" msgstr "E478: Bly kalm!" -#: ../ex_cmds.c:4717 #, c-format msgid "E661: Sorry, no '%s' help for %s" msgstr "E661: Jammer, geen '%s' hulp vir %s nie" -#: ../ex_cmds.c:4719 #, c-format msgid "E149: Sorry, no help for %s" msgstr "E149: Jammer, geen hulp vir %s nie" -#: ../ex_cmds.c:4751 #, c-format msgid "Sorry, help file \"%s\" not found" msgstr "Jammer, hulplêer \"%s\" kan nie gevind word nie" -#: ../ex_cmds.c:5323 -#, c-format -msgid "E150: Not a directory: %s" -msgstr "E150: Nie 'n gids nie: %s" +#, fuzzy, c-format +#~ msgid "E151: No match: %s" +#~ msgstr "E480: Geen treffer: %s" -#: ../ex_cmds.c:5446 #, c-format msgid "E152: Cannot open %s for writing" msgstr "E152: Kan nie %s oopmaak om te skryf nie" -#: ../ex_cmds.c:5471 #, c-format msgid "E153: Unable to open %s for reading" msgstr "E153: Kan nie %s oop maak om te lees nie" -#: ../ex_cmds.c:5500 #, c-format msgid "E670: Mix of help file encodings within a language: %s" msgstr "E670: 'n Mengsel van hulplêer enkoderings in 'n taal: %s" -#: ../ex_cmds.c:5565 #, c-format msgid "E154: Duplicate tag \"%s\" in file %s/%s" msgstr "E154: Duplikaat etiket \"%s\" in lêer %s/%s" -#: ../ex_cmds.c:5687 +#, c-format +msgid "E150: Not a directory: %s" +msgstr "E150: Nie 'n gids nie: %s" + #, c-format msgid "E160: Unknown sign command: %s" msgstr "E160: Onbekende funksie: %s" -#: ../ex_cmds.c:5704 msgid "E156: Missing sign name" msgstr "E156: Ontbrekende tekennaam" -#: ../ex_cmds.c:5746 msgid "E612: Too many signs defined" msgstr "E612: Te veel tekens gedefinieer" -#: ../ex_cmds.c:5813 #, c-format msgid "E239: Invalid sign text: %s" msgstr "E239: Ongeldige tekenteks: %s" -#: ../ex_cmds.c:5844 ../ex_cmds.c:6035 #, c-format msgid "E155: Unknown sign: %s" msgstr "E155: Onbekende opsie: %s" -#: ../ex_cmds.c:5877 msgid "E159: Missing sign number" msgstr "E159: Ontbrekende tekennommer" -#: ../ex_cmds.c:5971 #, c-format msgid "E158: Invalid buffer name: %s" msgstr "E158: Ongeldige buffernaam: %s" -#: ../ex_cmds.c:6008 -#, c-format +#~ msgid "E934: Cannot jump to a buffer that does not have a name" +#~ msgstr "" + +#, c-format msgid "E157: Invalid sign ID: %" msgstr "E157: Ongeldige teken ID: %" -#: ../ex_cmds.c:6066 +#, c-format +#~ msgid "E885: Not possible to change sign %s" +#~ msgstr "" + msgid " (not supported)" msgstr " (word nie ondersteun nie)" -#: ../ex_cmds.c:6169 msgid "[Deleted]" msgstr "[Geskrap]" -#: ../ex_cmds2.c:139 +#, fuzzy +#~ msgid "No old files" +#~ msgstr "Geen ingeslote lêers nie" + msgid "Entering Debug mode. Type \"cont\" to continue." msgstr "Ontfoutmodus begin nou. Tik \"cont\" om te verlaat." -#: ../ex_cmds2.c:143 ../ex_docmd.c:759 #, c-format msgid "line %: %s" msgstr "reël %: %s" -#: ../ex_cmds2.c:145 #, c-format msgid "cmd: %s" msgstr "cmd: %s" -#: ../ex_cmds2.c:322 +#~ msgid "frame is zero" +#~ msgstr "" + +#, c-format +#~ msgid "frame at highest level: %d" +#~ msgstr "" + #, c-format msgid "Breakpoint in \"%s%s\" line %" msgstr "Inspeksiepunt in \"%s%s\" reël %" -#: ../ex_cmds2.c:581 #, c-format msgid "E161: Breakpoint not found: %s" msgstr "E161: Inspeksiepunt kon nie gevind word nie: %s" -#: ../ex_cmds2.c:611 msgid "No breakpoints defined" msgstr "Geen inspeksiepunte gedefinieer nie" -#: ../ex_cmds2.c:617 #, c-format msgid "%3d %s %s line %" msgstr "%3d %s %s reël %" -#: ../ex_cmds2.c:942 -msgid "E750: First use \":profile start {fname}\"" -msgstr "" +#~ msgid "E750: First use \":profile start {fname}\"" +#~ msgstr "" -#: ../ex_cmds2.c:1269 #, fuzzy, c-format -msgid "Save changes to \"%s\"?" -msgstr "Stoor veranderinge na \"%.*s\"?" +#~ msgid "Save changes to \"%s\"?" +#~ msgstr "Stoor veranderinge na \"%.*s\"?" -#: ../ex_cmds2.c:1271 ../ex_docmd.c:8851 msgid "Untitled" msgstr "Ongetiteld" -#: ../ex_cmds2.c:1421 #, c-format msgid "E162: No write since last change for buffer \"%s\"" msgstr "E162: Buffer \"%s\" is nie geskryf sedert vorige wysiging nie" -#: ../ex_cmds2.c:1480 msgid "Warning: Entered other buffer unexpectedly (check autocommands)" msgstr "Waarskuwing: Ander buffer onverwags betree (kyk na outobevele)" -#: ../ex_cmds2.c:1826 msgid "E163: There is only one file to edit" msgstr "E163: Daar is net een lêer om te bewerk" -#: ../ex_cmds2.c:1828 msgid "E164: Cannot go before first file" msgstr "E164: Kan nie vóór die eerste lêer gaan nie" -#: ../ex_cmds2.c:1830 msgid "E165: Cannot go beyond last file" msgstr "E165: Kan nie verby die laaste lêer gaan nie" -#: ../ex_cmds2.c:2175 #, c-format msgid "E666: compiler not supported: %s" msgstr "E666: vertaler word nie ondersteun nie: %s" -#: ../ex_cmds2.c:2257 #, c-format msgid "Searching for \"%s\" in \"%s\"" msgstr "Besig om te soek vir \"%s\" in \"%s\"" -#: ../ex_cmds2.c:2284 #, c-format msgid "Searching for \"%s\"" msgstr "Besig om te soek vir \"%s\"" -#: ../ex_cmds2.c:2307 -#, c-format -msgid "not found in 'runtimepath': \"%s\"" -msgstr "kon nie in 'runtimepath' gevind word nie: \"%s\"" +#, fuzzy, c-format +#~ msgid "not found in '%s': \"%s\"" +#~ msgstr "kon nie in 'runtimepath' gevind word nie: \"%s\"" -#: ../ex_cmds2.c:2472 #, c-format msgid "Cannot source a directory: \"%s\"" msgstr "Kan nie gids uitvoer nie: \"%s\"" -#: ../ex_cmds2.c:2518 #, c-format msgid "could not source \"%s\"" msgstr "kon nie \"%s\" uitvoer nie" -#: ../ex_cmds2.c:2520 #, c-format msgid "line %: could not source \"%s\"" msgstr "reël %: kon nie \"%s\" uitvoer nie" -#: ../ex_cmds2.c:2535 #, c-format msgid "sourcing \"%s\"" msgstr "besig om \"%s\" uit te voer" -#: ../ex_cmds2.c:2537 #, c-format msgid "line %: sourcing \"%s\"" msgstr "reël %: voer nou \"%s\" uit" -#: ../ex_cmds2.c:2693 #, c-format msgid "finished sourcing %s" msgstr "%s klaar uitgevoer" -#: ../ex_cmds2.c:2765 #, fuzzy -msgid "modeline" -msgstr "1 reël meer" +#~ msgid "modeline" +#~ msgstr "1 reël meer" -#: ../ex_cmds2.c:2767 #, fuzzy -msgid "--cmd argument" -msgstr " vim [parameters] " +#~ msgid "--cmd argument" +#~ msgstr " vim [parameters] " -#: ../ex_cmds2.c:2769 #, fuzzy -msgid "-c argument" -msgstr " vim [parameters] " +#~ msgid "-c argument" +#~ msgstr " vim [parameters] " -#: ../ex_cmds2.c:2771 #, fuzzy -msgid "environment variable" -msgstr "Stel die 'LANG' omgewingsveranderlike na jou lokaal toe" +#~ msgid "environment variable" +#~ msgstr "Stel die 'LANG' omgewingsveranderlike na jou lokaal toe" -#: ../ex_cmds2.c:2773 #, fuzzy -msgid "error handler" -msgstr "Fout en onderbreking" +#~ msgid "error handler" +#~ msgstr "Fout en onderbreking" -#: ../ex_cmds2.c:3020 msgid "W15: Warning: Wrong line separator, ^M may be missing" msgstr "W15: Waarskuwing: Verkeerde reëlskeiding, ^M ontbreek dalk" -#: ../ex_cmds2.c:3139 msgid "E167: :scriptencoding used outside of a sourced file" msgstr "E167: ':scriptencoding' buite 'n uitvoerlêer gebruik" -#: ../ex_cmds2.c:3166 msgid "E168: :finish used outside of a sourced file" msgstr "E168: ':finish' buite 'n uitvoerlêer gebruik" -#: ../ex_cmds2.c:3389 #, c-format msgid "Current %slanguage: \"%s\"" msgstr "Huidige %staal: \"%s\"" -#: ../ex_cmds2.c:3404 #, c-format msgid "E197: Cannot set language to \"%s\"" msgstr "E197: Kan nie taal na \"%s\" verander nie" #. don't redisplay the window #. don't wait for return -#: ../ex_docmd.c:387 msgid "Entering Ex mode. Type \"visual\" to go to Normal mode." msgstr "Betree Ex modus. Tik \"visual\" om na Normale modus terug te keer." -#: ../ex_docmd.c:428 msgid "E501: At end-of-file" msgstr "E501: By lêereinde" -#: ../ex_docmd.c:513 msgid "E169: Command too recursive" msgstr "E169: Bevel te rekursief" -#: ../ex_docmd.c:1006 +#, fuzzy +#~ msgid "line %" +#~ msgstr "reël %4ld:" + #, c-format msgid "E605: Exception not caught: %s" msgstr "E605: Uitsondering nie gevang nie: %s" -#: ../ex_docmd.c:1085 msgid "End of sourced file" msgstr "Einde van uitvoerlêer" -#: ../ex_docmd.c:1086 msgid "End of function" msgstr "Einde van funksie " -#: ../ex_docmd.c:1628 msgid "E464: Ambiguous use of user-defined command" msgstr "E464: Dubbelsinnige gebruik van gebruiker-gedefinieerde bevel" -#: ../ex_docmd.c:1638 msgid "E492: Not an editor command" msgstr "E492: Nie 'n verwerkerbevel nie" -#: ../ex_docmd.c:1729 msgid "E493: Backwards range given" msgstr "E493: Terugwaardse omvang gegee" -#: ../ex_docmd.c:1733 msgid "Backwards range given, OK to swap" msgstr "Terugwaardse omvang gegee, OK om te ruil" #. append #. typed wrong -#: ../ex_docmd.c:1787 msgid "E494: Use w or w>>" msgstr "E494: Gebruik w of w>>" -#: ../ex_docmd.c:3454 msgid "E319: The command is not available in this version" msgstr "E319: Jammer, die bevel is nie geïmplementeer nie" -#: ../ex_docmd.c:3752 -msgid "E172: Only one file name allowed" -msgstr "E172: Slegs een lêernaam toegelaat" - -#: ../ex_docmd.c:4238 msgid "1 more file to edit. Quit anyway?" msgstr "Nog 1 lêer om te bewerk. Stop in elk geval?" -#: ../ex_docmd.c:4242 #, c-format msgid "%d more files to edit. Quit anyway?" msgstr "Nog %d lêers om te bewerk. Stop in elk geval?" -#: ../ex_docmd.c:4248 msgid "E173: 1 more file to edit" msgstr "E173: Nog 1 lêer om te bewerk" -#: ../ex_docmd.c:4250 #, c-format msgid "E173: % more files to edit" msgstr "E173: Nog % lêers om te bewerk" -#: ../ex_docmd.c:4320 msgid "E174: Command already exists: add ! to replace it" msgstr "E174: Bevel bestaan alreeds: gebruik ! om te herdefinieer" -#: ../ex_docmd.c:4432 +#, fuzzy msgid "" "\n" -" Name Args Range Complete Definition" +" Name Args Address Complete Definition" msgstr "" "\n" " Naam Args Reeks Klaar Definisie" -#: ../ex_docmd.c:4516 msgid "No user-defined commands found" msgstr "Geen gebruiker-gedefinieerde bevele gevind nie" -#: ../ex_docmd.c:4538 msgid "E175: No attribute specified" msgstr "E175: Geen eienskappe gespesifiseer nie" -#: ../ex_docmd.c:4583 msgid "E176: Invalid number of arguments" msgstr "E176: Ongeldige aantal parameters" -#: ../ex_docmd.c:4594 msgid "E177: Count cannot be specified twice" msgstr "E177: Telling kan nie twee keer gespesifiseer word nie" -#: ../ex_docmd.c:4603 msgid "E178: Invalid default value for count" msgstr "E178: Ongeldige verstekwaarde vir telling" -#: ../ex_docmd.c:4625 #, fuzzy -msgid "E179: argument required for -complete" -msgstr "E179: parameter nodig vir voltooiing" +#~ msgid "E179: argument required for -complete" +#~ msgstr "E179: parameter nodig vir voltooiing" + +#, fuzzy +#~ msgid "E179: argument required for -addr" +#~ msgstr "E179: parameter nodig vir voltooiing" -#: ../ex_docmd.c:4635 #, c-format msgid "E181: Invalid attribute: %s" msgstr "E181: Ongeldige eienskap: %s" -#: ../ex_docmd.c:4678 msgid "E182: Invalid command name" msgstr "E182: Ongeldige bevelnaam" -#: ../ex_docmd.c:4691 msgid "E183: User defined commands must start with an uppercase letter" msgstr "E183: Gebruiker-gedefinieerde bevele moet met 'n hoofletter begin" -#: ../ex_docmd.c:4696 #, fuzzy -msgid "E841: Reserved name, cannot be used for user defined command" -msgstr "E464: Dubbelsinnige gebruik van gebruiker-gedefinieerde bevel" +#~ msgid "E841: Reserved name, cannot be used for user defined command" +#~ msgstr "E464: Dubbelsinnige gebruik van gebruiker-gedefinieerde bevel" -#: ../ex_docmd.c:4751 #, c-format msgid "E184: No such user-defined command: %s" msgstr "E184: Geen gebruiker-gedefinieerde bevel nie: %s" -#: ../ex_docmd.c:5219 +#, fuzzy, c-format +#~ msgid "E180: Invalid address type value: %s" +#~ msgstr "E180: Ongeldige voltooiingswaarde: %s" + #, c-format msgid "E180: Invalid complete value: %s" msgstr "E180: Ongeldige voltooiingswaarde: %s" -#: ../ex_docmd.c:5225 msgid "E468: Completion argument only allowed for custom completion" msgstr "E468: Voltooiingsargument words slegs toegelaat vir eie voltooiing" -#: ../ex_docmd.c:5231 msgid "E467: Custom completion requires a function argument" msgstr "E467: Eie voltooiing benodig 'n funksie parameter" -#: ../ex_docmd.c:5257 #, fuzzy, c-format -msgid "E185: Cannot find color scheme '%s'" -msgstr "E185: Kan nie kleurskema %s vind nie" +#~ msgid "E185: Cannot find color scheme '%s'" +#~ msgstr "E185: Kan nie kleurskema %s vind nie" -#: ../ex_docmd.c:5263 msgid "Greetings, Vim user!" msgstr "Goeiedag, Vim gebruiker!" -#: ../ex_docmd.c:5431 #, fuzzy -msgid "E784: Cannot close last tab page" -msgstr "E444: Kan nie laaste venster toemaak nie" +#~ msgid "E784: Cannot close last tab page" +#~ msgstr "E444: Kan nie laaste venster toemaak nie" -#: ../ex_docmd.c:5462 #, fuzzy -msgid "Already only one tab page" -msgstr "Daar is alreeds slegs een venster" +#~ msgid "Already only one tab page" +#~ msgstr "Daar is alreeds slegs een venster" -#: ../ex_docmd.c:6004 #, fuzzy, c-format -msgid "Tab page %d" -msgstr "Bladsy %d" +#~ msgid "Tab page %d" +#~ msgstr "Bladsy %d" -#: ../ex_docmd.c:6295 msgid "No swap file" msgstr "Geen ruillêer" -#: ../ex_docmd.c:6478 -#, fuzzy -msgid "E747: Cannot change directory, buffer is modified (add ! to override)" -msgstr "E509: Kan rugsteunlêer nie skep nie (gebruik ! om te dwing)" - -#: ../ex_docmd.c:6485 msgid "E186: No previous directory" msgstr "E186: Geen vorige gids nie" -#: ../ex_docmd.c:6530 msgid "E187: Unknown" msgstr "E187: Onbekend" -#: ../ex_docmd.c:6610 msgid "E465: :winsize requires two number arguments" msgstr "E465: ':winsize' benodig twee nommer parameters" -#: ../ex_docmd.c:6655 -msgid "E188: Obtaining window position not implemented for this platform" -msgstr "" -"E188: Verkryging van vensterposisie is nie vir hierdie platform " -"geïmplementeer nie" - -#: ../ex_docmd.c:6662 -msgid "E466: :winpos requires two number arguments" -msgstr "E466: :winpos benodig twee parameters" - -#: ../ex_docmd.c:7241 -#, fuzzy, c-format -msgid "E739: Cannot create directory: %s" -msgstr "Kan nie gids uitvoer nie: \"%s\"" - -#: ../ex_docmd.c:7268 #, c-format msgid "E189: \"%s\" exists (add ! to override)" msgstr "E189: \"%s\" bestaan (gebruik ! om te dwing)" -#: ../ex_docmd.c:7273 #, c-format msgid "E190: Cannot open \"%s\" for writing" msgstr "E190: Kan \"%s\" nie oopmaak vir skryf nie" #. set mark -#: ../ex_docmd.c:7294 msgid "E191: Argument must be a letter or forward/backward quote" msgstr "" "E191: Parameter moet 'n letter of 'n terug/vorentoe aanhalingsteken wees" -#: ../ex_docmd.c:7333 msgid "E192: Recursive use of :normal too deep" msgstr "E192: Rekursiewe gebruik van ':normal' te diep" -#: ../ex_docmd.c:7807 msgid "E194: No alternate file name to substitute for '#'" msgstr "E194: Geen alternatiewe lêernaam vir '#' nie" -#: ../ex_docmd.c:7841 msgid "E495: no autocommand file name to substitute for \"\"" msgstr "E495: geen outobevel-lêernaam om \"\" mee te vervang nie" -#: ../ex_docmd.c:7850 msgid "E496: no autocommand buffer number to substitute for \"\"" msgstr "E496: geen outobevel buffernommer om \"\" mee te vervang nie" -#: ../ex_docmd.c:7861 msgid "E497: no autocommand match name to substitute for \"\"" msgstr "E497: geen outobevel treffernaam om \"\" mee te vervang nie" -#: ../ex_docmd.c:7870 msgid "E498: no :source file name to substitute for \"\"" msgstr "E498: geen ':source' lêernaam om \"\" mee te vervang nie" -#: ../ex_docmd.c:7876 #, fuzzy -msgid "E842: no line number to use for \"\"" -msgstr "E498: geen ':source' lêernaam om \"\" mee te vervang nie" +#~ msgid "E842: no line number to use for \"\"" +#~ msgstr "E498: geen ':source' lêernaam om \"\" mee te vervang nie" -#: ../ex_docmd.c:7903 #, c-format msgid "E499: Empty file name for '%' or '#', only works with \":p:h\"" msgstr "E499: Leë lêernaam vir '%' of '#', werk slegs met \":p:h\"" -#: ../ex_docmd.c:7905 msgid "E500: Evaluates to an empty string" msgstr "E500: Evalueer na 'n leë string" -#: ../ex_docmd.c:8838 -msgid "E195: Cannot open viminfo file for reading" -msgstr "E195: Kan 'viminfo' lêer nie oopmaak om te lees nie" - -#: ../ex_eval.c:464 msgid "E608: Cannot :throw exceptions with 'Vim' prefix" msgstr "E608: Kan nie uitsonderings ':throw' met 'Vim' voorvoegsel nie" #. always scroll up, don't overwrite -#: ../ex_eval.c:496 #, c-format msgid "Exception thrown: %s" msgstr "Uitsondering gegooi: %s" -#: ../ex_eval.c:545 +#. always scroll up, don't overwrite #, c-format msgid "Exception finished: %s" msgstr "Uitsondering het klaar gemaak: %s" -#: ../ex_eval.c:546 #, c-format msgid "Exception discarded: %s" msgstr "Uitsondering weg gegooi: %s" -#: ../ex_eval.c:588 ../ex_eval.c:634 #, c-format msgid "%s, line %" msgstr "%s, reël %" #. always scroll up, don't overwrite -#: ../ex_eval.c:608 #, c-format msgid "Exception caught: %s" msgstr "Uitsondering gevang: %s" -#: ../ex_eval.c:676 #, c-format msgid "%s made pending" msgstr "%s is afwagtend gemaak" -#: ../ex_eval.c:679 #, c-format msgid "%s resumed" msgstr "%s teruggekeer" -#: ../ex_eval.c:683 #, c-format msgid "%s discarded" msgstr "%s weg gegooi" -#: ../ex_eval.c:708 msgid "Exception" msgstr "Uitsondering" -#: ../ex_eval.c:713 msgid "Error and interrupt" msgstr "Fout en onderbreking" -#: ../ex_eval.c:715 msgid "Error" msgstr "Fout" #. if (pending & CSTP_INTERRUPT) -#: ../ex_eval.c:717 msgid "Interrupt" msgstr "Onderbreek" -#: ../ex_eval.c:795 msgid "E579: :if nesting too deep" msgstr "E579: geneste ':if' te diep" -#: ../ex_eval.c:830 msgid "E580: :endif without :if" msgstr "E580: ':endif' sonder ':if'" -#: ../ex_eval.c:873 msgid "E581: :else without :if" msgstr "E581: ':else' sonder ':if'" -#: ../ex_eval.c:876 msgid "E582: :elseif without :if" msgstr "E582: ':elseif' sonder ':if'" -#: ../ex_eval.c:880 msgid "E583: multiple :else" msgstr "E583: meer as een ':else'" -#: ../ex_eval.c:883 msgid "E584: :elseif after :else" msgstr "E584: ':elseif' na ':else'" -#: ../ex_eval.c:941 #, fuzzy -msgid "E585: :while/:for nesting too deep" -msgstr "E585: ':while' te diep genes" +#~ msgid "E585: :while/:for nesting too deep" +#~ msgstr "E585: ':while' te diep genes" -#: ../ex_eval.c:1028 #, fuzzy -msgid "E586: :continue without :while or :for" -msgstr "E586: ':continue' sonder ':while'" +#~ msgid "E586: :continue without :while or :for" +#~ msgstr "E586: ':continue' sonder ':while'" -#: ../ex_eval.c:1061 #, fuzzy -msgid "E587: :break without :while or :for" -msgstr "E587: ':break' sonder ':while'" +#~ msgid "E587: :break without :while or :for" +#~ msgstr "E587: ':break' sonder ':while'" -#: ../ex_eval.c:1102 #, fuzzy -msgid "E732: Using :endfor with :while" -msgstr "E170: Ontbrekende ':endwhile'" +#~ msgid "E732: Using :endfor with :while" +#~ msgstr "E170: Ontbrekende ':endwhile'" -#: ../ex_eval.c:1104 #, fuzzy -msgid "E733: Using :endwhile with :for" -msgstr "E170: Ontbrekende ':endwhile'" +#~ msgid "E733: Using :endwhile with :for" +#~ msgstr "E170: Ontbrekende ':endwhile'" -#: ../ex_eval.c:1247 msgid "E601: :try nesting too deep" msgstr "E601: geneste ':try' te diep" -#: ../ex_eval.c:1317 msgid "E603: :catch without :try" msgstr "E603: ':catch' sonder ':try'" #. Give up for a ":catch" after ":finally" and ignore it. #. * Just parse. -#: ../ex_eval.c:1332 msgid "E604: :catch after :finally" msgstr "E604: ':catch' na ':finally'" -#: ../ex_eval.c:1451 msgid "E606: :finally without :try" msgstr "E606: ':finally' sonder ':try'" #. Give up for a multiple ":finally" and ignore it. -#: ../ex_eval.c:1467 msgid "E607: multiple :finally" msgstr "E607: meer as een ':finally'" -#: ../ex_eval.c:1571 msgid "E602: :endtry without :try" msgstr "E602: ':endtry' sonder ':try'" -#: ../ex_eval.c:2026 msgid "E193: :endfunction not inside a function" msgstr "E193: ':endfunction' nie in 'n funksie nie" -#: ../ex_getln.c:1643 #, fuzzy -msgid "E788: Not allowed to edit another buffer now" -msgstr "E48: Nie toegelaat in sandput nie" +#~ msgid "E788: Not allowed to edit another buffer now" +#~ msgstr "E48: Nie toegelaat in sandput nie" -#: ../ex_getln.c:1656 #, fuzzy -msgid "E811: Not allowed to change buffer information now" -msgstr "E94: Geen buffer wat by %s pas nie" +#~ msgid "E811: Not allowed to change buffer information now" +#~ msgstr "E94: Geen buffer wat by %s pas nie" -#: ../ex_getln.c:3178 -msgid "tagname" -msgstr "etiketnaam" +#, c-format +#~ msgid "E5408: Unable to get g:Nvim_color_cmdline callback: %s" +#~ msgstr "" -#: ../ex_getln.c:3181 -msgid " kind file\n" -msgstr " tipe lêer\n" +#, c-format +#~ msgid "E5409: Unable to get g:Nvim_color_expr callback: %s" +#~ msgstr "" -#: ../ex_getln.c:4799 -msgid "'history' option is zero" -msgstr "'history' opsie is nul" +#, c-format +#~ msgid "E5407: Callback has thrown an exception: %s" +#~ msgstr "" + +#~ msgid "E5400: Callback should return list" +#~ msgstr "" -#: ../ex_getln.c:5046 #, c-format -msgid "" -"\n" -"# %s History (newest to oldest):\n" -msgstr "" -"\n" -"# %s Geskiedenis (van nuutste na oudste):\n" +#~ msgid "E5401: List item %i is not a List" +#~ msgstr "" + +#, c-format +#~ msgid "E5402: List item %i has incorrect length: %li /= 3" +#~ msgstr "" + +#~ msgid "E5403: Chunk %i start %" +#~ msgstr "" + +#~ msgid "E5405: Chunk %i start %" +#~ msgstr "" + +#~ msgid "E5404: Chunk %i end %" +#~ msgstr "" -#: ../ex_getln.c:5047 -msgid "Command Line" -msgstr "Bevelreël" +#~ msgid "E5406: Chunk %i end %" +#~ msgstr "" -#: ../ex_getln.c:5048 -msgid "Search String" -msgstr "Soekstring" +msgid "tagname" +msgstr "etiketnaam" -#: ../ex_getln.c:5049 -msgid "Expression" -msgstr "Uitdrukking" +msgid " kind file\n" +msgstr " tipe lêer\n" -#: ../ex_getln.c:5050 -msgid "Input Line" -msgstr "Invoer Lyn" +msgid "'history' option is zero" +msgstr "'history' opsie is nul" -#: ../ex_getln.c:5117 msgid "E198: cmd_pchar beyond the command length" msgstr "E198: 'cmd_pchar' verby die einde van opdraglengte" -#: ../ex_getln.c:5279 msgid "E199: Active window or buffer deleted" msgstr "E199: Aktiewe venster of buffer geskrap" -#: ../file_search.c:203 -msgid "E854: path too long for completion" -msgstr "" +#~ msgid "E854: path too long for completion" +#~ msgstr "" -#: ../file_search.c:446 #, c-format msgid "" "E343: Invalid path: '**[number]' must be at the end of the path or be " @@ -2052,267 +1999,208 @@ msgstr "" "E343: Ongeldige pad: '**[nommer]' moet aan die einde van 'n pad wees of " "gevolg wees deur %s'." -#: ../file_search.c:1505 #, c-format msgid "E344: Can't find directory \"%s\" in cdpath" msgstr "E344: Kan nie gids \"%s\" in 'cdpath' vind nie" -#: ../file_search.c:1508 #, c-format msgid "E345: Can't find file \"%s\" in path" msgstr "E345: Kan lêer \"%s\" nie vind in pad nie" -#: ../file_search.c:1512 #, c-format msgid "E346: No more directory \"%s\" found in cdpath" msgstr "E346: Geen gids \"%s\" meer gevind in 'cdpath' nie" -#: ../file_search.c:1515 #, c-format msgid "E347: No more file \"%s\" found in path" msgstr "E347: Geen lêer \"%s\" meer gevind in pad nie" -#: ../fileio.c:137 #, fuzzy -msgid "E812: Autocommands changed buffer or buffer name" -msgstr "E135: *Filter* Outobevele mag nie die huidige buffer verander nie" +#~ msgid "E812: Autocommands changed buffer or buffer name" +#~ msgstr "E135: *Filter* Outobevele mag nie die huidige buffer verander nie" -#: ../fileio.c:368 msgid "Illegal file name" msgstr "Ongeldige lêernaam" -#: ../fileio.c:395 ../fileio.c:476 ../fileio.c:2543 ../fileio.c:2578 msgid "is a directory" msgstr "is 'n gids" -#: ../fileio.c:397 msgid "is not a file" msgstr "is nie 'n lêer nie" -#: ../fileio.c:508 ../fileio.c:3522 msgid "[New File]" msgstr "[Nuwe lêer]" -#: ../fileio.c:511 -msgid "[New DIRECTORY]" -msgstr "" +#~ msgid "[New DIRECTORY]" +#~ msgstr "" -#: ../fileio.c:529 ../fileio.c:532 -msgid "[File too big]" -msgstr "" +#. libuv only returns -errno in Unix and in Windows open() does not +#. set EOVERFLOW +#~ msgid "[File too big]" +#~ msgstr "" -#: ../fileio.c:534 msgid "[Permission Denied]" msgstr "[Toestemming Geweier]" -#: ../fileio.c:653 msgid "E200: *ReadPre autocommands made the file unreadable" msgstr "E200: '*ReadPre' outobevele het die lêer onleesbaar gemaak" -#: ../fileio.c:655 msgid "E201: *ReadPre autocommands must not change current buffer" msgstr "E201: '*ReadPre' outobevele mag nie die huidige buffer verander nie" -#: ../fileio.c:672 -msgid "Nvim: Reading from stdin...\n" -msgstr "Vim: Lees nou vanaf 'stdin'...\n" - #. Re-opening the original file failed! -#: ../fileio.c:909 msgid "E202: Conversion made file unreadable!" msgstr "E202: Omsetting het lêer onleesbaar gemaak!" #. fifo or socket -#: ../fileio.c:1782 msgid "[fifo/socket]" msgstr "[fifo/socket]" #. fifo -#: ../fileio.c:1788 msgid "[fifo]" msgstr "[fifo]" #. or socket -#: ../fileio.c:1794 msgid "[socket]" msgstr "[socket]" #. or character special -#: ../fileio.c:1801 #, fuzzy -msgid "[character special]" -msgstr "1 karakter" +#~ msgid "[character special]" +#~ msgstr "1 karakter" -#: ../fileio.c:1815 msgid "[CR missing]" msgstr "[CR ontbreek]" -#: ../fileio.c:1819 msgid "[long lines split]" msgstr "[lang reëls verdeel]" -#: ../fileio.c:1823 ../fileio.c:3512 msgid "[NOT converted]" msgstr "[NIE omgesit nie]" -#: ../fileio.c:1826 ../fileio.c:3515 msgid "[converted]" msgstr "[omgesit]" -#: ../fileio.c:1831 #, fuzzy, c-format -msgid "[CONVERSION ERROR in line %]" -msgstr "[ONWETTIGE GREEP in reël %]" +#~ msgid "[CONVERSION ERROR in line %]" +#~ msgstr "[ONWETTIGE GREEP in reël %]" -#: ../fileio.c:1835 #, c-format msgid "[ILLEGAL BYTE in line %]" msgstr "[ONWETTIGE GREEP in reël %]" -#: ../fileio.c:1838 msgid "[READ ERRORS]" msgstr "[LEESFOUTE]" -#: ../fileio.c:2104 msgid "Can't find temp file for conversion" msgstr "Kan nie tydelike lêer vir omsetting vind nie" -#: ../fileio.c:2110 msgid "Conversion with 'charconvert' failed" msgstr "Omsetting met 'charconvert' het gefaal" -#: ../fileio.c:2113 msgid "can't read output of 'charconvert'" msgstr "kan afvoer van 'charconvert' nie lees nie" -#: ../fileio.c:2437 #, fuzzy -msgid "E676: No matching autocommands for acwrite buffer" -msgstr "Geen passende outobevele nie" +#~ msgid "E676: No matching autocommands for acwrite buffer" +#~ msgstr "Geen passende outobevele nie" -#: ../fileio.c:2466 msgid "E203: Autocommands deleted or unloaded buffer to be written" msgstr "E203: Outobevele het die skryfbuffer geskrap of uitgelaai" -#: ../fileio.c:2486 msgid "E204: Autocommand changed number of lines in unexpected way" msgstr "E204: Outobevel het etlike reëls op onverwagse wyse verander " -#: ../fileio.c:2548 ../fileio.c:2565 msgid "is not a file or writable device" msgstr "is nie 'n lêer of 'n skryfbare toestel nie" -#: ../fileio.c:2601 msgid "is read-only (add ! to override)" msgstr "is lees-alleen (gebruik ! om te dwing)" -#: ../fileio.c:2886 msgid "E506: Can't write to backup file (add ! to override)" msgstr "E506: Kan nie na rugsteunlêer skryf nie (gebruik ! om te dwing)" -#: ../fileio.c:2898 -msgid "E507: Close error for backup file (add ! to override)" -msgstr "E507: Sluitfout vir rugsteunlêer (gebruik ! om te dwing)" +#, fuzzy, c-format +#~ msgid "E507: Close error for backup file (add ! to override): %s" +#~ msgstr "E507: Sluitfout vir rugsteunlêer (gebruik ! om te dwing)" -#: ../fileio.c:2901 msgid "E508: Can't read file for backup (add ! to override)" msgstr "E508: Kan rugsteunlêer nie lees nie (gebruik ! om te dwing)" -#: ../fileio.c:2923 msgid "E509: Cannot create backup file (add ! to override)" msgstr "E509: Kan rugsteunlêer nie skep nie (gebruik ! om te dwing)" -#: ../fileio.c:3008 msgid "E510: Can't make backup file (add ! to override)" msgstr "E510: Kan rugsteunlêer nie skep nie (gebruik ! om te dwing)" #. Can't write without a tempfile! -#: ../fileio.c:3121 msgid "E214: Can't find temp file for writing" msgstr "E214: Kan nie tydelike lêer vind vir skryf nie" -#: ../fileio.c:3134 msgid "E213: Cannot convert (add ! to write without conversion)" msgstr "E213: Kan nie omsit nie (gebruik ! om te skryf sonder omsetting)" -#: ../fileio.c:3169 msgid "E166: Can't open linked file for writing" msgstr "E166: Kan lêer nie oopmaak vir skryf nie" -#: ../fileio.c:3173 -msgid "E212: Can't open file for writing" -msgstr "E212: Kan lêer nie oopmaak vir skryf nie" +#, fuzzy, c-format +#~ msgid "E212: Can't open file for writing: %s" +#~ msgstr "E212: Kan lêer nie oopmaak vir skryf nie" -#: ../fileio.c:3363 -msgid "E667: Fsync failed" -msgstr "E667: 'Fsync' het gefaal" +#, fuzzy, c-format +#~ msgid "E667: Fsync failed: %s" +#~ msgstr "E667: 'Fsync' het gefaal" -#: ../fileio.c:3398 -msgid "E512: Close failed" -msgstr "E512: Sluiting gefaal" +#, fuzzy, c-format +#~ msgid "E512: Close failed: %s" +#~ msgstr "E512: Sluiting gefaal" -#: ../fileio.c:3436 #, fuzzy -msgid "E513: write error, conversion failed (make 'fenc' empty to override)" -msgstr "E513: skryffout, omsetting gefaal" +#~ msgid "E513: write error, conversion failed (make 'fenc' empty to override)" +#~ msgstr "E513: skryffout, omsetting gefaal" -#: ../fileio.c:3441 -#, c-format -msgid "" -"E513: write error, conversion failed in line % (make 'fenc' empty to " -"override)" -msgstr "" +#, fuzzy +#~ msgid "E513: write error, conversion failed in line %" +#~ msgstr "E513: skryffout, omsetting gefaal" -#: ../fileio.c:3448 msgid "E514: write error (file system full?)" msgstr "E514: skryffout (lêerstelsel vol?)" -#: ../fileio.c:3506 msgid " CONVERSION ERROR" msgstr " OMSETTINGSFOUT" -#: ../fileio.c:3509 #, fuzzy, c-format -msgid " in line %;" -msgstr "reël %" +#~ msgid " in line %;" +#~ msgstr "reël %" -#: ../fileio.c:3519 msgid "[Device]" msgstr "[Toestel]" -#: ../fileio.c:3522 msgid "[New]" msgstr "[Nuut]" -#: ../fileio.c:3535 msgid " [a]" msgstr " [a]" -#: ../fileio.c:3535 msgid " appended" msgstr " bygevoeg" -#: ../fileio.c:3537 msgid " [w]" msgstr " [w]" -#: ../fileio.c:3537 msgid " written" msgstr " geskryf" -#: ../fileio.c:3579 msgid "E205: Patchmode: can't save original file" msgstr "E205: patchmode: kan oorspronklike lêer nie stoor nie" -#: ../fileio.c:3602 msgid "E206: patchmode: can't touch empty original file" msgstr "E206: patchmode: kan leë oorspronglêer nie 'touch' nie" -#: ../fileio.c:3616 msgid "E207: Can't delete backup file" msgstr "E207: Kan rugsteunlêer nie verwyder nie" -#: ../fileio.c:3672 +#. Set highlight for error messages. msgid "" "\n" "WARNING: Original file may be lost or damaged\n" @@ -2320,96 +2208,75 @@ msgstr "" "\n" "WAARSKUWING: Oorspronklike lêer mag verlore of beskadig wees\n" -#: ../fileio.c:3675 msgid "don't quit the editor until the file is successfully written!" msgstr "moenie die verwerker verlaat voor die lêer suksesvol geskryf is nie!" -#: ../fileio.c:3795 -msgid "[dos]" -msgstr "[dos]" - -#: ../fileio.c:3795 msgid "[dos format]" msgstr "[dos formaat]" -#: ../fileio.c:3801 -msgid "[mac]" -msgstr "[mac]" +msgid "[dos]" +msgstr "[dos]" -#: ../fileio.c:3801 msgid "[mac format]" msgstr "[mac formaat]" -#: ../fileio.c:3807 -msgid "[unix]" -msgstr "[unix]" +msgid "[mac]" +msgstr "[mac]" -#: ../fileio.c:3807 msgid "[unix format]" msgstr "[unix formaat]" -#: ../fileio.c:3831 +msgid "[unix]" +msgstr "[unix]" + msgid "1 line, " msgstr "1 reël, " -#: ../fileio.c:3833 #, c-format msgid "% lines, " msgstr "% reëls, " -#: ../fileio.c:3836 msgid "1 character" msgstr "1 karakter" -#: ../fileio.c:3838 #, c-format msgid "% characters" msgstr "% karakters" -#: ../fileio.c:3849 -msgid "[noeol]" -msgstr "[noeol]" - -#: ../fileio.c:3849 msgid "[Incomplete last line]" msgstr "[Onvoltooide laaste reël]" -#. don't overwrite messages here -#. must give this prompt -#. don't use emsg() here, don't want to flush the buffers -#: ../fileio.c:3865 +msgid "[noeol]" +msgstr "[noeol]" + +#. Don't overwrite messages here. +#. Must give this prompt. +#. Don't use emsg() here, don't want to flush the buffers. msgid "WARNING: The file has been changed since reading it!!!" msgstr "WAARSKUWING: Die lêer het verander sedert dit gelees is!!!" -#: ../fileio.c:3867 msgid "Do you really want to write to it" msgstr "Wil jy regtig soontoe skryf?" -#: ../fileio.c:4648 #, c-format msgid "E208: Error writing to \"%s\"" msgstr "E208: Kan nie skryf na \"%s\"" -#: ../fileio.c:4655 #, c-format msgid "E209: Error closing \"%s\"" msgstr "E209: Kan \"%s\" nie sluit nie" -#: ../fileio.c:4657 #, c-format msgid "E210: Error reading \"%s\"" msgstr "E210: Kan \"%s\" nie lees nie" -#: ../fileio.c:4883 msgid "E246: FileChangedShell autocommand deleted buffer" msgstr "E246: 'FileChangedShell' outobevel het buffer verwyder" -#: ../fileio.c:4894 #, fuzzy, c-format -msgid "E211: File \"%s\" no longer available" -msgstr "E211: Waarskuwing: Lêer \"%s\" is nie meer beskikbaar nie" +#~ msgid "E211: File \"%s\" no longer available" +#~ msgstr "E211: Waarskuwing: Lêer \"%s\" is nie meer beskikbaar nie" -#: ../fileio.c:4906 #, c-format msgid "" "W12: Warning: File \"%s\" has changed and the buffer was changed in Vim as " @@ -2418,42 +2285,34 @@ msgstr "" "W12: Waarskuwing: Lêer \"%s\" het verander sedert bewerking begin het en die " "buffer in Vim het ook verander" -#: ../fileio.c:4907 #, fuzzy -msgid "See \":help W12\" for more info." -msgstr "Sien \":help W11\" vir meer inligting." +#~ msgid "See \":help W12\" for more info." +#~ msgstr "Sien \":help W11\" vir meer inligting." -#: ../fileio.c:4910 #, c-format msgid "W11: Warning: File \"%s\" has changed since editing started" msgstr "W11: Waarskuwing: Lêer \"%s\" het verander sedert bewerking begin het" -#: ../fileio.c:4911 msgid "See \":help W11\" for more info." msgstr "Sien \":help W11\" vir meer inligting." -#: ../fileio.c:4914 #, c-format msgid "W16: Warning: Mode of file \"%s\" has changed since editing started" msgstr "" "W16: Waarskuwing: Modus van lêer \"%s\" het verander sedert bewerking begin " "het" -#: ../fileio.c:4915 #, fuzzy -msgid "See \":help W16\" for more info." -msgstr "Sien \":help W11\" vir meer inligting." +#~ msgid "See \":help W16\" for more info." +#~ msgstr "Sien \":help W11\" vir meer inligting." -#: ../fileio.c:4927 #, c-format msgid "W13: Warning: File \"%s\" has been created after editing started" msgstr "W13: Waarskuwing: Lêer \"%s\" is geskep sedert bewerking begin het" -#: ../fileio.c:4947 msgid "Warning" msgstr "Waarskuwing" -#: ../fileio.c:4948 msgid "" "&OK\n" "&Load File" @@ -2461,48 +2320,46 @@ msgstr "" "&OK\n" "&Laai Lêer" -#: ../fileio.c:5065 #, c-format msgid "E462: Could not prepare for reloading \"%s\"" msgstr "E462: Kon nie voorberei vir herlaai nie \"%s\"" -#: ../fileio.c:5078 #, c-format msgid "E321: Could not reload \"%s\"" msgstr "E321: Kon nie \"%s\" herlaai nie" -#: ../fileio.c:5601 msgid "--Deleted--" msgstr "--Geskrap--" -#: ../fileio.c:5732 #, c-format -msgid "auto-removing autocommand: %s " -msgstr "" +#~ msgid "auto-removing autocommand: %s " +#~ msgstr "" #. the group doesn't exist -#: ../fileio.c:5772 #, c-format msgid "E367: No such group: \"%s\"" msgstr "E367: Geen sodanige groep nie: \"%s\"" -#: ../fileio.c:5897 +#, fuzzy +#~ msgid "E936: Cannot delete the current group" +#~ msgstr "E351: Kan nie vou skrap met huidige 'foldmethod' nie" + +#~ msgid "W19: Deleting augroup that is still in use" +#~ msgstr "" + #, c-format msgid "E215: Illegal character after *: %s" msgstr "E215: Ongeldige karakter na *: %s" -#: ../fileio.c:5905 #, c-format msgid "E216: No such event: %s" msgstr "E216: Geen sodanige gebeurtenis nie: %s" -#: ../fileio.c:5907 #, c-format msgid "E216: No such group or event: %s" msgstr "E216: Geen sodanige groep of gebeurtenis nie: %s" #. Highlight title -#: ../fileio.c:6090 msgid "" "\n" "--- Auto-Commands ---" @@ -2510,108 +2367,88 @@ msgstr "" "\n" "--- Outobevele ---" -#: ../fileio.c:6293 #, fuzzy, c-format -msgid "E680: : invalid buffer number " -msgstr "ongeldige buffernommer" +#~ msgid "E680: : invalid buffer number " +#~ msgstr "ongeldige buffernommer" -#: ../fileio.c:6370 msgid "E217: Can't execute autocommands for ALL events" msgstr "E217: Kan nie outobevele uitvoer vir 'ALL' gebeurtenisse nie" -#: ../fileio.c:6393 msgid "No matching autocommands" msgstr "Geen passende outobevele nie" -#: ../fileio.c:6831 msgid "E218: autocommand nesting too deep" msgstr "E218: outobevele te diep genes" -#: ../fileio.c:7143 #, c-format msgid "%s Auto commands for \"%s\"" msgstr "%s outobevele vir \"%s\"" -#: ../fileio.c:7149 #, c-format msgid "Executing %s" msgstr "Voer %s uit" -#: ../fileio.c:7211 #, c-format msgid "autocommand %s" msgstr "outobevel %s" -#: ../fileio.c:7795 msgid "E219: Missing {." msgstr "E219: Ontbrekende {." -#: ../fileio.c:7797 msgid "E220: Missing }." msgstr "E220: Ontbrekende }." -#: ../fold.c:93 msgid "E490: No fold found" msgstr "E490: Geen vou gevind nie" -#: ../fold.c:544 msgid "E350: Cannot create fold with current 'foldmethod'" msgstr "E350: Kan nie vou skep met huidige 'foldmethod' nie" -#: ../fold.c:546 msgid "E351: Cannot delete fold with current 'foldmethod'" msgstr "E351: Kan nie vou skrap met huidige 'foldmethod' nie" -#: ../fold.c:1784 -#, c-format -msgid "+--%3ld lines folded " -msgstr "+--%3ld reëls gevou " +#, fuzzy, c-format +#~ msgid "+--%3ld line folded" +#~ msgid_plural "+--%3ld lines folded " +#~ msgstr[0] "+--%3ld reëls gevou " +#~ msgstr[1] "+--%3ld reëls gevou " #. buffer has already been read -#: ../getchar.c:273 msgid "E222: Add to read buffer" msgstr "E222: Voeg by leesbuffer" -#: ../getchar.c:2040 msgid "E223: recursive mapping" msgstr "E223: rekursiewe binding" -#: ../getchar.c:2849 #, c-format msgid "E224: global abbreviation already exists for %s" msgstr "E224: globale afkorting bestaan alreeds vir %s" -#: ../getchar.c:2852 #, c-format msgid "E225: global mapping already exists for %s" msgstr "E225: globale binding bestaan alreeds vir %s" -#: ../getchar.c:2952 #, c-format msgid "E226: abbreviation already exists for %s" msgstr "E226: afkorting bestaan already vir %s" -#: ../getchar.c:2955 #, c-format msgid "E227: mapping already exists for %s" msgstr "E227: binding bestaan alreeds vir %s" -#: ../getchar.c:3008 msgid "No abbreviation found" msgstr "Geen afkorting gevind nie" -#: ../getchar.c:3010 msgid "No mapping found" msgstr "Geen binding gevind nie" -#: ../getchar.c:3974 msgid "E228: makemap: Illegal mode" msgstr "E228: makemap: Ongeldige modus" -#. key value of 'cedit' option -#. type of cmdline window or 0 -#. result of cmdline window or 0 -#: ../globals.h:924 +#. /< key value of 'cedit' option +#. /< type of cmdline window or 0 +#. /< result of cmdline window or 0 +#. /< cmdline recursion level msgid "--No lines in buffer--" msgstr "--Geen reëls in buffer--" @@ -2619,691 +2456,566 @@ msgstr "--Geen re #. * The error messages that can be shared are included here. #. * Excluded are errors that are only used once and debugging messages. #. -#: ../globals.h:996 msgid "E470: Command aborted" msgstr "E470: Bevel gekanselleer" -#: ../globals.h:997 +#, fuzzy +#~ msgid "E905: Cannot set this option after startup" +#~ msgstr "E529: Kan nie 'term' stel na leë string nie" + +#, fuzzy +#~ msgid "E903: Could not spawn API job" +#~ msgstr "E623: Kon nie 'cscope' proses skep nie" + msgid "E471: Argument required" msgstr "E471: Parameter benodig" -#: ../globals.h:998 msgid "E10: \\ should be followed by /, ? or &" msgstr "E10: \\ moet gevolg word deur /, ? of &" -#: ../globals.h:1000 msgid "E11: Invalid in command-line window; executes, CTRL-C quits" msgstr "E11: Ongeldig in bevelreël venster: voer uit, CTRL-C stop" -#: ../globals.h:1002 msgid "E12: Command not allowed from exrc/vimrc in current dir or tag search" msgstr "" "E12: Bevel uit exrc/vimrc nie toegelaat in huidige gids- of etiketsoektog nie" -#: ../globals.h:1003 msgid "E171: Missing :endif" msgstr "E171: Ontbrekende ':endif'" -#: ../globals.h:1004 msgid "E600: Missing :endtry" msgstr "E600: Ontbrekende ':endtry'" -#: ../globals.h:1005 msgid "E170: Missing :endwhile" msgstr "E170: Ontbrekende ':endwhile'" -#: ../globals.h:1006 #, fuzzy -msgid "E170: Missing :endfor" -msgstr "E171: Ontbrekende ':endif'" +#~ msgid "E170: Missing :endfor" +#~ msgstr "E171: Ontbrekende ':endif'" -#: ../globals.h:1007 msgid "E588: :endwhile without :while" msgstr "E588: ':endwhile' sonder ':while'" -#: ../globals.h:1008 #, fuzzy -msgid "E588: :endfor without :for" -msgstr "E580: ':endif' sonder ':if'" +#~ msgid "E588: :endfor without :for" +#~ msgstr "E580: ':endif' sonder ':if'" -#: ../globals.h:1009 msgid "E13: File exists (add ! to override)" msgstr "E13: Lêer bestaan (gebruik ! om te dwing)" -#: ../globals.h:1010 msgid "E472: Command failed" msgstr "E472: Bevel het gefaal" -#: ../globals.h:1011 msgid "E473: Internal error" msgstr "E473: Interne fout" -#: ../globals.h:1012 msgid "Interrupted" msgstr "Onderbreek" -#: ../globals.h:1013 msgid "E14: Invalid address" msgstr "E14: Ongeldige adres" -#: ../globals.h:1014 msgid "E474: Invalid argument" msgstr "E474: Ongeldige parameter" -#: ../globals.h:1015 #, c-format msgid "E475: Invalid argument: %s" msgstr "E475: Ongeldige parameter: %s" -#: ../globals.h:1016 #, c-format msgid "E15: Invalid expression: %s" msgstr "E15: Ongeldige uitdrukking: %s" -#: ../globals.h:1017 msgid "E16: Invalid range" msgstr "E16: Ongeldige omvang" -#: ../globals.h:1018 msgid "E476: Invalid command" msgstr "E476: Ongeldige bevel" -#: ../globals.h:1019 #, c-format msgid "E17: \"%s\" is a directory" msgstr "E17: \"%s\" is 'n gids" -#: ../globals.h:1020 #, fuzzy -msgid "E900: Invalid job id" -msgstr "E49: Ongeldige rolgrootte" +#~ msgid "E900: Invalid job id" +#~ msgstr "E49: Ongeldige rolgrootte" -#: ../globals.h:1021 -msgid "E901: Job table is full" -msgstr "" +#~ msgid "E901: Job table is full" +#~ msgstr "" + +#, c-format +#~ msgid "E903: Process failed to start: %s: \"%s\"" +#~ msgstr "" + +#~ msgid "E904: Job is not connected to a pty" +#~ msgstr "" -#: ../globals.h:1024 #, c-format msgid "E364: Library call failed for \"%s()\"" msgstr "E364: Biblioteekroep het gefaal vir \"%s\"()" -#: ../globals.h:1026 +#, fuzzy, c-format +#~ msgid "E739: Cannot create directory %s: %s" +#~ msgstr "Kan nie gids uitvoer nie: \"%s\"" + msgid "E19: Mark has invalid line number" msgstr "E19: Merker het ongeldige reëlnommer" -#: ../globals.h:1027 msgid "E20: Mark not set" msgstr "E20: Merker nie gestel nie" -#: ../globals.h:1029 msgid "E21: Cannot make changes, 'modifiable' is off" msgstr "E21: Kan nie wysig nie, 'modifiable' is af" -#: ../globals.h:1030 msgid "E22: Scripts nested too deep" msgstr "E22: Skripte te diep ge-nes" -#: ../globals.h:1031 msgid "E23: No alternate file" msgstr "E23: Geen alternatiewe lêer nie" -#: ../globals.h:1032 msgid "E24: No such abbreviation" msgstr "E24: Afkorting bestaan nie" -#: ../globals.h:1033 msgid "E477: No ! allowed" msgstr "E477: Geen ! toegelaat nie" -#: ../globals.h:1035 msgid "E25: Nvim does not have a built-in GUI" msgstr "E25: GUI kan nie gebruik word nie: Nie tydens kompilering gekies nie" -#: ../globals.h:1036 #, c-format msgid "E28: No such highlight group name: %s" msgstr "E28: Geen sodanige uitliggroepnaam nie: %s" -#: ../globals.h:1037 msgid "E29: No inserted text yet" msgstr "E29: Nog geen ingevoegde teks nie" -#: ../globals.h:1038 msgid "E30: No previous command line" msgstr "E30: Geen vorige bevelreël nie" -#: ../globals.h:1039 msgid "E31: No such mapping" msgstr "E31: Geen so 'n binding nie" -#: ../globals.h:1040 msgid "E479: No match" msgstr "E479: Geen treffer nie" -#: ../globals.h:1041 #, c-format msgid "E480: No match: %s" msgstr "E480: Geen treffer: %s" -#: ../globals.h:1042 msgid "E32: No file name" msgstr "E32: Geen lêernaam" -#: ../globals.h:1044 msgid "E33: No previous substitute regular expression" msgstr "E33: Geen vorige vervangingspatroon nie" -#: ../globals.h:1045 msgid "E34: No previous command" msgstr "E34: Geen vorige bevel nie" -#: ../globals.h:1046 msgid "E35: No previous regular expression" msgstr "E35: Geen vorige patroon nie" -#: ../globals.h:1047 msgid "E481: No range allowed" msgstr "E481: Geen omvang toegelaat nie" -#: ../globals.h:1048 msgid "E36: Not enough room" msgstr "E36: Te min plek" -#: ../globals.h:1049 -#, c-format -msgid "E482: Can't create file %s" -msgstr "E482: Kan nie lêer %s skep nie" - -#: ../globals.h:1050 msgid "E483: Can't get temp file name" msgstr "E483: Kan nie tydelike lêernaam kry nie" -#: ../globals.h:1051 #, c-format msgid "E484: Can't open file %s" msgstr "E484: Kan nie lêer %s oopmaak nie" -#: ../globals.h:1052 #, c-format msgid "E485: Can't read file %s" msgstr "E485: Kan nie lêer %s lees nie" -#: ../globals.h:1054 msgid "E37: No write since last change (add ! to override)" msgstr "E37: Ongeskryf sedert vorige verandering (gebruik ! om te dwing)" -#: ../globals.h:1055 #, fuzzy -msgid "E37: No write since last change" -msgstr "[Ongestoor sedert vorige verandering]\n" +#~ msgid "E37: No write since last change" +#~ msgstr "[Ongestoor sedert vorige verandering]\n" -#: ../globals.h:1056 msgid "E38: Null argument" msgstr "E38: Nul parameter" -#: ../globals.h:1057 msgid "E39: Number expected" msgstr "E39: Nommer verwag" -#: ../globals.h:1058 #, c-format msgid "E40: Can't open errorfile %s" msgstr "E40: Kan nie foutlêer %s oopmaak nie" -#: ../globals.h:1059 msgid "E41: Out of memory!" msgstr "E41: Geheue op!" -#: ../globals.h:1060 msgid "Pattern not found" msgstr "Patroon nie gevind nie" -#: ../globals.h:1061 #, c-format msgid "E486: Pattern not found: %s" msgstr "E486: Patroon nie gevind nie: %s" -#: ../globals.h:1062 msgid "E487: Argument must be positive" msgstr "E487: Parameter moet positief wees" -#: ../globals.h:1064 msgid "E459: Cannot go back to previous directory" msgstr "E459: Kan nie terug gaan na die vorige gids nie" -#: ../globals.h:1066 msgid "E42: No Errors" msgstr "E42: Geen Foute" -#: ../globals.h:1067 -msgid "E776: No location list" -msgstr "" +#~ msgid "E776: No location list" +#~ msgstr "" -#: ../globals.h:1068 msgid "E43: Damaged match string" msgstr "E43: Beskadige trefferstring" -#: ../globals.h:1069 msgid "E44: Corrupted regexp program" msgstr "E44: Korrupte patroonprogram" -#: ../globals.h:1071 msgid "E45: 'readonly' option is set (add ! to override)" msgstr "E45: 'readonly' opsie is aan (gebruik ! om te dwing)" -#: ../globals.h:1073 -#, fuzzy, c-format -msgid "E46: Cannot change read-only variable \"%s\"" -msgstr "E46: Kan nie lees-alleen veranderlike stel nie \"%s\"" - -#: ../globals.h:1075 -#, fuzzy, c-format -msgid "E794: Cannot set variable in the sandbox: \"%s\"" -msgstr "E46: Kan nie lees-alleen veranderlike stel nie \"%s\"" - -#: ../globals.h:1076 msgid "E47: Error while reading errorfile" msgstr "E47: Fout tydens lees van 'errorfile'" -#: ../globals.h:1078 msgid "E48: Not allowed in sandbox" msgstr "E48: Nie toegelaat in sandput nie" -#: ../globals.h:1080 msgid "E523: Not allowed here" msgstr "E523: Nie hier toegelaat nie" -#: ../globals.h:1082 msgid "E359: Screen mode setting not supported" msgstr "E359: Skermmodus instelling nie ondersteun nie" -#: ../globals.h:1083 msgid "E49: Invalid scroll size" msgstr "E49: Ongeldige rolgrootte" -#: ../globals.h:1084 msgid "E91: 'shell' option is empty" msgstr "E91: 'shell' (dop) opsie is leeg" -#: ../globals.h:1085 msgid "E255: Couldn't read in sign data!" msgstr "E255: Fout -- kon nie tekendata lees nie!" -#: ../globals.h:1086 msgid "E72: Close error on swap file" msgstr "E72: Sluitfout met ruillêer" -#: ../globals.h:1087 msgid "E73: tag stack empty" msgstr "E73: etiketstapel leeg" -#: ../globals.h:1088 msgid "E74: Command too complex" msgstr "E74: Bevel te kompleks" -#: ../globals.h:1089 msgid "E75: Name too long" msgstr "E75: Naam te lank" -#: ../globals.h:1090 msgid "E76: Too many [" msgstr "E76: Te veel [" -#: ../globals.h:1091 msgid "E77: Too many file names" msgstr "E77: Te veel lêername" -#: ../globals.h:1092 msgid "E488: Trailing characters" msgstr "E488: Oorbodige karakters" -#: ../globals.h:1093 +#, fuzzy, c-format +#~ msgid "E488: Trailing characters: %s" +#~ msgstr "E488: Oorbodige karakters" + msgid "E78: Unknown mark" msgstr "E78: Onbekende merker" -#: ../globals.h:1094 msgid "E79: Cannot expand wildcards" msgstr "E79: Kan nie plekhouers uitbrei nie" -#: ../globals.h:1096 msgid "E591: 'winheight' cannot be smaller than 'winminheight'" msgstr "E591: 'winheight' kan nie kleiner as 'winminheight' wees nie" -#: ../globals.h:1098 msgid "E592: 'winwidth' cannot be smaller than 'winminwidth'" msgstr "E592: 'winwidth' kan nie kleiner as 'winminwidth' wees nie" -#: ../globals.h:1099 msgid "E80: Error while writing" msgstr "E80: Fout tydens skryfoperasie" -#: ../globals.h:1100 -msgid "Zero count" -msgstr "Nul telling" +#, fuzzy +#~ msgid "E939: Positive count required" +#~ msgstr "E397: Lêernaam benodig" -#: ../globals.h:1101 msgid "E81: Using not in a script context" msgstr "E81: Gebruik van '' buite skripkonteks" -#: ../globals.h:1102 #, fuzzy, c-format -msgid "E685: Internal error: %s" -msgstr "E473: Interne fout" +#~ msgid "E685: Internal error: %s" +#~ msgstr "E473: Interne fout" -#: ../globals.h:1104 -msgid "E363: pattern uses more memory than 'maxmempattern'" -msgstr "" +#~ msgid "E363: pattern uses more memory than 'maxmempattern'" +#~ msgstr "" -#: ../globals.h:1105 #, fuzzy -msgid "E749: empty buffer" -msgstr "E279: Nie 'n SNiFF+ buffer nie" +#~ msgid "E749: empty buffer" +#~ msgstr "E279: Nie 'n SNiFF+ buffer nie" + +#, c-format +msgid "E86: Buffer % does not exist" +msgstr "E86: Buffer % bestaan nie" -#: ../globals.h:1108 #, fuzzy -msgid "E682: Invalid search pattern or delimiter" -msgstr "E383: Ongeldige soekstring: %s" +#~ msgid "E682: Invalid search pattern or delimiter" +#~ msgstr "E383: Ongeldige soekstring: %s" -#: ../globals.h:1109 msgid "E139: File is loaded in another buffer" msgstr "E139: Lêer is gelaai in ander buffer" -#: ../globals.h:1110 #, fuzzy, c-format -msgid "E764: Option '%s' is not set" -msgstr "E236: Font \"%s\" is nie 'n vaste-wydte font nie" +#~ msgid "E764: Option '%s' is not set" +#~ msgstr "E236: Font \"%s\" is nie 'n vaste-wydte font nie" -#: ../globals.h:1111 #, fuzzy -msgid "E850: Invalid register name" -msgstr "E354: Ongeldige registernaam: '%s'" +#~ msgid "E850: Invalid register name" +#~ msgstr "E354: Ongeldige registernaam: '%s'" + +#, fuzzy, c-format +#~ msgid "E919: Directory not found in '%s': \"%s\"" +#~ msgstr "E161: Inspeksiepunt kon nie gevind word nie: %s" + +msgid "E519: Option not supported" +msgstr "E519: Opsie is nie ondersteun nie" + +#, fuzzy +#~ msgid "E856: Filename too long" +#~ msgstr "E75: Naam te lank" + +#~ msgid "E806: using Float as a String" +#~ msgstr "" -#: ../globals.h:1114 msgid "search hit TOP, continuing at BOTTOM" msgstr "soektog het BO getref, gaan voort van ONDER af" -#: ../globals.h:1115 msgid "search hit BOTTOM, continuing at TOP" msgstr "soektog het ONDER getref, gaan voort van BO af" -#: ../hardcopy.c:240 msgid "E550: Missing colon" msgstr "E550: Ontbrekende dubbelpunt" -#: ../hardcopy.c:252 msgid "E551: Illegal component" msgstr "E551: Ongeldige komponent" -#: ../hardcopy.c:259 msgid "E552: digit expected" msgstr "E552: syfer verwag" -#: ../hardcopy.c:473 #, c-format msgid "Page %d" msgstr "Bladsy %d" -#: ../hardcopy.c:597 msgid "No text to be printed" msgstr "Geen teks om te druk nie" -#: ../hardcopy.c:668 -#, c-format -msgid "Printing page %d (%d%%)" -msgstr "Druk nou bladsy %d (%d%%)" +#, fuzzy, c-format +#~ msgid "Printing page %d (%zu%%)" +#~ msgstr "Druk nou bladsy %d (%d%%)" -#: ../hardcopy.c:680 #, c-format msgid " Copy %d of %d" msgstr " Kopie %d van %d" -#: ../hardcopy.c:733 #, c-format msgid "Printed: %s" msgstr "Gedruk: %s" -#: ../hardcopy.c:740 msgid "Printing aborted" msgstr "Drukkery gestaak" -#: ../hardcopy.c:1365 msgid "E455: Error writing to PostScript output file" msgstr "E455: Kan nie na 'PostScript' afvoerlêer skryf nie" -#: ../hardcopy.c:1747 #, c-format msgid "E624: Can't open file \"%s\"" msgstr "E624: Kan nie lêer \"%s\" oopmaak nie" -#: ../hardcopy.c:1756 ../hardcopy.c:2470 #, c-format msgid "E457: Can't read PostScript resource file \"%s\"" msgstr "E457: Kan nie 'PostScript' hulpbron-lêer \"%s\" lees nie" -#: ../hardcopy.c:1772 #, c-format msgid "E618: file \"%s\" is not a PostScript resource file" msgstr "E618: Lêer \"%s\" is nie 'n 'PostScript' hulpbron-lêer nie" -#: ../hardcopy.c:1788 ../hardcopy.c:1805 ../hardcopy.c:1844 #, c-format msgid "E619: file \"%s\" is not a supported PostScript resource file" msgstr "" "E619: Lêer \"%s\" is nie 'n ondersteunde 'PostScript' hulpbron-lêer nie" -#: ../hardcopy.c:1856 #, c-format msgid "E621: \"%s\" resource file has wrong version" msgstr "E621: \"%s\" die hulpbron lêer het die verkeerde weergawe" -#: ../hardcopy.c:2225 -msgid "E673: Incompatible multi-byte encoding and character set." -msgstr "" +#~ msgid "E673: Incompatible multi-byte encoding and character set." +#~ msgstr "" -#: ../hardcopy.c:2238 -msgid "E674: printmbcharset cannot be empty with multi-byte encoding." -msgstr "" +#~ msgid "E674: printmbcharset cannot be empty with multi-byte encoding." +#~ msgstr "" -#: ../hardcopy.c:2254 -msgid "E675: No default font specified for multi-byte printing." -msgstr "" +#~ msgid "E675: No default font specified for multi-byte printing." +#~ msgstr "" -#: ../hardcopy.c:2426 msgid "E324: Can't open PostScript output file" msgstr "E324: Kan nie 'PostScript' afvoerlêer oopmaak nie" -#: ../hardcopy.c:2458 #, c-format msgid "E456: Can't open file \"%s\"" msgstr "E456: Kan nie lêer %s oopmaak nie" -#: ../hardcopy.c:2583 msgid "E456: Can't find PostScript resource file \"prolog.ps\"" msgstr "E456: Kan nie 'PostScript' hulpbron-lêer \"prolog.ps\" lees nie" -#: ../hardcopy.c:2593 #, fuzzy -msgid "E456: Can't find PostScript resource file \"cidfont.ps\"" -msgstr "E456: Kan nie 'PostScript' hulpbron-lêer \"%s\" vind nie" +#~ msgid "E456: Can't find PostScript resource file \"cidfont.ps\"" +#~ msgstr "E456: Kan nie 'PostScript' hulpbron-lêer \"%s\" vind nie" -#: ../hardcopy.c:2622 ../hardcopy.c:2639 ../hardcopy.c:2665 #, c-format msgid "E456: Can't find PostScript resource file \"%s.ps\"" msgstr "E456: Kan nie 'PostScript' hulpbron-lêer \"%s\" vind nie" -#: ../hardcopy.c:2654 #, fuzzy, c-format -msgid "E620: Unable to convert to print encoding \"%s\"" -msgstr "E620: Kon nie van wye-greep na \"%s\" enkodering verander nie" +#~ msgid "E620: Unable to convert to print encoding \"%s\"" +#~ msgstr "E620: Kon nie van wye-greep na \"%s\" enkodering verander nie" -#: ../hardcopy.c:2877 msgid "Sending to printer..." msgstr "Besig om te stuur na drukker..." -#: ../hardcopy.c:2881 msgid "E365: Failed to print PostScript file" msgstr "E365: Kon nie 'PostScript' lêer druk nie" -#: ../hardcopy.c:2883 msgid "Print job sent." msgstr "Druktaak gestuur." -#: ../if_cscope.c:85 msgid "Add a new database" msgstr "Voeg 'n nuwe databasis by" -#: ../if_cscope.c:87 msgid "Query for a pattern" msgstr "Soek vir 'n patroon" -#: ../if_cscope.c:89 msgid "Show this message" msgstr "Wys hierdie boodskap" -#: ../if_cscope.c:91 msgid "Kill a connection" msgstr "Sluit 'n verbinding" -#: ../if_cscope.c:93 msgid "Reinit all connections" msgstr "Herstel alle verbindings" -#: ../if_cscope.c:95 msgid "Show connections" msgstr "Wys verbindings" -#: ../if_cscope.c:101 #, c-format msgid "E560: Usage: cs[cope] %s" msgstr "E560: Gebruik: cs[cope] %s" -#: ../if_cscope.c:225 msgid "This cscope command does not support splitting the window.\n" msgstr "" "Hierdie 'cscope' bevel ondersteun nie die splitsing van die venster nie.\n" -#: ../if_cscope.c:266 msgid "E562: Usage: cstag " msgstr "E562: Gebruik: 'cstag '" -#: ../if_cscope.c:313 msgid "E257: cstag: tag not found" msgstr "E257: 'cstag': etiket nie gevind nie" -#: ../if_cscope.c:461 #, c-format msgid "E563: stat(%s) error: %d" msgstr "E563: 'stat(%s)' fout: %d" -#: ../if_cscope.c:551 #, c-format msgid "E564: %s is not a directory or a valid cscope database" msgstr "E564: %s is nie 'n gids of 'n geldige 'cscope' databasis nie" -#: ../if_cscope.c:566 #, c-format msgid "Added cscope database %s" msgstr "'cscope' databasis %s bygevoeg" -#: ../if_cscope.c:616 -#, c-format -msgid "E262: error reading cscope connection %" -msgstr "E262: 'cscope' verbinding % kon nie gelees word nie" +#, fuzzy, c-format +#~ msgid "E262: error reading cscope connection %" +#~ msgstr "E262: 'cscope' verbinding % kon nie gelees word nie" -#: ../if_cscope.c:711 msgid "E561: unknown cscope search type" msgstr "E561: onbekende 'cscope' soektipe" -#: ../if_cscope.c:752 ../if_cscope.c:789 msgid "E566: Could not create cscope pipes" msgstr "E566: Kon nie 'cscope' pype skep nie" -#: ../if_cscope.c:767 msgid "E622: Could not fork for cscope" msgstr "E622: Kon nie vurk vir 'cscope' nie" -#: ../if_cscope.c:849 #, fuzzy -msgid "cs_create_connection setpgid failed" -msgstr "'cs_create_connection' uitvoering het misluk" +#~ msgid "cs_create_connection setpgid failed" +#~ msgstr "'cs_create_connection' uitvoering het misluk" -#: ../if_cscope.c:853 ../if_cscope.c:889 msgid "cs_create_connection exec failed" msgstr "'cs_create_connection' uitvoering het misluk" -#: ../if_cscope.c:863 ../if_cscope.c:902 msgid "cs_create_connection: fdopen for to_fp failed" msgstr "'cs_create_connection': 'fdopen' vir 'to_fp' het misluk" -#: ../if_cscope.c:865 ../if_cscope.c:906 msgid "cs_create_connection: fdopen for fr_fp failed" msgstr "'cs_create_connection': 'fdopen' vir 'fr_fp' het misluk" -#: ../if_cscope.c:890 msgid "E623: Could not spawn cscope process" msgstr "E623: Kon nie 'cscope' proses skep nie" -#: ../if_cscope.c:932 msgid "E567: no cscope connections" msgstr "E567: geen 'cscope' verbindings nie" -#: ../if_cscope.c:1009 #, c-format msgid "E469: invalid cscopequickfix flag %c for %c" msgstr "E469: ongeldige 'cscopequickfix' vlag %c vir %c" -#: ../if_cscope.c:1058 #, c-format msgid "E259: no matches found for cscope query %s of %s" msgstr "E259: geen treffers gevind vir 'cscope' versoek %s van %s nie" -#: ../if_cscope.c:1142 msgid "cscope commands:\n" msgstr "'cscope' bevele:\n" -#: ../if_cscope.c:1150 #, fuzzy, c-format -msgid "%-5s: %s%*s (Usage: %s)" -msgstr "%-5s: %-30s: (Gebruik: %s)" +#~ msgid "%-5s: %s%*s (Usage: %s)" +#~ msgstr "%-5s: %-30s: (Gebruik: %s)" -#: ../if_cscope.c:1155 -msgid "" -"\n" -" c: Find functions calling this function\n" -" d: Find functions called by this function\n" -" e: Find this egrep pattern\n" -" f: Find this file\n" -" g: Find this definition\n" -" i: Find files #including this file\n" -" s: Find this C symbol\n" -" t: Find this text string\n" -msgstr "" +#~ msgid "" +#~ "\n" +#~ " a: Find assignments to this symbol\n" +#~ " c: Find functions calling this function\n" +#~ " d: Find functions called by this function\n" +#~ " e: Find this egrep pattern\n" +#~ " f: Find this file\n" +#~ " g: Find this definition\n" +#~ " i: Find files #including this file\n" +#~ " s: Find this C symbol\n" +#~ " t: Find this text string\n" +#~ msgstr "" -#: ../if_cscope.c:1226 msgid "E568: duplicate cscope database not added" msgstr "E568: duplikaat 'cscope' databasis nie bygevoeg nie" -#: ../if_cscope.c:1335 #, c-format msgid "E261: cscope connection %s not found" msgstr "E261: 'cscope' verbinding %s nie gevind nie" -#: ../if_cscope.c:1364 #, c-format msgid "cscope connection %s closed" msgstr "'cscope' verbinding %s gesluit" #. should not reach here -#: ../if_cscope.c:1486 msgid "E570: fatal error in cs_manage_matches" msgstr "E570: fatale fout in 'cs_manage_matches'" -#: ../if_cscope.c:1693 #, c-format msgid "Cscope tag: %s" msgstr "Cscope etiket: %s" -#: ../if_cscope.c:1711 +#. Column headers for match number, line number and filename. msgid "" "\n" " # line" @@ -3311,329 +3023,314 @@ msgstr "" "\n" " # reël" -#: ../if_cscope.c:1713 msgid "filename / context / line\n" msgstr "lêernaam / konteks / reël\n" -#: ../if_cscope.c:1809 #, c-format msgid "E609: Cscope error: %s" msgstr "E609: Cscope fout: %s" -#: ../if_cscope.c:2053 msgid "All cscope databases reset" msgstr "Alle 'cscope' databasisse herstel" -#: ../if_cscope.c:2123 msgid "no cscope connections\n" msgstr "geen 'cscope' verbindings nie\n" -#: ../if_cscope.c:2126 msgid " # pid database name prepend path\n" msgstr " # pid databasis naam gidsvoorvoegsel\n" -#: ../main.c:144 -#, fuzzy -msgid "Unknown option argument" -msgstr "Onbekende opsie" +#, c-format +#~ msgid "E1502: Lua failed to grow stack to %i" +#~ msgstr "" -#: ../main.c:146 -msgid "Too many edit arguments" -msgstr "Te veel redigeer-parameters" +#~ msgid "" +#~ "E5100: Cannot convert given lua table: table should either have a sequence " +#~ "of positive integer keys or contain only string keys" +#~ msgstr "" + +#~ msgid "E5101: Cannot convert given lua type" +#~ msgstr "" + +#, c-format +#~ msgid "E5102: Lua failed to grow stack to %i" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "E5104: Error while creating lua chunk: %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, fuzzy, c-format +#~ msgid "E5105: Error while calling lua chunk: %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, fuzzy, c-format +#~ msgid "E5109: Error while creating lua chunk: %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, fuzzy, c-format +#~ msgid "E5110: Error while creating lua function: %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, fuzzy, c-format +#~ msgid "E5111: Error while calling lua function: %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, fuzzy, c-format +#~ msgid "E5112: Error while creating lua chunk: %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, fuzzy, c-format +#~ msgid "E5113: Error while calling lua chunk: %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" -#: ../main.c:148 +#, fuzzy, c-format +#~ msgid "E5106: Error while creating vim module: %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#~ msgid "E970: Failed to initialize lua interpreter" +#~ msgstr "" + +#. stack: vim, error +#, fuzzy, c-format +#~ msgid "E5117: Error while updating package paths: %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, fuzzy, c-format +#~ msgid "E5107: Error while creating lua chunk for luaeval(): %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, fuzzy, c-format +#~ msgid "E5108: Error while calling lua chunk for luaeval(): %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, c-format +#~ msgid "E5114: Error while converting print argument #%i: %.*s" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "E5115: Error while loading debug string: %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, fuzzy, c-format +#~ msgid "E5116: Error while calling debug string: %.*s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +msgid "cannot save undo information" +msgstr "kan nie herwin-inligting stoor nie" + +#. Error messages msgid "Argument missing after" msgstr "Parameter ontbreek na" -#: ../main.c:150 #, fuzzy -msgid "Garbage after option argument" -msgstr "Gemors na opsie" +#~ msgid "Garbage after option argument" +#~ msgstr "Gemors na opsie" + +#, fuzzy +#~ msgid "Unknown option argument" +#~ msgstr "Onbekende opsie" + +msgid "Too many edit arguments" +msgstr "Te veel redigeer-parameters" -#: ../main.c:152 msgid "Too many \"+command\", \"-c command\" or \"--cmd command\" arguments" msgstr "Te veel \"+command\", \"-c command\" of \"--cmd command\" parameters" -#: ../main.c:154 -msgid "Invalid argument for" -msgstr "Ongeldige parameter vir" - -#: ../main.c:294 -#, c-format -msgid "%d files to edit\n" -msgstr "%d lêers om te bewerk\n" +#, fuzzy, c-format +#~ msgid "E5421: Failed to open stdin: %s" +#~ msgstr "E286: Gefaal om invoermetode oop te maak" -#: ../main.c:1342 msgid "Attempt to open script file again: \"" msgstr "Probeer weer om skriplêer oop te maak: \"" -#: ../main.c:1350 msgid "Cannot open for reading: \"" msgstr "Kan nie oopmaak om te lees nie: \"" -#: ../main.c:1393 msgid "Cannot open for script output: \"" msgstr "Kan nie oopmaak vir skrip-afvoer nie: \"" -#: ../main.c:1622 msgid "Vim: Warning: Output is not to a terminal\n" msgstr "Vim: Waarskuwing: Afvoer gaan nie na 'n terminaal nie\n" -#: ../main.c:1624 msgid "Vim: Warning: Input is not from a terminal\n" msgstr "Vim: Waarskuwing: Invoer kom nie vanaf 'n terminaal nie\n" #. just in case.. -#: ../main.c:1891 msgid "pre-vimrc command line" msgstr "vóór-'vimrc' bevelreël" -#: ../main.c:1964 #, c-format msgid "E282: Cannot read from \"%s\"" msgstr "E282: Kan nie lees uit \"%s\" nie" -#: ../main.c:2149 +#, fuzzy msgid "" "\n" -"More info with: \"vim -h\"\n" +"More info with \"" msgstr "" "\n" "Meer inligting met: \"vim -h\"\n" -#: ../main.c:2178 -msgid "[file ..] edit specified file(s)" -msgstr "[lêer ..] bewerk lêer(s)" +#. kill us with CTRL-C here, if you like +#, fuzzy +#~ msgid "Usage:\n" +#~ msgstr "" +#~ "\n" +#~ "\n" +#~ "gebruik:" -#: ../main.c:2179 -msgid "- read text from stdin" -msgstr "- lees teks uit 'stdin'" - -#: ../main.c:2180 -msgid "-t tag edit file where tag is defined" -msgstr "-t tag bewerk lêer waar etiket gedefinieer is" - -#: ../main.c:2181 -msgid "-q [errorfile] edit file with first error" -msgstr "-q [foutlêer] bewerk lêer met eerste fout" +#, fuzzy +#~ msgid " nvim [options] [file ...] Edit file(s)\n" +#~ msgstr "[lêer ..] bewerk lêer(s)" -#: ../main.c:2187 -msgid "" -"\n" -"\n" -"usage:" -msgstr "" -"\n" -"\n" -"gebruik:" +#, fuzzy +#~ msgid " nvim [options] - Read text from stdin\n" +#~ msgstr "- lees teks uit 'stdin'" -#: ../main.c:2189 -msgid " vim [arguments] " -msgstr " vim [parameters] " +#, fuzzy +#~ msgid " nvim [options] -t Edit file where tag is defined\n" +#~ msgstr "-t tag bewerk lêer waar etiket gedefinieer is" -#: ../main.c:2193 -msgid "" -"\n" -" or:" -msgstr "" -"\n" -" of:" +#, fuzzy +#~ msgid " nvim [options] -q [errorfile] Edit file with first error\n" +#~ msgstr "-q [foutlêer] bewerk lêer met eerste fout" -#: ../main.c:2196 +#, fuzzy msgid "" "\n" -"\n" -"Arguments:\n" +"Options:\n" msgstr "" "\n" -"\n" -"Parameters:\n" - -#: ../main.c:2197 -msgid "--\t\t\tOnly file names after this" -msgstr "--\t\t\tSlegs lêername hierna" - -#: ../main.c:2199 -msgid "--literal\t\tDon't expand wildcards" -msgstr "--literal\t\tMoet nie plekhouers uitbrei nie" - -#: ../main.c:2201 -msgid "-v\t\t\tVi mode (like \"vi\")" -msgstr "-v\t\t\tVi modus (soos \"vi\")" - -#: ../main.c:2202 -msgid "-e\t\t\tEx mode (like \"ex\")" -msgstr "-e\t\t\tEx modus (soos \"ex\")" - -#: ../main.c:2203 -msgid "-E\t\t\tImproved Ex mode" -msgstr "" - -#: ../main.c:2204 -msgid "-s\t\t\tSilent (batch) mode (only for \"ex\")" -msgstr "-s\t\t\tStil (bondel) modus (slegs vir \"ex\")" - -#: ../main.c:2205 -msgid "-d\t\t\tDiff mode (like \"vimdiff\")" -msgstr "-d\t\t\tDiff modus (soos \"vimdiff\")" - -#: ../main.c:2206 -msgid "-y\t\t\tEasy mode (like \"evim\", modeless)" -msgstr "-y\t\t\tEasy modus (soos \"evim\", modusloos)" - -#: ../main.c:2207 -msgid "-R\t\t\tReadonly mode (like \"view\")" -msgstr "-R\t\t\tLeesalleen modus (soos \"view\")" - -#: ../main.c:2208 -msgid "-Z\t\t\tRestricted mode (like \"rvim\")" -msgstr "-Z\t\t\tBeperkte modus (soos \"rvim\")" +"--- Opsies ---" -#: ../main.c:2209 -msgid "-m\t\t\tModifications (writing files) not allowed" -msgstr "-m\t\t\tVeranderings (skryf van lêers) nie toegelaat nie" +#, fuzzy +#~ msgid " -- Only file names after this\n" +#~ msgstr "--\t\t\tSlegs lêername hierna" -#: ../main.c:2210 -msgid "-M\t\t\tModifications in text not allowed" -msgstr "-M\t\t\tVeranderings aan teks nie toegelaat nie" +#, fuzzy +#~ msgid " + Start at end of file\n" +#~ msgstr " vir twee modusse " -#: ../main.c:2211 -msgid "-b\t\t\tBinary mode" -msgstr "-b\t\t\tBinêre modus" +#, fuzzy +#~ msgid " --cmd Execute before any config\n" +#~ msgstr "--cmd \tVoer uit voor enige .vimrc-lêer gelaai word" -#: ../main.c:2212 -msgid "-l\t\t\tLisp mode" -msgstr "-l\t\t\tLisp modus" +#, fuzzy +#~ msgid " +, -c Execute after config and first file\n" +#~ msgstr "-c \t\tVoer uit na eerste lêer gelaai is" -#: ../main.c:2213 -msgid "-C\t\t\tCompatible with Vi: 'compatible'" -msgstr "-C\t\t\tVersoenbaar met Vi: 'compatible'" +#, fuzzy +#~ msgid " -b Binary mode\n" +#~ msgstr " vir twee modusse " -#: ../main.c:2214 -msgid "-N\t\t\tNot fully Vi compatible: 'nocompatible'" -msgstr "-N\t\t\tNie ten volle Vi-versoenbaar nie: 'nocompatible'" +#, fuzzy +#~ msgid " -d Diff mode\n" +#~ msgstr " vir twee modusse " -#: ../main.c:2215 -msgid "-V[N][fname]\t\tBe verbose [level N] [log messages to fname]" -msgstr "" +#~ msgid " -e, -E Ex mode, Improved Ex mode\n" +#~ msgstr "" -#: ../main.c:2216 -msgid "-D\t\t\tDebugging mode" -msgstr "-D\t\t\tOntfoutmodus" +#, fuzzy +#~ msgid " -es Silent (batch) mode\n" +#~ msgstr " vir twee modusse " -#: ../main.c:2217 -msgid "-n\t\t\tNo swap file, use memory only" -msgstr "-n\t\t\tGeen ruillêer, gebruik slegs geheue" +#~ msgid " -h, --help Print this help message\n" +#~ msgstr "" -#: ../main.c:2218 -msgid "-r\t\t\tList swap files and exit" -msgstr "-r\t\t\tLys ruillêers en verlaat vim" +#~ msgid " -i Use this shada file\n" +#~ msgstr "" -#: ../main.c:2219 -msgid "-r (with file name)\tRecover crashed session" -msgstr "-r (met lêer naam)\tHerwin ineengestorte sessie" +#, fuzzy +#~ msgid " -m Modifications (writing files) not allowed\n" +#~ msgstr "-m\t\t\tVeranderings (skryf van lêers) nie toegelaat nie" -#: ../main.c:2220 -msgid "-L\t\t\tSame as -r" -msgstr "-L\t\t\tSelfde as -r" +#, fuzzy +#~ msgid " -M Modifications in text not allowed\n" +#~ msgstr "-M\t\t\tVeranderings aan teks nie toegelaat nie" -#: ../main.c:2221 -msgid "-A\t\t\tstart in Arabic mode" -msgstr "-A\t\t\tbegin in Arabiese modus" +#, fuzzy +#~ msgid " -n No swap file, use memory only\n" +#~ msgstr "-n\t\t\tGeen ruillêer, gebruik slegs geheue" -#: ../main.c:2222 -msgid "-H\t\t\tStart in Hebrew mode" -msgstr "-H\t\t\tBegin in Hebreeuse modus" +#, fuzzy +#~ msgid " -o[N] Open N windows (default: one per file)\n" +#~ msgstr "-o[N]\t\tMaak N vensters oop (verstek: een vir elke lêer)" -#: ../main.c:2223 -msgid "-F\t\t\tStart in Farsi mode" -msgstr "-F\t\t\tBegin in Farsi modus" +#, fuzzy +msgid "" +" -O[N] Open N vertical windows (default: one per file)\n" +msgstr "-o[N]\t\tMaak N vensters oop (verstek: een vir elke lêer)" -#: ../main.c:2224 -msgid "-T \tSet terminal type to " -msgstr "-T \tStel terminaaltipe na " +#, fuzzy +#~ msgid " -p[N] Open N tab pages (default: one per file)\n" +#~ msgstr "-o[N]\t\tMaak N vensters oop (verstek: een vir elke lêer)" -#: ../main.c:2225 -msgid "-u \t\tUse instead of any .vimrc" -msgstr "-u \t\tGebruik in plaas van enige ander .vimrc" +#~ msgid " -r, -L List swap files\n" +#~ msgstr "" -#: ../main.c:2226 -msgid "--noplugin\t\tDon't load plugin scripts" -msgstr "--noplugin\t\tMoet nie inpropskripte laai nie" +#~ msgid " -r Recover edit state for this file\n" +#~ msgstr "" -#: ../main.c:2227 #, fuzzy -msgid "-p[N]\t\tOpen N tab pages (default: one for each file)" -msgstr "-o[N]\t\tMaak N vensters oop (verstek: een vir elke lêer)" - -#: ../main.c:2228 -msgid "-o[N]\t\tOpen N windows (default: one for each file)" -msgstr "-o[N]\t\tMaak N vensters oop (verstek: een vir elke lêer)" +#~ msgid " -R Read-only mode\n" +#~ msgstr " vir twee modusse " -#: ../main.c:2229 -msgid "-O[N]\t\tLike -o but split vertically" -msgstr "-O[N]\t\tSoos -o maar verdeel vertikaal" +#, fuzzy +#~ msgid " -S Source after loading the first file\n" +#~ msgstr "" +#~ "-S \t\tVoer bevele in lêer uit na eerste lêer gelaai is" -#: ../main.c:2230 -msgid "+\t\t\tStart at end of file" -msgstr "+\t\t\tBegin by einde van lêer" +#, fuzzy +#~ msgid " -s Read Normal mode commands from \n" +#~ msgstr "-s \t\tLees Normale-modus bevele van lêer " -#: ../main.c:2231 -msgid "+\t\tStart at line " -msgstr "+\t\tBegin by reël " +#~ msgid " -u Use this config file\n" +#~ msgstr "" -#: ../main.c:2232 -msgid "--cmd \tExecute before loading any vimrc file" -msgstr "--cmd \tVoer uit voor enige .vimrc-lêer gelaai word" +#, fuzzy +#~ msgid " -v, --version Print version information\n" +#~ msgstr "--version\t\tSkryf weergawe-inligting en sluit" -#: ../main.c:2233 -msgid "-c \t\tExecute after loading the first file" -msgstr "-c \t\tVoer uit na eerste lêer gelaai is" +#~ msgid " -V[N][file] Verbose [level][file]\n" +#~ msgstr "" -#: ../main.c:2235 -msgid "-S \t\tSource file after loading the first file" -msgstr "" -"-S \t\tVoer bevele in lêer uit na eerste lêer gelaai is" +#, fuzzy +#~ msgid " -Z Restricted mode\n" +#~ msgstr " vir twee modusse " -#: ../main.c:2236 -msgid "-s \tRead Normal mode commands from file " -msgstr "-s \t\tLees Normale-modus bevele van lêer " +#~ msgid " --api-info Write msgpack-encoded API metadata to stdout\n" +#~ msgstr "" -#: ../main.c:2237 -msgid "-w \tAppend all typed commands to file " -msgstr "-w \tLas alle getikte bevele aan by lêer " +#~ msgid " --embed Use stdin/stdout as a msgpack-rpc channel\n" +#~ msgstr "" -#: ../main.c:2238 -msgid "-W \tWrite all typed commands to file " -msgstr "-W \tSkryf alle getikte bevele na lêer " +#~ msgid " --headless Don't start a user interface\n" +#~ msgstr "" -#: ../main.c:2240 -msgid "--startuptime \tWrite startup timing messages to " -msgstr "" +#, fuzzy +#~ msgid " --literal Don't expand wildcards\n" +#~ msgstr "--literal\t\tMoet nie plekhouers uitbrei nie" -#: ../main.c:2242 -msgid "-i \t\tUse instead of .viminfo" -msgstr "-i \t\tGebruik in plaas van .viminfo" +#, fuzzy +#~ msgid " --noplugin Don't load plugins\n" +#~ msgstr "--noplugin\t\tMoet nie inpropskripte laai nie" -#: ../main.c:2243 -msgid "-h or --help\tPrint Help (this message) and exit" -msgstr "-h of --help\tSkryf Hulp (hierdie boodskap) en sluit" +#~ msgid " --startuptime Write startup timing messages to \n" +#~ msgstr "" -#: ../main.c:2244 -msgid "--version\t\tPrint version information and exit" -msgstr "--version\t\tSkryf weergawe-inligting en sluit" +#~ msgid "" +#~ "\n" +#~ "See \":help startup-options\" for all options.\n" +#~ msgstr "" -#: ../mark.c:676 msgid "No marks set" msgstr "Geen merkers gestel nie" -#: ../mark.c:678 #, c-format msgid "E283: No marks matching \"%s\"" msgstr "E283: Geen merkers pas op \"%s\" nie" #. Highlight title -#: ../mark.c:687 msgid "" "\n" "mark line col file/text" @@ -3642,7 +3339,6 @@ msgstr "" "merk reël kol lêer/teks" #. Highlight title -#: ../mark.c:789 msgid "" "\n" " jump line col file/text" @@ -3651,7 +3347,6 @@ msgstr "" " spring reël kol lêer/teks" #. Highlight title -#: ../mark.c:831 msgid "" "\n" "change line col text" @@ -3659,110 +3354,63 @@ msgstr "" "\n" "verander reël kol teks" -#: ../mark.c:1238 -msgid "" -"\n" -"# File marks:\n" -msgstr "" -"\n" -"# Lêermerkers:\n" - -#. Write the jumplist with -' -#: ../mark.c:1271 -msgid "" -"\n" -"# Jumplist (newest first):\n" -msgstr "" -"\n" -"# Springlys (nuutste eerste):\n" - -#: ../mark.c:1352 -msgid "" -"\n" -"# History of marks within files (newest to oldest):\n" -msgstr "" -"\n" -"# Geskiedenis van merkers in lêers (nuutste tot oudste):\n" - -#: ../mark.c:1431 -msgid "Missing '>'" -msgstr "Ontbrekende '>'" - -#: ../memfile.c:426 msgid "E293: block was not locked" msgstr "E293: blok was nie gesluit nie" -#: ../memfile.c:799 msgid "E294: Seek error in swap file read" msgstr "E294: Soekfout in lees van ruillêer" -#: ../memfile.c:803 msgid "E295: Read error in swap file" msgstr "E295: Leesfout in ruillêer" -#: ../memfile.c:849 msgid "E296: Seek error in swap file write" msgstr "E296: Soekfout in skryf van ruillêer" -#: ../memfile.c:865 msgid "E297: Write error in swap file" msgstr "E297: Skryffout in ruillêer" -#: ../memfile.c:1036 msgid "E300: Swap file already exists (symlink attack?)" msgstr "E300: Ruillêer bestaan alreeds! ('symlink' probleem?)" -#: ../memline.c:318 msgid "E298: Didn't get block nr 0?" msgstr "E298: Het nie blok no 0 gekry nie?" -#: ../memline.c:361 msgid "E298: Didn't get block nr 1?" msgstr "E298: Het nie blok no 1 gekry nie?" -#: ../memline.c:377 msgid "E298: Didn't get block nr 2?" msgstr "E298: Het nie blok no 2 gekry nie?" #. could not (re)open the swap file, what can we do???? -#: ../memline.c:465 msgid "E301: Oops, lost the swap file!!!" msgstr "E301: Hiert, die ruillêer is weg!!!" -#: ../memline.c:477 msgid "E302: Could not rename swap file" msgstr "E302: Kon nie ruillêer vernoem nie" -#: ../memline.c:554 #, c-format msgid "E303: Unable to open swap file for \"%s\", recovery impossible" msgstr "E303: Kon nie ruillêer oopmaak vir \"%s\" nie, herwinning onmoontlik" -#: ../memline.c:666 #, fuzzy -msgid "E304: ml_upd_block0(): Didn't get block 0??" -msgstr "E304: 'ml_timestamp': Het nie blok 0 gekry nie??" +#~ msgid "E304: ml_upd_block0(): Didn't get block 0??" +#~ msgstr "E304: 'ml_timestamp': Het nie blok 0 gekry nie??" #. no swap files found -#: ../memline.c:830 #, c-format msgid "E305: No swap file found for %s" msgstr "E305: Geen ruillêer gevind vir %s nie" -#: ../memline.c:839 msgid "Enter number of swap file to use (0 to quit): " msgstr "Tik die nommer van die ruillêer om te gebruik (0 om te stop)" -#: ../memline.c:879 #, c-format msgid "E306: Cannot open %s" msgstr "E306: Kan %s nie oopmaak nie" -#: ../memline.c:897 msgid "Unable to read block 0 from " msgstr "Kan nie blok 0 lees vanaf " -#: ../memline.c:900 msgid "" "\n" "Maybe no changes were made or Vim did not update the swap file." @@ -3770,28 +3418,22 @@ msgstr "" "\n" "Vim het die ruillêer nie opgedateer nie. Dalk was niks verander nie." -#: ../memline.c:909 msgid " cannot be used with this version of Vim.\n" msgstr " kan nie gebruik word met hierdie weergawe van Vim nie.\n" -#: ../memline.c:911 msgid "Use Vim version 3.0.\n" msgstr "Gebruik Vim weergawe 3.0.\n" -#: ../memline.c:916 #, c-format msgid "E307: %s does not look like a Vim swap file" msgstr "E307: %s lyk nie soos 'n Vim ruillêer nie" -#: ../memline.c:922 msgid " cannot be used on this computer.\n" msgstr " kan nie gebruik word op hierdie rekenaar nie.\n" -#: ../memline.c:924 msgid "The file was created on " msgstr "Die lêer is geskep op " -#: ../memline.c:928 msgid "" ",\n" "or the file has been damaged." @@ -3799,85 +3441,66 @@ msgstr "" ",\n" "of die lêer is beskadig." -#: ../memline.c:945 -msgid " has been damaged (page size is smaller than minimum value).\n" -msgstr "" +#~ msgid " has been damaged (page size is smaller than minimum value).\n" +#~ msgstr "" -#: ../memline.c:974 #, c-format msgid "Using swap file \"%s\"" msgstr "Gebruik ruillêer \"%s\"" -#: ../memline.c:980 #, c-format msgid "Original file \"%s\"" msgstr "Oorspronklike lêer \"%s\"" -#: ../memline.c:995 msgid "E308: Warning: Original file may have been changed" msgstr "E308: Waarskuwing: Oorspronklike lêer is dalk gewysig" -#: ../memline.c:1061 #, c-format msgid "E309: Unable to read block 1 from %s" msgstr "E309: Kan nie block 1 lees van %s" -#: ../memline.c:1065 msgid "???MANY LINES MISSING" msgstr "???BAIE REËLS WEG" -#: ../memline.c:1076 msgid "???LINE COUNT WRONG" msgstr "???REËLTELLING FOUTIEF" -#: ../memline.c:1082 msgid "???EMPTY BLOCK" msgstr "???LEË BLOK" -#: ../memline.c:1103 msgid "???LINES MISSING" msgstr "???REËLS WEG" -#: ../memline.c:1128 #, c-format msgid "E310: Block 1 ID wrong (%s not a .swp file?)" msgstr "E310: Blok 1 se ID is foutief (%s nie 'n .swp lêer nie?)" -#: ../memline.c:1133 msgid "???BLOCK MISSING" msgstr "???BLOK WEG" -#: ../memline.c:1147 msgid "??? from here until ???END lines may be messed up" msgstr "??? van hier tot ???END mag reëls deurmekaar wees" -#: ../memline.c:1164 msgid "??? from here until ???END lines may have been inserted/deleted" msgstr "??? van hier tot ???END mag daar reëls ingevoeg/geskrap wees" -#: ../memline.c:1181 msgid "???END" msgstr "???END" -#: ../memline.c:1238 msgid "E311: Recovery Interrupted" msgstr "E311: Herwinning onderbreek" -#: ../memline.c:1243 msgid "" "E312: Errors detected while recovering; look for lines starting with ???" msgstr "" "E312: Foute raakgesien gedurende herwinning; soek vir reëls wat begin met ???" -#: ../memline.c:1245 msgid "See \":help E312\" for more information." msgstr "Sien \":help E312\" vir meer inligting." -#: ../memline.c:1249 msgid "Recovery completed. You should check if everything is OK." msgstr "Herwinning is klaar. Kyk of alles reg is." -#: ../memline.c:1251 msgid "" "\n" "(You might want to write out this file under another name\n" @@ -3885,16 +3508,13 @@ msgstr "" "\n" "(Jy wil dalk die lêer stoor onder 'n ander naam\n" -#: ../memline.c:1252 #, fuzzy -msgid "and run diff with the original file to check for changes)" -msgstr "en dit \"diff\" teen die oorspronklike lêer om wysigings te soek)\n" +#~ msgid "and run diff with the original file to check for changes)" +#~ msgstr "en dit \"diff\" teen die oorspronklike lêer om wysigings te soek)\n" -#: ../memline.c:1254 -msgid "Recovery completed. Buffer contents equals file contents." -msgstr "" +#~ msgid "Recovery completed. Buffer contents equals file contents." +#~ msgstr "" -#: ../memline.c:1255 #, fuzzy msgid "" "\n" @@ -3905,51 +3525,42 @@ msgstr "" "\n" #. use msg() to start the scrolling properly -#: ../memline.c:1327 msgid "Swap files found:" msgstr "Ruillêers gevind:" -#: ../memline.c:1446 msgid " In current directory:\n" msgstr " In huidige gids:\n" -#: ../memline.c:1448 msgid " Using specified name:\n" msgstr " Wat gespesifiseerde naam gebruik:\n" -#: ../memline.c:1450 msgid " In directory " msgstr " In gids " -#: ../memline.c:1465 msgid " -- none --\n" msgstr " -- geen --\n" -#: ../memline.c:1527 msgid " owned by: " msgstr " eienaar: " -#: ../memline.c:1529 msgid " dated: " msgstr " gedateer: " -#: ../memline.c:1532 ../memline.c:3231 msgid " dated: " msgstr " gedateer: " -#: ../memline.c:1548 msgid " [from Vim version 3.0]" msgstr " [van Vim weergawe 3.0]" -#: ../memline.c:1550 msgid " [does not look like a Vim swap file]" msgstr " [lyk nie soos 'n Vim ruillêer nie]" -#: ../memline.c:1552 +#~ msgid " [garbled strings (not nul terminated)]" +#~ msgstr "" + msgid " file name: " msgstr " lêernaam: " -#: ../memline.c:1558 msgid "" "\n" " modified: " @@ -3957,15 +3568,12 @@ msgstr "" "\n" " gewysig: " -#: ../memline.c:1559 msgid "YES" msgstr "JA" -#: ../memline.c:1559 msgid "no" msgstr "nee" -#: ../memline.c:1562 msgid "" "\n" " user name: " @@ -3973,11 +3581,9 @@ msgstr "" "\n" " gebruikersnaam: " -#: ../memline.c:1568 msgid " host name: " msgstr " gasheernaam: " -#: ../memline.c:1570 msgid "" "\n" " host name: " @@ -3985,7 +3591,6 @@ msgstr "" "\n" " gasheernaam: " -#: ../memline.c:1575 msgid "" "\n" " process ID: " @@ -3993,11 +3598,9 @@ msgstr "" "\n" " proses ID: " -#: ../memline.c:1579 msgid " (still running)" msgstr " (nog steeds aan die uitvoer)" -#: ../memline.c:1586 msgid "" "\n" " [not usable on this computer]" @@ -4005,97 +3608,75 @@ msgstr "" "\n" " [nie bruikbaar op hierdie rekenaar nie]" -#: ../memline.c:1590 msgid " [cannot be read]" msgstr " [kan nie gelees word nie]" -#: ../memline.c:1593 msgid " [cannot be opened]" msgstr " [kan nie oopgemaak word nie]" -#: ../memline.c:1698 msgid "E313: Cannot preserve, there is no swap file" msgstr "E313: Kan nie bewaar nie, daar is geen ruillêer nie" -#: ../memline.c:1747 msgid "File preserved" msgstr "Lêer bewaar" -#: ../memline.c:1749 msgid "E314: Preserve failed" msgstr "E314: Kon nie bewaar nie" -#: ../memline.c:1819 #, c-format msgid "E315: ml_get: invalid lnum: %" msgstr "E315: 'ml_get': ongeldige 'lnum': %" -#: ../memline.c:1851 #, c-format msgid "E316: ml_get: cannot find line %" msgstr "E316: 'ml_get': kan reël % nie vind nie" -#: ../memline.c:2236 msgid "E317: pointer block id wrong 3" msgstr "E317: wyser blok id verkeerd 3" -#: ../memline.c:2311 msgid "stack_idx should be 0" msgstr "'stack_idx' moet 0 wees" -#: ../memline.c:2369 msgid "E318: Updated too many blocks?" msgstr "E318: Te veel blokke opgedateer?" -#: ../memline.c:2511 msgid "E317: pointer block id wrong 4" msgstr "E317: wyser blok id verkeerd 4" -#: ../memline.c:2536 msgid "deleted block 1?" msgstr "verwyder blok 1?" -#: ../memline.c:2707 #, c-format msgid "E320: Cannot find line %" msgstr "E320: Kan nie reël % vind nie" -#: ../memline.c:2916 msgid "E317: pointer block id wrong" msgstr "E317: wyser blok id verkeerd" -#: ../memline.c:2930 msgid "pe_line_count is zero" msgstr "'pe_line_count' is nul" -#: ../memline.c:2955 #, c-format msgid "E322: line number out of range: % past the end" msgstr "E322: reëlnommer buite perke: % verby die einde" -#: ../memline.c:2959 #, c-format msgid "E323: line count wrong in block %" msgstr "E323: reëltelling mag verkeerd wees in blok %" -#: ../memline.c:2999 msgid "Stack size increases" msgstr "Stapel grootte verhoog" -#: ../memline.c:3038 msgid "E317: pointer block id wrong 2" msgstr "E317: wyser blok id verkeerd 2" -#: ../memline.c:3070 #, c-format -msgid "E773: Symlink loop for \"%s\"" -msgstr "" +#~ msgid "E773: Symlink loop for \"%s\"" +#~ msgstr "" -#: ../memline.c:3221 msgid "E325: ATTENTION" msgstr "E325: LET OP" -#: ../memline.c:3222 msgid "" "\n" "Found a swap file by the name \"" @@ -4103,44 +3684,35 @@ msgstr "" "\n" "Het 'n ruillêer gevind met die naam \"" -#: ../memline.c:3226 msgid "While opening file \"" msgstr "Tydens oopmaak van lêer \"" -#: ../memline.c:3239 msgid " NEWER than swap file!\n" msgstr " NUWER as die ruillêer!\n" -#: ../memline.c:3244 +#. Some of these messages are long to allow translation to +#. * other languages. #, fuzzy msgid "" "\n" "(1) Another program may be editing the same file. If this is the case,\n" " be careful not to end up with two different instances of the same\n" -" file when making changes." +" file when making changes. Quit, or continue with caution.\n" msgstr "" "\n" "(1) 'n Ander program mag besig wees met hierdie lêer.\n" " Indien wel, pas op om nie met twee verskillende weergawes\n" " van dieselfde lêer te sit wanneer veranderinge gemaak word nie.\n" -#: ../memline.c:3245 -#, fuzzy -msgid " Quit, or continue with caution.\n" -msgstr " Stop, of gaan versigtig voort.\n" - -#: ../memline.c:3246 #, fuzzy -msgid "(2) An edit session for this file crashed.\n" -msgstr "" -"\n" -"(2) 'n Bewerkingsessie van hierdie lêer het ineengestort.\n" +#~ msgid "(2) An edit session for this file crashed.\n" +#~ msgstr "" +#~ "\n" +#~ "(2) 'n Bewerkingsessie van hierdie lêer het ineengestort.\n" -#: ../memline.c:3247 msgid " If this is the case, use \":recover\" or \"vim -r " msgstr " Indien wel, gebruik \":recover\" of \"vim -r" -#: ../memline.c:3249 msgid "" "\"\n" " to recover the changes (see \":help recovery\").\n" @@ -4148,11 +3720,9 @@ msgstr "" "\"\n" " om die veranderinge te herwin (sien \":help recovery\").\n" -#: ../memline.c:3250 msgid " If you did this already, delete the swap file \"" msgstr " Indien jy dit alreeds gedoen het, verwyder die ruillêer \"" -#: ../memline.c:3252 msgid "" "\"\n" " to avoid this message.\n" @@ -4160,23 +3730,15 @@ msgstr "" "\"\n" " om hierdie boodskap te vermy.\n" -#: ../memline.c:3450 ../memline.c:3452 msgid "Swap file \"" msgstr "Ruillêer \"" -#: ../memline.c:3451 ../memline.c:3455 msgid "\" already exists!" msgstr "\" bestaan alreeds!" -#: ../memline.c:3457 msgid "VIM - ATTENTION" msgstr "VIM - LET OP" -#: ../memline.c:3459 -msgid "Swap file already exists!" -msgstr "Ruillêer bestaan alreeds!" - -#: ../memline.c:3464 msgid "" "&Open Read-Only\n" "&Edit anyway\n" @@ -4190,7 +3752,6 @@ msgstr "" "&Verlaat\n" "&Stop" -#: ../memline.c:3467 #, fuzzy msgid "" "&Open Read-Only\n" @@ -4214,48 +3775,47 @@ msgstr "" #. #. ".s?a" #. ".saa": tried enough, give up -#: ../memline.c:3528 msgid "E326: Too many swap files found" msgstr "E326: Te veel ruillêers gevind" -#: ../memory.c:227 +#, fuzzy, c-format +msgid "" +"E303: Unable to create directory \"%s\" for swap file, recovery impossible: " +"%s" +msgstr "E303: Kon nie ruillêer oopmaak vir \"%s\" nie, herwinning onmoontlik" + +#~ msgid "Vim: Data too large to fit into virtual memory space\n" +#~ msgstr "" + #, c-format msgid "E342: Out of memory! (allocating % bytes)" msgstr "E342: Geheue is op! (ken % grepe toe)" -#: ../menu.c:62 msgid "E327: Part of menu-item path is not sub-menu" msgstr "E327: Deel van kieslys-item pad is nie 'n sub-kieslys nie" -#: ../menu.c:63 msgid "E328: Menu only exists in another mode" msgstr "E328: Kieslys bestaan slegs in 'n ander modus" -#: ../menu.c:64 #, fuzzy, c-format -msgid "E329: No menu \"%s\"" -msgstr "E329: Geen kieslys met daardie naam nie" +#~ msgid "E329: No menu \"%s\"" +#~ msgstr "E329: Geen kieslys met daardie naam nie" #. Only a mnemonic or accelerator is not valid. -#: ../menu.c:329 -msgid "E792: Empty menu name" -msgstr "" +#~ msgid "E792: Empty menu name" +#~ msgstr "" -#: ../menu.c:340 msgid "E330: Menu path must not lead to a sub-menu" msgstr "E330: Kieslyspad moenie lei na 'n sub-kieslys nie" -#: ../menu.c:365 msgid "E331: Must not add menu items directly to menu bar" msgstr "E331: Moenie kieslysitems direk by kieslysstaaf voeg nie" -#: ../menu.c:370 msgid "E332: Separator cannot be part of a menu path" msgstr "E332: Verdeler kan nie deel wees van kieslyspad nie" #. Now we have found the matching menu, and we list the mappings #. Highlight title -#: ../menu.c:762 msgid "" "\n" "--- Menus ---" @@ -4263,70 +3823,49 @@ msgstr "" "\n" "--- Kieslyste ---" -#: ../menu.c:1313 msgid "E333: Menu path must lead to a menu item" msgstr "E333: Kieslyspad moet lei na 'n kieslysitem" -#: ../menu.c:1330 #, c-format msgid "E334: Menu not found: %s" msgstr "E334: Kieslys nie gevind nie: %s" -#: ../menu.c:1396 #, c-format msgid "E335: Menu not defined for %s mode" msgstr "E335: Kieslys nie gedefinieer vir %s modus nie" -#: ../menu.c:1426 -msgid "E336: Menu path must lead to a sub-menu" -msgstr "E336: Kieslyspad moet lei na 'n sub-kieslys" - -#: ../menu.c:1447 -msgid "E337: Menu not found - check menu names" -msgstr "E337: Kieslys nie gevind nie - maak seker oor die kieslys name" - -#: ../message.c:423 #, c-format msgid "Error detected while processing %s:" msgstr "Fout ontdek tydens verwerking van %s: " -#: ../message.c:445 #, c-format msgid "line %4ld:" msgstr "reël %4ld:" -#: ../message.c:617 #, c-format msgid "E354: Invalid register name: '%s'" msgstr "E354: Ongeldige registernaam: '%s'" -#: ../message.c:986 msgid "Interrupt: " msgstr "Onderbreek: " -#: ../message.c:988 #, fuzzy -msgid "Press ENTER or type command to continue" -msgstr "Druk ENTER of tik 'n bevel om voort te gaan" +#~ msgid "Press ENTER or type command to continue" +#~ msgstr "Druk ENTER of tik 'n bevel om voort te gaan" -#: ../message.c:1843 #, fuzzy, c-format -msgid "%s line %" -msgstr "%s, reël %" +#~ msgid "%s line %" +#~ msgstr "%s, reël %" -#: ../message.c:2392 msgid "-- More --" msgstr "-- Meer --" -#: ../message.c:2398 -msgid " SPACE/d/j: screen/page/line down, b/u/k: up, q: quit " -msgstr "" +#~ msgid " SPACE/d/j: screen/page/line down, b/u/k: up, q: quit " +#~ msgstr "" -#: ../message.c:3021 ../message.c:3031 msgid "Question" msgstr "Vraag" -#: ../message.c:3023 msgid "" "&Yes\n" "&No" @@ -4334,7 +3873,6 @@ msgstr "" "&Ja\n" "&Nee" -#: ../message.c:3033 msgid "" "&Yes\n" "&No\n" @@ -4344,7 +3882,6 @@ msgstr "" "&Nee\n" "&Kanselleer" -#: ../message.c:3045 msgid "" "&Yes\n" "&No\n" @@ -4358,180 +3895,131 @@ msgstr "" "&Gooi alles weg\n" "&Kanselleer" -#: ../message.c:3058 -#, fuzzy -msgid "E766: Insufficient arguments for printf()" -msgstr "E116: Ongeldige parameters vir funksie %s" - -#: ../message.c:3119 -msgid "E807: Expected Float argument for printf()" -msgstr "" - -#: ../message.c:3873 -#, fuzzy -msgid "E767: Too many arguments to printf()" -msgstr "E118: Te veel parameters vir funksie: %s" - -#: ../misc1.c:2256 msgid "W10: Warning: Changing a readonly file" msgstr "W10: Waarskuwing: Jy wysig aan 'n leesalleen lêer" -#: ../misc1.c:2537 -msgid "Type number and or click with mouse (empty cancels): " -msgstr "" +#~ msgid "Type number and or click with mouse (empty cancels): " +#~ msgstr "" -#: ../misc1.c:2539 -msgid "Type number and (empty cancels): " -msgstr "" +#~ msgid "Type number and (empty cancels): " +#~ msgstr "" -#: ../misc1.c:2585 msgid "1 more line" msgstr "1 reël meer" -#: ../misc1.c:2588 msgid "1 line less" msgstr "1 reël minder" -#: ../misc1.c:2593 #, c-format msgid "% more lines" msgstr "% meer reëls" -#: ../misc1.c:2596 #, c-format msgid "% fewer lines" msgstr "% minder reëls" -#: ../misc1.c:2599 msgid " (Interrupted)" msgstr " (Onderbreek)" -#: ../misc1.c:2635 -msgid "Beep!" -msgstr "" +#~ msgid "Beep!" +#~ msgstr "" -#: ../misc2.c:738 #, c-format msgid "Calling shell to execute: \"%s\"" msgstr "Roep dop om uit te voer: \"%s\"" -#: ../normal.c:183 +#. +#. * nv_*(): functions called to handle Normal and Visual mode commands. +#. * n_*(): functions called to handle Normal mode commands. +#. * v_*(): functions called to handle Visual mode commands. +#. msgid "E349: No identifier under cursor" msgstr "E349: Geen identifiseerder onder loper nie" -#: ../normal.c:1866 #, fuzzy -msgid "E774: 'operatorfunc' is empty" -msgstr "E221: 'commentstring' opsie is leeg" +#~ msgid "E774: 'operatorfunc' is empty" +#~ msgstr "E221: 'commentstring' opsie is leeg" -#: ../normal.c:2637 msgid "Warning: terminal cannot highlight" msgstr "Waarskuwing: terminaal kan nie teks uitlig nie" -#: ../normal.c:2807 msgid "E348: No string under cursor" msgstr "E348: Geen string onder loper nie" -#: ../normal.c:3937 msgid "E352: Cannot erase folds with current 'foldmethod'" msgstr "E352: Kan nie voue verwyder met huidige 'foldmethod' nie" -#: ../normal.c:5897 msgid "E664: changelist is empty" msgstr "E664: 'changelist' is leeg" -#: ../normal.c:5899 msgid "E662: At start of changelist" msgstr "E662: By die begin van die veranderingslys" -#: ../normal.c:5901 msgid "E663: At end of changelist" msgstr "E663: By die einde van die veranderingslys" -#: ../normal.c:7053 msgid "Type :quit to exit Nvim" msgstr "Tik :quit om Vim te verlaat" # Het te doen met < en > -#: ../ops.c:248 #, c-format msgid "1 line %sed 1 time" msgstr "1 reël 1 keer ge-%s" -#: ../ops.c:250 #, c-format msgid "1 line %sed %d times" msgstr "1 reël ge-%s %d keer" -#: ../ops.c:253 #, c-format msgid "% lines %sed 1 time" msgstr "% reëls 1 keer ge-%s" -#: ../ops.c:256 #, c-format msgid "% lines %sed %d times" msgstr "% reëls ge-%s %d keer" -#: ../ops.c:592 #, c-format msgid "% lines to indent... " msgstr "% reëls om in te keep..." -#: ../ops.c:634 msgid "1 line indented " msgstr "1 reël ingekeep " -#: ../ops.c:636 #, c-format msgid "% lines indented " msgstr "% reëls ingekeep " -#: ../ops.c:938 #, fuzzy -msgid "E748: No previously used register" -msgstr "E186: Geen vorige gids nie" +#~ msgid "E748: No previously used register" +#~ msgstr "E186: Geen vorige gids nie" -#. must display the prompt -#: ../ops.c:1433 -msgid "cannot yank; delete anyway" -msgstr "kan nie pluk nie: verwyder in elk geval" - -#: ../ops.c:1929 msgid "1 line changed" msgstr "1 reël verander" -#: ../ops.c:1931 #, c-format msgid "% lines changed" msgstr "% reëls verander" -#: ../ops.c:2521 #, fuzzy -msgid "block of 1 line yanked" -msgstr "1 reël gepluk" +#~ msgid "block of 1 line yanked" +#~ msgstr "1 reël gepluk" -#: ../ops.c:2523 msgid "1 line yanked" msgstr "1 reël gepluk" -#: ../ops.c:2525 #, fuzzy, c-format -msgid "block of % lines yanked" -msgstr "% reëls gepluk" +#~ msgid "block of % lines yanked" +#~ msgstr "% reëls gepluk" -#: ../ops.c:2528 #, c-format msgid "% lines yanked" msgstr "% reëls gepluk" -#: ../ops.c:2710 #, c-format msgid "E353: Nothing in register %s" msgstr "E353: Niks in register %s nie" #. Highlight title -#: ../ops.c:3185 msgid "" "\n" "--- Registers ---" @@ -4539,29 +4027,15 @@ msgstr "" "\n" "--- Registers ---" -#: ../ops.c:4455 -msgid "Illegal register name" -msgstr "Ongeldige registernaam" - -#: ../ops.c:4533 -msgid "" -"\n" -"# Registers:\n" -msgstr "" -"\n" -"# Registers:\n" - -#: ../ops.c:4575 -#, c-format -msgid "E574: Unknown register type %d" -msgstr "E574: Onbekende registertipe %d" +#~ msgid "" +#~ "E883: search pattern and expression register may not contain two or more " +#~ "lines" +#~ msgstr "" -#: ../ops.c:5089 #, c-format msgid "% Cols; " msgstr "% Kolomme; " -#: ../ops.c:5097 #, c-format msgid "" "Selected %s% of % Lines; % of % Words; " @@ -4570,7 +4044,6 @@ msgstr "" "%s% van % reëls gekies; % van % Woorde; " "% van % Grepe" -#: ../ops.c:5105 #, fuzzy, c-format msgid "" "Selected %s% of % Lines; % of % Words; " @@ -4580,7 +4053,6 @@ msgstr "" "% van % Grepe" # njj: Karakters kan meerdere grepe wees, sien ':h multibyte' -#: ../ops.c:5123 #, c-format msgid "" "Col %s of %s; Line % of %; Word % of %; Byte " @@ -4590,7 +4062,6 @@ msgstr "" "Greep % van %" # njj: Karakters kan meerdere grepe wees, sien ':h multibyte' -#: ../ops.c:5133 #, fuzzy, c-format msgid "" "Col %s of %s; Line % of %; Word % of %; Char " @@ -4599,148 +4070,104 @@ msgstr "" "Kol %s van %s; Reël % van %; Woord % van %; " "Greep % van %" -#: ../ops.c:5146 #, c-format msgid "(+% for BOM)" msgstr "(+% vir 'BOM')" -#: ../option.c:1238 -msgid "%<%f%h%m%=Page %N" -msgstr "%<%f%h%m%=Bladsy %N" - -#: ../option.c:1574 -msgid "Thanks for flying Vim" -msgstr "Dankie dat jy vlieg met Vim" - #. found a mismatch: skip -#: ../option.c:2698 msgid "E518: Unknown option" msgstr "E518: Onbekende opsie" -#: ../option.c:2709 -msgid "E519: Option not supported" -msgstr "E519: Opsie is nie ondersteun nie" - -#: ../option.c:2740 msgid "E520: Not allowed in a modeline" msgstr "E520: Nie toegelaat in 'n moduslyn nie" -#: ../option.c:2815 -msgid "E846: Key code not set" -msgstr "" +#~ msgid "E846: Key code not set" +#~ msgstr "" -#: ../option.c:2924 msgid "E521: Number required after =" msgstr "E521: Nommer vereis na =" -#: ../option.c:3226 ../option.c:3864 -msgid "E522: Not found in termcap" -msgstr "E522: Nie gevind in 'termcap' nie" - -#: ../option.c:3335 #, c-format msgid "E539: Illegal character <%s>" msgstr "E539: Ongeldige karakter <%s>" -#: ../option.c:3862 -msgid "E529: Cannot set 'term' to empty string" -msgstr "E529: Kan nie 'term' stel na leë string nie" +#, c-format +#~ msgid "For option %s" +#~ msgstr "" -#: ../option.c:3885 msgid "E589: 'backupext' and 'patchmode' are equal" msgstr "E589: 'backupext' en 'patchmode' is dieselfde" -#: ../option.c:3964 -msgid "E834: Conflicts with value of 'listchars'" -msgstr "" +#~ msgid "E834: Conflicts with value of 'listchars'" +#~ msgstr "" -#: ../option.c:3966 -msgid "E835: Conflicts with value of 'fillchars'" -msgstr "" +#~ msgid "E835: Conflicts with value of 'fillchars'" +#~ msgstr "" -#: ../option.c:4163 msgid "E524: Missing colon" msgstr "E524: Ontbrekende dubbelpunt" -#: ../option.c:4165 msgid "E525: Zero length string" msgstr "E525: Nul-lengte string" -#: ../option.c:4220 #, c-format msgid "E526: Missing number after <%s>" msgstr "E526: Ontbrekende nommer na <%s>" -#: ../option.c:4232 msgid "E527: Missing comma" msgstr "E527: Ontbrekende komma" -#: ../option.c:4239 msgid "E528: Must specify a ' value" msgstr "E528: Moet 'n ' waarde spesifiseer" -#: ../option.c:4271 msgid "E595: contains unprintable or wide character" msgstr "E595: bevat 'n ondrukbare of wye karakter" -#: ../option.c:4469 #, c-format msgid "E535: Illegal character after <%c>" msgstr "E535: Ongeldige karakter na <%c>" -#: ../option.c:4534 msgid "E536: comma required" msgstr "E536: komma benodig" -#: ../option.c:4543 #, c-format msgid "E537: 'commentstring' must be empty or contain %s" msgstr "E537: 'commentstring' moet leeg wees of %s bevat" -#: ../option.c:4928 msgid "E540: Unclosed expression sequence" msgstr "E540: Onvoltooide uitdrukkingreeks" -#: ../option.c:4932 msgid "E541: too many items" msgstr "E541: te veel items" -#: ../option.c:4934 msgid "E542: unbalanced groups" msgstr "E542: ongebalanseerde groepe" -#: ../option.c:5148 msgid "E590: A preview window already exists" msgstr "E590: Daar bestaan reeds 'n voorskouvenster" -#: ../option.c:5311 msgid "W17: Arabic requires UTF-8, do ':set encoding=utf-8'" msgstr "W17: Arabies benodig UTF-8, doen ':set encoding=utf-8'" -#: ../option.c:5623 #, c-format msgid "E593: Need at least %d lines" msgstr "E593: Benodig ten minste %d reëls" -#: ../option.c:5631 #, c-format msgid "E594: Need at least %d columns" msgstr "E594: Benodig ten minste %d kolomme" -#: ../option.c:6011 #, c-format msgid "E355: Unknown option: %s" msgstr "E355: Onbekende opsie: %s" #. There's another character after zeros or the string -#. * is empty. In both cases, we are trying to set a -#. * num option using a string. -#: ../option.c:6037 +#. is empty. In both cases, we are trying to set a +#. num option using a string. #, fuzzy, c-format -msgid "E521: Number required: &%s = '%s'" -msgstr "E521: Nommer vereis na =" +#~ msgid "E521: Number required: &%s = '%s'" +#~ msgstr "E521: Nommer vereis na =" -#: ../option.c:6149 msgid "" "\n" "--- Terminal codes ---" @@ -4748,7 +4175,6 @@ msgstr "" "\n" "--- Terminaal kodes ---" -#: ../option.c:6151 msgid "" "\n" "--- Global option values ---" @@ -4756,7 +4182,6 @@ msgstr "" "\n" "--- Globale opsie waardes ---" -#: ../option.c:6153 msgid "" "\n" "--- Local option values ---" @@ -4764,7 +4189,6 @@ msgstr "" "\n" "--- Lokale opsie waardes ---" -#: ../option.c:6155 msgid "" "\n" "--- Options ---" @@ -4772,29 +4196,28 @@ msgstr "" "\n" "--- Opsies ---" -#: ../option.c:6816 msgid "E356: get_varp ERROR" msgstr "E356: 'get_varp' FOUT" -#: ../option.c:7696 #, c-format msgid "E357: 'langmap': Matching character missing for %s" msgstr "E357: 'langmap': Passende karakter ontbreek vir %s" -#: ../option.c:7715 #, c-format msgid "E358: 'langmap': Extra characters after semicolon: %s" msgstr "E358: 'langmap: Ekstra karakters na kommapunt: %s" -#: ../os/shell.c:194 -msgid "" -"\n" -"Cannot execute shell " -msgstr "" -"\n" -"Kan nie dop uitvoer nie " +#, c-format +#~ msgid "dlerror = \"%s\"" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "E5420: Failed to write to file: %s" +#~ msgstr "E365: Kon nie 'PostScript' lêer druk nie" + +msgid "Vim: Error reading input, exiting...\n" +msgstr "Vim: Fout met lees van invoer, verlaat...\n" -#: ../os/shell.c:439 msgid "" "\n" "shell returned " @@ -4802,959 +4225,930 @@ msgstr "" "\n" "dop lewer " -#: ../os_unix.c:465 ../os_unix.c:471 -msgid "" -"\n" -"Could not get security context for " -msgstr "" +#~ msgid "" +#~ "\n" +#~ "shell failed to start: " +#~ msgstr "" -#: ../os_unix.c:479 -msgid "" -"\n" -"Could not set security context for " -msgstr "" +#. Can happen if system() tries to send input to a shell command that was +#. backgrounded (:call system("cat - &", "foo")). #3529 #5241 +#, fuzzy, c-format +#~ msgid "E5677: Error writing input to shell-command: %s" +#~ msgstr "E208: Kan nie skryf na \"%s\"" -#: ../os_unix.c:1558 ../os_unix.c:1647 -#, c-format -msgid "dlerror = \"%s\"" -msgstr "" +#~ msgid "" +#~ "\n" +#~ "Could not get security context for " +#~ msgstr "" + +#~ msgid "" +#~ "\n" +#~ "Could not set security context for " +#~ msgstr "" -#: ../path.c:1449 #, c-format msgid "E447: Can't find file \"%s\" in path" msgstr "E447: Kan lêer \"%s\" nie vind in pad nie" -#: ../quickfix.c:359 #, c-format msgid "E372: Too many %%%c in format string" msgstr "E372: Te veel %%%c in formaatstring" -#: ../quickfix.c:371 #, c-format msgid "E373: Unexpected %%%c in format string" msgstr "E373: Onverwagte %%%c in formaatstring" -#: ../quickfix.c:420 msgid "E374: Missing ] in format string" msgstr "E374: Ontbrekende ] in formaatstring" -#: ../quickfix.c:431 #, c-format msgid "E375: Unsupported %%%c in format string" msgstr "E375: Ongesteunde %%%c in formaatstring" -#: ../quickfix.c:448 #, c-format msgid "E376: Invalid %%%c in format string prefix" msgstr "E376: Ongeldige %%%c in formaatstringvoorvoegsel" -#: ../quickfix.c:454 #, c-format msgid "E377: Invalid %%%c in format string" msgstr "E377: Ongeldige %%%c in formaatstring" #. nothing found -#: ../quickfix.c:477 msgid "E378: 'errorformat' contains no pattern" msgstr "E378: 'errorformat' bevat geen patroon nie" -#: ../quickfix.c:695 msgid "E379: Missing or empty directory name" msgstr "E379: Ontbrekende of leë gidsnaam" -#: ../quickfix.c:1305 msgid "E553: No more items" msgstr "E553: Geen items meer nie" -#: ../quickfix.c:1674 +#~ msgid "E924: Current window was closed" +#~ msgstr "" + +#~ msgid "E925: Current quickfix was changed" +#~ msgstr "" + +#~ msgid "E926: Current location list was changed" +#~ msgstr "" + #, c-format msgid "(%d of %d)%s%s: " msgstr "(%d van %d)%s%s: " -#: ../quickfix.c:1676 msgid " (line deleted)" msgstr " (reël verwyder)" -#: ../quickfix.c:1863 +#, fuzzy, c-format +#~ msgid "%serror list %d of %d; %d errors " +#~ msgstr "foutelys %d van %d; %d foute" + msgid "E380: At bottom of quickfix stack" msgstr "E380: Onder aan 'quickfix' stapel" -#: ../quickfix.c:1869 msgid "E381: At top of quickfix stack" msgstr "E381: Bo aan 'quickfix' stapel" -#: ../quickfix.c:1880 -#, c-format -msgid "error list %d of %d; %d errors" -msgstr "foutelys %d van %d; %d foute" +#~ msgid "No entries" +#~ msgstr "" -#: ../quickfix.c:2427 msgid "E382: Cannot write, 'buftype' option is set" msgstr "E382: Kan nie skryf nie, 'buftype' opsie is aan" -#: ../quickfix.c:2812 -msgid "E683: File name missing or invalid pattern" -msgstr "" +#~ msgid "E683: File name missing or invalid pattern" +#~ msgstr "" -#: ../quickfix.c:2911 #, fuzzy, c-format -msgid "Cannot open file \"%s\"" -msgstr "Kan nie lêer %s oopmaak nie" +#~ msgid "Cannot open file \"%s\"" +#~ msgstr "Kan nie lêer %s oopmaak nie" -#: ../quickfix.c:3429 #, fuzzy -msgid "E681: Buffer is not loaded" -msgstr "1 buffer uitgelaai" +#~ msgid "E681: Buffer is not loaded" +#~ msgstr "1 buffer uitgelaai" -#: ../quickfix.c:3487 #, fuzzy -msgid "E777: String or List expected" -msgstr "E548: syfer verwag" +#~ msgid "E777: String or List expected" +#~ msgstr "E548: syfer verwag" -#: ../regexp.c:359 #, c-format msgid "E369: invalid item in %s%%[]" msgstr "E369: ongeldige item in %s%%[]" -#: ../regexp.c:374 #, fuzzy, c-format -msgid "E769: Missing ] after %s[" -msgstr "E69: Ontbrekende ] na %s%%[" +#~ msgid "E769: Missing ] after %s[" +#~ msgstr "E69: Ontbrekende ] na %s%%[" -#: ../regexp.c:375 #, c-format msgid "E53: Unmatched %s%%(" msgstr "E53: Onpaar %s%%(" -#: ../regexp.c:376 #, c-format msgid "E54: Unmatched %s(" msgstr "E54: Onpaar %s(" -#: ../regexp.c:377 #, c-format msgid "E55: Unmatched %s)" msgstr "E55: Onpaar %s)" -#: ../regexp.c:378 msgid "E66: \\z( not allowed here" msgstr "E66: \\z( nie hier toegelaat nie" -#: ../regexp.c:379 msgid "E67: \\z1 et al. not allowed here" msgstr "E67: \\z1 e.a. nie hier toegelaat nie" -#: ../regexp.c:380 #, c-format msgid "E69: Missing ] after %s%%[" msgstr "E69: Ontbrekende ] na %s%%[" -#: ../regexp.c:381 #, c-format msgid "E70: Empty %s%%[]" msgstr "E70: Leë %s%%[]" -#: ../regexp.c:1209 ../regexp.c:1224 msgid "E339: Pattern too long" msgstr "E339: Patroon te lank" -#: ../regexp.c:1371 msgid "E50: Too many \\z(" msgstr "E50: Te veel \\z(" -#: ../regexp.c:1378 #, c-format msgid "E51: Too many %s(" msgstr "E51: Te veel %s(" -#: ../regexp.c:1427 msgid "E52: Unmatched \\z(" msgstr "E52: Onpaar \\z(" -#: ../regexp.c:1637 #, c-format msgid "E59: invalid character after %s@" msgstr "E59: ongeldige karakter na %s@" -#: ../regexp.c:1672 #, c-format msgid "E60: Too many complex %s{...}s" msgstr "E60: Te veel komplekse %s{...}ies" -#: ../regexp.c:1687 #, c-format msgid "E61: Nested %s*" msgstr "E61: Geneste %s*" -#: ../regexp.c:1690 #, c-format msgid "E62: Nested %s%c" msgstr "E62: Geneste %s%c" -#: ../regexp.c:1800 msgid "E63: invalid use of \\_" msgstr "E63: ongeldige gebruik van \\_" -#: ../regexp.c:1850 #, c-format msgid "E64: %s%c follows nothing" msgstr "E64: %s%c volg niks" -#: ../regexp.c:1902 msgid "E65: Illegal back reference" msgstr "E65: Ongeldige tru-verwysing" -#: ../regexp.c:1943 msgid "E68: Invalid character after \\z" msgstr "E68: ongeldige karakter na \\z" -#: ../regexp.c:2049 ../regexp_nfa.c:1296 #, fuzzy, c-format -msgid "E678: Invalid character after %s%%[dxouU]" -msgstr "E71: Ongeldige karakter na %s%%" +#~ msgid "E678: Invalid character after %s%%[dxouU]" +#~ msgstr "E71: Ongeldige karakter na %s%%" -#: ../regexp.c:2107 #, c-format msgid "E71: Invalid character after %s%%" msgstr "E71: Ongeldige karakter na %s%%" -#: ../regexp.c:3017 +#, fuzzy, c-format +#~ msgid "E888: (NFA regexp) cannot repeat %s" +#~ msgstr "E50: Te veel \\z(" + #, c-format msgid "E554: Syntax error in %s{...}" msgstr "E554: Sintaksfout in %s{...}" -#: ../regexp.c:3805 msgid "External submatches:\n" msgstr "Eksterne subtreffers:\n" -#: ../regexp.c:7022 -msgid "" -"E864: \\%#= can only be followed by 0, 1, or 2. The automatic engine will be " -"used " -msgstr "" +#~ msgid "" +#~ "E864: \\%#= can only be followed by 0, 1, or 2. The automatic engine will be " +#~ "used " +#~ msgstr "" -#: ../regexp_nfa.c:239 -msgid "E865: (NFA) Regexp end encountered prematurely" -msgstr "" +#~ msgid "Switching to backtracking RE engine for pattern: " +#~ msgstr "" -#: ../regexp_nfa.c:240 -#, c-format -msgid "E866: (NFA regexp) Misplaced %c" -msgstr "" +#~ msgid " TERMINAL" +#~ msgstr "" -#: ../regexp_nfa.c:242 -#, c-format -msgid "E877: (NFA regexp) Invalid character class: %" -msgstr "" +msgid " VREPLACE" +msgstr " VVERVANG" -#: ../regexp_nfa.c:1261 -#, c-format -msgid "E867: (NFA) Unknown operator '\\z%c'" -msgstr "" +msgid " REPLACE" +msgstr " VERVANG" -#: ../regexp_nfa.c:1387 -#, c-format -msgid "E867: (NFA) Unknown operator '\\%%%c'" -msgstr "" +msgid " REVERSE" +msgstr " OMKEER" -#: ../regexp_nfa.c:1802 -#, c-format -msgid "E869: (NFA) Unknown operator '\\@%c'" -msgstr "" +msgid " INSERT" +msgstr " INVOEG" -#: ../regexp_nfa.c:1831 -msgid "E870: (NFA regexp) Error reading repetition limits" -msgstr "" +msgid " (insert)" +msgstr " (invoeg)" -#. Can't have a multi follow a multi. -#: ../regexp_nfa.c:1895 -msgid "E871: (NFA regexp) Can't have a multi follow a multi !" -msgstr "" +msgid " (replace)" +msgstr " (vervang)" -#. Too many `(' -#: ../regexp_nfa.c:2037 -msgid "E872: (NFA regexp) Too many '('" -msgstr "" +msgid " (vreplace)" +msgstr " (vvervang)" -#: ../regexp_nfa.c:2042 -#, fuzzy -msgid "E879: (NFA regexp) Too many \\z(" -msgstr "E50: Te veel \\z(" +msgid " Hebrew" +msgstr " Hebreeus" -#: ../regexp_nfa.c:2066 -msgid "E873: (NFA regexp) proper termination error" -msgstr "" +msgid " Arabic" +msgstr " Arabies" -#: ../regexp_nfa.c:2599 -msgid "E874: (NFA) Could not pop the stack !" -msgstr "" - -#: ../regexp_nfa.c:3298 -msgid "" -"E875: (NFA regexp) (While converting from postfix to NFA), too many states " -"left on stack" -msgstr "" - -#: ../regexp_nfa.c:3302 -msgid "E876: (NFA regexp) Not enough space to store the whole NFA " -msgstr "" - -#: ../regexp_nfa.c:4571 ../regexp_nfa.c:4869 -msgid "" -"Could not open temporary log file for writing, displaying on stderr ... " -msgstr "" - -#: ../regexp_nfa.c:4840 -#, c-format -msgid "(NFA) COULD NOT OPEN %s !" -msgstr "" - -#: ../regexp_nfa.c:6049 -#, fuzzy -msgid "Could not open temporary log file for writing " -msgstr "E214: Kan nie tydelike lêer vind vir skryf nie" - -#: ../screen.c:7435 -msgid " VREPLACE" -msgstr " VVERVANG" - -#: ../screen.c:7437 -msgid " REPLACE" -msgstr " VERVANG" - -#: ../screen.c:7440 -msgid " REVERSE" -msgstr " OMKEER" - -#: ../screen.c:7441 -msgid " INSERT" -msgstr " INVOEG" - -#: ../screen.c:7443 -msgid " (insert)" -msgstr " (invoeg)" - -#: ../screen.c:7445 -msgid " (replace)" -msgstr " (vervang)" - -#: ../screen.c:7447 -msgid " (vreplace)" -msgstr " (vvervang)" - -#: ../screen.c:7449 -msgid " Hebrew" -msgstr " Hebreeus" - -#: ../screen.c:7454 -msgid " Arabic" -msgstr " Arabies" - -#: ../screen.c:7456 -msgid " (lang)" -msgstr " (taal)" - -#: ../screen.c:7459 msgid " (paste)" msgstr " (plak)" -#: ../screen.c:7469 msgid " VISUAL" msgstr " VISUELE" -#: ../screen.c:7470 msgid " VISUAL LINE" msgstr " VISUELE REËL" -#: ../screen.c:7471 msgid " VISUAL BLOCK" msgstr " VISUELE BLOK" -#: ../screen.c:7472 msgid " SELECT" msgstr " KIES" -#: ../screen.c:7473 msgid " SELECT LINE" msgstr " KIES REËL" -#: ../screen.c:7474 msgid " SELECT BLOCK" msgstr " KIES BLOK" -#: ../screen.c:7486 ../screen.c:7541 msgid "recording" msgstr "besig om op te neem" -#: ../search.c:487 #, c-format msgid "E383: Invalid search string: %s" msgstr "E383: Ongeldige soekstring: %s" -#: ../search.c:832 #, c-format msgid "E384: search hit TOP without match for: %s" msgstr "E384: soektog het BO getref sonder treffer vir: %s" -#: ../search.c:835 #, c-format msgid "E385: search hit BOTTOM without match for: %s" msgstr "E385: soektog het ONDER getref sonder treffer vir: %s" -#: ../search.c:1200 msgid "E386: Expected '?' or '/' after ';'" msgstr "E386: Verwag '?' of '/' na ';'" -#: ../search.c:4085 msgid " (includes previously listed match)" msgstr " (sluit in vorige gelyste treffer)" #. cursor at status line -#: ../search.c:4104 msgid "--- Included files " msgstr "--- Ingeslote lêers" -#: ../search.c:4106 msgid "not found " msgstr "nie gevind nie " -#: ../search.c:4107 msgid "in path ---\n" msgstr "in pad ---\n" -#: ../search.c:4168 msgid " (Already listed)" msgstr " (Alreeds gelys)" -#: ../search.c:4170 msgid " NOT FOUND" msgstr " NIE GEVIND NIE" -#: ../search.c:4211 #, c-format msgid "Scanning included file: %s" msgstr "Deursoek ingeslote lêer: %s" -#: ../search.c:4216 #, fuzzy, c-format -msgid "Searching included file %s" -msgstr "Deursoek ingeslote lêer: %s" +#~ msgid "Searching included file %s" +#~ msgstr "Deursoek ingeslote lêer: %s" -#: ../search.c:4405 msgid "E387: Match is on current line" msgstr "E387: Treffer is op huidige reël" -#: ../search.c:4517 msgid "All included files were found" msgstr "Alle ingeslote lêers is gevind" -#: ../search.c:4519 msgid "No included files" msgstr "Geen ingeslote lêers nie" -#: ../search.c:4527 msgid "E388: Couldn't find definition" msgstr "E388: Kon definisie nie vind nie" -#: ../search.c:4529 msgid "E389: Couldn't find pattern" msgstr "E389: Kon patroon nie vind nie" -#: ../search.c:4668 -#, fuzzy -msgid "Substitute " -msgstr "1 vervanging" +#~ msgid "too few bytes read" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "System error while skipping in ShaDa file: %s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" -#: ../search.c:4681 #, c-format -msgid "" -"\n" -"# Last %sSearch Pattern:\n" -"~" -msgstr "" +#~ msgid "" +#~ "Error while reading ShaDa file: last entry specified that it occupies " +#~ "% bytes, but file ended earlier" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "System error while closing ShaDa file: %s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, fuzzy, c-format +#~ msgid "System error while writing ShaDa file: %s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, fuzzy, c-format +#~ msgid "Reading ShaDa file \"%s\"%s%s%s" +#~ msgstr "Besig om viminfo lêer \"%s\"%s%s%s te lees" + +msgid " info" +msgstr " inligting" + +msgid " marks" +msgstr " merkers" -#: ../spell.c:951 #, fuzzy -msgid "E759: Format error in spell file" -msgstr "E297: Skryffout in ruillêer" +#~ msgid " oldfiles" +#~ msgstr "Geen ingeslote lêers nie" -#: ../spell.c:952 -msgid "E758: Truncated spell file" -msgstr "" +msgid " FAILED" +msgstr " GEFAAL" -#: ../spell.c:953 #, c-format -msgid "Trailing text in %s line %d: %s" -msgstr "" +#~ msgid "System error while opening ShaDa file %s for reading: %s" +#~ msgstr "" + +#~ msgid "additional elements of ShaDa " +#~ msgstr "" + +#~ msgid "additional data of ShaDa " +#~ msgstr "" -#: ../spell.c:954 #, c-format -msgid "Affix name too long in %s line %d: %s" -msgstr "" +#~ msgid "Failed to write variable %s" +#~ msgstr "" -#: ../spell.c:955 -#, fuzzy -msgid "E761: Format error in affix file FOL, LOW or UPP" -msgstr "E431: Formaatfout in etiketlêer \"%s\"" +#, c-format +#~ msgid "" +#~ "Failed to parse ShaDa file due to a msgpack parser error at position " +#~ "%" +#~ msgstr "" -#: ../spell.c:957 -msgid "E762: Character in FOL, LOW or UPP is out of range" -msgstr "" +#, c-format +#~ msgid "" +#~ "Failed to parse ShaDa file: incomplete msgpack string at position %" +#~ msgstr "" -#: ../spell.c:958 -msgid "Compressing word tree..." -msgstr "" +#, c-format +#~ msgid "" +#~ "Failed to parse ShaDa file: extra bytes in msgpack string at position " +#~ "%" +#~ msgstr "" -#: ../spell.c:1951 -msgid "E756: Spell checking is not enabled" -msgstr "" +#, c-format +#~ msgid "" +#~ "System error while opening ShaDa file %s for reading to merge before writing " +#~ "it: %s" +#~ msgstr "" -#: ../spell.c:2249 +#. Tried names from .tmp.a to .tmp.z, all failed. Something must be +#. wrong then. #, c-format -msgid "Warning: Cannot find word list \"%s.%s.spl\" or \"%s.ascii.spl\"" -msgstr "" +#~ msgid "E138: All %s.tmp.X files exist, cannot write ShaDa file!" +#~ msgstr "" -#: ../spell.c:2473 #, fuzzy, c-format -msgid "Reading spell file \"%s\"" -msgstr "Gebruik ruillêer \"%s\"" - -#: ../spell.c:2496 -#, fuzzy -msgid "E757: This does not look like a spell file" -msgstr "E307: %s lyk nie soos 'n Vim ruillêer nie" +#~ msgid "System error while opening temporary ShaDa file %s for writing: %s" +#~ msgstr "E214: Kan nie tydelike lêer vind vir skryf nie" -#: ../spell.c:2501 -msgid "E771: Old spell file, needs to be updated" -msgstr "" +#, c-format +#~ msgid "Failed to create directory %s for writing ShaDa file: %s" +#~ msgstr "" -#: ../spell.c:2504 -msgid "E772: Spell file is for newer version of Vim" -msgstr "" +#, c-format +#~ msgid "System error while opening ShaDa file %s for writing: %s" +#~ msgstr "" -#: ../spell.c:2602 -#, fuzzy -msgid "E770: Unsupported section in spell file" -msgstr "E297: Skryffout in ruillêer" +#, fuzzy, c-format +#~ msgid "Writing ShaDa file \"%s\"" +#~ msgstr "Besig om viminfo lêer \"%s\" te stoor" -#: ../spell.c:3762 #, fuzzy, c-format -msgid "Warning: region %s not supported" -msgstr "E519: Opsie is nie ondersteun nie" +#~ msgid "Failed setting uid and gid for file %s: %s" +#~ msgstr "%s klaar uitgevoer" -#: ../spell.c:4550 #, fuzzy, c-format -msgid "Reading affix file %s ..." -msgstr "Deursoek etiketlêer %s" +#~ msgid "E137: ShaDa file is not writable: %s" +#~ msgstr "E137: Viminfo lêer is nie skryfbaar nie: %s" -#: ../spell.c:4589 ../spell.c:5635 ../spell.c:6140 #, c-format -msgid "Conversion failure for word in %s line %d: %s" -msgstr "" +#~ msgid "Can't rename ShaDa file from %s to %s!" +#~ msgstr "" -#: ../spell.c:4630 ../spell.c:6170 -#, c-format -msgid "Conversion in %s not supported: from %s to %s" -msgstr "" +#, fuzzy, c-format +#~ msgid "Did not rename %s because %s does not looks like a ShaDa file" +#~ msgstr " [lyk nie soos 'n Vim ruillêer nie]" -#: ../spell.c:4642 #, c-format -msgid "Invalid value for FLAG in %s line %d: %s" -msgstr "" +#~ msgid "Did not rename %s to %s because there were errors during writing it" +#~ msgstr "" -#: ../spell.c:4655 #, c-format -msgid "FLAG after using flags in %s line %d: %s" -msgstr "" +#~ msgid "Do not forget to remove %s or rename it manually to %s." +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "System error while reading ShaDa file: %s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" + +#, fuzzy, c-format +#~ msgid "System error while reading integer from ShaDa file: %s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" -#: ../spell.c:4723 #, c-format -msgid "" -"Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in %s line " -"%d" -msgstr "" +#~ msgid "" +#~ "Error while reading ShaDa file: expected positive integer at position " +#~ "%, but got nothing" +#~ msgstr "" -#: ../spell.c:4731 #, c-format -msgid "" -"Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in %s line " -"%d" -msgstr "" +#~ msgid "" +#~ "Error while reading ShaDa file: expected positive integer at position " +#~ "%" +#~ msgstr "" -#: ../spell.c:4747 #, c-format -msgid "Wrong COMPOUNDRULES value in %s line %d: %s" -msgstr "" +#~ msgid "" +#~ "Error while reading ShaDa file: there is an item at position % that " +#~ "is stated to be too long" +#~ msgstr "" -#: ../spell.c:4771 +#. kSDItemUnknown cannot possibly pass that far because it is -1 and that +#. will fail in msgpack_read_uint64. But kSDItemMissing may and it will +#. otherwise be skipped because (1 << 0) will never appear in flags. #, c-format -msgid "Wrong COMPOUNDWORDMAX value in %s line %d: %s" -msgstr "" +#~ msgid "" +#~ "Error while reading ShaDa file: there is an item at position % that " +#~ "must not be there: Missing items are for internal uses only" +#~ msgstr "" -#: ../spell.c:4777 #, c-format -msgid "Wrong COMPOUNDMIN value in %s line %d: %s" -msgstr "" +#~ msgid "" +#~ "Error while reading ShaDa file: buffer list at position % contains " +#~ "entry that is not a dictionary" +#~ msgstr "" -#: ../spell.c:4783 #, c-format -msgid "Wrong COMPOUNDSYLMAX value in %s line %d: %s" -msgstr "" +#~ msgid "" +#~ "Error while reading ShaDa file: buffer list at position % contains " +#~ "entry with invalid line number" +#~ msgstr "" -#: ../spell.c:4795 #, c-format -msgid "Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s" -msgstr "" +#~ msgid "" +#~ "Error while reading ShaDa file: buffer list at position % contains " +#~ "entry with invalid column number" +#~ msgstr "" -#: ../spell.c:4847 #, c-format -msgid "Different combining flag in continued affix block in %s line %d: %s" -msgstr "" +#~ msgid "" +#~ "Error while reading ShaDa file: buffer list at position % contains " +#~ "entry that does not have a file name" +#~ msgstr "" -#: ../spell.c:4850 -#, fuzzy, c-format -msgid "Duplicate affix in %s line %d: %s" -msgstr "E154: Duplikaat etiket \"%s\" in lêer %s/%s" +#. values for ts_isdiff +#. no different byte (yet) +#. different byte found +#. inserting character +#. values for ts_flags +#. already checked that prefix is OK +#. tried split at this point +#. did a delete, "ts_delidx" has index +#. special values ts_prefixdepth +#. not using prefixes +#. walking through the prefix tree +#. highest value that's not special +#. mode values for find_word +#. find word case-folded +#. find keep-case word +#. find word after prefix +#. find case-folded compound word +#. find keep-case compound word +#, fuzzy +#~ msgid "E759: Format error in spell file" +#~ msgstr "E297: Skryffout in ruillêer" -#: ../spell.c:4871 -#, c-format -msgid "" -"Affix also used for BAD/RARE/KEEPCASE/NEEDAFFIX/NEEDCOMPOUND/NOSUGGEST in %s " -"line %d: %s" -msgstr "" +#~ msgid "E756: Spell checking is not enabled" +#~ msgstr "" -#: ../spell.c:4893 #, c-format -msgid "Expected Y or N in %s line %d: %s" -msgstr "" +#~ msgid "Warning: Cannot find word list \"%s.%s.spl\" or \"%s.ascii.spl\"" +#~ msgstr "" -#: ../spell.c:4968 -#, c-format -msgid "Broken condition in %s line %d: %s" -msgstr "" +#, fuzzy +#~ msgid "E797: SpellFileMissing autocommand deleted buffer" +#~ msgstr "E246: 'FileChangedShell' outobevel het buffer verwyder" -#: ../spell.c:5091 -#, c-format -msgid "Expected REP(SAL) count in %s line %d" -msgstr "" +#. This is probably an error. Give a warning and +#. accept the words anyway. +#, fuzzy, c-format +#~ msgid "Warning: region %s not supported" +#~ msgstr "E519: Opsie is nie ondersteun nie" -#: ../spell.c:5120 -#, c-format -msgid "Expected MAP count in %s line %d" -msgstr "" +#~ msgid "Sorry, no suggestions" +#~ msgstr "" -#: ../spell.c:5132 -#, c-format -msgid "Duplicate character in MAP in %s line %d" -msgstr "" +#, fuzzy, c-format +#~ msgid "Sorry, only % suggestions" +#~ msgstr " op % reëls" -#: ../spell.c:5176 -#, c-format -msgid "Unrecognized or duplicate item in %s line %d: %s" -msgstr "" +#. for when 'cmdheight' > 1 +#. avoid more prompt +#, fuzzy, c-format +#~ msgid "Change \"%.*s\" to:" +#~ msgstr "Stoor veranderinge na \"%.*s\"?" -#: ../spell.c:5197 #, c-format -msgid "Missing FOL/LOW/UPP line in %s" -msgstr "" - -#: ../spell.c:5220 -msgid "COMPOUNDSYLMAX used without SYLLABLE" -msgstr "" +#~ msgid " < \"%.*s\"" +#~ msgstr "" -#: ../spell.c:5236 #, fuzzy -msgid "Too many postponed prefixes" -msgstr "Te veel redigeer-parameters" +#~ msgid "E752: No previous spell replacement" +#~ msgstr "E35: Geen vorige patroon nie" -#: ../spell.c:5238 -#, fuzzy -msgid "Too many compound flags" -msgstr "Te veel redigeer-parameters" +#, fuzzy, c-format +#~ msgid "E753: Not found: %s" +#~ msgstr "E334: Kieslys nie gevind nie: %s" -#: ../spell.c:5240 -msgid "Too many postponed prefixes and/or compound flags" -msgstr "" +#~ msgid "E758: Truncated spell file" +#~ msgstr "" -#: ../spell.c:5250 #, c-format -msgid "Missing SOFO%s line in %s" -msgstr "" +#~ msgid "Trailing text in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:5253 #, c-format -msgid "Both SAL and SOFO lines in %s" -msgstr "" +#~ msgid "Affix name too long in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:5331 -#, c-format -msgid "Flag is not a number in %s line %d: %s" -msgstr "" +#, fuzzy +#~ msgid "E761: Format error in affix file FOL, LOW or UPP" +#~ msgstr "E431: Formaatfout in etiketlêer \"%s\"" -#: ../spell.c:5334 -#, c-format -msgid "Illegal flag in %s line %d: %s" -msgstr "" +#~ msgid "E762: Character in FOL, LOW or UPP is out of range" +#~ msgstr "" -#: ../spell.c:5493 ../spell.c:5501 -#, c-format -msgid "%s value differs from what is used in another .aff file" -msgstr "" +#~ msgid "Compressing word tree..." +#~ msgstr "" -#: ../spell.c:5602 #, fuzzy, c-format -msgid "Reading dictionary file %s ..." -msgstr "Deursoek woordeboek: %s" +#~ msgid "Reading spell file \"%s\"" +#~ msgstr "Gebruik ruillêer \"%s\"" -#: ../spell.c:5611 -#, c-format -msgid "E760: No word count in %s" -msgstr "" +#, fuzzy +#~ msgid "E757: This does not look like a spell file" +#~ msgstr "E307: %s lyk nie soos 'n Vim ruillêer nie" -#: ../spell.c:5669 -#, c-format -msgid "line %6d, word %6d - %s" -msgstr "" +#, fuzzy, c-format +#~ msgid "E5042: Failed to read spell file %s: %s" +#~ msgstr "E482: Kan nie lêer %s skep nie" + +#~ msgid "E771: Old spell file, needs to be updated" +#~ msgstr "" + +#~ msgid "E772: Spell file is for newer version of Vim" +#~ msgstr "" + +#, fuzzy +#~ msgid "E770: Unsupported section in spell file" +#~ msgstr "E297: Skryffout in ruillêer" -#: ../spell.c:5691 #, fuzzy, c-format -msgid "Duplicate word in %s line %d: %s" -msgstr "Patroon gevind in elke reël: %s" +#~ msgid "E778: This does not look like a .sug file: %s" +#~ msgstr "E307: %s lyk nie soos 'n Vim ruillêer nie" -#: ../spell.c:5694 #, c-format -msgid "First duplicate word in %s line %d: %s" -msgstr "" +#~ msgid "E779: Old .sug file, needs to be updated: %s" +#~ msgstr "" -#: ../spell.c:5746 #, c-format -msgid "%d duplicate word(s) in %s" -msgstr "" +#~ msgid "E780: .sug file is for newer version of Vim: %s" +#~ msgstr "" -#: ../spell.c:5748 #, c-format -msgid "Ignored %d word(s) with non-ASCII characters in %s" -msgstr "" +#~ msgid "E781: .sug file doesn't match .spl file: %s" +#~ msgstr "" -#: ../spell.c:6115 #, fuzzy, c-format -msgid "Reading word file %s ..." -msgstr "Lees nou vanaf stdin... " +#~ msgid "E782: error while reading .sug file: %s" +#~ msgstr "E47: Fout tydens lees van 'errorfile'" -#: ../spell.c:6155 -#, c-format -msgid "Duplicate /encoding= line ignored in %s line %d: %s" -msgstr "" +#, fuzzy, c-format +#~ msgid "Reading affix file %s ..." +#~ msgstr "Deursoek etiketlêer %s" -#: ../spell.c:6159 #, c-format -msgid "/encoding= line after word ignored in %s line %d: %s" -msgstr "" +#~ msgid "Conversion failure for word in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:6180 #, c-format -msgid "Duplicate /regions= line ignored in %s line %d: %s" -msgstr "" +#~ msgid "Conversion in %s not supported: from %s to %s" +#~ msgstr "" -#: ../spell.c:6185 #, c-format -msgid "Too many regions in %s line %d: %s" -msgstr "" +#~ msgid "Invalid value for FLAG in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:6198 #, c-format -msgid "/ line ignored in %s line %d: %s" -msgstr "" +#~ msgid "FLAG after using flags in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:6224 -#, fuzzy, c-format -msgid "Invalid region nr in %s line %d: %s" -msgstr "E573: Ongeldige bediener-id gebruik: %s" +#, c-format +#~ msgid "" +#~ "Defining COMPOUNDFORBIDFLAG after PFX item may give wrong results in %s line " +#~ "%d" +#~ msgstr "" -#: ../spell.c:6230 #, c-format -msgid "Unrecognized flags in %s line %d: %s" -msgstr "" +#~ msgid "" +#~ "Defining COMPOUNDPERMITFLAG after PFX item may give wrong results in %s line " +#~ "%d" +#~ msgstr "" -#: ../spell.c:6257 #, c-format -msgid "Ignored %d words with non-ASCII characters" -msgstr "" +#~ msgid "Wrong COMPOUNDRULES value in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:6656 #, c-format -msgid "Compressed %d of %d nodes; %d (%d%%) remaining" -msgstr "" +#~ msgid "Wrong COMPOUNDWORDMAX value in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:7340 -msgid "Reading back spell file..." -msgstr "" +#, c-format +#~ msgid "Wrong COMPOUNDMIN value in %s line %d: %s" +#~ msgstr "" -#. Go through the trie of good words, soundfold each word and add it to -#. the soundfold trie. -#: ../spell.c:7357 -msgid "Performing soundfolding..." -msgstr "" +#, c-format +#~ msgid "Wrong COMPOUNDSYLMAX value in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:7368 #, c-format -msgid "Number of words after soundfolding: %" -msgstr "" +#~ msgid "Wrong CHECKCOMPOUNDPATTERN value in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:7476 #, c-format -msgid "Total number of words: %d" -msgstr "" +#~ msgid "Different combining flag in continued affix block in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:7655 #, fuzzy, c-format -msgid "Writing suggestion file %s ..." -msgstr "Besig om viminfo lêer \"%s\" te stoor" +#~ msgid "Duplicate affix in %s line %d: %s" +#~ msgstr "E154: Duplikaat etiket \"%s\" in lêer %s/%s" -#: ../spell.c:7707 ../spell.c:7927 #, c-format -msgid "Estimated runtime memory use: %d bytes" -msgstr "" +#~ msgid "" +#~ "Affix also used for BAD/RARE/KEEPCASE/NEEDAFFIX/NEEDCOMPOUND/NOSUGGESTin %s " +#~ "line %d: %s" +#~ msgstr "" -#: ../spell.c:7820 -msgid "E751: Output file name must not have region name" -msgstr "" +#, c-format +#~ msgid "Expected Y or N in %s line %d: %s" +#~ msgstr "" + +#, c-format +#~ msgid "Broken condition in %s line %d: %s" +#~ msgstr "" + +#, c-format +#~ msgid "Expected REP(SAL) count in %s line %d" +#~ msgstr "" + +#, c-format +#~ msgid "Expected MAP count in %s line %d" +#~ msgstr "" + +#, c-format +#~ msgid "Duplicate character in MAP in %s line %d" +#~ msgstr "" + +#, c-format +#~ msgid "Unrecognized or duplicate item in %s line %d: %s" +#~ msgstr "" + +#, c-format +#~ msgid "Missing FOL/LOW/UPP line in %s" +#~ msgstr "" + +#~ msgid "COMPOUNDSYLMAX used without SYLLABLE" +#~ msgstr "" -#: ../spell.c:7822 #, fuzzy -msgid "E754: Only up to 8 regions supported" -msgstr "E519: Opsie is nie ondersteun nie" +#~ msgid "Too many postponed prefixes" +#~ msgstr "Te veel redigeer-parameters" + +#, fuzzy +#~ msgid "Too many compound flags" +#~ msgstr "Te veel redigeer-parameters" + +#~ msgid "Too many postponed prefixes and/or compound flags" +#~ msgstr "" + +#, c-format +#~ msgid "Missing SOFO%s line in %s" +#~ msgstr "" + +#, c-format +#~ msgid "Both SAL and SOFO lines in %s" +#~ msgstr "" + +#, c-format +#~ msgid "Flag is not a number in %s line %d: %s" +#~ msgstr "" + +#, c-format +#~ msgid "Illegal flag in %s line %d: %s" +#~ msgstr "" + +#, c-format +#~ msgid "%s value differs from what is used in another .aff file" +#~ msgstr "" -#: ../spell.c:7846 #, fuzzy, c-format -msgid "E755: Invalid region in %s" -msgstr "E15: Ongeldige uitdrukking: %s" +#~ msgid "Reading dictionary file %s ..." +#~ msgstr "Deursoek woordeboek: %s" -#: ../spell.c:7907 -msgid "Warning: both compounding and NOBREAK specified" -msgstr "" +#, c-format +#~ msgid "E760: No word count in %s" +#~ msgstr "" + +#, c-format +#~ msgid "line %6d, word %6d - %s" +#~ msgstr "" -#: ../spell.c:7920 #, fuzzy, c-format -msgid "Writing spell file %s ..." -msgstr "Besig om viminfo lêer \"%s\" te stoor" +#~ msgid "Duplicate word in %s line %d: %s" +#~ msgstr "Patroon gevind in elke reël: %s" -#: ../spell.c:7925 -msgid "Done!" -msgstr "" +#, c-format +#~ msgid "First duplicate word in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:8034 #, c-format -msgid "E765: 'spellfile' does not have % entries" -msgstr "" +#~ msgid "%d duplicate word(s) in %s" +#~ msgstr "" -#: ../spell.c:8074 #, c-format -msgid "Word '%.*s' removed from %s" -msgstr "" +#~ msgid "Ignored %d word(s) with non-ASCII characters in %s" +#~ msgstr "" + +#, fuzzy, c-format +#~ msgid "Reading word file %s ..." +#~ msgstr "Lees nou vanaf stdin... " -#: ../spell.c:8117 #, c-format -msgid "Word '%.*s' added to %s" -msgstr "" +#~ msgid "Duplicate /encoding= line ignored in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:8381 -msgid "E763: Word characters differ between spell files" -msgstr "" +#, c-format +#~ msgid "/encoding= line after word ignored in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:8684 -msgid "Sorry, no suggestions" -msgstr "" +#, c-format +#~ msgid "Duplicate /regions= line ignored in %s line %d: %s" +#~ msgstr "" + +#, c-format +#~ msgid "Too many regions in %s line %d: %s" +#~ msgstr "" + +#, c-format +#~ msgid "/ line ignored in %s line %d: %s" +#~ msgstr "" -#: ../spell.c:8687 #, fuzzy, c-format -msgid "Sorry, only % suggestions" -msgstr " op % reëls" +#~ msgid "Invalid region nr in %s line %d: %s" +#~ msgstr "E573: Ongeldige bediener-id gebruik: %s" + +#, c-format +#~ msgid "Unrecognized flags in %s line %d: %s" +#~ msgstr "" + +#, c-format +#~ msgid "Ignored %d words with non-ASCII characters" +#~ msgstr "" + +#, c-format +#~ msgid "Compressed %d of %d nodes; %d (%d%%) remaining" +#~ msgstr "" + +#~ msgid "Reading back spell file..." +#~ msgstr "" + +#. Go through the trie of good words, soundfold each word and add it to +#. the soundfold trie. +#~ msgid "Performing soundfolding..." +#~ msgstr "" + +#, c-format +#~ msgid "Number of words after soundfolding: %" +#~ msgstr "" + +#, c-format +#~ msgid "Total number of words: %d" +#~ msgstr "" -#. for when 'cmdheight' > 1 -#. avoid more prompt -#: ../spell.c:8704 #, fuzzy, c-format -msgid "Change \"%.*s\" to:" -msgstr "Stoor veranderinge na \"%.*s\"?" +#~ msgid "Writing suggestion file %s ..." +#~ msgstr "Besig om viminfo lêer \"%s\" te stoor" -#: ../spell.c:8737 #, c-format -msgid " < \"%.*s\"" -msgstr "" +#~ msgid "Estimated runtime memory use: %d bytes" +#~ msgstr "" + +#~ msgid "E751: Output file name must not have region name" +#~ msgstr "" -#: ../spell.c:8882 #, fuzzy -msgid "E752: No previous spell replacement" -msgstr "E35: Geen vorige patroon nie" +#~ msgid "E754: Only up to 8 regions supported" +#~ msgstr "E519: Opsie is nie ondersteun nie" -#: ../spell.c:8925 #, fuzzy, c-format -msgid "E753: Not found: %s" -msgstr "E334: Kieslys nie gevind nie: %s" +#~ msgid "E755: Invalid region in %s" +#~ msgstr "E15: Ongeldige uitdrukking: %s" + +#~ msgid "Warning: both compounding and NOBREAK specified" +#~ msgstr "" -#: ../spell.c:9276 #, fuzzy, c-format -msgid "E778: This does not look like a .sug file: %s" -msgstr "E307: %s lyk nie soos 'n Vim ruillêer nie" +#~ msgid "Writing spell file %s ..." +#~ msgstr "Besig om viminfo lêer \"%s\" te stoor" + +#~ msgid "Done!" +#~ msgstr "" -#: ../spell.c:9282 #, c-format -msgid "E779: Old .sug file, needs to be updated: %s" -msgstr "" +#~ msgid "E765: 'spellfile' does not have % entries" +#~ msgstr "" -#: ../spell.c:9286 #, c-format -msgid "E780: .sug file is for newer version of Vim: %s" -msgstr "" +#~ msgid "Word '%.*s' removed from %s" +#~ msgstr "" -#: ../spell.c:9295 #, c-format -msgid "E781: .sug file doesn't match .spl file: %s" -msgstr "" +#~ msgid "Word '%.*s' added to %s" +#~ msgstr "" -#: ../spell.c:9305 -#, fuzzy, c-format -msgid "E782: error while reading .sug file: %s" -msgstr "E47: Fout tydens lees van 'errorfile'" +#~ msgid "E763: Word characters differ between spell files" +#~ msgstr "" #. This should have been checked when generating the .spl #. file. -#: ../spell.c:11575 -msgid "E783: duplicate char in MAP entry" -msgstr "" +#~ msgid "E783: duplicate char in MAP entry" +#~ msgstr "" + +#, fuzzy +#~ msgid "E766: Insufficient arguments for printf()" +#~ msgstr "E116: Ongeldige parameters vir funksie %s" + +#~ msgid "E807: Expected Float argument for printf()" +#~ msgstr "" + +#, fuzzy +#~ msgid "E767: Too many arguments to printf()" +#~ msgstr "E118: Te veel parameters vir funksie: %s" -#: ../syntax.c:266 msgid "No Syntax items defined for this buffer" msgstr "Geen Sintaks-items gedefinieer vir hierdie buffer nie" -#: ../syntax.c:3083 ../syntax.c:3104 ../syntax.c:3127 #, c-format msgid "E390: Illegal argument: %s" msgstr "E390: Ongeldige parameter: %s" -#: ../syntax.c:3299 +#~ msgid "syntax iskeyword " +#~ msgstr "" + #, c-format msgid "E391: No such syntax cluster: %s" msgstr "E391: Geen sodanige sintakskluster nie: %s" -#: ../syntax.c:3433 msgid "syncing on C-style comments" msgstr "sinchroniseer met C-styl kommentaar" -#: ../syntax.c:3439 msgid "no syncing" msgstr "geen sinchronisering" -#: ../syntax.c:3441 msgid "syncing starts " msgstr "sinchronisasie begin " -#: ../syntax.c:3443 ../syntax.c:3506 msgid " lines before top line" msgstr " reëls voor boonste lyn" -#: ../syntax.c:3448 msgid "" "\n" "--- Syntax sync items ---" @@ -5762,7 +5156,6 @@ msgstr "" "\n" "--- Sintaks sync items ---" -#: ../syntax.c:3452 msgid "" "\n" "syncing on items" @@ -5770,7 +5163,6 @@ msgstr "" "\n" "sinchronisering met items" -#: ../syntax.c:3457 msgid "" "\n" "--- Syntax items ---" @@ -5778,275 +5170,216 @@ msgstr "" "\n" "--- Sintaks items ---" -#: ../syntax.c:3475 #, c-format msgid "E392: No such syntax cluster: %s" msgstr "E392: Geen sodanige sintakskluster nie: %s" -#: ../syntax.c:3497 msgid "minimal " msgstr "minimaal " -#: ../syntax.c:3503 msgid "maximal " msgstr "maksimaal " -#: ../syntax.c:3513 msgid "; match " msgstr "; treffer " -#: ../syntax.c:3515 msgid " line breaks" msgstr " reël breuke" -#: ../syntax.c:4076 msgid "E395: contains argument not accepted here" msgstr "E395: bevat parameters nie hier aanvaar nie" -#: ../syntax.c:4096 #, fuzzy -msgid "E844: invalid cchar value" -msgstr "E474: Ongeldige parameter" +#~ msgid "E844: invalid cchar value" +#~ msgstr "E474: Ongeldige parameter" -#: ../syntax.c:4107 msgid "E393: group[t]here not accepted here" msgstr "E393: 'group[t]here' nie hier aanvaar nie" -#: ../syntax.c:4126 #, c-format msgid "E394: Didn't find region item for %s" msgstr "E394: Kon nie omgewingsitem vind vir %s nie" -#: ../syntax.c:4188 msgid "E397: Filename required" msgstr "E397: Lêernaam benodig" -#: ../syntax.c:4221 #, fuzzy -msgid "E847: Too many syntax includes" -msgstr "E77: Te veel lêername" +#~ msgid "E847: Too many syntax includes" +#~ msgstr "E77: Te veel lêername" -#: ../syntax.c:4303 #, fuzzy, c-format -msgid "E789: Missing ']': %s" -msgstr "E398: Ontbrekende '=': %s" +#~ msgid "E789: Missing ']': %s" +#~ msgstr "E398: Ontbrekende '=': %s" + +#, fuzzy, c-format +#~ msgid "E890: trailing char after ']': %s]%s" +#~ msgstr "E488: Oorbodige karakters" -#: ../syntax.c:4531 #, c-format msgid "E398: Missing '=': %s" msgstr "E398: Ontbrekende '=': %s" -#: ../syntax.c:4666 #, c-format msgid "E399: Not enough arguments: syntax region %s" msgstr "E399: Nie genoeg parameters nie: sintaksomgewing %s" -#: ../syntax.c:4870 #, fuzzy -msgid "E848: Too many syntax clusters" -msgstr "E391: Geen sodanige sintakskluster nie: %s" +#~ msgid "E848: Too many syntax clusters" +#~ msgstr "E391: Geen sodanige sintakskluster nie: %s" -#: ../syntax.c:4954 msgid "E400: No cluster specified" msgstr "E400: Geen kluster gespesifiseer nie" #. end delimiter not found -#: ../syntax.c:4986 #, c-format msgid "E401: Pattern delimiter not found: %s" msgstr "E401: Patroonbegrenser nie gevind nie: %s" -#: ../syntax.c:5049 #, c-format msgid "E402: Garbage after pattern: %s" msgstr "E402: Gemors na patroon: %s" -#: ../syntax.c:5120 msgid "E403: syntax sync: line continuations pattern specified twice" msgstr "E403: sintaks sync: reëlvoortgaanpatroon twee keer gespesifiseer" -#: ../syntax.c:5169 #, c-format msgid "E404: Illegal arguments: %s" msgstr "E404: Ongeldige parameters: %s" -#: ../syntax.c:5217 #, c-format msgid "E405: Missing equal sign: %s" msgstr "E405: Ontbrekende gelykaanteken: %s" -#: ../syntax.c:5222 #, c-format msgid "E406: Empty argument: %s" msgstr "E406: Leë parameter: %s" -#: ../syntax.c:5240 #, c-format msgid "E407: %s not allowed here" msgstr "E407: %s nie toegelaat hier nie" -#: ../syntax.c:5246 #, c-format msgid "E408: %s must be first in contains list" msgstr "E408: %s moet vóór in 'contains' lys wees" -#: ../syntax.c:5304 #, c-format msgid "E409: Unknown group name: %s" msgstr "E409: Onbekende groepnaam: %s" -#: ../syntax.c:5512 #, c-format msgid "E410: Invalid :syntax subcommand: %s" msgstr "E410: Ongeldige :syntax subbevel %s" -#: ../syntax.c:5854 -msgid "" -" TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN" -msgstr "" +#~ msgid "" +#~ " TOTAL COUNT MATCH SLOWEST AVERAGE NAME PATTERN" +#~ msgstr "" -#: ../syntax.c:6146 msgid "E679: recursive loop loading syncolor.vim" msgstr "E679: rekursiewe lus gedurende laai van syncolor.vim" -#: ../syntax.c:6256 #, c-format msgid "E411: highlight group not found: %s" msgstr "E411: uitliggroep nie gevind nie: %s" -#: ../syntax.c:6278 #, c-format msgid "E412: Not enough arguments: \":highlight link %s\"" msgstr "E412: Te min parameters: \":highlight link %s\"" -#: ../syntax.c:6284 #, c-format msgid "E413: Too many arguments: \":highlight link %s\"" msgstr "E413: Te veel parameters: \":highlight link %s\"" -#: ../syntax.c:6302 msgid "E414: group has settings, highlight link ignored" msgstr "" "E414: groep het instellings, uitligskakel ('highlight link') geïgnoreer" -#: ../syntax.c:6367 #, c-format msgid "E415: unexpected equal sign: %s" msgstr "E415: onverwagte gelykaanteken: %s" -#: ../syntax.c:6395 #, c-format msgid "E416: missing equal sign: %s" msgstr "E416: ontbrekende gelykaanteken: %s" -#: ../syntax.c:6418 #, c-format msgid "E417: missing argument: %s" msgstr "E417: ontbrekende parameter: %s" -#: ../syntax.c:6446 #, c-format msgid "E418: Illegal value: %s" msgstr "E418: Ongeldige waarde: %s" -#: ../syntax.c:6496 msgid "E419: FG color unknown" msgstr "E419: FG kleur onbekend" -#: ../syntax.c:6504 msgid "E420: BG color unknown" msgstr "E420: BG kleur onbekend" -#: ../syntax.c:6564 #, c-format msgid "E421: Color name or number not recognized: %s" msgstr "E421: Kleurnaam of -nommer nie herken nie: %s" -#: ../syntax.c:6714 -#, c-format -msgid "E422: terminal code too long: %s" -msgstr "E422: terminaalkode te lank: %s" - -#: ../syntax.c:6753 #, c-format msgid "E423: Illegal argument: %s" msgstr "E423: Ongeldige parameter: %s" -#: ../syntax.c:6925 msgid "E424: Too many different highlighting attributes in use" msgstr "E424: Te veel verskillende uitlig-eienskappe in gebruik" -#: ../syntax.c:7427 msgid "E669: Unprintable character in group name" msgstr "E669: Onvertoonbare karakter in groepnaam" -#: ../syntax.c:7434 msgid "W18: Invalid character in group name" msgstr "W18: Ongeldige karakter groepnaam" -#: ../syntax.c:7448 -msgid "E849: Too many highlight and syntax groups" -msgstr "" +#~ msgid "E849: Too many highlight and syntax groups" +#~ msgstr "" -#: ../tag.c:104 msgid "E555: at bottom of tag stack" msgstr "E555: onderaan etiketstapel" -#: ../tag.c:105 msgid "E556: at top of tag stack" msgstr "E556: bo-aan etiketstapel" -#: ../tag.c:380 msgid "E425: Cannot go before first matching tag" msgstr "E425: Kan nie vóór eerste etiket-treffer gaan nie" -#: ../tag.c:504 #, c-format msgid "E426: tag not found: %s" msgstr "E426: etiket nie gevind nie: %s" -#: ../tag.c:528 msgid " # pri kind tag" msgstr " # pri tipe etiket" -#: ../tag.c:531 msgid "file\n" msgstr "lêer\n" -#: ../tag.c:829 msgid "E427: There is only one matching tag" msgstr "E427: Daar is slegs een etiket-treffer" -#: ../tag.c:831 msgid "E428: Cannot go beyond last matching tag" msgstr "E428: Kan nie verby laaste etiket-treffer gaan nie" -#: ../tag.c:850 #, c-format msgid "File \"%s\" does not exist" msgstr "Lêer \"%s\" bestaan nie" #. Give an indication of the number of matching tags -#: ../tag.c:859 #, c-format msgid "tag %d of %d%s" msgstr "etiket %d van %d%s" -#: ../tag.c:862 msgid " or more" msgstr " of meer" -#: ../tag.c:864 msgid " Using tag with different case!" msgstr " Gaan etiket met ander kas gebruik!" -#: ../tag.c:909 #, c-format msgid "E429: File \"%s\" does not exist" msgstr "E429: Lêer \"%s\" bestaan nie" #. Highlight title -#: ../tag.c:960 msgid "" "\n" " # TO tag FROM line in file/text" @@ -6054,275 +5387,173 @@ msgstr "" "\n" " # NA etiket VAN reël in lêer/teks" -#: ../tag.c:1303 #, c-format msgid "Searching tags file %s" msgstr "Deursoek etiketlêer %s" -#: ../tag.c:1545 -msgid "Ignoring long line in tags file" -msgstr "" +#~ msgid "Ignoring long line in tags file" +#~ msgstr "" -#: ../tag.c:1915 #, c-format msgid "E431: Format error in tags file \"%s\"" msgstr "E431: Formaatfout in etiketlêer \"%s\"" -#: ../tag.c:1917 #, c-format msgid "Before byte %" msgstr "Voor greep %" -#: ../tag.c:1929 #, c-format msgid "E432: Tags file not sorted: %s" msgstr "E432: Etiketlêer ongesorteer: %s" #. never opened any tags file -#: ../tag.c:1960 msgid "E433: No tags file" msgstr "E433: Geen etiketlêer nie" -#: ../tag.c:2536 msgid "E434: Can't find tag pattern" msgstr "E434: Kan nie etiketpatroon vind nie" -#: ../tag.c:2544 msgid "E435: Couldn't find tag, just guessing!" msgstr "E435: Kon nie etiket vind nie, ek raai maar!" -#: ../tag.c:2797 #, fuzzy, c-format -msgid "Duplicate field name: %s" -msgstr "gelaaide fontnaam: %s" - -#: ../term.c:1442 -msgid "' not known. Available builtin terminals are:" -msgstr "' onbekend. Beskikbare ingeboude terminale is:" - -#: ../term.c:1463 -msgid "defaulting to '" -msgstr "gebruik verstek '" - -#: ../term.c:1731 -msgid "E557: Cannot open termcap file" -msgstr "E557: Kan nie 'termcap'-lêer oopmaak nie" - -#: ../term.c:1735 -msgid "E558: Terminal entry not found in terminfo" -msgstr "E558: Terminaalinskrywing nie in 'terminfo' gevind nie" - -#: ../term.c:1737 -msgid "E559: Terminal entry not found in termcap" -msgstr "E559: Terminaalinskrywing nie in 'termcap' gevind nie" - -#: ../term.c:1878 -#, c-format -msgid "E436: No \"%s\" entry in termcap" -msgstr "E436: Geen \"%s\" inskrywing in termcap nie" - -#: ../term.c:2249 -msgid "E437: terminal capability \"cm\" required" -msgstr "E437: terminaalvermoë \"cm\" vereis" - -#. Highlight title -#: ../term.c:4376 -msgid "" -"\n" -"--- Terminal keys ---" -msgstr "" -"\n" -"--- Terminaal sleutels ---" - -#: ../ui.c:481 -msgid "Vim: Error reading input, exiting...\n" -msgstr "Vim: Fout met lees van invoer, verlaat...\n" +#~ msgid "Duplicate field name: %s" +#~ msgstr "gelaaide fontnaam: %s" #. This happens when the FileChangedRO autocommand changes the #. * file in a way it becomes shorter. -#: ../undo.c:379 -msgid "E881: Line count changed unexpectedly" -msgstr "" +#~ msgid "E881: Line count changed unexpectedly" +#~ msgstr "" -#: ../undo.c:627 #, fuzzy, c-format -msgid "E828: Cannot open undo file for writing: %s" -msgstr "E212: Kan lêer nie oopmaak vir skryf nie" +#~ msgid "E828: Cannot open undo file for writing: %s" +#~ msgstr "E212: Kan lêer nie oopmaak vir skryf nie" + +#, fuzzy, c-format +#~ msgid "E5003: Unable to create directory \"%s\" for undo file: %s" +#~ msgstr "E346: Geen gids \"%s\" meer gevind in 'cdpath' nie" -#: ../undo.c:717 #, c-format -msgid "E825: Corrupted undo file (%s): %s" -msgstr "" +#~ msgid "E825: Corrupted undo file (%s): %s" +#~ msgstr "" -#: ../undo.c:1039 -msgid "Cannot write undo file in any directory in 'undodir'" -msgstr "" +#~ msgid "Cannot write undo file in any directory in 'undodir'" +#~ msgstr "" -#: ../undo.c:1074 #, c-format -msgid "Will not overwrite with undo file, cannot read: %s" -msgstr "" +#~ msgid "Will not overwrite with undo file, cannot read: %s" +#~ msgstr "" -#: ../undo.c:1092 #, c-format -msgid "Will not overwrite, this is not an undo file: %s" -msgstr "" +#~ msgid "Will not overwrite, this is not an undo file: %s" +#~ msgstr "" -#: ../undo.c:1108 -msgid "Skipping undo file write, nothing to undo" -msgstr "" +#~ msgid "Skipping undo file write, nothing to undo" +#~ msgstr "" -#: ../undo.c:1121 #, fuzzy, c-format -msgid "Writing undo file: %s" -msgstr "Besig om viminfo lêer \"%s\" te stoor" +#~ msgid "Writing undo file: %s" +#~ msgstr "Besig om viminfo lêer \"%s\" te stoor" -#: ../undo.c:1213 #, fuzzy, c-format -msgid "E829: write error in undo file: %s" -msgstr "E297: Skryffout in ruillêer" +#~ msgid "E829: write error in undo file: %s" +#~ msgstr "E297: Skryffout in ruillêer" -#: ../undo.c:1280 #, c-format -msgid "Not reading undo file, owner differs: %s" -msgstr "" +#~ msgid "Not reading undo file, owner differs: %s" +#~ msgstr "" -#: ../undo.c:1292 #, fuzzy, c-format -msgid "Reading undo file: %s" -msgstr "Besig om viminfo lêer \"%s\"%s%s%s te lees" +#~ msgid "Reading undo file: %s" +#~ msgstr "Besig om viminfo lêer \"%s\"%s%s%s te lees" -#: ../undo.c:1299 #, fuzzy, c-format -msgid "E822: Cannot open undo file for reading: %s" -msgstr "E195: Kan 'viminfo' lêer nie oopmaak om te lees nie" +#~ msgid "E822: Cannot open undo file for reading: %s" +#~ msgstr "E195: Kan 'viminfo' lêer nie oopmaak om te lees nie" -#: ../undo.c:1308 #, fuzzy, c-format -msgid "E823: Not an undo file: %s" -msgstr "E484: Kan nie lêer %s oopmaak nie" +#~ msgid "E823: Not an undo file: %s" +#~ msgstr "E484: Kan nie lêer %s oopmaak nie" -#: ../undo.c:1313 #, fuzzy, c-format -msgid "E824: Incompatible undo file: %s" -msgstr "E484: Kan nie lêer %s oopmaak nie" +#~ msgid "E824: Incompatible undo file: %s" +#~ msgstr "E484: Kan nie lêer %s oopmaak nie" -#: ../undo.c:1328 -msgid "File contents changed, cannot use undo info" -msgstr "" +#~ msgid "File contents changed, cannot use undo info" +#~ msgstr "" -#: ../undo.c:1497 #, fuzzy, c-format -msgid "Finished reading undo file %s" -msgstr "%s klaar uitgevoer" +#~ msgid "Finished reading undo file %s" +#~ msgstr "%s klaar uitgevoer" -#: ../undo.c:1586 ../undo.c:1812 -msgid "Already at oldest change" -msgstr "" +#~ msgid "Already at oldest change" +#~ msgstr "" -#: ../undo.c:1597 ../undo.c:1814 -msgid "Already at newest change" -msgstr "" +#~ msgid "Already at newest change" +#~ msgstr "" -#: ../undo.c:1806 #, fuzzy, c-format -msgid "E830: Undo number % not found" -msgstr "E92: buffer % kon nie gevind word nie" +#~ msgid "E830: Undo number % not found" +#~ msgstr "E92: buffer % kon nie gevind word nie" -#: ../undo.c:1979 msgid "E438: u_undo: line numbers wrong" msgstr "E438: u_undo: reëlnommers foutief" -#: ../undo.c:2183 #, fuzzy -msgid "more line" -msgstr "1 reël meer" +#~ msgid "more line" +#~ msgstr "1 reël meer" -#: ../undo.c:2185 #, fuzzy -msgid "more lines" -msgstr "1 reël meer" +#~ msgid "more lines" +#~ msgstr "1 reël meer" -#: ../undo.c:2187 #, fuzzy -msgid "line less" -msgstr "1 reël minder" +#~ msgid "line less" +#~ msgstr "1 reël minder" -#: ../undo.c:2189 #, fuzzy -msgid "fewer lines" -msgstr "% minder reëls" +#~ msgid "fewer lines" +#~ msgstr "% minder reëls" -#: ../undo.c:2193 #, fuzzy -msgid "change" -msgstr "1 verandering" +#~ msgid "change" +#~ msgstr "1 verandering" -#: ../undo.c:2195 #, fuzzy -msgid "changes" -msgstr "1 verandering" +#~ msgid "changes" +#~ msgstr "1 verandering" -#: ../undo.c:2225 #, fuzzy, c-format -msgid "% %s; %s #% %s" -msgstr "%R, %K" +#~ msgid "% %s; %s #% %s" +#~ msgstr "%R, %K" -#: ../undo.c:2228 -msgid "before" -msgstr "" +#~ msgid "after" +#~ msgstr "" -#: ../undo.c:2228 -msgid "after" -msgstr "" +#~ msgid "before" +#~ msgstr "" -#: ../undo.c:2325 #, fuzzy -msgid "Nothing to undo" -msgstr "Geen binding gevind nie" +#~ msgid "Nothing to undo" +#~ msgstr "Geen binding gevind nie" -#: ../undo.c:2330 -msgid "number changes when saved" -msgstr "" +#~ msgid "number changes when saved" +#~ msgstr "" -#: ../undo.c:2360 #, fuzzy, c-format -msgid "% seconds ago" -msgstr "% Kolomme; " +#~ msgid "% seconds ago" +#~ msgstr "% Kolomme; " -#: ../undo.c:2372 #, fuzzy -msgid "E790: undojoin is not allowed after undo" -msgstr "E407: %s nie toegelaat hier nie" +#~ msgid "E790: undojoin is not allowed after undo" +#~ msgstr "E407: %s nie toegelaat hier nie" -#: ../undo.c:2466 msgid "E439: undo list corrupt" msgstr "E439: herstellys korrup" -#: ../undo.c:2495 msgid "E440: undo line missing" msgstr "E440: herstelreël ontbreek" -#: ../version.c:600 -msgid "" -"\n" -"Included patches: " -msgstr "" -"\n" -"Ingeslote laslappies:" - -#: ../version.c:627 -#, fuzzy -msgid "" -"\n" -"Extra patches: " -msgstr "Eksterne subtreffers:\n" - -#: ../version.c:639 ../version.c:864 -msgid "Modified by " -msgstr "Gewysig deur " - -#: ../version.c:646 msgid "" "\n" "Compiled " @@ -6330,981 +5561,877 @@ msgstr "" "\n" "Gekompileer op " -#: ../version.c:649 msgid "by " msgstr "deur " -#: ../version.c:660 -msgid "" -"\n" -"Huge version " -msgstr "" -"\n" -"Enorme weergawe " - -#: ../version.c:661 -msgid "without GUI." -msgstr "sonder GUI." - -#: ../version.c:662 -msgid " Features included (+) or not (-):\n" -msgstr " Kenmerke in- (+) of uitgesluit (-):\n" +#~ msgid "" +#~ "\n" +#~ "\n" +#~ "Features: " +#~ msgstr "" -#: ../version.c:667 msgid " system vimrc file: \"" msgstr " stelsel vimrc-lêer: \"" -#: ../version.c:672 -msgid " user vimrc file: \"" -msgstr " gebruiker vimrc-lêer: \"" - -#: ../version.c:677 -msgid " 2nd user vimrc file: \"" -msgstr " 2de gebruiker vimrc-lêer \"" - -#: ../version.c:682 -msgid " 3rd user vimrc file: \"" -msgstr " 3de gebruiker vimrc-lêer \"" - -#: ../version.c:687 -msgid " user exrc file: \"" -msgstr " gebruiker exrc-lêer: \"" - -#: ../version.c:692 -msgid " 2nd user exrc file: \"" -msgstr " 2de gebruiker exrc-lêer: \"" - -#: ../version.c:699 msgid " fall-back for $VIM: \"" msgstr " bystand vir $VIM: \"" -#: ../version.c:705 msgid " f-b for $VIMRUNTIME: \"" msgstr " bystand vir $VIMRUNTIME: \"" -#: ../version.c:709 -msgid "Compilation: " -msgstr "Kompilering: " - -#: ../version.c:712 -msgid "Linking: " -msgstr "Koppeling: " +#, fuzzy +#~ msgid "Nvim is open source and freely distributable" +#~ msgstr "Vim is vryekode, en vrylik verspreibaar" -#: ../version.c:717 -msgid " DEBUG BUILD" -msgstr " ONTFOUTINGS-KOMPILERING" +#~ msgid "https://neovim.io/community" +#~ msgstr "" -#: ../version.c:767 -msgid "VIM - Vi IMproved" -msgstr "VIM - Vi Met skop" +#, fuzzy +#~ msgid "type :help nvim if you are new! " +#~ msgstr "tik :help uganda as jy hou van Vim " -# njj: :)) -#: ../version.c:769 -msgid "version " -msgstr "Weergawe " +#, fuzzy +#~ msgid "type :checkhealth to optimize Nvim" +#~ msgstr "Tik :quit om Vim te verlaat" -#: ../version.c:770 -msgid "by Bram Moolenaar et al." -msgstr "deur Bram Moolenaar et al." +msgid "type :q to exit " +msgstr "tik :q om program verlaat " -#: ../version.c:774 -msgid "Vim is open source and freely distributable" -msgstr "Vim is vryekode, en vrylik verspreibaar" +#, fuzzy +#~ msgid "type :help for help " +#~ msgstr "tik :q om program verlaat " -#: ../version.c:776 msgid "Help poor children in Uganda!" msgstr "Help arm kinders in Uganda!" -#: ../version.c:777 msgid "type :help iccf for information " msgstr "tik :help iccf vir meer inligting hieroor " -#: ../version.c:779 -msgid "type :q to exit " -msgstr "tik :q om program verlaat " - -#: ../version.c:780 -msgid "type :help or for on-line help" -msgstr "tik :help of vir aanlyn hulp " - -#: ../version.c:781 -msgid "type :help version7 for version info" -msgstr "tik :help version7 vir weergawe-inligting" - -#: ../version.c:784 -msgid "Running in Vi compatible mode" -msgstr "Voer tans uit in Vi-versoenbare modus" - -#: ../version.c:785 -msgid "type :set nocp for Vim defaults" -msgstr "tik :set nocp vir Vim verstekwaardes " - -#: ../version.c:786 -msgid "type :help cp-default for info on this" -msgstr "tik :help cp-default vir meer inligting hieroor" - -#: ../version.c:827 msgid "Sponsor Vim development!" msgstr "Borg Vim ontwikkeling!" -#: ../version.c:828 msgid "Become a registered Vim user!" msgstr "Word 'n geregistreerde Vim gebruiker!" -#: ../version.c:831 msgid "type :help sponsor for information " msgstr "tik :help sponsor vir meer inligting hieroor " -#: ../version.c:832 msgid "type :help register for information " msgstr "tik :help register vir meer inligting hieroor " -#: ../version.c:834 msgid "menu Help->Sponsor/Register for information " msgstr "menu Hulp->Borg/Registreer vir meer inligting" -#: ../window.c:119 msgid "Already only one window" msgstr "Daar is alreeds slegs een venster" -#: ../window.c:224 msgid "E441: There is no preview window" msgstr "E441: Daar is nie 'n voorskou-venster nie" -#: ../window.c:559 msgid "E442: Can't split topleft and botright at the same time" msgstr "E442: Kan nie bo-links en onder-regs terselfdertyd verdeel nie" -#: ../window.c:1228 msgid "E443: Cannot rotate when another window is split" msgstr "E443: Kan nie roteer terwyl 'n ander venster verdeel is nie" -#: ../window.c:1803 msgid "E444: Cannot close last window" msgstr "E444: Kan nie laaste venster toemaak nie" -#: ../window.c:1810 #, fuzzy -msgid "E813: Cannot close autocmd window" -msgstr "E444: Kan nie laaste venster toemaak nie" +#~ msgid "E813: Cannot close autocmd window" +#~ msgstr "E444: Kan nie laaste venster toemaak nie" -#: ../window.c:1814 #, fuzzy -msgid "E814: Cannot close window, only autocmd window would remain" -msgstr "E444: Kan nie laaste venster toemaak nie" +#~ msgid "E814: Cannot close window, only autocmd window would remain" +#~ msgstr "E444: Kan nie laaste venster toemaak nie" -#: ../window.c:2717 msgid "E445: Other window contains changes" msgstr "E445: Die ander venster bevat veranderinge" -#: ../window.c:4805 msgid "E446: No file name under cursor" msgstr "E446: Geen lêernaam onder loper" -#~ msgid "[Error List]" -#~ msgstr "[Foutlys]" +#, c-format +#~ msgid "E799: Invalid ID: % (must be greater than or equal to 1)" +#~ msgstr "" -#~ msgid "[No File]" -#~ msgstr "[Geen lêer]" +#, fuzzy, c-format +#~ msgid "E801: ID already taken: %" +#~ msgstr "E157: Ongeldige teken ID: %" -#~ msgid "Patch file" -#~ msgstr "Laslap lêer" - -#~ msgid "E106: Unknown variable: \"%s\"" -#~ msgstr "E106: Onbekende veranderlike: \"%s\"" +#, fuzzy +#~ msgid "List or number required" +#~ msgstr "E471: Parameter benodig" -#~ msgid "" -#~ "&OK\n" -#~ "&Cancel" +#, c-format +#~ msgid "E802: Invalid ID: % (must be greater than or equal to 1)" #~ msgstr "" -#~ "&OK\n" -#~ "&Kanselleer" -#~ msgid "E240: No connection to Vim server" -#~ msgstr "E240: Geen verbinding met Vim bediener" +#, fuzzy, c-format +#~ msgid "E803: ID not found: %" +#~ msgstr "E320: Kan nie reël % vind nie" -#~ msgid "E277: Unable to read a server reply" -#~ msgstr "E277: Kon bediener-terugvoer nie lees nie" +#~ msgid "WARNING: tag command changed a buffer!!!" +#~ msgstr "WAARSKUWING: etiketbevel het buffer verander!!!" -#~ msgid "E241: Unable to send to %s" -#~ msgstr "E241: Kan nie na %s stuur nie" +#~ msgid "Leave: %s" +#~ msgstr "Verlaat: %s" -#~ msgid "E130: Undefined function: %s" -#~ msgstr "E130: Ongedefinieerde funksie: %s" +#~ msgid "File name '%s' is valid" +#~ msgstr "lêernaam '%s is ongeldig" -#~ msgid "Save As" -#~ msgstr "Stoor As" +#~ msgid "Not a proper file name: '%s'" +#~ msgstr "Nie 'n geldige lêernaam nie: '%s'" -#~ msgid "Source Vim script" -#~ msgstr "Voer Vim skrip uit" +#~ msgid "Change dir debugging enabled." +#~ msgstr "Verandergids ontfouting in staat gestel" -#~ msgid "Edit File" -#~ msgstr "Verander lêer" +#~ msgid "Warning: %s option changed from modeline" +#~ msgstr "Waarskuwing: %s opsie verander vanaf moduslyn" -#~ msgid " (NOT FOUND)" -#~ msgstr " (NIE GEVIND NIE)" +#~ msgid "Security error: shell command output is a symbolic link" +#~ msgstr "Sekuriteitsfout: Dop-bevel afvoer is 'n simboliese skakel" -#~ msgid "Edit File in new window" -#~ msgstr "Bewerk lêer in nuwe venster" +#~ msgid "No fold at this line" +#~ msgstr "Geen vou by hierdie reël nie" -#~ msgid "Append File" -#~ msgstr "Las aan by lêer" +#~ msgid "Fold must be at least two lines" +#~ msgstr "'n Vou moet ten minste 2 reëls wees" -#~ msgid "Window position: X %d, Y %d" -#~ msgstr "Vensterposisie: X %d, Y %d" +#~ msgid "Security error: filter input is a symbolic link: %s" +#~ msgstr "Sekuriteitsfout: filter invoer is 'n simboliese skakel" -#~ msgid "Save Redirection" -#~ msgstr "Stoor Herversturing" +#~ msgid "Security error: 'charconvert' output is a symbolic link" +#~ msgstr "Sekuriteitsfout: 'charconvert' afvoer is 'n simboliese skakel" -#~ msgid "Save View" -#~ msgstr "Stoor Oorsig" +#~ msgid "Security error: filter output is a symbolic link: %s" +#~ msgstr "Sekuriteitsfout: filter afvoer is 'n simboliese skakel" -#~ msgid "Save Session" -#~ msgstr "Stoor Sessie" +#~ msgid "makeef option not set" +#~ msgstr "'makeef' opsie nie aan nie" -#~ msgid "Save Setup" -#~ msgstr "Stoor konfigurasie" +#~ msgid "line ~%: %s" +#~ msgstr "reël ~%: %s" -#~ msgid "E196: No digraphs in this version" -#~ msgstr "E196: Geen digrawe in hierdie weergawe nie" +#~ msgid "Security error: new viminfo file is a symbolic link" +#~ msgstr "Sekuriteitsfout: nuwe viminfo lêer is a simboliese skakel" -#~ msgid "[NL found]" -#~ msgstr "[NL gevind]" +#~ msgid " PPC has a much better architecture. " +#~ msgstr " PPC het 'n veel beter argitektuur. " -#~ msgid "[crypted]" -#~ msgstr "[gekodeer]" +#~ msgid " WARNING: Intel CPU detected. " +#~ msgstr " WAARSKUWING: Intel SVE bespeur. " -#~ msgid "[CONVERSION ERROR]" -#~ msgstr "[OMSETTINGSFOUT]" +#~ msgid "Unexpected magic character; check META." +#~ msgstr "Onverwagte toorkarakter; kyk na META." -#~ msgid "NetBeans disallows writes of unmodified buffers" -#~ msgstr "NetBeans laat nie skryf toe van onveranderde buffers nie" +#~ msgid "\\* follows nothing" +#~ msgstr "\\* volg niks" -#~ msgid "Partial writes disallowed for NetBeans buffers" -#~ msgstr "Gedeeltelike skryf word nie toegelaat vir NetBeans buffers nie" +#~ msgid "\\{ follows nothing" +#~ msgstr "\\{ volg niks" -#~ msgid "E460: The resource fork would be lost (add ! to override)" -#~ msgstr "E460: Die hulpbronvurk sal verlore gaan (gebruik ! om te dwing)" +#~ msgid "\\@ follows nothing" +#~ msgstr "\\@ volg niks" -#~ msgid " " -#~ msgstr " " +#~ msgid "\\+ follows nothing" +#~ msgstr "\\+ volg niks" -#~ msgid "E616: vim_SelFile: can't get font %s" -#~ msgstr "E616: 'vim_SelFile': kan font %s nie kry nie" +#~ msgid "\\= follows nothing" +#~ msgstr "\\= volg niks" -#~ msgid "E614: vim_SelFile: can't return to current directory" -#~ msgstr "E614: 'vim_SelFile': Kan nie terugkeer na huidige gids nie" +#~ msgid "Nested *, \\=, \\+, \\! or \\{" +#~ msgstr "Geneste *, \\=, \\+, \\! of \\{" -#~ msgid "Pathname:" -#~ msgstr "Gidsnaam:" +#~ msgid "Unmatched \\(" +#~ msgstr "Onpaar \\(" -#~ msgid "E615: vim_SelFile: can't get current directory" -#~ msgstr "E615: vim_SelFile: Kan nie huidige gids verkry nie" +#~ msgid "Too many \\(" +#~ msgstr "Te veel \\(" -#~ msgid "OK" -#~ msgstr "OK" +#~ msgid "Ambiguous mapping, conflicts with \"%s\"" +#~ msgstr "Dubbelsinnige binding, bots met \"%s\"" -#~ msgid "Cancel" -#~ msgstr "Kanselleer" +#~ msgid "Ambiguous mapping" +#~ msgstr "Dubbelsinnige binding" -#~ msgid "Vim dialog" -#~ msgstr "Vim dialooghokkie" +#~ msgid "Command too long" +#~ msgstr "Bevel te lank" -#~ msgid "Scrollbar Widget: Could not get geometry of thumb pixmap." -#~ msgstr "" -#~ "Rolstaafelement: Kon nie pikselmatriks-duimnael se geometrie kry nie" +#~ msgid "GUI is not running" +#~ msgstr "GUI voer nie uit nie" -#~ msgid "E232: Cannot create BalloonEval with both message and callback" -#~ msgstr "E232: Kan nie BalloonEval skep met beide boodskap en terugroep nie" +#~ msgid "Cannot clear all highlight groups" +#~ msgstr "Kan nie alle uitliggroepe leegmaak nie" -#~ msgid "E229: Cannot start the GUI" -#~ msgstr "E229: Kan nie die GUI begin nie" +#~ msgid "Library call failed" +#~ msgstr "Biblioteekfunksieroep het gefaal" -#~ msgid "E230: Cannot read from \"%s\"" -#~ msgstr "E230: Kan nie lees uit \"%s\" nie" +#~ msgid "some" +#~ msgstr "sommige" -#~ msgid "E665: Cannot start GUI, no valid font found" -#~ msgstr "E665: Kan nie GUI begin nie, geen geldige font gevind nie" +#~ msgid "deadly signal" +#~ msgstr "dodelike sein" -#~ msgid "E231: 'guifontwide' invalid" -#~ msgstr "E231: 'guifontwide' ongeldig" +#~ msgid "Unsupported screen mode" +#~ msgstr "Ongesteunde skermmodus" -#~ msgid "E599: Value of 'imactivatekey' is invalid" -#~ msgstr "E599: Waarde van 'imactivatekey' is ongeldig" +#~ msgid "PC (16 bits Vim)" +#~ msgstr "PC (16 bisse Vim)" -#~ msgid "E254: Cannot allocate color %s" -#~ msgstr "E254: Kan nie kleur %s toeken nie" +#~ msgid "PC (32 bits Vim)" +#~ msgstr "PC (32 bisse Vim)" -#~ msgid "Vim dialog..." -#~ msgstr "Vim dialooghokkie..." +#~ msgid "Out of memory" +#~ msgstr "Geheue op" -#~ msgid "Input _Methods" -#~ msgstr "Invoer _Metodes" +#~ msgid "Sorry, deleting a menu is not possible in the Athena version" +#~ msgstr "" +#~ "Jammer, in die Athena weergawe is dit onmoontlik om 'n kieslys te skrap" -#~ msgid "VIM - Search and Replace..." -#~ msgstr "VIM - Soek en Vervang..." +#~ msgid "Can't create input context." +#~ msgstr "Kan nie invoerkonteks skep nie." -#~ msgid "VIM - Search..." -#~ msgstr "VIM - Soek..." +#~ msgid "Unrecognized sniff request [%s]" +#~ msgstr "Onbekende sniff versoek [%s]" -#~ msgid "Find what:" -#~ msgstr "Soek na:" +#~ msgid "-- SNiFF+ commands --" +#~ msgstr "-- SNiFF+ bevele --" -#~ msgid "Replace with:" -#~ msgstr "Vervang met:" +#~ msgid "Retrieve next symbol" +#~ msgstr "Kry volgende simbool" -#~ msgid "Match whole word only" -#~ msgstr "Tref slegs presiese woord" +#~ msgid "cs_add_common: alloc fail #4" +#~ msgstr "'cs_add_common': toeken onsuksesvol #4" -#~ msgid "Match case" -#~ msgstr "Tref kas" +#~ msgid "cs_add_common: alloc fail #3" +#~ msgstr "'cs_add_common': toeken onsuksesvol #3" -#~ msgid "Direction" -#~ msgstr "Rigting" +#~ msgid "cs_add_common: alloc fail #2" +#~ msgstr "'cs_add_common': toeken onsuksesvol #2" -#~ msgid "Up" -#~ msgstr "Op" +#~ msgid "cs_add_common: alloc fail #1" +#~ msgstr "'cs_add_common': toeken onsuksesvol #1" -#~ msgid "Down" -#~ msgstr "Af" +#~ msgid "automata ERROR: internal" +#~ msgstr "automata FOUT: intern" -#~ msgid "Find Next" -#~ msgstr "Vind volgende" +#~ msgid "Your language Font missing" +#~ msgstr "Jou taal Font ontbreek" -#~ msgid "Replace" -#~ msgstr "Vervang" +#~ msgid "fontset name: %s" +#~ msgstr "fontstel naam: %s" -#~ msgid "Replace All" -#~ msgstr "Vervang alles" +#~ msgid " sh : export LANG=ko" +#~ msgstr " sh: export LANG=af" -#~ msgid "Vim: Received \"die\" request from session manager\n" -#~ msgstr "Vim: Het die \"die\" opdrag ontvang van sessiebestuurder\n" +#~ msgid " csh: setenv LANG ko" +#~ msgstr " csh: setenv LANG af" -#~ msgid "Vim: Main window unexpectedly destroyed\n" -#~ msgstr "Vim: Hoofvenster onverwags verwoes\n" +#~ msgid "For korean:" +#~ msgstr "Vir Afrikaans:" -#~ msgid "Font Selection" -#~ msgstr "Fontkeuse" +#~ msgid "locale is not set correctly" +#~ msgstr "lokaal is nie korrek gestel nie" -#~ msgid "Used CUT_BUFFER0 instead of empty selection" -#~ msgstr "'CUT_BUFFER0' is gebruik in plaas van leë seleksie" +#~ msgid "Error: During loading fontset %s" +#~ msgstr "Fout: Gedurende die laai van fontstel %s" -#~ msgid "Filter" -#~ msgstr "Filter" +#~ msgid "Topic:" +#~ msgstr "Onderwerp:" -#~ msgid "Directories" -#~ msgstr "Gidse" +#~ msgid "VIM - Help on..." +#~ msgstr "VIM - Hulp met.." -#~ msgid "Help" -#~ msgstr "Hulp" +#~ msgid "Cannot use :normal from event handler" +#~ msgstr "Kan ':normal' nie vanuit gebeurtenishanteerder gebruik nie" -#~ msgid "Files" -#~ msgstr "Lêers" +#~ msgid "Invalid line number: %" +#~ msgstr "Ongeldige reëlnommer: %" -#~ msgid "Selection" -#~ msgstr "Seleksie" +#~ msgid "Missing filename" +#~ msgstr "Ontbrekende lêernaam" -#~ msgid "Undo" -#~ msgstr "Herroep" - -#~ msgid "E671: Cannot find window title \"%s\"" -#~ msgstr "E671: Kan nie venster titel vind nie \"%s\"" +#~ msgid "No servers found for this display" +#~ msgstr "Geen bedieners gevind vir die 'display' nie" -#~ msgid "E243: Argument not supported: \"-%s\"; Use the OLE version." -#~ msgstr "E243: Parameter nie bekend: \"-%s\"; Gebruik die OLE weergawe." +#~ msgid "E258: no matches found in cscope connections" +#~ msgstr "E258: geen treffers gevind in 'cscope' verbindings nie" -#~ msgid "E672: Unable to open window inside MDI application" -#~ msgstr "E672: Kon nie venster oopmaak binne 'n MDI toepassing nie" +#~ msgid "Binary tag search" +#~ msgstr "Binêre etiketsoek" -#~ msgid "Find string (use '\\\\' to find a '\\')" -#~ msgstr "Vind string (gebruik '\\\\' om 'n '\\' te vind" +#~ msgid "Linear tag search" +#~ msgstr "Liniêre etiketsoek" -#~ msgid "Find & Replace (use '\\\\' to find a '\\')" -#~ msgstr "Vind & vervang string (gebruik '\\\\' om 'n '\\' te vind" +#~ msgid " LINE" +#~ msgstr " REËL" -#~ msgid "" -#~ "Vim E458: Cannot allocate colormap entry, some colors may be incorrect" -#~ msgstr "" -#~ "Vim E458: Kan nie kleurkaart-inskrywing toeken nie, sommige kleure mag " -#~ "verkeerd wees" +#~ msgid " BLOCK" +#~ msgstr " BLOK" -#~ msgid "E250: Fonts for the following charsets are missing in fontset %s:" -#~ msgstr "" -#~ "E250: Fonte vir die volgende karakterstelle ontbreek in fontversameling " -#~ "%s:" +#~ msgid "% lines ~ed" +#~ msgstr "% reëls ge-~" -#~ msgid "E252: Fontset name: %s" -#~ msgstr "E252: Fontstel naam: %s" +#~ msgid "1 line ~ed" +#~ msgstr "1 reël ge-~" -#~ msgid "Font '%s' is not fixed-width" -#~ msgstr "Font '%s' is nie 'n vaste-wydte font nie" +#~ msgid "--help\t\tShow Gnome arguments" +#~ msgstr "--help\t\tWys Gnome parameters" -#~ msgid "E253: Fontset name: %s\n" -#~ msgstr "E253: Fonstel naam: %s\n" +#~ msgid "\"\n" +#~ msgstr "\"\n" -#~ msgid "Font0: %s\n" -#~ msgstr "Font0: %s\n" +#~ msgid "E249: couldn't read VIM instance registry property" +#~ msgstr "E249: kon nie VIM instansie register-kenmerk lees nie" -#~ msgid "Font1: %s\n" -#~ msgstr "Font1: %s\n" +#~ msgid "%2d %-5ld %-34s \n" +#~ msgstr "%2d %-5ld %-34s \n" -#~ msgid "Font% width is not twice that of font0\n" -#~ msgstr "Font% wydte is nie twee keer díe van font0 nie\n" +# njj: dalk 'verbinding' ipv 'verbinding' orals? +#~ msgid "couldn't malloc\n" +#~ msgstr "kon nie 'malloc' nie\n" -#~ msgid "Font0 width: %\n" -#~ msgstr "Font0 wydte: %\n" +#~ msgid "E260: cscope connection not found" +#~ msgstr "E260: 'cscope' verbinding nie gevind nie" -#~ msgid "" -#~ "Font1 width: %\n" -#~ "\n" -#~ msgstr "" -#~ "Font1 wydte: %\n" -#~ "\n" +#~ msgid "error reading cscope connection %d" +#~ msgstr "'cscope' verbinding %d kon nie gelees word nie" -#~ msgid "E256: Hangul automata ERROR" -#~ msgstr "E256: Hangul outomatiserings FOUT" +#~ msgid "Run Macro" +#~ msgstr "Voer Makro uit" -#~ msgid "E563: stat error" -#~ msgstr "E563: 'stat' fout" +#~ msgid "function " +#~ msgstr "funksie " -#~ msgid "E625: cannot open cscope database: %s" -#~ msgstr "E625: Kon nie 'cscope' databasis oopmaak nie: %s" +#~ msgid "E463: Region is guarded, cannot modify" +#~ msgstr "E463: Omgewing is onder bewaking, kan nie verander nie" -#~ msgid "E626: cannot get cscope database information" -#~ msgstr "E626: kan nie 'cscope' databasisinligting kry nie" +#~ msgid "E233: cannot open display" +#~ msgstr "E233: kan nie vertoonskerm oopmaak nie" -#~ msgid "E569: maximum number of cscope connections reached" -#~ msgstr "E569: maksimum aantal 'cscope' verbindings bereik" +#~ msgid "E247: no registered server named \"%s\"" +#~ msgstr "E247: geen geregistreerde bediener genaamd \"%s\"" -#~ msgid "" -#~ "E263: Sorry, this command is disabled, the Python library could not be " -#~ "loaded." +#~ msgid "E800: Arabic cannot be used: Not enabled at compile time\n" #~ msgstr "" -#~ "E263: Jammer, hierdie bevel is afgeskakel, die Python biblioteek lêer kon " -#~ "nie gelaai word nie." +#~ "E800: Arabies kan nie gebruik word nie: Nie tydens kompilering gekies " +#~ "nie\n" -#~ msgid "E659: Cannot invoke Python recursively" -#~ msgstr "E659: Kan nie Python rekursief roep nie" +#~ msgid "E27: Farsi cannot be used: Not enabled at compile time\n" +#~ msgstr "" +#~ "E27: Farsi kan nie gebruik word nie: Nie tydens kompilering gekies nie\n" -#~ msgid "can't delete OutputObject attributes" -#~ msgstr "kan nie 'OutputObject' eienskappe skrap nie" +#~ msgid "E26: Hebrew cannot be used: Not enabled at compile time\n" +#~ msgstr "" +#~ "E26: Hebreeus kan nie gebruik word nie: Nie tydens kompilering gekies " +#~ "nie\n" -#~ msgid "softspace must be an integer" -#~ msgstr "'softspace' moet 'n heelgetal wees" +#~ msgid "E448: Could not load library function %s" +#~ msgstr "E448: Kon nie biblioteek funksie laai nie %s" -#~ msgid "invalid attribute" -#~ msgstr "ongeldige eienskap" +#~ msgid "E234: Unknown fontset: %s" +#~ msgstr "E234: Onbekende fontstel: %s" -#~ msgid "writelines() requires list of strings" -#~ msgstr "'writelines()' benodig 'n lys van stringe" +#~ msgid "Path length too long!" +#~ msgstr "Pad-lengte te lank" -#~ msgid "E264: Python: Error initialising I/O objects" -#~ msgstr "E264: Python: Kon nie I/O objekte inwy nie" +#~ msgid "gvimext.dll error" +#~ msgstr "'gvimext.dll' fout" -# njj: net 'n voorstel .. -#~ msgid "invalid expression" -#~ msgstr "ongeldige uitdrukking" +#~ msgid "Error creating process: Check if gvim is in your path!" +#~ msgstr "FOut met die skep van proses: Kyk of gvim in jou pad is!" -#~ msgid "expressions disabled at compile time" -#~ msgstr "uitdrukkings afgeskakel tydens kompilering" +#~ msgid "Edits the selected file(s) with Vim" +#~ msgstr "Wysig die gekose lêer(s) met Vim" -#~ msgid "attempt to refer to deleted buffer" -#~ msgstr "poging om na 'n geskrapte buffer te verwys" +#~ msgid "Edit with existing Vim - &" +#~ msgstr "Wysig met bestaande Vim - &" -#~ msgid "line number out of range" -#~ msgstr "reëlnommer buite omvang" +#~ msgid "Edit with &Vim" +#~ msgstr "Wysig met &Vim" -#~ msgid "" -#~ msgstr "" +#~ msgid "&Diff with Vim" +#~ msgstr "Wys verskille ('&diff') met Vim" -#~ msgid "invalid mark name" -#~ msgstr "onbekende merknaam" +#~ msgid "Edit with single &Vim" +#~ msgstr "Wysig met 'n enkel &Vim" -#~ msgid "no such buffer" -#~ msgstr "buffer bestaan nie" +#~ msgid "Edit with &multiple Vims" +#~ msgstr "Wysig met &meer as een Vim" -#~ msgid "attempt to refer to deleted window" -#~ msgstr "poging om na geskrapte venster te verwys" +#~ msgid "E299: Perl evaluation forbidden in sandbox without the Safe module" +#~ msgstr "" +#~ "E299: Perl evaluasie verbied in die sandput sonder die 'Safe' module" -#~ msgid "readonly attribute" -#~ msgstr "leesalleen eienskap" +#~ msgid "" +#~ "Sorry, this command is disabled: the Perl library could not be loaded." +#~ msgstr "" +#~ "Jammer, hierdie bevel is afgeskakel: die Perl biblioteek kon nie gelaai " +#~ "word nie." -#~ msgid "cursor position outside buffer" -#~ msgstr "loperposisie buite buffer" +#~ msgid "E370: Could not load library %s" +#~ msgstr "E370: Kon nie biblioteek laai nie %s" -#~ msgid "" -#~ msgstr "" +#~ msgid "type :help windows95 for info on this" +#~ msgstr "tik :help windows95 vir meer inligting hieroor" -#~ msgid "" -#~ msgstr "" +#~ msgid "WARNING: Windows 95/98/ME detected" +#~ msgstr "WAARSKUWING: Windows 95/98/ME bespeur" -#~ msgid "" -#~ msgstr "" +#~ msgid " for Vim defaults " +#~ msgstr " vir Vim verstekwaardes" -#~ msgid "no such window" -#~ msgstr "geen sodanige venster nie" +#~ msgid "menu Edit->Global Settings->Toggle Vi Compatible" +#~ msgstr "menu Redigeer->Global verstellings->Stel en herstel Vi Versoenbaar" -#~ msgid "cannot save undo information" -#~ msgstr "kan nie herwin-inligting stoor nie" +#~ msgid "menu Edit->Global Settings->Toggle Insert Mode " +#~ msgstr "menu Redigeer->Globale verstellings->Stel en herstel Invoeg Modus" -#~ msgid "cannot delete line" -#~ msgstr "kan reël nie verwyder nie" +#~ msgid "Running modeless, typed text is inserted" +#~ msgstr "Voer modus-loos uit, getikte teks word ingevoeg" -#~ msgid "cannot replace line" -#~ msgstr "kan reël nie vervang nie" +#~ msgid "menu Help->Orphans for information " +#~ msgstr "menu Hulp->Weeskinders vir meer inligting hieroor " -#~ msgid "cannot insert line" -#~ msgstr "kan reël nie byvoeg nie" +#~ msgid "Compiler: " +#~ msgstr "Kompileerder: " -#~ msgid "string cannot contain newlines" -#~ msgstr "string kan nie 'newlines' bevat nie" +#~ msgid " system menu file: \"" +#~ msgstr " stelsel kieslys-lêer: \"" -#~ msgid "" -#~ "E266: Sorry, this command is disabled, the Ruby library could not be " -#~ "loaded." -#~ msgstr "" -#~ "E266: Jammer, hierdie bevel is afgeskakel, die Ruby biblioteeklêer kon " -#~ "nie gelaai word nie." +#~ msgid "3rd user gvimrc file: \"" +#~ msgstr "3de gebruiker gvimrc-lêer: \"" -#~ msgid "E273: unknown longjmp status %d" -#~ msgstr "E273: Onbekende 'longjmp' status %d" +#~ msgid "2nd user gvimrc file: \"" +#~ msgstr "2de gebruiker gvimrc-lêer: \"" -#~ msgid "Toggle implementation/definition" -#~ msgstr "Stel en herstel implimentasie/definisie" +#~ msgid " user gvimrc file: \"" +#~ msgstr " gebruiker gvimrc-lêer: \"" -#~ msgid "Show base class of" -#~ msgstr "Wys basisklas van" +#~ msgid " system gvimrc file: \"" +#~ msgstr " stelsel gvimrc-lêer: \"" -#~ msgid "Show overridden member function" -#~ msgstr "Wys vervangde lidfunksie" +#~ msgid "with (classic) GUI." +#~ msgstr "met (klassieke) GUI." -#~ msgid "Retrieve from file" -#~ msgstr "Gaan haal uit lêer" +#~ msgid "with Cocoa GUI." +#~ msgstr "met Cocoa GUI." -#~ msgid "Retrieve from project" -#~ msgstr "Gaan haal uit projek" +#~ msgid "with Carbon GUI." +#~ msgstr "met Carbon GUI." -#~ msgid "Retrieve from all projects" -#~ msgstr "Gaan haal uit alle projekte" +#~ msgid "with GUI." +#~ msgstr "met GUI." -#~ msgid "Retrieve" -#~ msgstr "Gaan haal" +#~ msgid "with Photon GUI." +#~ msgstr "met Photon GUI." -#~ msgid "Show source of" -#~ msgstr "Wys kode van" +#~ msgid "with BeOS GUI." +#~ msgstr "met BeOS GUI" -#~ msgid "Find symbol" -#~ msgstr "Vind simbool" +#~ msgid "with X11-Athena GUI." +#~ msgstr "met X11-Athena GUI" -#~ msgid "Browse class" -#~ msgstr "Kyk klas deur" +#~ msgid "with X11-neXtaw GUI." +#~ msgstr "met X11-neXtaw GUI" -#~ msgid "Show class in hierarchy" -#~ msgstr "Wys klas in hiërargie" - -#~ msgid "Show class in restricted hierarchy" -#~ msgstr "Wys klas in beperkte hiërargie" - -#~ msgid "Xref refers to" -#~ msgstr "Xref verwys na" - -#~ msgid "Xref referred by" -#~ msgstr "Xref verwys deur" +#~ msgid "with X11-Motif GUI." +#~ msgstr "met X11-Motif GUI." -#~ msgid "Xref has a" -#~ msgstr "Xref het 'n" +#~ msgid "with GTK GUI." +#~ msgstr "met GTK GUI" -#~ msgid "Xref used by" -#~ msgstr "Xref gebruik deur" +#~ msgid "with GTK2 GUI." +#~ msgstr "met GTK2 GUI" -#~ msgid "Show docu of" -#~ msgstr "Wys 'docu' van" +#~ msgid "with GTK-GNOME GUI." +#~ msgstr "met GTK-GNOME GUI." -#~ msgid "Generate docu for" -#~ msgstr "Genereer 'docu' vir" +#~ msgid "with GTK2-GNOME GUI." +#~ msgstr "met GTK2-GNOME GUI." #~ msgid "" -#~ "Cannot connect to SNiFF+. Check environment (sniffemacs must be found in " -#~ "$PATH).\n" +#~ "\n" +#~ "Tiny version " #~ msgstr "" -#~ "Kan nie 'n verbinding met 'SNiFF+' maak nie. Kyk of die omgewing reg is " -#~ "('sniffemacs' moet in '$PATH' gevind word).\n" - -#~ msgid "E274: Sniff: Error during read. Disconnected" -#~ msgstr "E274: Sniff: Fout gedurende lees. Verbinding gebreek" - -#~ msgid "SNiFF+ is currently " -#~ msgstr "SNiFF+ is tans" - -#~ msgid "not " -#~ msgstr "nie " - -#~ msgid "connected" -#~ msgstr "gekonnekteer" - -#~ msgid "E275: Unknown SNiFF+ request: %s" -#~ msgstr "E275: Onbekende SNiFF+ versoek: %s" - -#~ msgid "E276: Error connecting to SNiFF+" -#~ msgstr "E276: Fout in konnekteer met SNiFF+" - -#~ msgid "E278: SNiFF+ not connected" -#~ msgstr "E278: SNiFF+ is nie gekonnekteer nie" - -#~ msgid "Sniff: Error during write. Disconnected" -#~ msgstr "Sniff: Fout gedurende stoor. Verbinding gebreek" - -#~ msgid "not implemented yet" -#~ msgstr "nog nie geïmplementeer nie" - -#~ msgid "unknown option" -#~ msgstr "onbekende opsie" - -#~ msgid "cannot set line(s)" -#~ msgstr "kan nie reël(s) stel nie" - -#~ msgid "mark not set" -#~ msgstr "merker nie gestel nie" - -#~ msgid "row %d column %d" -#~ msgstr "ry %d kolom %d" - -#~ msgid "cannot insert/append line" -#~ msgstr "kan nie reël invoeg/aanlas nie" - -#~ msgid "unknown flag: " -#~ msgstr "onbekende vlag: " - -#~ msgid "unknown vimOption" -#~ msgstr "onbekende 'vimOption'" - -#~ msgid "keyboard interrupt" -#~ msgstr "sleutelbordonderbreking" - -#~ msgid "vim error" -#~ msgstr "vim fout" - -#~ msgid "cannot create buffer/window command: object is being deleted" -#~ msgstr "kan nie buffer/venster bevel skep nie: voorwerp word geskrap" +#~ "\n" +#~ "Piepklein weergawe " #~ msgid "" -#~ "cannot register callback command: buffer/window is already being deleted" +#~ "\n" +#~ "Small version " #~ msgstr "" -#~ "kan nie terugroepbevel registreer nie: buffer/venster word alreeds geskrap" +#~ "\n" +#~ "Klein weergawe " #~ msgid "" -#~ "E280: TCL FATAL ERROR: reflist corrupt!? Please report this to vim-" -#~ "dev@vim.org" -#~ msgstr "" -#~ "E280: TCL FATALE FOUT: verwlys korrup!? Rapporteer dit asb. aan " - -#~ msgid "cannot register callback command: buffer/window reference not found" +#~ "\n" +#~ "Normal version " #~ msgstr "" -#~ "kan terugroepbevel nie registreer nie: buffer/vensterverwysing nie gevind " -#~ "nie" +#~ "\n" +#~ "Normale weergawe " #~ msgid "" -#~ "E571: Sorry, this command is disabled: the Tcl library could not be " -#~ "loaded." +#~ "\n" +#~ "Big version " #~ msgstr "" -#~ "E571: Jammer, hierdie bevel is afgeskakel, die Tcl biblioteek kon nie " -#~ "gelaai word nie." +#~ "\n" +#~ "Groot weergawe " #~ msgid "" -#~ "E281: TCL ERROR: exit code is not int!? Please report this to vim-dev@vim." -#~ "org" +#~ "\n" +#~ "RISC OS version" #~ msgstr "" -#~ "E281: TCL FOUT: verlaatkode is nie 'n 'int'!? Rapporteer dit asb. aan " -#~ "" - -#~ msgid "cannot get line" -#~ msgstr "kan nie reël kry nie" - -#~ msgid "Unable to register a command server name" -#~ msgstr "Kon nie bevelbediener naam registreer nie" - -#~ msgid "E248: Failed to send command to the destination program" -#~ msgstr "E248: Het gefaal om bevel na doel program te stuur" - -#~ msgid "E251: VIM instance registry property is badly formed. Deleted!" -#~ msgstr "E251: VIM instansie register-kenmerk is swak gevorm. Geskrap!" - -#~ msgid "This Vim was not compiled with the diff feature." -#~ msgstr "Hierdie Vim is nie gekompileer met 'diff' funksionaliteit nie." - -#~ msgid "-register\t\tRegister this gvim for OLE" -#~ msgstr "-register\t\tRegistreer hierdie gvim vir OLE" - -#~ msgid "-unregister\t\tUnregister gvim for OLE" -#~ msgstr "-unregister\t\tOnregistreer gvim vir OLE" - -#~ msgid "-g\t\t\tRun using GUI (like \"gvim\")" -#~ msgstr "-g\t\t\tVoer uit met die GUI (soos \"gvim\")" - -#~ msgid "-f or --nofork\tForeground: Don't fork when starting GUI" -#~ msgstr "-f of --nofork\tVoorgrond: Moenie vurk wanneer GUI begin nie" - -#~ msgid "-V[N]\t\tVerbose level" -#~ msgstr "-V[N]\t\tOmslagtigheidsgraad" - -#~ msgid "-f\t\t\tDon't use newcli to open window" -#~ msgstr "-f\t\t\tMoet nie 'newcli' gebruik om venster oop te maak nie" - -#~ msgid "-dev \t\tUse for I/O" -#~ msgstr "-dev \t\tGebruik vir I/O" - -#~ msgid "-U \t\tUse instead of any .gvimrc" -#~ msgstr "-U \t\tGebruik in plaas van enige .gvimrc" - -#~ msgid "-x\t\t\tEdit encrypted files" -#~ msgstr "-x\t\t\tBewerk geënkripteerde lêers" - -#~ msgid "-display \tConnect vim to this particular X-server" -#~ msgstr "-display \tKoppel vim aan hierdie X-bediener" - -#~ msgid "-X\t\t\tDo not connect to X server" -#~ msgstr "-X\t\t\tMoet nie verbinding met X-bediener maak nie" +#~ "\n" +#~ "RISC OS weergawe" -#~ msgid "--remote \tEdit in a Vim server if possible" +#~ msgid "" +#~ "\n" +#~ "MacOS version" #~ msgstr "" -#~ "--remote \tWysig die in a Vim bediener indien moontlik" +#~ "\n" +#~ "MacOS weergawe" -#~ msgid "--remote-silent Same, don't complain if there is no server" +#~ msgid "" +#~ "\n" +#~ "MacOS X version" #~ msgstr "" -#~ "--remote-silent Dieselfde, moet nie kla as daar nie so 'n " -#~ "bediener is nie" +#~ "\n" +#~ "MacOS X weergawe" #~ msgid "" -#~ "--remote-wait As --remote but wait for files to have been edited" +#~ "\n" +#~ "MacOS X (unix) version" #~ msgstr "" -#~ "--remote-wait Soos '--remote', maar wag vir lêers om gewysig te " -#~ "word" +#~ "\n" +#~ "MacOS X (unix) weergawe" #~ msgid "" -#~ "--remote-wait-silent Same, don't complain if there is no server" +#~ "\n" +#~ "16-bit MS-DOS version" #~ msgstr "" -#~ "--remote-wait-silent Dieselfde, moet nie kla as daar nie so 'n " -#~ "bediener is nie" +#~ "\n" +#~ "16-bis MS-DOS weergawe" -#~ msgid "--remote-send \tSend to a Vim server and exit" +#~ msgid "" +#~ "\n" +#~ "32-bit MS-DOS version" #~ msgstr "" -#~ "--remote-send \tStuur na 'n Vim-bediener en verlaat" +#~ "\n" +#~ "32-bis MS-DOS weergawe" #~ msgid "" -#~ "--remote-expr \tEvaluate in a Vim server and print result" +#~ "\n" +#~ "MS-Windows 16-bit version" #~ msgstr "" -#~ "--remote-expr \tEvalueer in 'n Vim-bediener en druk resultaat" - -#~ msgid "--serverlist\t\tList available Vim server names and exit" -#~ msgstr "--serverlist\t\tLys beskikbare Vim-bediener name en verlaat" - -#~ msgid "--servername \tSend to/become the Vim server " -#~ msgstr "--servername \tStuur na/word die Vim-bediener " +#~ "\n" +#~ "MS-Windows 16-bis weergawe" #~ msgid "" #~ "\n" -#~ "Arguments recognised by gvim (Motif version):\n" +#~ "MS-Windows 32-bit console version" #~ msgstr "" #~ "\n" -#~ "Parameters deur gvim herken (Motif weergawe):\n" +#~ "MS-Windows 32-bis konsole weergawe" + +#~ msgid " with OLE support" +#~ msgstr " met OLE ondersteuning" + +#~ msgid " in Win32s mode" +#~ msgstr " in Win32s modus" #~ msgid "" #~ "\n" -#~ "Arguments recognised by gvim (neXtaw version):\n" +#~ "MS-Windows 32-bit GUI version" #~ msgstr "" #~ "\n" -#~ "Parameters deur gvim herken (neXtaw weergawe):\n" +#~ "MS-Windows 32-bis GUI version" #~ msgid "" #~ "\n" -#~ "Arguments recognised by gvim (Athena version):\n" +#~ "MS-Windows 16/32-bit GUI version" #~ msgstr "" #~ "\n" -#~ "Parameters deur gvim herken (Athena weergawe):\n" +#~ "MS-Windows 16/32-bis GUI weergawe" -#~ msgid "-display \tRun vim on " -#~ msgstr "-display \tVoer vim op uit" +#~ msgid "No undo possible; continue anyway" +#~ msgstr "Geen herstel moontlik; gaan in elk geval voort" -#~ msgid "-iconic\t\tStart vim iconified" -#~ msgstr "-iconic\t\tBegin vim as ikoon" +#~ msgid "new shell started\n" +#~ msgstr "nuwe dop begin\n" -#~ msgid "-name \t\tUse resource as if vim was " -#~ msgstr "-name \t\tGebruik hulpbron asof vim was" +#~ msgid "E430: Tag file path truncated for %s\n" +#~ msgstr "E430: Etiketlêergids afgekap vir %s\n" -#~ msgid "\t\t\t (Unimplemented)\n" -#~ msgstr "\t\t\t (Nog nie geïmplementeer nie)\n" +#~ msgid "Enter nr of choice ( to abort): " +#~ msgstr "Sleutel nommer van keuse in ( om te stop): " -#~ msgid "-background \tUse for the background (also: -bg)" -#~ msgstr "-background \tGebruik vir die agtergrond (ook: -bg)" +#~ msgid "E396: containedin argument not accepted here" +#~ msgstr "E396: 'containedin' parameter nie hier aanvaar nie" -#~ msgid "-foreground \tUse for normal text (also: -fg)" -#~ msgstr "-voorgrond \tGebruik vir normale teks (ook: -fg)" +#~ msgid "E363: pattern caused out-of-stack error" +#~ msgstr "E363: patroon het lëe-stapel fout veroorsaak" -#~ msgid "-font \t\tUse for normal text (also: -fn)" -#~ msgstr "-font \t\tGebruik vir normale teks (ook -fn)" +#~ msgid "E361: Crash intercepted; regexp too complex?" +#~ msgstr "E361: Ineenstorting onderskep. Patroon te kompleks?" -#~ msgid "-boldfont \tUse for bold text" -#~ msgstr "­boldfont \t Gebruik vir vetletter teks" +#~ msgid "E58: %s{ operand could be empty" +#~ msgstr "E58: %s{ operand mag leeg wees" -#~ msgid "-italicfont \tUse for italic text" -#~ msgstr "-italicfont \tGebruik vir kursiewe teks" +#~ msgid "E57: %s+ operand could be empty" +#~ msgstr "E57: %s+ operand mag leeg wees" -#~ msgid "-geometry \tUse for initial geometry (also: -geom)" -#~ msgstr "-geometry \tGebruik vir aanvanklike geometrie" +#~ msgid "E56: %s* operand could be empty" +#~ msgstr "E56: %s* operand mag leeg wees" -#~ msgid "-borderwidth \tUse a border width of (also: -bw)" -#~ msgstr "-borderwidth \tGebruik 'n grenswydte van (ook: -bw)" +#~ msgid "Vim Warning" +#~ msgstr "Vim Waarskuwing" #~ msgid "" -#~ "-scrollbarwidth Use a scrollbar width of (also: -sw)" +#~ "VIMRUN.EXE not found in your $PATH.\n" +#~ "External commands will not pause after completion.\n" +#~ "See :help win32-vimrun for more information." #~ msgstr "" -#~ "-scrollbarwidth \tGebruik 'n rolstaafwydte van (ook: -sw>" +#~ "'VIMRUN.EXE' nie gevind in '$PATH' nie.\n" +#~ "Eksterne opdragte sal nie wag na voltooiing nie\n" +#~ "Sien ':help win32-vimrun' vir meer inligting." -#~ msgid "-menuheight \tUse a menu bar height of (also: -mh)" -#~ msgstr "" -#~ "-menuheight \tGebruik a kieslysstaafhoogte van (ook: -mh)" +#~ msgid "E371: Command not found" +#~ msgstr "E371: Bevel nie gevind nie" -#~ msgid "-reverse\t\tUse reverse video (also: -rv)" -#~ msgstr "-reverse\t\tGebruik tru-video (ook: -rv)" +#~ msgid "shutdown" +#~ msgstr "sit af" -#~ msgid "+reverse\t\tDon't use reverse video (also: +rv)" -#~ msgstr "+reverse\t\tMoet nie tru-video gebruik nie (ook: +rv)" +#~ msgid "logoff" +#~ msgstr "teken uit" -#~ msgid "-xrm \tSet the specified resource" -#~ msgstr "-xrm \tStel die gespesifiseerde hulpbron" +#~ msgid "close" +#~ msgstr "maak toe" + +#~ msgid "Vim: Caught %s event\n" +#~ msgstr "Vim: Het %s gebeurtenis gevang\n" + +#~ msgid "shell returned %d" +#~ msgstr "dop het %d gelewer" + +#~ msgid "Could not fix up function pointers to the DLL!" +#~ msgstr "Kon nie funksiewysers na die DLL opstel nie!" + +#~ msgid "Could not load vim32.dll!" +#~ msgstr "Kon nie 'vim32.dll' laai nie!" + +#~ msgid "VIM Error" +#~ msgstr "VIM Fout" + +#~ msgid "Could not allocate memory for command line." +#~ msgstr "Kan nie geheue toeken vir bevelreël nie" + +#~ msgid "At line" +#~ msgstr "By reël" + +#~ msgid "XSMP ICE connection watch failed" +#~ msgstr "XSMP ICE konneksie beloer het gefaal" + +#~ msgid "XSMP opening connection" +#~ msgstr "XSMP maak nou konneksie oop" + +#~ msgid "XSMP handling save-yourself request" +#~ msgstr "XSMP hanteer 'save-yourself' versoek" + +#~ msgid "Opening the X display failed" +#~ msgstr "Oopmaak van die X vertoonskerm het gefaal" + +#~ msgid "XSMP lost ICE connection" +#~ msgstr "XSMP het ICE konneksie verloor" #~ msgid "" #~ "\n" -#~ "Arguments recognised by gvim (RISC OS version):\n" +#~ "Command terminated\n" #~ msgstr "" #~ "\n" -#~ "Parameters wat gvim verstaan (RISC OS weergawe):\n" +#~ "Bevel beëindig\n" -#~ msgid "--columns \tInitial width of window in columns" -#~ msgstr "--columns \tAanvanklike wydte van venster in kolomme" +#~ msgid "" +#~ "\n" +#~ "Cannot fork\n" +#~ msgstr "" +#~ "\n" +#~ "Kan nie vurk nie\n" -#~ msgid "--rows \tInitial height of window in rows" -#~ msgstr "--rows \tAanvanklike hoogte van venster in rye" +#~ msgid "" +#~ "\n" +#~ "Cannot create pipes\n" +#~ msgstr "" +#~ "\n" +#~ "Kan nie pype skep nie\n" #~ msgid "" #~ "\n" -#~ "Arguments recognised by gvim (GTK+ version):\n" +#~ "Cannot execute shell sh\n" #~ msgstr "" #~ "\n" -#~ "Parameters wat gvim verstaan (GTK+ weergawe):\n" +#~ "Kan nie dop 'sh' uitvoer nie\n" -#~ msgid "-display \tRun vim on (also: --display)" -#~ msgstr "-display \tVoer vim op uit: (ook --display)" +#~ msgid "Opening the X display timed out" +#~ msgstr "Oopmaak van die X-vertoonskerm het uitgetel" -#~ msgid "--role \tSet a unique role to identify the main window" -#~ msgstr "--role \tStel 'n unieke rol om die hoofvenster te identifiseer" +#~ msgid "Testing the X display failed" +#~ msgstr "Toetsing van die X-vertoonskerm het gefaal" -#~ msgid "--socketid \tOpen Vim inside another GTK widget" -#~ msgstr "--socketid \tMaak Vim in 'n ander GTK element oop" +#~ msgid "" +#~ "\n" +#~ "Vim: Got X error\n" +#~ msgstr "" +#~ "\n" +#~ "Vim: Het X fout ontvang\n" -#~ msgid "-P \tOpen Vim inside parent application" -#~ msgstr "-P \tMaak Vim oop binne 'n ouer toepassing" +#~ msgid "Opening the X display took % msec" +#~ msgstr "Om die X-vertoonskerm oop te maak het % msek gevat" -#~ msgid "No display" -#~ msgstr "Geen vertoonskerm" +#~ msgid "Vim: Caught deadly signal\n" +#~ msgstr "Vim: Het dodelike sein gevang\n" -#~ msgid ": Send failed.\n" -#~ msgstr ": Stuur het gefaal.\n" +#~ msgid "Vim: Caught deadly signal %s\n" +#~ msgstr "Vim: Het dodelike sein %s gevang\n" -#~ msgid ": Send failed. Trying to execute locally\n" -#~ msgstr ": Stuur het gefaal. Probeer om lokaal uit te voer\n" +#~ msgid "Vim: Double signal, exiting\n" +#~ msgstr "Vim: Dubbel sein, staak\n" -#~ msgid "%d of %d edited" -#~ msgstr "%d van %d lêers bewerk" +#~ msgid "E245: Illegal char '%c' in font name \"%s\"" +#~ msgstr "E245: Ongeldige karakter '%c' in fontnaam \"%s\"" -#~ msgid "No display: Send expression failed.\n" -#~ msgstr "Geen vertoonskerm: Stuur van uitdrukking het gefaal.\n" +#~ msgid "E244: Illegal charset name \"%s\" in font name \"%s\"" +#~ msgstr "E244: Ongeldige karakterstelnaam \"%s\" in fontnaam \"%s\"" -#~ msgid ": Send expression failed.\n" -#~ msgstr ": Stuur van uitdrukking het gefaal.\n" +#~ msgid "Printing '%s'" +#~ msgstr "Druk nou '%s'" -#~ msgid "E543: Not a valid codepage" -#~ msgstr "E543: Nie 'n geldige kodeblad nie" +#~ msgid "E238: Print error: %s" +#~ msgstr "E238: Drukfout: %s" -#~ msgid "E285: Failed to create input context" -#~ msgstr "E285: Gefaal met die skep van invoerkonteks" +#~ msgid "E613: Unknown printer font: %s" +#~ msgstr "E613: Onbekende drukker font: %s" -#~ msgid "E286: Failed to open input method" -#~ msgstr "E286: Gefaal om invoermetode oop te maak" +#~ msgid "to %s on %s" +#~ msgstr "na %s op %s" -#~ msgid "E287: Warning: Could not set destroy callback to IM" -#~ msgstr "E287: Waarskuwing: Kon nie uitwis-terugroep na IM stel nie" +#~ msgid "'columns' is not 80, cannot execute external commands" +#~ msgstr "'columns' is nie 80 nie, kan nie eksterne bevele uitvoer nie" -#~ msgid "E288: input method doesn't support any style" -#~ msgstr "E288: invoermetode ondersteun geen styl nie" +#~ msgid "...(truncated)" +#~ msgstr "...(afgekap)" -#~ msgid "E289: input method doesn't support my preedit type" -#~ msgstr "E289: invoermetode ondersteun nie my voor-bewerking tipe nie" +#~ msgid "I/O ERROR" +#~ msgstr "I/O FOUT" -#~ msgid "E290: over-the-spot style requires fontset" -#~ msgstr "E290: oor-die-plek styl vereis fontstel" +#~ msgid "ANCHOR_BUF_SIZE too small." +#~ msgstr "'ANCHOR_BUF_SIZE' is te klein" -#~ msgid "E291: Your GTK+ is older than 1.2.3. Status area disabled" -#~ msgstr "E291: Jou GTK+ is ouer as 1.2.3. Statusarea afgeskakel" +#~ msgid " returned\n" +#~ msgstr " teruggekeer\n" -#~ msgid "E292: Input Method Server is not running" -#~ msgstr "E292: Invoermetodebediener voer nie uit nie" +#~ msgid "shell " +#~ msgstr "dop " -#~ msgid "" -#~ "\n" -#~ " [not usable with this version of Vim]" -#~ msgstr "" -#~ "\n" -#~ " [nie bruikbaar met hierdie weergawe van Vim nie]" +#~ msgid "Cannot execute " +#~ msgstr "Kan nie uitvoer nie " -#~ msgid "" -#~ "&Open Read-Only\n" -#~ "&Edit anyway\n" -#~ "&Recover\n" -#~ "&Quit\n" -#~ "&Abort\n" -#~ "&Delete it" -#~ msgstr "" -#~ "&Maak as lees-alleen oop\n" -#~ "&Bewerk in elk geval\n" -#~ "&Herwin\n" -#~ "&Verlaat\n" -#~ "&Stop\n" -#~ "S&krap dit" +#~ msgid "mch_get_shellsize: not a console??\n" +#~ msgstr "'mch_get_shellsize': nie 'n konsole nie??\n" -#~ msgid "Tear off this menu" -#~ msgstr "Skeur die kieslys af" +#~ msgid "cannot change console mode ?!\n" +#~ msgstr "kan konsole-modus nie verander nie ?!\n" -#~ msgid "[string too long]" -#~ msgstr "[string te lank]" +#~ msgid "Vim exiting with %d\n" +#~ msgstr "Vim stop met %d\n" -#~ msgid "Hit ENTER to continue" -#~ msgstr "Druk ENTER om voort te gaan" +#~ msgid "Cannot create " +#~ msgstr "Kan nie skep nie: " -#~ msgid " (RET/BS: line, SPACE/b: page, d/u: half page, q: quit)" -#~ msgstr " (RET/BS: reël, SPACE/b: bladsy, d/u: halwe bladsy, q: los dit" +#~ msgid "Cannot open NIL:\n" +#~ msgstr "Kan nie NIL: oopmaak nie\n" -#~ msgid " (RET: line, SPACE: page, d: half page, q: quit)" -#~ msgstr " (RET: reël, SPACE: bladsy, d: halwe bladsy, q: los dit" +#~ msgid "Need %s version %\n" +#~ msgstr "Benodig %s weergawe %\n" -#~ msgid "Save File dialog" -#~ msgstr "Stoor Lêer dialooghokkie" +#~ msgid "Need Amigados version 2.04 or later\n" +#~ msgstr "Benodig Amigados weergawe 2.04 of later\n" -#~ msgid "Open File dialog" -#~ msgstr "Maak lêer oop dialooghokkie" +#~ msgid "VIM: Can't open window!\n" +#~ msgstr "VIM: Kan nie venster oopmaak nie!\n" -#~ msgid "E338: Sorry, no file browser in console mode" -#~ msgstr "E338: Jammer, lêerblaaier nie beskikbaar in konsole-modus nie" +#~ msgid "cannot open " +#~ msgstr "kan nie oopmaak nie " -#~ msgid "Vim: preserving files...\n" -#~ msgstr "Vim: bewaar lêers...\n" +#~ msgid "E538: No mouse support" +#~ msgstr "E538: Geen muisondersteuning nie" -#~ msgid "Vim: Finished.\n" -#~ msgstr "Vim: Klaar.\n" +#~ msgid "E534: Invalid wide font" +#~ msgstr "E534: Ongeldige wye font" -#~ msgid "ERROR: " -#~ msgstr "FOUT: " +#~ msgid "E533: can't select wide font" +#~ msgstr "E533: kan nie wye font kies nie" + +#~ msgid "E598: Invalid fontset" +#~ msgstr "E598: Ongeldige fontstel" + +#~ msgid "E597: can't select fontset" +#~ msgstr "E597: kan nie fontstel kies nie" + +#~ msgid "E617: Cannot be changed in the GTK+ 2 GUI" +#~ msgstr "E617: Kan nie 'term' verander in die GTK+ 2 GUI nie" + +#~ msgid "E531: Use \":gui\" to start the GUI" +#~ msgstr "E531: Gebruik \":gui\" om die GUI te begin" + +#~ msgid "E530: Cannot change term in GUI" +#~ msgstr "E530: Kan nie 'term' verander in GUI nie" + +#~ msgid "freeing % lines" +#~ msgstr "laat % reëls gaan" + +#~ msgid "E658: NetBeans connection lost for buffer %" +#~ msgstr "E658: NetBeans konneksie vir buffer % verloor" + +#~ msgid "read from Netbeans socket" +#~ msgstr "lees vanaf Netbeans 'socket'" + +#~ msgid "E668: Wrong access mode for NetBeans connection info file: \"%s\"" +#~ msgstr "" +#~ "E668: Verkeerde toegangsmodue vir NetBeans konneksie inligtingslêer: \"%s" +#~ "\"" + +#~ msgid "Cannot connect to Netbeans" +#~ msgstr "Kan nie aan Netbeans koppel nie" + +#~ msgid "Cannot connect to Netbeans #2" +#~ msgstr "Kan nie aan Netbeans #2 koppel nie" + +#~ msgid "Keys don't match!" +#~ msgstr "Sleutels verskil!" + +#~ msgid "Enter same key again: " +#~ msgstr "Voer die sleutel weer in: " + +#~ msgid "Enter encryption key: " +#~ msgstr "Voer enkripsie-sleutel in: " + +#~ msgid "E547: Illegal mouseshape" +#~ msgstr "E547: Ongeldige muisvorm" + +#~ msgid "E341: Internal error: lalloc(%, )" +#~ msgstr "E341: Interne fout: 'lalloc(%, )'" + +#~ msgid "E340: Line is becoming too long" +#~ msgstr "E340: Rëel word te lank" + +#~ msgid "" +#~ "[calls] total re/malloc()'s %, total free()'s %\n" +#~ "\n" +#~ msgstr "" +#~ "[roepe] totaal re/malloc()'s %, totale free()'s %\n" +#~ "\n" #~ msgid "" #~ "\n" @@ -7315,782 +6442,1187 @@ msgstr "E446: Geen l #~ "[grepe] totaal 'alloc'-vrygelaat %-%, in gebruik " #~ "%, piekgebruik %\n" +#~ msgid "ERROR: " +#~ msgstr "FOUT: " + +#~ msgid "Vim: Finished.\n" +#~ msgstr "Vim: Klaar.\n" + +#~ msgid "Vim: preserving files...\n" +#~ msgstr "Vim: bewaar lêers...\n" + +#~ msgid "E338: Sorry, no file browser in console mode" +#~ msgstr "E338: Jammer, lêerblaaier nie beskikbaar in konsole-modus nie" + +#~ msgid "Open File dialog" +#~ msgstr "Maak lêer oop dialooghokkie" + +#~ msgid "Save File dialog" +#~ msgstr "Stoor Lêer dialooghokkie" + +#~ msgid " (RET: line, SPACE: page, d: half page, q: quit)" +#~ msgstr " (RET: reël, SPACE: bladsy, d: halwe bladsy, q: los dit" + +#~ msgid " (RET/BS: line, SPACE/b: page, d/u: half page, q: quit)" +#~ msgstr " (RET/BS: reël, SPACE/b: bladsy, d/u: halwe bladsy, q: los dit" + +#~ msgid "Hit ENTER to continue" +#~ msgstr "Druk ENTER om voort te gaan" + +#~ msgid "[string too long]" +#~ msgstr "[string te lank]" + +#~ msgid "Tear off this menu" +#~ msgstr "Skeur die kieslys af" + +#~ msgid "" +#~ "&Open Read-Only\n" +#~ "&Edit anyway\n" +#~ "&Recover\n" +#~ "&Quit\n" +#~ "&Abort\n" +#~ "&Delete it" +#~ msgstr "" +#~ "&Maak as lees-alleen oop\n" +#~ "&Bewerk in elk geval\n" +#~ "&Herwin\n" +#~ "&Verlaat\n" +#~ "&Stop\n" +#~ "S&krap dit" + #~ msgid "" -#~ "[calls] total re/malloc()'s %, total free()'s %\n" #~ "\n" +#~ " [not usable with this version of Vim]" #~ msgstr "" -#~ "[roepe] totaal re/malloc()'s %, totale free()'s %\n" #~ "\n" +#~ " [nie bruikbaar met hierdie weergawe van Vim nie]" -#~ msgid "E340: Line is becoming too long" -#~ msgstr "E340: Rëel word te lank" +#~ msgid "E292: Input Method Server is not running" +#~ msgstr "E292: Invoermetodebediener voer nie uit nie" -#~ msgid "E341: Internal error: lalloc(%, )" -#~ msgstr "E341: Interne fout: 'lalloc(%, )'" +#~ msgid "E291: Your GTK+ is older than 1.2.3. Status area disabled" +#~ msgstr "E291: Jou GTK+ is ouer as 1.2.3. Statusarea afgeskakel" -#~ msgid "E547: Illegal mouseshape" -#~ msgstr "E547: Ongeldige muisvorm" +#~ msgid "E290: over-the-spot style requires fontset" +#~ msgstr "E290: oor-die-plek styl vereis fontstel" -#~ msgid "Enter encryption key: " -#~ msgstr "Voer enkripsie-sleutel in: " +#~ msgid "E289: input method doesn't support my preedit type" +#~ msgstr "E289: invoermetode ondersteun nie my voor-bewerking tipe nie" -#~ msgid "Enter same key again: " -#~ msgstr "Voer die sleutel weer in: " +#~ msgid "E288: input method doesn't support any style" +#~ msgstr "E288: invoermetode ondersteun geen styl nie" -#~ msgid "Keys don't match!" -#~ msgstr "Sleutels verskil!" +#~ msgid "E287: Warning: Could not set destroy callback to IM" +#~ msgstr "E287: Waarskuwing: Kon nie uitwis-terugroep na IM stel nie" -#~ msgid "Cannot connect to Netbeans #2" -#~ msgstr "Kan nie aan Netbeans #2 koppel nie" +#~ msgid "E285: Failed to create input context" +#~ msgstr "E285: Gefaal met die skep van invoerkonteks" -#~ msgid "Cannot connect to Netbeans" -#~ msgstr "Kan nie aan Netbeans koppel nie" +#~ msgid "E543: Not a valid codepage" +#~ msgstr "E543: Nie 'n geldige kodeblad nie" -#~ msgid "E668: Wrong access mode for NetBeans connection info file: \"%s\"" +#~ msgid ": Send expression failed.\n" +#~ msgstr ": Stuur van uitdrukking het gefaal.\n" + +#~ msgid "No display: Send expression failed.\n" +#~ msgstr "Geen vertoonskerm: Stuur van uitdrukking het gefaal.\n" + +#~ msgid "%d of %d edited" +#~ msgstr "%d van %d lêers bewerk" + +#~ msgid ": Send failed. Trying to execute locally\n" +#~ msgstr ": Stuur het gefaal. Probeer om lokaal uit te voer\n" + +#~ msgid ": Send failed.\n" +#~ msgstr ": Stuur het gefaal.\n" + +#~ msgid "No display" +#~ msgstr "Geen vertoonskerm" + +#~ msgid "-P \tOpen Vim inside parent application" +#~ msgstr "-P \tMaak Vim oop binne 'n ouer toepassing" + +#~ msgid "--socketid \tOpen Vim inside another GTK widget" +#~ msgstr "--socketid \tMaak Vim in 'n ander GTK element oop" + +#~ msgid "--role \tSet a unique role to identify the main window" +#~ msgstr "--role \tStel 'n unieke rol om die hoofvenster te identifiseer" + +#~ msgid "-display \tRun vim on (also: --display)" +#~ msgstr "-display \tVoer vim op uit: (ook --display)" + +#~ msgid "" +#~ "\n" +#~ "Arguments recognised by gvim (GTK+ version):\n" #~ msgstr "" -#~ "E668: Verkeerde toegangsmodue vir NetBeans konneksie inligtingslêer: \"%s" -#~ "\"" +#~ "\n" +#~ "Parameters wat gvim verstaan (GTK+ weergawe):\n" -#~ msgid "read from Netbeans socket" -#~ msgstr "lees vanaf Netbeans 'socket'" +#~ msgid "--rows \tInitial height of window in rows" +#~ msgstr "--rows \tAanvanklike hoogte van venster in rye" -#~ msgid "E658: NetBeans connection lost for buffer %" -#~ msgstr "E658: NetBeans konneksie vir buffer % verloor" +#~ msgid "--columns \tInitial width of window in columns" +#~ msgstr "--columns \tAanvanklike wydte van venster in kolomme" -#~ msgid "freeing % lines" -#~ msgstr "laat % reëls gaan" +#~ msgid "" +#~ "\n" +#~ "Arguments recognised by gvim (RISC OS version):\n" +#~ msgstr "" +#~ "\n" +#~ "Parameters wat gvim verstaan (RISC OS weergawe):\n" -#~ msgid "E530: Cannot change term in GUI" -#~ msgstr "E530: Kan nie 'term' verander in GUI nie" +#~ msgid "-xrm \tSet the specified resource" +#~ msgstr "-xrm \tStel die gespesifiseerde hulpbron" -#~ msgid "E531: Use \":gui\" to start the GUI" -#~ msgstr "E531: Gebruik \":gui\" om die GUI te begin" +#~ msgid "+reverse\t\tDon't use reverse video (also: +rv)" +#~ msgstr "+reverse\t\tMoet nie tru-video gebruik nie (ook: +rv)" -#~ msgid "E617: Cannot be changed in the GTK+ 2 GUI" -#~ msgstr "E617: Kan nie 'term' verander in die GTK+ 2 GUI nie" +#~ msgid "-reverse\t\tUse reverse video (also: -rv)" +#~ msgstr "-reverse\t\tGebruik tru-video (ook: -rv)" -#~ msgid "E597: can't select fontset" -#~ msgstr "E597: kan nie fontstel kies nie" +#~ msgid "-menuheight \tUse a menu bar height of (also: -mh)" +#~ msgstr "" +#~ "-menuheight \tGebruik a kieslysstaafhoogte van (ook: -mh)" -#~ msgid "E598: Invalid fontset" -#~ msgstr "E598: Ongeldige fontstel" +#~ msgid "" +#~ "-scrollbarwidth Use a scrollbar width of (also: -sw)" +#~ msgstr "" +#~ "-scrollbarwidth \tGebruik 'n rolstaafwydte van (ook: -sw>" -#~ msgid "E533: can't select wide font" -#~ msgstr "E533: kan nie wye font kies nie" +#~ msgid "-borderwidth \tUse a border width of (also: -bw)" +#~ msgstr "-borderwidth \tGebruik 'n grenswydte van (ook: -bw)" -#~ msgid "E534: Invalid wide font" -#~ msgstr "E534: Ongeldige wye font" +#~ msgid "-geometry \tUse for initial geometry (also: -geom)" +#~ msgstr "-geometry \tGebruik vir aanvanklike geometrie" -#~ msgid "E538: No mouse support" -#~ msgstr "E538: Geen muisondersteuning nie" +#~ msgid "-italicfont \tUse for italic text" +#~ msgstr "-italicfont \tGebruik vir kursiewe teks" -#~ msgid "cannot open " -#~ msgstr "kan nie oopmaak nie " +#~ msgid "-boldfont \tUse for bold text" +#~ msgstr "­boldfont \t Gebruik vir vetletter teks" -#~ msgid "VIM: Can't open window!\n" -#~ msgstr "VIM: Kan nie venster oopmaak nie!\n" +#~ msgid "-font \t\tUse for normal text (also: -fn)" +#~ msgstr "-font \t\tGebruik vir normale teks (ook -fn)" -#~ msgid "Need Amigados version 2.04 or later\n" -#~ msgstr "Benodig Amigados weergawe 2.04 of later\n" +#~ msgid "-foreground \tUse for normal text (also: -fg)" +#~ msgstr "-voorgrond \tGebruik vir normale teks (ook: -fg)" -#~ msgid "Need %s version %\n" -#~ msgstr "Benodig %s weergawe %\n" +#~ msgid "-background \tUse for the background (also: -bg)" +#~ msgstr "-background \tGebruik vir die agtergrond (ook: -bg)" -#~ msgid "Cannot open NIL:\n" -#~ msgstr "Kan nie NIL: oopmaak nie\n" +#~ msgid "\t\t\t (Unimplemented)\n" +#~ msgstr "\t\t\t (Nog nie geïmplementeer nie)\n" + +#~ msgid "-name \t\tUse resource as if vim was " +#~ msgstr "-name \t\tGebruik hulpbron asof vim was" + +#~ msgid "-iconic\t\tStart vim iconified" +#~ msgstr "-iconic\t\tBegin vim as ikoon" + +#~ msgid "-display \tRun vim on " +#~ msgstr "-display \tVoer vim op uit" + +#~ msgid "" +#~ "\n" +#~ "Arguments recognised by gvim (Athena version):\n" +#~ msgstr "" +#~ "\n" +#~ "Parameters deur gvim herken (Athena weergawe):\n" + +#~ msgid "" +#~ "\n" +#~ "Arguments recognised by gvim (neXtaw version):\n" +#~ msgstr "" +#~ "\n" +#~ "Parameters deur gvim herken (neXtaw weergawe):\n" + +#~ msgid "" +#~ "\n" +#~ "Arguments recognised by gvim (Motif version):\n" +#~ msgstr "" +#~ "\n" +#~ "Parameters deur gvim herken (Motif weergawe):\n" + +#~ msgid "--servername \tSend to/become the Vim server " +#~ msgstr "--servername \tStuur na/word die Vim-bediener " + +#~ msgid "--serverlist\t\tList available Vim server names and exit" +#~ msgstr "--serverlist\t\tLys beskikbare Vim-bediener name en verlaat" + +#~ msgid "" +#~ "--remote-expr \tEvaluate in a Vim server and print result" +#~ msgstr "" +#~ "--remote-expr \tEvalueer in 'n Vim-bediener en druk resultaat" + +#~ msgid "--remote-send \tSend to a Vim server and exit" +#~ msgstr "" +#~ "--remote-send \tStuur na 'n Vim-bediener en verlaat" + +#~ msgid "" +#~ "--remote-wait-silent Same, don't complain if there is no server" +#~ msgstr "" +#~ "--remote-wait-silent Dieselfde, moet nie kla as daar nie so 'n " +#~ "bediener is nie" + +#~ msgid "" +#~ "--remote-wait As --remote but wait for files to have been edited" +#~ msgstr "" +#~ "--remote-wait Soos '--remote', maar wag vir lêers om gewysig te " +#~ "word" + +#~ msgid "--remote-silent Same, don't complain if there is no server" +#~ msgstr "" +#~ "--remote-silent Dieselfde, moet nie kla as daar nie so 'n " +#~ "bediener is nie" + +#~ msgid "--remote \tEdit in a Vim server if possible" +#~ msgstr "" +#~ "--remote \tWysig die in a Vim bediener indien moontlik" + +#~ msgid "-X\t\t\tDo not connect to X server" +#~ msgstr "-X\t\t\tMoet nie verbinding met X-bediener maak nie" + +#~ msgid "-display \tConnect vim to this particular X-server" +#~ msgstr "-display \tKoppel vim aan hierdie X-bediener" + +#~ msgid "-x\t\t\tEdit encrypted files" +#~ msgstr "-x\t\t\tBewerk geënkripteerde lêers" + +#~ msgid "-U \t\tUse instead of any .gvimrc" +#~ msgstr "-U \t\tGebruik in plaas van enige .gvimrc" + +#~ msgid "-dev \t\tUse for I/O" +#~ msgstr "-dev \t\tGebruik vir I/O" + +#~ msgid "-f\t\t\tDon't use newcli to open window" +#~ msgstr "-f\t\t\tMoet nie 'newcli' gebruik om venster oop te maak nie" + +#~ msgid "-V[N]\t\tVerbose level" +#~ msgstr "-V[N]\t\tOmslagtigheidsgraad" + +#~ msgid "-f or --nofork\tForeground: Don't fork when starting GUI" +#~ msgstr "-f of --nofork\tVoorgrond: Moenie vurk wanneer GUI begin nie" + +#~ msgid "-g\t\t\tRun using GUI (like \"gvim\")" +#~ msgstr "-g\t\t\tVoer uit met die GUI (soos \"gvim\")" + +#~ msgid "-unregister\t\tUnregister gvim for OLE" +#~ msgstr "-unregister\t\tOnregistreer gvim vir OLE" + +#~ msgid "-register\t\tRegister this gvim for OLE" +#~ msgstr "-register\t\tRegistreer hierdie gvim vir OLE" + +#~ msgid "This Vim was not compiled with the diff feature." +#~ msgstr "Hierdie Vim is nie gekompileer met 'diff' funksionaliteit nie." + +#~ msgid "E251: VIM instance registry property is badly formed. Deleted!" +#~ msgstr "E251: VIM instansie register-kenmerk is swak gevorm. Geskrap!" + +#~ msgid "E248: Failed to send command to the destination program" +#~ msgstr "E248: Het gefaal om bevel na doel program te stuur" + +#~ msgid "Unable to register a command server name" +#~ msgstr "Kon nie bevelbediener naam registreer nie" + +#~ msgid "cannot get line" +#~ msgstr "kan nie reël kry nie" + +#~ msgid "" +#~ "E281: TCL ERROR: exit code is not int!? Please report this to vim-dev@vim." +#~ "org" +#~ msgstr "" +#~ "E281: TCL FOUT: verlaatkode is nie 'n 'int'!? Rapporteer dit asb. aan " +#~ "" + +#~ msgid "" +#~ "E571: Sorry, this command is disabled: the Tcl library could not be " +#~ "loaded." +#~ msgstr "" +#~ "E571: Jammer, hierdie bevel is afgeskakel, die Tcl biblioteek kon nie " +#~ "gelaai word nie." + +#~ msgid "cannot register callback command: buffer/window reference not found" +#~ msgstr "" +#~ "kan terugroepbevel nie registreer nie: buffer/vensterverwysing nie gevind " +#~ "nie" + +#~ msgid "" +#~ "E280: TCL FATAL ERROR: reflist corrupt!? Please report this to vim-" +#~ "dev@vim.org" +#~ msgstr "" +#~ "E280: TCL FATALE FOUT: verwlys korrup!? Rapporteer dit asb. aan " + +#~ msgid "" +#~ "cannot register callback command: buffer/window is already being deleted" +#~ msgstr "" +#~ "kan nie terugroepbevel registreer nie: buffer/venster word alreeds geskrap" + +#~ msgid "cannot create buffer/window command: object is being deleted" +#~ msgstr "kan nie buffer/venster bevel skep nie: voorwerp word geskrap" + +#~ msgid "vim error" +#~ msgstr "vim fout" + +#~ msgid "keyboard interrupt" +#~ msgstr "sleutelbordonderbreking" + +#~ msgid "unknown vimOption" +#~ msgstr "onbekende 'vimOption'" + +#~ msgid "unknown flag: " +#~ msgstr "onbekende vlag: " + +#~ msgid "cannot insert/append line" +#~ msgstr "kan nie reël invoeg/aanlas nie" + +#~ msgid "row %d column %d" +#~ msgstr "ry %d kolom %d" + +#~ msgid "mark not set" +#~ msgstr "merker nie gestel nie" + +#~ msgid "cannot set line(s)" +#~ msgstr "kan nie reël(s) stel nie" + +#~ msgid "unknown option" +#~ msgstr "onbekende opsie" + +#~ msgid "not implemented yet" +#~ msgstr "nog nie geïmplementeer nie" + +#~ msgid "Sniff: Error during write. Disconnected" +#~ msgstr "Sniff: Fout gedurende stoor. Verbinding gebreek" + +#~ msgid "E278: SNiFF+ not connected" +#~ msgstr "E278: SNiFF+ is nie gekonnekteer nie" + +#~ msgid "E276: Error connecting to SNiFF+" +#~ msgstr "E276: Fout in konnekteer met SNiFF+" + +#~ msgid "E275: Unknown SNiFF+ request: %s" +#~ msgstr "E275: Onbekende SNiFF+ versoek: %s" + +#~ msgid "connected" +#~ msgstr "gekonnekteer" + +#~ msgid "not " +#~ msgstr "nie " + +#~ msgid "SNiFF+ is currently " +#~ msgstr "SNiFF+ is tans" + +#~ msgid "E274: Sniff: Error during read. Disconnected" +#~ msgstr "E274: Sniff: Fout gedurende lees. Verbinding gebreek" + +#~ msgid "" +#~ "Cannot connect to SNiFF+. Check environment (sniffemacs must be found in " +#~ "$PATH).\n" +#~ msgstr "" +#~ "Kan nie 'n verbinding met 'SNiFF+' maak nie. Kyk of die omgewing reg is " +#~ "('sniffemacs' moet in '$PATH' gevind word).\n" + +#~ msgid "Generate docu for" +#~ msgstr "Genereer 'docu' vir" + +#~ msgid "Show docu of" +#~ msgstr "Wys 'docu' van" + +#~ msgid "Xref used by" +#~ msgstr "Xref gebruik deur" + +#~ msgid "Xref has a" +#~ msgstr "Xref het 'n" + +#~ msgid "Xref referred by" +#~ msgstr "Xref verwys deur" + +#~ msgid "Xref refers to" +#~ msgstr "Xref verwys na" + +#~ msgid "Show class in restricted hierarchy" +#~ msgstr "Wys klas in beperkte hiërargie" + +#~ msgid "Show class in hierarchy" +#~ msgstr "Wys klas in hiërargie" + +#~ msgid "Browse class" +#~ msgstr "Kyk klas deur" + +#~ msgid "Find symbol" +#~ msgstr "Vind simbool" + +#~ msgid "Show source of" +#~ msgstr "Wys kode van" + +#~ msgid "Retrieve" +#~ msgstr "Gaan haal" + +#~ msgid "Retrieve from all projects" +#~ msgstr "Gaan haal uit alle projekte" + +#~ msgid "Retrieve from project" +#~ msgstr "Gaan haal uit projek" + +#~ msgid "Retrieve from file" +#~ msgstr "Gaan haal uit lêer" + +#~ msgid "Show overridden member function" +#~ msgstr "Wys vervangde lidfunksie" + +#~ msgid "Show base class of" +#~ msgstr "Wys basisklas van" + +#~ msgid "Toggle implementation/definition" +#~ msgstr "Stel en herstel implimentasie/definisie" + +#~ msgid "E273: unknown longjmp status %d" +#~ msgstr "E273: Onbekende 'longjmp' status %d" + +#~ msgid "" +#~ "E266: Sorry, this command is disabled, the Ruby library could not be " +#~ "loaded." +#~ msgstr "" +#~ "E266: Jammer, hierdie bevel is afgeskakel, die Ruby biblioteeklêer kon " +#~ "nie gelaai word nie." + +#~ msgid "string cannot contain newlines" +#~ msgstr "string kan nie 'newlines' bevat nie" + +#~ msgid "cannot insert line" +#~ msgstr "kan reël nie byvoeg nie" + +#~ msgid "cannot replace line" +#~ msgstr "kan reël nie vervang nie" + +#~ msgid "cannot delete line" +#~ msgstr "kan reël nie verwyder nie" + +#~ msgid "no such window" +#~ msgstr "geen sodanige venster nie" + +#~ msgid "" +#~ msgstr "" + +#~ msgid "" +#~ msgstr "" + +#~ msgid "" +#~ msgstr "" -#~ msgid "Cannot create " -#~ msgstr "Kan nie skep nie: " +#~ msgid "cursor position outside buffer" +#~ msgstr "loperposisie buite buffer" -#~ msgid "Vim exiting with %d\n" -#~ msgstr "Vim stop met %d\n" +#~ msgid "readonly attribute" +#~ msgstr "leesalleen eienskap" -#~ msgid "cannot change console mode ?!\n" -#~ msgstr "kan konsole-modus nie verander nie ?!\n" +#~ msgid "attempt to refer to deleted window" +#~ msgstr "poging om na geskrapte venster te verwys" -#~ msgid "mch_get_shellsize: not a console??\n" -#~ msgstr "'mch_get_shellsize': nie 'n konsole nie??\n" +#~ msgid "no such buffer" +#~ msgstr "buffer bestaan nie" -#~ msgid "Cannot execute " -#~ msgstr "Kan nie uitvoer nie " +#~ msgid "invalid mark name" +#~ msgstr "onbekende merknaam" -#~ msgid "shell " -#~ msgstr "dop " +#~ msgid "" +#~ msgstr "" -#~ msgid " returned\n" -#~ msgstr " teruggekeer\n" +#~ msgid "line number out of range" +#~ msgstr "reëlnommer buite omvang" -#~ msgid "ANCHOR_BUF_SIZE too small." -#~ msgstr "'ANCHOR_BUF_SIZE' is te klein" +#~ msgid "attempt to refer to deleted buffer" +#~ msgstr "poging om na 'n geskrapte buffer te verwys" -#~ msgid "I/O ERROR" -#~ msgstr "I/O FOUT" +#~ msgid "expressions disabled at compile time" +#~ msgstr "uitdrukkings afgeskakel tydens kompilering" -#~ msgid "...(truncated)" -#~ msgstr "...(afgekap)" +# njj: net 'n voorstel .. +#~ msgid "invalid expression" +#~ msgstr "ongeldige uitdrukking" -#~ msgid "'columns' is not 80, cannot execute external commands" -#~ msgstr "'columns' is nie 80 nie, kan nie eksterne bevele uitvoer nie" +#~ msgid "E264: Python: Error initialising I/O objects" +#~ msgstr "E264: Python: Kon nie I/O objekte inwy nie" -#~ msgid "to %s on %s" -#~ msgstr "na %s op %s" +#~ msgid "writelines() requires list of strings" +#~ msgstr "'writelines()' benodig 'n lys van stringe" -#~ msgid "E613: Unknown printer font: %s" -#~ msgstr "E613: Onbekende drukker font: %s" +#~ msgid "invalid attribute" +#~ msgstr "ongeldige eienskap" -#~ msgid "E238: Print error: %s" -#~ msgstr "E238: Drukfout: %s" +#~ msgid "softspace must be an integer" +#~ msgstr "'softspace' moet 'n heelgetal wees" -#~ msgid "Printing '%s'" -#~ msgstr "Druk nou '%s'" +#~ msgid "can't delete OutputObject attributes" +#~ msgstr "kan nie 'OutputObject' eienskappe skrap nie" -#~ msgid "E244: Illegal charset name \"%s\" in font name \"%s\"" -#~ msgstr "E244: Ongeldige karakterstelnaam \"%s\" in fontnaam \"%s\"" +#~ msgid "E659: Cannot invoke Python recursively" +#~ msgstr "E659: Kan nie Python rekursief roep nie" -#~ msgid "E245: Illegal char '%c' in font name \"%s\"" -#~ msgstr "E245: Ongeldige karakter '%c' in fontnaam \"%s\"" +#~ msgid "" +#~ "E263: Sorry, this command is disabled, the Python library could not be " +#~ "loaded." +#~ msgstr "" +#~ "E263: Jammer, hierdie bevel is afgeskakel, die Python biblioteek lêer kon " +#~ "nie gelaai word nie." -#~ msgid "Vim: Double signal, exiting\n" -#~ msgstr "Vim: Dubbel sein, staak\n" +#~ msgid "E569: maximum number of cscope connections reached" +#~ msgstr "E569: maksimum aantal 'cscope' verbindings bereik" -#~ msgid "Vim: Caught deadly signal %s\n" -#~ msgstr "Vim: Het dodelike sein %s gevang\n" +#~ msgid "E626: cannot get cscope database information" +#~ msgstr "E626: kan nie 'cscope' databasisinligting kry nie" -#~ msgid "Vim: Caught deadly signal\n" -#~ msgstr "Vim: Het dodelike sein gevang\n" +#~ msgid "E625: cannot open cscope database: %s" +#~ msgstr "E625: Kon nie 'cscope' databasis oopmaak nie: %s" -#~ msgid "Opening the X display took % msec" -#~ msgstr "Om die X-vertoonskerm oop te maak het % msek gevat" +#~ msgid "E563: stat error" +#~ msgstr "E563: 'stat' fout" + +#~ msgid "E256: Hangul automata ERROR" +#~ msgstr "E256: Hangul outomatiserings FOUT" #~ msgid "" +#~ "Font1 width: %\n" #~ "\n" -#~ "Vim: Got X error\n" #~ msgstr "" +#~ "Font1 wydte: %\n" #~ "\n" -#~ "Vim: Het X fout ontvang\n" -#~ msgid "Testing the X display failed" -#~ msgstr "Toetsing van die X-vertoonskerm het gefaal" +#~ msgid "Font0 width: %\n" +#~ msgstr "Font0 wydte: %\n" -#~ msgid "Opening the X display timed out" -#~ msgstr "Oopmaak van die X-vertoonskerm het uitgetel" +#~ msgid "Font% width is not twice that of font0\n" +#~ msgstr "Font% wydte is nie twee keer díe van font0 nie\n" -#~ msgid "" -#~ "\n" -#~ "Cannot execute shell sh\n" -#~ msgstr "" -#~ "\n" -#~ "Kan nie dop 'sh' uitvoer nie\n" +#~ msgid "Font1: %s\n" +#~ msgstr "Font1: %s\n" -#~ msgid "" -#~ "\n" -#~ "Cannot create pipes\n" -#~ msgstr "" -#~ "\n" -#~ "Kan nie pype skep nie\n" +#~ msgid "Font0: %s\n" +#~ msgstr "Font0: %s\n" -#~ msgid "" -#~ "\n" -#~ "Cannot fork\n" +#~ msgid "E253: Fontset name: %s\n" +#~ msgstr "E253: Fonstel naam: %s\n" + +#~ msgid "Font '%s' is not fixed-width" +#~ msgstr "Font '%s' is nie 'n vaste-wydte font nie" + +#~ msgid "E252: Fontset name: %s" +#~ msgstr "E252: Fontstel naam: %s" + +#~ msgid "E250: Fonts for the following charsets are missing in fontset %s:" #~ msgstr "" -#~ "\n" -#~ "Kan nie vurk nie\n" +#~ "E250: Fonte vir die volgende karakterstelle ontbreek in fontversameling " +#~ "%s:" #~ msgid "" -#~ "\n" -#~ "Command terminated\n" +#~ "Vim E458: Cannot allocate colormap entry, some colors may be incorrect" #~ msgstr "" -#~ "\n" -#~ "Bevel beëindig\n" +#~ "Vim E458: Kan nie kleurkaart-inskrywing toeken nie, sommige kleure mag " +#~ "verkeerd wees" -#~ msgid "XSMP lost ICE connection" -#~ msgstr "XSMP het ICE konneksie verloor" +#~ msgid "Find & Replace (use '\\\\' to find a '\\')" +#~ msgstr "Vind & vervang string (gebruik '\\\\' om 'n '\\' te vind" -#~ msgid "Opening the X display failed" -#~ msgstr "Oopmaak van die X vertoonskerm het gefaal" +#~ msgid "Find string (use '\\\\' to find a '\\')" +#~ msgstr "Vind string (gebruik '\\\\' om 'n '\\' te vind" -#~ msgid "XSMP handling save-yourself request" -#~ msgstr "XSMP hanteer 'save-yourself' versoek" +#~ msgid "E672: Unable to open window inside MDI application" +#~ msgstr "E672: Kon nie venster oopmaak binne 'n MDI toepassing nie" -#~ msgid "XSMP opening connection" -#~ msgstr "XSMP maak nou konneksie oop" +#~ msgid "E243: Argument not supported: \"-%s\"; Use the OLE version." +#~ msgstr "E243: Parameter nie bekend: \"-%s\"; Gebruik die OLE weergawe." -#~ msgid "XSMP ICE connection watch failed" -#~ msgstr "XSMP ICE konneksie beloer het gefaal" +#~ msgid "Undo" +#~ msgstr "Herroep" -#~ msgid "XSMP SmcOpenConnection failed: %s" -#~ msgstr "XSMP 'SmcOpenConnection' het gefaal: %s" +#~ msgid "Selection" +#~ msgstr "Seleksie" -#~ msgid "At line" -#~ msgstr "By reël" +#~ msgid "Files" +#~ msgstr "Lêers" -#~ msgid "Could not allocate memory for command line." -#~ msgstr "Kan nie geheue toeken vir bevelreël nie" +#~ msgid "Help" +#~ msgstr "Hulp" -#~ msgid "VIM Error" -#~ msgstr "VIM Fout" +#~ msgid "Directories" +#~ msgstr "Gidse" -#~ msgid "Could not load vim32.dll!" -#~ msgstr "Kon nie 'vim32.dll' laai nie!" +#~ msgid "Filter" +#~ msgstr "Filter" -#~ msgid "Could not fix up function pointers to the DLL!" -#~ msgstr "Kon nie funksiewysers na die DLL opstel nie!" +#~ msgid "Used CUT_BUFFER0 instead of empty selection" +#~ msgstr "'CUT_BUFFER0' is gebruik in plaas van leë seleksie" -#~ msgid "shell returned %d" -#~ msgstr "dop het %d gelewer" +#~ msgid "Font Selection" +#~ msgstr "Fontkeuse" -#~ msgid "Vim: Caught %s event\n" -#~ msgstr "Vim: Het %s gebeurtenis gevang\n" +#~ msgid "Vim: Main window unexpectedly destroyed\n" +#~ msgstr "Vim: Hoofvenster onverwags verwoes\n" -#~ msgid "close" -#~ msgstr "maak toe" +#~ msgid "Vim: Received \"die\" request from session manager\n" +#~ msgstr "Vim: Het die \"die\" opdrag ontvang van sessiebestuurder\n" -#~ msgid "logoff" -#~ msgstr "teken uit" +#~ msgid "Replace All" +#~ msgstr "Vervang alles" -#~ msgid "shutdown" -#~ msgstr "sit af" +#~ msgid "Replace" +#~ msgstr "Vervang" -#~ msgid "E371: Command not found" -#~ msgstr "E371: Bevel nie gevind nie" +#~ msgid "Find Next" +#~ msgstr "Vind volgende" -#~ msgid "" -#~ "VIMRUN.EXE not found in your $PATH.\n" -#~ "External commands will not pause after completion.\n" -#~ "See :help win32-vimrun for more information." -#~ msgstr "" -#~ "'VIMRUN.EXE' nie gevind in '$PATH' nie.\n" -#~ "Eksterne opdragte sal nie wag na voltooiing nie\n" -#~ "Sien ':help win32-vimrun' vir meer inligting." +#~ msgid "Down" +#~ msgstr "Af" -#~ msgid "Vim Warning" -#~ msgstr "Vim Waarskuwing" +#~ msgid "Up" +#~ msgstr "Op" -#~ msgid "E56: %s* operand could be empty" -#~ msgstr "E56: %s* operand mag leeg wees" +#~ msgid "Direction" +#~ msgstr "Rigting" -#~ msgid "E57: %s+ operand could be empty" -#~ msgstr "E57: %s+ operand mag leeg wees" +#~ msgid "Match case" +#~ msgstr "Tref kas" -#~ msgid "E58: %s{ operand could be empty" -#~ msgstr "E58: %s{ operand mag leeg wees" +#~ msgid "Match whole word only" +#~ msgstr "Tref slegs presiese woord" -#~ msgid "E361: Crash intercepted; regexp too complex?" -#~ msgstr "E361: Ineenstorting onderskep. Patroon te kompleks?" +#~ msgid "Replace with:" +#~ msgstr "Vervang met:" -#~ msgid "E363: pattern caused out-of-stack error" -#~ msgstr "E363: patroon het lëe-stapel fout veroorsaak" +#~ msgid "Find what:" +#~ msgstr "Soek na:" -#~ msgid "E396: containedin argument not accepted here" -#~ msgstr "E396: 'containedin' parameter nie hier aanvaar nie" +#~ msgid "VIM - Search..." +#~ msgstr "VIM - Soek..." -#~ msgid "Enter nr of choice ( to abort): " -#~ msgstr "Sleutel nommer van keuse in ( om te stop): " +#~ msgid "VIM - Search and Replace..." +#~ msgstr "VIM - Soek en Vervang..." -#~ msgid "E430: Tag file path truncated for %s\n" -#~ msgstr "E430: Etiketlêergids afgekap vir %s\n" +#~ msgid "Input _Methods" +#~ msgstr "Invoer _Metodes" -#~ msgid "new shell started\n" -#~ msgstr "nuwe dop begin\n" +#~ msgid "Vim dialog..." +#~ msgstr "Vim dialooghokkie..." -#~ msgid "No undo possible; continue anyway" -#~ msgstr "Geen herstel moontlik; gaan in elk geval voort" +#~ msgid "E599: Value of 'imactivatekey' is invalid" +#~ msgstr "E599: Waarde van 'imactivatekey' is ongeldig" -#~ msgid "" -#~ "\n" -#~ "MS-Windows 16/32-bit GUI version" -#~ msgstr "" -#~ "\n" -#~ "MS-Windows 16/32-bis GUI weergawe" +#~ msgid "E231: 'guifontwide' invalid" +#~ msgstr "E231: 'guifontwide' ongeldig" -#~ msgid "" -#~ "\n" -#~ "MS-Windows 32-bit GUI version" -#~ msgstr "" -#~ "\n" -#~ "MS-Windows 32-bis GUI version" +#~ msgid "E665: Cannot start GUI, no valid font found" +#~ msgstr "E665: Kan nie GUI begin nie, geen geldige font gevind nie" -#~ msgid " in Win32s mode" -#~ msgstr " in Win32s modus" +#~ msgid "E230: Cannot read from \"%s\"" +#~ msgstr "E230: Kan nie lees uit \"%s\" nie" -#~ msgid " with OLE support" -#~ msgstr " met OLE ondersteuning" +#~ msgid "E229: Cannot start the GUI" +#~ msgstr "E229: Kan nie die GUI begin nie" -#~ msgid "" -#~ "\n" -#~ "MS-Windows 32-bit console version" -#~ msgstr "" -#~ "\n" -#~ "MS-Windows 32-bis konsole weergawe" +#~ msgid "E232: Cannot create BalloonEval with both message and callback" +#~ msgstr "E232: Kan nie BalloonEval skep met beide boodskap en terugroep nie" -#~ msgid "" -#~ "\n" -#~ "MS-Windows 16-bit version" +#~ msgid "Scrollbar Widget: Could not get geometry of thumb pixmap." #~ msgstr "" -#~ "\n" -#~ "MS-Windows 16-bis weergawe" +#~ "Rolstaafelement: Kon nie pikselmatriks-duimnael se geometrie kry nie" -#~ msgid "" -#~ "\n" -#~ "32-bit MS-DOS version" -#~ msgstr "" -#~ "\n" -#~ "32-bis MS-DOS weergawe" +#~ msgid "Vim dialog" +#~ msgstr "Vim dialooghokkie" -#~ msgid "" -#~ "\n" -#~ "16-bit MS-DOS version" -#~ msgstr "" -#~ "\n" -#~ "16-bis MS-DOS weergawe" +#~ msgid "Cancel" +#~ msgstr "Kanselleer" -#~ msgid "" -#~ "\n" -#~ "MacOS X (unix) version" -#~ msgstr "" -#~ "\n" -#~ "MacOS X (unix) weergawe" +#~ msgid "OK" +#~ msgstr "OK" -#~ msgid "" -#~ "\n" -#~ "MacOS X version" -#~ msgstr "" -#~ "\n" -#~ "MacOS X weergawe" +#~ msgid "E615: vim_SelFile: can't get current directory" +#~ msgstr "E615: vim_SelFile: Kan nie huidige gids verkry nie" -#~ msgid "" -#~ "\n" -#~ "MacOS version" -#~ msgstr "" -#~ "\n" -#~ "MacOS weergawe" +#~ msgid "Pathname:" +#~ msgstr "Gidsnaam:" -#~ msgid "" -#~ "\n" -#~ "RISC OS version" -#~ msgstr "" -#~ "\n" -#~ "RISC OS weergawe" +#~ msgid "E614: vim_SelFile: can't return to current directory" +#~ msgstr "E614: 'vim_SelFile': Kan nie terugkeer na huidige gids nie" -#~ msgid "" -#~ "\n" -#~ "Big version " -#~ msgstr "" -#~ "\n" -#~ "Groot weergawe " +#~ msgid "E616: vim_SelFile: can't get font %s" +#~ msgstr "E616: 'vim_SelFile': kan font %s nie kry nie" -#~ msgid "" -#~ "\n" -#~ "Normal version " -#~ msgstr "" -#~ "\n" -#~ "Normale weergawe " +#~ msgid " " +#~ msgstr " " -#~ msgid "" -#~ "\n" -#~ "Small version " -#~ msgstr "" -#~ "\n" -#~ "Klein weergawe " +#~ msgid "E460: The resource fork would be lost (add ! to override)" +#~ msgstr "E460: Die hulpbronvurk sal verlore gaan (gebruik ! om te dwing)" -#~ msgid "" -#~ "\n" -#~ "Tiny version " -#~ msgstr "" -#~ "\n" -#~ "Piepklein weergawe " +#~ msgid "Partial writes disallowed for NetBeans buffers" +#~ msgstr "Gedeeltelike skryf word nie toegelaat vir NetBeans buffers nie" -#~ msgid "with GTK2-GNOME GUI." -#~ msgstr "met GTK2-GNOME GUI." +#~ msgid "NetBeans disallows writes of unmodified buffers" +#~ msgstr "NetBeans laat nie skryf toe van onveranderde buffers nie" -#~ msgid "with GTK-GNOME GUI." -#~ msgstr "met GTK-GNOME GUI." +#~ msgid "[CONVERSION ERROR]" +#~ msgstr "[OMSETTINGSFOUT]" -#~ msgid "with GTK2 GUI." -#~ msgstr "met GTK2 GUI" +#~ msgid "[crypted]" +#~ msgstr "[gekodeer]" -#~ msgid "with GTK GUI." -#~ msgstr "met GTK GUI" +#~ msgid "[NL found]" +#~ msgstr "[NL gevind]" -#~ msgid "with X11-Motif GUI." -#~ msgstr "met X11-Motif GUI." +#~ msgid "E196: No digraphs in this version" +#~ msgstr "E196: Geen digrawe in hierdie weergawe nie" -#~ msgid "with X11-neXtaw GUI." -#~ msgstr "met X11-neXtaw GUI" +#~ msgid "Save Setup" +#~ msgstr "Stoor konfigurasie" -#~ msgid "with X11-Athena GUI." -#~ msgstr "met X11-Athena GUI" +#~ msgid "Save Session" +#~ msgstr "Stoor Sessie" -#~ msgid "with BeOS GUI." -#~ msgstr "met BeOS GUI" +#~ msgid "Save View" +#~ msgstr "Stoor Oorsig" -#~ msgid "with Photon GUI." -#~ msgstr "met Photon GUI." +#~ msgid "Save Redirection" +#~ msgstr "Stoor Herversturing" -#~ msgid "with GUI." -#~ msgstr "met GUI." +#~ msgid "Window position: X %d, Y %d" +#~ msgstr "Vensterposisie: X %d, Y %d" -#~ msgid "with Carbon GUI." -#~ msgstr "met Carbon GUI." +#~ msgid "Append File" +#~ msgstr "Las aan by lêer" -#~ msgid "with Cocoa GUI." -#~ msgstr "met Cocoa GUI." +#~ msgid "Edit File in new window" +#~ msgstr "Bewerk lêer in nuwe venster" -#~ msgid "with (classic) GUI." -#~ msgstr "met (klassieke) GUI." +#~ msgid " (NOT FOUND)" +#~ msgstr " (NIE GEVIND NIE)" -#~ msgid " system gvimrc file: \"" -#~ msgstr " stelsel gvimrc-lêer: \"" +#~ msgid "Edit File" +#~ msgstr "Verander lêer" -#~ msgid " user gvimrc file: \"" -#~ msgstr " gebruiker gvimrc-lêer: \"" +#~ msgid "Source Vim script" +#~ msgstr "Voer Vim skrip uit" -#~ msgid "2nd user gvimrc file: \"" -#~ msgstr "2de gebruiker gvimrc-lêer: \"" +#~ msgid "Save As" +#~ msgstr "Stoor As" -#~ msgid "3rd user gvimrc file: \"" -#~ msgstr "3de gebruiker gvimrc-lêer: \"" +#~ msgid "E130: Undefined function: %s" +#~ msgstr "E130: Ongedefinieerde funksie: %s" -#~ msgid " system menu file: \"" -#~ msgstr " stelsel kieslys-lêer: \"" +#~ msgid "E277: Unable to read a server reply" +#~ msgstr "E277: Kon bediener-terugvoer nie lees nie" -#~ msgid "Compiler: " -#~ msgstr "Kompileerder: " +#~ msgid "E240: No connection to Vim server" +#~ msgstr "E240: Geen verbinding met Vim bediener" -#~ msgid "menu Help->Orphans for information " -#~ msgstr "menu Hulp->Weeskinders vir meer inligting hieroor " +#~ msgid "" +#~ "&OK\n" +#~ "&Cancel" +#~ msgstr "" +#~ "&OK\n" +#~ "&Kanselleer" -#~ msgid "Running modeless, typed text is inserted" -#~ msgstr "Voer modus-loos uit, getikte teks word ingevoeg" +#~ msgid "E106: Unknown variable: \"%s\"" +#~ msgstr "E106: Onbekende veranderlike: \"%s\"" -#~ msgid "menu Edit->Global Settings->Toggle Insert Mode " -#~ msgstr "menu Redigeer->Globale verstellings->Stel en herstel Invoeg Modus" +#~ msgid "Patch file" +#~ msgstr "Laslap lêer" -#~ msgid " for two modes " -#~ msgstr " vir twee modusse " +#~ msgid "[No File]" +#~ msgstr "[Geen lêer]" -#~ msgid "menu Edit->Global Settings->Toggle Vi Compatible" -#~ msgstr "menu Redigeer->Global verstellings->Stel en herstel Vi Versoenbaar" +#~ msgid "[Error List]" +#~ msgstr "[Foutlys]" -#~ msgid " for Vim defaults " -#~ msgstr " vir Vim verstekwaardes" +#~ msgid "type :help cp-default for info on this" +#~ msgstr "tik :help cp-default vir meer inligting hieroor" -#~ msgid "WARNING: Windows 95/98/ME detected" -#~ msgstr "WAARSKUWING: Windows 95/98/ME bespeur" +#~ msgid "type :set nocp for Vim defaults" +#~ msgstr "tik :set nocp vir Vim verstekwaardes " -#~ msgid "type :help windows95 for info on this" -#~ msgstr "tik :help windows95 vir meer inligting hieroor" +#~ msgid "Running in Vi compatible mode" +#~ msgstr "Voer tans uit in Vi-versoenbare modus" -#~ msgid "E370: Could not load library %s" -#~ msgstr "E370: Kon nie biblioteek laai nie %s" +#~ msgid "type :help version7 for version info" +#~ msgstr "tik :help version7 vir weergawe-inligting" -#~ msgid "" -#~ "Sorry, this command is disabled: the Perl library could not be loaded." -#~ msgstr "" -#~ "Jammer, hierdie bevel is afgeskakel: die Perl biblioteek kon nie gelaai " -#~ "word nie." +#~ msgid "type :help or for on-line help" +#~ msgstr "tik :help of vir aanlyn hulp " -#~ msgid "E299: Perl evaluation forbidden in sandbox without the Safe module" -#~ msgstr "" -#~ "E299: Perl evaluasie verbied in die sandput sonder die 'Safe' module" +#~ msgid "by Bram Moolenaar et al." +#~ msgstr "deur Bram Moolenaar et al." -#~ msgid "Edit with &multiple Vims" -#~ msgstr "Wysig met &meer as een Vim" +# njj: :)) +#~ msgid "version " +#~ msgstr "Weergawe " -#~ msgid "Edit with single &Vim" -#~ msgstr "Wysig met 'n enkel &Vim" +#~ msgid "VIM - Vi IMproved" +#~ msgstr "VIM - Vi Met skop" -#~ msgid "&Diff with Vim" -#~ msgstr "Wys verskille ('&diff') met Vim" +#~ msgid " DEBUG BUILD" +#~ msgstr " ONTFOUTINGS-KOMPILERING" -#~ msgid "Edit with &Vim" -#~ msgstr "Wysig met &Vim" +#~ msgid "Linking: " +#~ msgstr "Koppeling: " -#~ msgid "Edit with existing Vim - &" -#~ msgstr "Wysig met bestaande Vim - &" +#~ msgid "Compilation: " +#~ msgstr "Kompilering: " -#~ msgid "Edits the selected file(s) with Vim" -#~ msgstr "Wysig die gekose lêer(s) met Vim" +#~ msgid " 2nd user exrc file: \"" +#~ msgstr " 2de gebruiker exrc-lêer: \"" -#~ msgid "Error creating process: Check if gvim is in your path!" -#~ msgstr "FOut met die skep van proses: Kyk of gvim in jou pad is!" +#~ msgid " user exrc file: \"" +#~ msgstr " gebruiker exrc-lêer: \"" -#~ msgid "gvimext.dll error" -#~ msgstr "'gvimext.dll' fout" +#~ msgid " 3rd user vimrc file: \"" +#~ msgstr " 3de gebruiker vimrc-lêer \"" -#~ msgid "Path length too long!" -#~ msgstr "Pad-lengte te lank" +#~ msgid " 2nd user vimrc file: \"" +#~ msgstr " 2de gebruiker vimrc-lêer \"" -#~ msgid "E234: Unknown fontset: %s" -#~ msgstr "E234: Onbekende fontstel: %s" +#~ msgid " user vimrc file: \"" +#~ msgstr " gebruiker vimrc-lêer: \"" -#~ msgid "E235: Unknown font: %s" -#~ msgstr "E235: Onbekende font: %s" +#~ msgid " Features included (+) or not (-):\n" +#~ msgstr " Kenmerke in- (+) of uitgesluit (-):\n" -#~ msgid "E448: Could not load library function %s" -#~ msgstr "E448: Kon nie biblioteek funksie laai nie %s" +#~ msgid "without GUI." +#~ msgstr "sonder GUI." -#~ msgid "E26: Hebrew cannot be used: Not enabled at compile time\n" +#~ msgid "" +#~ "\n" +#~ "Huge version " #~ msgstr "" -#~ "E26: Hebreeus kan nie gebruik word nie: Nie tydens kompilering gekies " -#~ "nie\n" +#~ "\n" +#~ "Enorme weergawe " -#~ msgid "E27: Farsi cannot be used: Not enabled at compile time\n" +#~ msgid "Modified by " +#~ msgstr "Gewysig deur " + +#, fuzzy +#~ msgid "" +#~ "\n" +#~ "Extra patches: " +#~ msgstr "Eksterne subtreffers:\n" + +#~ msgid "" +#~ "\n" +#~ "Included patches: " #~ msgstr "" -#~ "E27: Farsi kan nie gebruik word nie: Nie tydens kompilering gekies nie\n" +#~ "\n" +#~ "Ingeslote laslappies:" -#~ msgid "E800: Arabic cannot be used: Not enabled at compile time\n" +#~ msgid "" +#~ "\n" +#~ "--- Terminal keys ---" #~ msgstr "" -#~ "E800: Arabies kan nie gebruik word nie: Nie tydens kompilering gekies " -#~ "nie\n" +#~ "\n" +#~ "--- Terminaal sleutels ---" -#~ msgid "E247: no registered server named \"%s\"" -#~ msgstr "E247: geen geregistreerde bediener genaamd \"%s\"" +#~ msgid "E437: terminal capability \"cm\" required" +#~ msgstr "E437: terminaalvermoë \"cm\" vereis" -#~ msgid "E233: cannot open display" -#~ msgstr "E233: kan nie vertoonskerm oopmaak nie" +#~ msgid "E436: No \"%s\" entry in termcap" +#~ msgstr "E436: Geen \"%s\" inskrywing in termcap nie" -#~ msgid "E463: Region is guarded, cannot modify" -#~ msgstr "E463: Omgewing is onder bewaking, kan nie verander nie" +#~ msgid "E559: Terminal entry not found in termcap" +#~ msgstr "E559: Terminaalinskrywing nie in 'termcap' gevind nie" -#~ msgid "function " -#~ msgstr "funksie " +#~ msgid "E558: Terminal entry not found in terminfo" +#~ msgstr "E558: Terminaalinskrywing nie in 'terminfo' gevind nie" -#~ msgid "Run Macro" -#~ msgstr "Voer Makro uit" +#~ msgid "E557: Cannot open termcap file" +#~ msgstr "E557: Kan nie 'termcap'-lêer oopmaak nie" -#~ msgid "E242: Color name not recognized: %s" -#~ msgstr "E242: Kleurnaam is onbekend: %s" +#~ msgid "defaulting to '" +#~ msgstr "gebruik verstek '" -#~ msgid "error reading cscope connection %d" -#~ msgstr "'cscope' verbinding %d kon nie gelees word nie" +#~ msgid "' not known. Available builtin terminals are:" +#~ msgstr "' onbekend. Beskikbare ingeboude terminale is:" -#~ msgid "E260: cscope connection not found" -#~ msgstr "E260: 'cscope' verbinding nie gevind nie" +#~ msgid "E422: terminal code too long: %s" +#~ msgstr "E422: terminaalkode te lank: %s" -#~ msgid "cscope connection closed" -#~ msgstr "'cscope' verbinding gesluit" +#, fuzzy +#~ msgid "Substitute " +#~ msgstr "1 vervanging" -# njj: dalk 'verbinding' ipv 'verbinding' orals? -#~ msgid "couldn't malloc\n" -#~ msgstr "kon nie 'malloc' nie\n" +#~ msgid " (lang)" +#~ msgstr " (taal)" -#~ msgid "%2d %-5ld %-34s \n" -#~ msgstr "%2d %-5ld %-34s \n" +#~ msgid "" +#~ "\n" +#~ "Cannot execute shell " +#~ msgstr "" +#~ "\n" +#~ "Kan nie dop uitvoer nie " -#~ msgid "E249: couldn't read VIM instance registry property" -#~ msgstr "E249: kon nie VIM instansie register-kenmerk lees nie" +#~ msgid "E522: Not found in termcap" +#~ msgstr "E522: Nie gevind in 'termcap' nie" -#~ msgid "\"\n" -#~ msgstr "\"\n" +#~ msgid "Thanks for flying Vim" +#~ msgstr "Dankie dat jy vlieg met Vim" -#~ msgid "--help\t\tShow Gnome arguments" -#~ msgstr "--help\t\tWys Gnome parameters" +#~ msgid "%<%f%h%m%=Page %N" +#~ msgstr "%<%f%h%m%=Bladsy %N" -#~ msgid "1 line ~ed" -#~ msgstr "1 reël ge-~" +#~ msgid "E574: Unknown register type %d" +#~ msgstr "E574: Onbekende registertipe %d" -#~ msgid "% lines ~ed" -#~ msgstr "% reëls ge-~" +#~ msgid "" +#~ "\n" +#~ "# Registers:\n" +#~ msgstr "" +#~ "\n" +#~ "# Registers:\n" -#~ msgid " BLOCK" -#~ msgstr " BLOK" +#~ msgid "Illegal register name" +#~ msgstr "Ongeldige registernaam" -#~ msgid " LINE" -#~ msgstr " REËL" +#~ msgid "cannot yank; delete anyway" +#~ msgstr "kan nie pluk nie: verwyder in elk geval" -#~ msgid "Linear tag search" -#~ msgstr "Liniêre etiketsoek" +#~ msgid "E337: Menu not found - check menu names" +#~ msgstr "E337: Kieslys nie gevind nie - maak seker oor die kieslys name" -#~ msgid "Binary tag search" -#~ msgstr "Binêre etiketsoek" +#~ msgid "E336: Menu path must lead to a sub-menu" +#~ msgstr "E336: Kieslyspad moet lei na 'n sub-kieslys" -#~ msgid "E258: no matches found in cscope connections" -#~ msgstr "E258: geen treffers gevind in 'cscope' verbindings nie" +#~ msgid "Swap file already exists!" +#~ msgstr "Ruillêer bestaan alreeds!" -#~ msgid "No servers found for this display" -#~ msgstr "Geen bedieners gevind vir die 'display' nie" +#, fuzzy +#~ msgid " Quit, or continue with caution.\n" +#~ msgstr " Stop, of gaan versigtig voort.\n" -#~ msgid "Missing filename" -#~ msgstr "Ontbrekende lêernaam" +#~ msgid "Missing '>'" +#~ msgstr "Ontbrekende '>'" -#~ msgid "Invalid line number: %" -#~ msgstr "Ongeldige reëlnommer: %" +#~ msgid "" +#~ "\n" +#~ "# History of marks within files (newest to oldest):\n" +#~ msgstr "" +#~ "\n" +#~ "# Geskiedenis van merkers in lêers (nuutste tot oudste):\n" -#~ msgid "Cannot use :normal from event handler" -#~ msgstr "Kan ':normal' nie vanuit gebeurtenishanteerder gebruik nie" +#~ msgid "" +#~ "\n" +#~ "# Jumplist (newest first):\n" +#~ msgstr "" +#~ "\n" +#~ "# Springlys (nuutste eerste):\n" -#~ msgid "VIM - Help on..." -#~ msgstr "VIM - Hulp met.." +#~ msgid "" +#~ "\n" +#~ "# File marks:\n" +#~ msgstr "" +#~ "\n" +#~ "# Lêermerkers:\n" -#~ msgid "Topic:" -#~ msgstr "Onderwerp:" +#~ msgid "-h or --help\tPrint Help (this message) and exit" +#~ msgstr "-h of --help\tSkryf Hulp (hierdie boodskap) en sluit" -#~ msgid "Error: During loading fontset %s" -#~ msgstr "Fout: Gedurende die laai van fontstel %s" +#~ msgid "-i \t\tUse instead of .viminfo" +#~ msgstr "-i \t\tGebruik in plaas van .viminfo" -#~ msgid "locale is not set correctly" -#~ msgstr "lokaal is nie korrek gestel nie" +#~ msgid "-W \tWrite all typed commands to file " +#~ msgstr "-W \tSkryf alle getikte bevele na lêer " -#~ msgid "For korean:" -#~ msgstr "Vir Afrikaans:" +#~ msgid "-w \tAppend all typed commands to file " +#~ msgstr "-w \tLas alle getikte bevele aan by lêer " -#~ msgid " csh: setenv LANG ko" -#~ msgstr " csh: setenv LANG af" +#~ msgid "+\t\tStart at line " +#~ msgstr "+\t\tBegin by reël " -#~ msgid " sh : export LANG=ko" -#~ msgstr " sh: export LANG=af" +#~ msgid "+\t\t\tStart at end of file" +#~ msgstr "+\t\t\tBegin by einde van lêer" -#~ msgid "fontset name: %s" -#~ msgstr "fontstel naam: %s" +#~ msgid "-O[N]\t\tLike -o but split vertically" +#~ msgstr "-O[N]\t\tSoos -o maar verdeel vertikaal" -#~ msgid "Your language Font missing" -#~ msgstr "Jou taal Font ontbreek" +#~ msgid "-u \t\tUse instead of any .vimrc" +#~ msgstr "-u \t\tGebruik in plaas van enige ander .vimrc" -#~ msgid "automata ERROR: internal" -#~ msgstr "automata FOUT: intern" +#~ msgid "-T \tSet terminal type to " +#~ msgstr "-T \tStel terminaaltipe na " -#~ msgid "cs_add_common: alloc fail #1" -#~ msgstr "'cs_add_common': toeken onsuksesvol #1" +#~ msgid "-F\t\t\tStart in Farsi mode" +#~ msgstr "-F\t\t\tBegin in Farsi modus" -#~ msgid "cs_add_common: alloc fail #2" -#~ msgstr "'cs_add_common': toeken onsuksesvol #2" +#~ msgid "-H\t\t\tStart in Hebrew mode" +#~ msgstr "-H\t\t\tBegin in Hebreeuse modus" -#~ msgid "cs_add_common: alloc fail #3" -#~ msgstr "'cs_add_common': toeken onsuksesvol #3" +#~ msgid "-A\t\t\tstart in Arabic mode" +#~ msgstr "-A\t\t\tbegin in Arabiese modus" -#~ msgid "cs_add_common: alloc fail #4" -#~ msgstr "'cs_add_common': toeken onsuksesvol #4" +#~ msgid "-L\t\t\tSame as -r" +#~ msgstr "-L\t\t\tSelfde as -r" -#~ msgid "Retrieve next symbol" -#~ msgstr "Kry volgende simbool" +#~ msgid "-r (with file name)\tRecover crashed session" +#~ msgstr "-r (met lêer naam)\tHerwin ineengestorte sessie" -#~ msgid "-- SNiFF+ commands --" -#~ msgstr "-- SNiFF+ bevele --" +#~ msgid "-r\t\t\tList swap files and exit" +#~ msgstr "-r\t\t\tLys ruillêers en verlaat vim" -#~ msgid "Unrecognized sniff request [%s]" -#~ msgstr "Onbekende sniff versoek [%s]" +#~ msgid "-D\t\t\tDebugging mode" +#~ msgstr "-D\t\t\tOntfoutmodus" -#~ msgid "Can't create input context." -#~ msgstr "Kan nie invoerkonteks skep nie." +#~ msgid "-N\t\t\tNot fully Vi compatible: 'nocompatible'" +#~ msgstr "-N\t\t\tNie ten volle Vi-versoenbaar nie: 'nocompatible'" -#~ msgid "Sorry, deleting a menu is not possible in the Athena version" -#~ msgstr "" -#~ "Jammer, in die Athena weergawe is dit onmoontlik om 'n kieslys te skrap" +#~ msgid "-C\t\t\tCompatible with Vi: 'compatible'" +#~ msgstr "-C\t\t\tVersoenbaar met Vi: 'compatible'" -#~ msgid "Out of memory" -#~ msgstr "Geheue op" +#~ msgid "-l\t\t\tLisp mode" +#~ msgstr "-l\t\t\tLisp modus" -#~ msgid "PC (32 bits Vim)" -#~ msgstr "PC (32 bisse Vim)" +#~ msgid "-b\t\t\tBinary mode" +#~ msgstr "-b\t\t\tBinêre modus" -#~ msgid "PC (16 bits Vim)" -#~ msgstr "PC (16 bisse Vim)" +#~ msgid "-Z\t\t\tRestricted mode (like \"rvim\")" +#~ msgstr "-Z\t\t\tBeperkte modus (soos \"rvim\")" -#~ msgid "Unsupported screen mode" -#~ msgstr "Ongesteunde skermmodus" +#~ msgid "-R\t\t\tReadonly mode (like \"view\")" +#~ msgstr "-R\t\t\tLeesalleen modus (soos \"view\")" -#~ msgid "deadly signal" -#~ msgstr "dodelike sein" +#~ msgid "-y\t\t\tEasy mode (like \"evim\", modeless)" +#~ msgstr "-y\t\t\tEasy modus (soos \"evim\", modusloos)" -#~ msgid "some" -#~ msgstr "sommige" +#~ msgid "-d\t\t\tDiff mode (like \"vimdiff\")" +#~ msgstr "-d\t\t\tDiff modus (soos \"vimdiff\")" -#~ msgid "Library call failed" -#~ msgstr "Biblioteekfunksieroep het gefaal" +#~ msgid "-s\t\t\tSilent (batch) mode (only for \"ex\")" +#~ msgstr "-s\t\t\tStil (bondel) modus (slegs vir \"ex\")" -#~ msgid "Cannot clear all highlight groups" -#~ msgstr "Kan nie alle uitliggroepe leegmaak nie" +#~ msgid "-e\t\t\tEx mode (like \"ex\")" +#~ msgstr "-e\t\t\tEx modus (soos \"ex\")" -#~ msgid "GUI is not running" -#~ msgstr "GUI voer nie uit nie" +#~ msgid "-v\t\t\tVi mode (like \"vi\")" +#~ msgstr "-v\t\t\tVi modus (soos \"vi\")" -#~ msgid "Command too long" -#~ msgstr "Bevel te lank" +#~ msgid "" +#~ "\n" +#~ "\n" +#~ "Arguments:\n" +#~ msgstr "" +#~ "\n" +#~ "\n" +#~ "Parameters:\n" -#~ msgid "Ambiguous mapping" -#~ msgstr "Dubbelsinnige binding" +#~ msgid "" +#~ "\n" +#~ " or:" +#~ msgstr "" +#~ "\n" +#~ " of:" -#~ msgid "Ambiguous mapping, conflicts with \"%s\"" -#~ msgstr "Dubbelsinnige binding, bots met \"%s\"" +#~ msgid " vim [arguments] " +#~ msgstr " vim [parameters] " -#~ msgid "Too many \\(" -#~ msgstr "Te veel \\(" +#~ msgid "%d files to edit\n" +#~ msgstr "%d lêers om te bewerk\n" -#~ msgid "Unmatched \\(" -#~ msgstr "Onpaar \\(" +#~ msgid "Invalid argument for" +#~ msgstr "Ongeldige parameter vir" -#~ msgid "Nested *, \\=, \\+, \\! or \\{" -#~ msgstr "Geneste *, \\=, \\+, \\! of \\{" +#~ msgid "Zero count" +#~ msgstr "Nul telling" -#~ msgid "\\= follows nothing" -#~ msgstr "\\= volg niks" +#~ msgid "Nvim: Reading from stdin...\n" +#~ msgstr "Vim: Lees nou vanaf 'stdin'...\n" -#~ msgid "\\+ follows nothing" -#~ msgstr "\\+ volg niks" +#~ msgid "Input Line" +#~ msgstr "Invoer Lyn" -#~ msgid "\\@ follows nothing" -#~ msgstr "\\@ volg niks" +#~ msgid "Expression" +#~ msgstr "Uitdrukking" -#~ msgid "\\{ follows nothing" -#~ msgstr "\\{ volg niks" +#~ msgid "Search String" +#~ msgstr "Soekstring" -#~ msgid "\\* follows nothing" -#~ msgstr "\\* volg niks" +#~ msgid "Command Line" +#~ msgstr "Bevelreël" -#~ msgid "Unexpected magic character; check META." -#~ msgstr "Onverwagte toorkarakter; kyk na META." +#~ msgid "" +#~ "\n" +#~ "# %s History (newest to oldest):\n" +#~ msgstr "" +#~ "\n" +#~ "# %s Geskiedenis (van nuutste na oudste):\n" -#~ msgid "type :help uganda if you like Vim " -#~ msgstr "tik :help uganda as jy hou van Vim " +#~ msgid "E195: Cannot open viminfo file for reading" +#~ msgstr "E195: Kan 'viminfo' lêer nie oopmaak om te lees nie" -#~ msgid " WARNING: Intel CPU detected. " -#~ msgstr " WAARSKUWING: Intel SVE bespeur. " +#~ msgid "E466: :winpos requires two number arguments" +#~ msgstr "E466: :winpos benodig twee parameters" -#~ msgid " PPC has a much better architecture. " -#~ msgstr " PPC het 'n veel beter argitektuur. " +#~ msgid "E188: Obtaining window position not implemented for this platform" +#~ msgstr "" +#~ "E188: Verkryging van vensterposisie is nie vir hierdie platform " +#~ "geïmplementeer nie" -#~ msgid "Security error: new viminfo file is a symbolic link" -#~ msgstr "Sekuriteitsfout: nuwe viminfo lêer is a simboliese skakel" +#, fuzzy +#~ msgid "" +#~ "E747: Cannot change directory, buffer is modified (add ! to override)" +#~ msgstr "E509: Kan rugsteunlêer nie skep nie (gebruik ! om te dwing)" -#~ msgid "line ~%: %s" -#~ msgstr "reël ~%: %s" +#~ msgid "E172: Only one file name allowed" +#~ msgstr "E172: Slegs een lêernaam toegelaat" -#~ msgid "makeef option not set" -#~ msgstr "'makeef' opsie nie aan nie" +#~ msgid "" +#~ "\n" +#~ "# Last Substitute String:\n" +#~ "$" +#~ msgstr "" +#~ "\n" +#~ "# Vorige Vervangstring:\n" +#~ "$" -#~ msgid "Security error: filter output is a symbolic link: %s" -#~ msgstr "Sekuriteitsfout: filter afvoer is 'n simboliese skakel" +#~ msgid "Illegal starting char" +#~ msgstr "Ongeldige beginkarakter" -#~ msgid "Security error: 'charconvert' output is a symbolic link" -#~ msgstr "Sekuriteitsfout: 'charconvert' afvoer is 'n simboliese skakel" +#~ msgid "# Value of 'encoding' when this file was written\n" +#~ msgstr "# Waarde van 'encoding' toe hierdie lêer gestoor is\n" -#~ msgid "Security error: filter input is a symbolic link: %s" -#~ msgstr "Sekuriteitsfout: filter invoer is 'n simboliese skakel" +#~ msgid "" +#~ "# You may edit it if you're careful!\n" +#~ "\n" +#~ msgstr "" +#~ "# Jy mag dit wysig as jy versigtig is!\n" +#~ "\n" -#~ msgid "Fold must be at least two lines" -#~ msgstr "'n Vou moet ten minste 2 reëls wees" +#~ msgid "# This viminfo file was generated by Vim %s.\n" +#~ msgstr "# Hierdie viminfo lêer is gegenereer deur Vim %s.\n" -#~ msgid "No fold at this line" -#~ msgstr "Geen vou by hierdie reël nie" +#~ msgid "E138: Can't write viminfo file %s!" +#~ msgstr "E138: Kan nie viminfo lêer %s stoor nie!" -#~ msgid "Security error: shell command output is a symbolic link" -#~ msgstr "Sekuriteitsfout: Dop-bevel afvoer is 'n simboliese skakel" +#~ msgid "E136: viminfo: Too many errors, skipping rest of file" +#~ msgstr "E136: viminfo: Te veel foute, slaan die res van die lêer oor" -#~ msgid "Warning: %s option changed from modeline" -#~ msgstr "Waarskuwing: %s opsie verander vanaf moduslyn" +#~ msgid "%sviminfo: %s in line: " +#~ msgstr "%sviminfo: %s in reël: " -#~ msgid "Change dir debugging enabled." -#~ msgstr "Verandergids ontfouting in staat gestel" +#~ msgid "" +#~ "\n" +#~ "# global variables:\n" +#~ msgstr "" +#~ "\n" +#~ "# globale veranderlikes:\n" -#~ msgid "Not a proper file name: '%s'" -#~ msgstr "Nie 'n geldige lêernaam nie: '%s'" +#, fuzzy +#~ msgid "E706: Variable type mismatch for: %s" +#~ msgstr "E93: Meer as een treffer vir %s" -#~ msgid "File name '%s' is valid" -#~ msgstr "lêernaam '%s is ongeldig" +#, fuzzy +#~ msgid "E724: variable nested too deep for displaying" +#~ msgstr "E22: Skripte te diep ge-nes" -#~ msgid "Leave: %s" -#~ msgstr "Verlaat: %s" +#~ msgid "" +#~ "\n" +#~ "# Buffer list:\n" +#~ msgstr "" +#~ "\n" +#~ "# Buffer lys:\n" -#~ msgid "WARNING: tag command changed a buffer!!!" -#~ msgstr "WAARSKUWING: etiketbevel het buffer verander!!!" +#, fuzzy +#~ msgid "Unable to get option value" +#~ msgstr "E258: Kan nie na kliënt stuur nie" diff --git a/src/nvim/po/fi.po b/src/nvim/po/fi.po index ce15cf076c..e491649e14 100644 --- a/src/nvim/po/fi.po +++ b/src/nvim/po/fi.po @@ -277,9 +277,6 @@ msgstr "E83: Puskuria ei voitu varata, käytetään toista..." #~ msgid "E937: Attempt to delete a buffer that is in use" #~ msgstr "E934: Ei voida hypätä puskuriin jolla ei ole nimeä" -msgid "E937: Attempt to delete a buffer that is in use" -msgstr "E937: Ei voida poistaa puskuria joka on käytössä" - msgid "E515: No buffers were unloaded" msgstr "E515: Puskureita ei vapautettu" @@ -412,9 +409,6 @@ msgstr "Loppu" msgid "Top" msgstr "Alku" -msgid "E382: Cannot write, 'buftype' option is set" -msgstr "E382: Ei voi kirjoittaa, buftype asetettu" - msgid "[Scratch]" msgstr "[Raapust]" @@ -570,9 +564,6 @@ msgstr "Luetaan: %s" msgid "Scanning tags." msgstr "Luetaan tägejä." -msgid "match in file" -msgstr "täsmäys tiedostossa" - msgid " Adding" msgstr " Lisätään" @@ -1348,10 +1339,6 @@ msgstr "E737: Avain on jo olemassa: %s" #~ msgid "tv_clear() argument" #~ msgstr "filter()-argumentti" -#, c-format -msgid "E940: Cannot lock or unlock variable %s" -msgstr "E940: Muuttujaa %s ei voi lukita tai avata" - msgid "E743: variable nested too deep for (un)lock" msgstr "E743: muuttujassa liian monta tasoa lukituksen käsittelyyn" @@ -1424,156 +1411,18 @@ msgstr "E907: Käytettiin erikoisarvoa Floattina" msgid "E808: Number or Float required" msgstr "E808: Number tai Float vaaditaan" -msgid "Entering Debug mode. Type \"cont\" to continue." -msgstr "Siirrytään vianetsintätilaan, kirjoita cont jatkaaksesi." - #, c-format msgid "line %ld: %s" msgstr "rivi %ld: %s" -#, c-format -msgid "cmd: %s" -msgstr "kmnt: %s" - -msgid "frame is zero" -msgstr "kehys on nolla" - -#, c-format -msgid "frame at highest level: %d" -msgstr "kehys ylimmällä tasolla: %d" - #, c-format msgid "Breakpoint in \"%s%s\" line %ld" msgstr "Katkaisukohta %s%s rivillä %ld" -#, c-format -msgid "E161: Breakpoint not found: %s" -msgstr "E161: Katkaisukohta puuttuu: %s" - -msgid "No breakpoints defined" -msgstr "Ei katkaisukohtia" - #, c-format msgid "%3d %s %s line %ld" msgstr "%3d %s %s rivi %ld" -msgid "E750: First use \":profile start {fname}\"" -msgstr "E750: Aloita käskyllä :profile start {fname}" - -msgid "Save As" -msgstr "Tallenna nimellä" - -#, c-format -msgid "Save changes to \"%s\"?" -msgstr "Tallennetaanko muutokset tiedostoon %s?" - -#, c-format -msgid "E947: Job still running in buffer \"%s\"" -msgstr "E947: Komento on vielä käynnissä puskurissa \"%s\"" - -#, c-format -msgid "E162: No write since last change for buffer \"%s\"" -msgstr "E162: Muutoksia ei ole kirjoitettu puskurin %s viime muutoksen jälkeen" - -msgid "Warning: Entered other buffer unexpectedly (check autocommands)" -msgstr "Varoitus: Puskuri vaihtui odottamatta (tarkista autocommands)" - -msgid "E163: There is only one file to edit" -msgstr "E163: Vain yksi tiedosto muokattavana" - -msgid "E164: Cannot go before first file" -msgstr "E164: Ensimmäisen tiedoston ohi ei voi mennä" - -msgid "E165: Cannot go beyond last file" -msgstr "E165: Viimeisen tiedoston ohi ei voi mennä" - -#, c-format -msgid "E666: compiler not supported: %s" -msgstr "E666: kääntäjää ei tueta: %s" - -#, c-format -msgid "Searching for \"%s\" in \"%s\"" -msgstr "Etsitään ilmausta %s kohteesta %s" - -#, c-format -msgid "Searching for \"%s\"" -msgstr "Etsitään ilmausta %s" - -#, c-format -msgid "not found in '%s': \"%s\"" -msgstr "'%s' ei löydy kohteesta: %s" - -#, c-format -msgid "W20: Required python version 2.x not supported, ignoring file: %s" -msgstr "W20: Vaadittu python-versio 2.x ei ole tuettu. Ohitetaan: %s" - -#, c-format -msgid "W21: Required python version 3.x not supported, ignoring file: %s" -msgstr "W21: Vaadittu python-versio 3.x ei ole tuettu. Ohitetaan: %s" - -msgid "Source Vim script" -msgstr "Lataa vim-skripti" - -#, c-format -msgid "Cannot source a directory: \"%s\"" -msgstr "Hakemistoa ei voi ladata: %s" - -#, c-format -msgid "could not source \"%s\"" -msgstr "ei voitu ladata %s" - -#, c-format -msgid "line %ld: could not source \"%s\"" -msgstr "rivi %ld: ei voitu ladata %s" - -#, c-format -msgid "sourcing \"%s\"" -msgstr "ladataan %s" - -#, c-format -msgid "line %ld: sourcing \"%s\"" -msgstr "rivi %ld: ladataan %s" - -#, c-format -msgid "finished sourcing %s" -msgstr "ladattu %s" - -#, c-format -msgid "continuing in %s" -msgstr "jatkaa kohdassa %s" - -msgid "modeline" -msgstr "mode-rivi" - -msgid "--cmd argument" -msgstr "--cmd-argumentti" - -msgid "-c argument" -msgstr "-c-argumentti" - -msgid "environment variable" -msgstr "ympäristömuuttuja" - -msgid "error handler" -msgstr "virhekäsittelin" - -msgid "W15: Warning: Wrong line separator, ^M may be missing" -msgstr "W15: Varoitus: Väärä rivierotin, ^M saattaa puuttua" - -msgid "E167: :scriptencoding used outside of a sourced file" -msgstr "E167: :scriptencoding ladatun tiedoston ulkopuolella" - -msgid "E168: :finish used outside of a sourced file" -msgstr "E168: :finish ladatun tiedoston ulkopuolella" - -#, c-format -msgid "Current %slanguage: \"%s\"" -msgstr "Käytössä oleva %skieli: %s" - -#, c-format -msgid "E197: Cannot set language to \"%s\"" -msgstr "E197: Kieleksi ei voitu asettaa kieltä %s" - # puhutaan merkin ulkoasusta snprintf(..., c, c, c, c) #, c-format msgid "<%s>%s%s %d, Hex %02x, Octal %03o" @@ -4021,10 +3870,6 @@ msgstr "" "\n" "--- Valikot ---" -#, c-format -msgid "E335: Menu not defined for %s mode" -msgstr "E335: Valikkoa ei ole määritelty %s-tilassa" - msgid "E333: Menu path must lead to a menu item" msgstr "E333: Valikkopolun on johdettava valikkokohtaan" @@ -4367,9 +4212,6 @@ msgstr "E541: liikaa kohteita" msgid "E542: unbalanced groups" msgstr "E542: epätasapainoisia ryhmiä" -msgid "E946: Cannot make a terminal with running job modifiable" -msgstr "E946: Terminaalia jossa suoritetaan komentoa ei voi tehdä muokattavaksi" - msgid "E590: A preview window already exists" msgstr "E590: Esikatseluikkuna on jo olemassa" @@ -4563,12 +4405,6 @@ msgstr "E369: virheellinen olio kohdassa %s%%[]" msgid "E769: Missing ] after %s[" msgstr "E769: ] puuttuu merkinnän %s[ jäljestä" -msgid "E944: Reverse range in character class" -msgstr "E944: Merkiluokan arvoalua on takaperin" - -msgid "E945: Range too large in character class" -msgstr "E945: Liian laaja valikoima merkkiluokassa" - #, c-format msgid "E53: Unmatched %s%%(" msgstr "E53: Pariton %s%%(" @@ -4595,9 +4431,6 @@ msgstr "E69: ] puuttuu merkinnän %s%%[ jäljestä" msgid "E70: Empty %s%%[]" msgstr "E70: Tyhjä %s%%[]" -msgid "E65: Illegal back reference" -msgstr "E65: Virheellinen täsmäysviittaus" - msgid "E339: Pattern too long" msgstr "E339: Liian pitkä kuvio" @@ -4814,9 +4647,6 @@ msgstr " vanhaatiedostoa" msgid " FAILED" msgstr " EPÄONNISTUI" -msgid "E797: SpellFileMissing autocommand deleted buffer" -msgstr "E797: SpellFileMissing autocommand poisti puskurin" - #, c-format #~ msgid "System error while opening ShaDa file %s for reading: %s" #~ msgstr "" -- cgit From 9837a9c40105d3d28fc99d62693e47b32cec0f06 Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Thu, 9 Nov 2017 02:20:12 +0100 Subject: compat: "v:count" distinct from "count" (#7407) --- src/nvim/eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 9752851d4e..0c0c03c8ed 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -334,7 +334,7 @@ static struct vimvar { // VV_SEND_SERVER "servername" // VV_REG "register" // VV_OP "operator" - VV(VV_COUNT, "count", VAR_NUMBER, VV_COMPAT+VV_RO), + VV(VV_COUNT, "count", VAR_NUMBER, VV_RO), VV(VV_COUNT1, "count1", VAR_NUMBER, VV_RO), VV(VV_PREVCOUNT, "prevcount", VAR_NUMBER, VV_RO), VV(VV_ERRMSG, "errmsg", VAR_STRING, VV_COMPAT), -- cgit From 9baa7ca37ff75921820fe5539f962a4e51f632ce Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 9 Nov 2017 11:10:40 +0100 Subject: test/oldtest: `count` is not special in Nvim #7407 --- src/nvim/testdir/test_unlet.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_unlet.vim b/src/nvim/testdir/test_unlet.vim index f6705997a9..96ba752d9f 100644 --- a/src/nvim/testdir/test_unlet.vim +++ b/src/nvim/testdir/test_unlet.vim @@ -3,7 +3,7 @@ func Test_read_only() try " this caused a crash - unlet count + unlet v:count catch call assert_true(v:exception =~ ':E795:') endtry -- cgit From 7e8212c459b285aacf2dd225c1dad5593314f094 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Fri, 10 Nov 2017 23:17:20 +0800 Subject: vim-patch:8.0.0224 Problem: When 'fileformats' is changed in a BufReadPre auto command, it does not take effect in readfile(). (Gary Johnson) Solution: Check the value of 'fileformats' after executing auto commands. (Christian Brabandt) https://github.com/vim/vim/commit/7a2699e868bca781e26b060a44fc714d87cfa4ba --- src/nvim/fileio.c | 20 +++++++++++++++----- src/nvim/testdir/test_fileformat.vim | 14 ++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index feb16f44d4..81ac98081d 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -302,11 +302,11 @@ readfile ( linenr_T skip_count = 0; linenr_T read_count = 0; int msg_save = msg_scroll; - linenr_T read_no_eol_lnum = 0; /* non-zero lnum when last line of - * last read was missing the eol */ - int try_mac = (vim_strchr(p_ffs, 'm') != NULL); - int try_dos = (vim_strchr(p_ffs, 'd') != NULL); - int try_unix = (vim_strchr(p_ffs, 'x') != NULL); + linenr_T read_no_eol_lnum = 0; // non-zero lnum when last line of + // last read was missing the eol + int try_mac; + int try_dos; + int try_unix; int file_rewind = FALSE; int can_retry; linenr_T conv_error = 0; /* line nr with conversion error */ @@ -639,6 +639,10 @@ readfile ( curbuf->b_op_start.lnum = ((from == 0) ? 1 : from); curbuf->b_op_start.col = 0; + try_mac = (vim_strchr(p_ffs, 'm') != NULL); + try_dos = (vim_strchr(p_ffs, 'd') != NULL); + try_unix = (vim_strchr(p_ffs, 'x') != NULL); + if (!read_buffer) { int m = msg_scroll; int n = msg_scrolled; @@ -668,6 +672,12 @@ readfile ( else apply_autocmds_exarg(EVENT_FILEREADPRE, sfname, sfname, FALSE, NULL, eap); + + // autocommands may have changed it + try_mac = (vim_strchr(p_ffs, 'm') != NULL); + try_dos = (vim_strchr(p_ffs, 'd') != NULL); + try_unix = (vim_strchr(p_ffs, 'x') != NULL); + if (msg_scrolled == n) msg_scroll = m; diff --git a/src/nvim/testdir/test_fileformat.vim b/src/nvim/testdir/test_fileformat.vim index 584f20cdfc..256a7d5b1c 100644 --- a/src/nvim/testdir/test_fileformat.vim +++ b/src/nvim/testdir/test_fileformat.vim @@ -15,3 +15,17 @@ func Test_fileformat_after_bw() call assert_equal(test_fileformats, &fileformat) set fileformats& endfunc + +func Test_fileformat_autocommand() + let filecnt=['', 'foobar', 'eins', '', 'zwei', 'drei', 'vier', 'fünf', ''] + let ffs=&ffs + call writefile(filecnt, 'Xfile', 'b') + au BufReadPre Xfile set ffs=dos ff=dos + new Xfile + call assert_equal('dos', &l:ff) + call assert_equal('dos', &ffs) + " cleanup + let &ffs=ffs + au! BufReadPre Xfile + bw! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index a31381eddf..c57ca1e815 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -880,7 +880,7 @@ static const int included_patches[] = { // 227, // 226, // 225, - // 224, + 224, 223, // 222, // 221 NA -- cgit From 67a2207c4a4d9b848a4759a7f1e11b5ad1265648 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Fri, 10 Nov 2017 23:28:58 +0800 Subject: vim-patch:8.0.0226 Problem: The test for patch 8.0.0224 misses the CR characters and passes even without the fix. (Christian Brabandt) Solution: Use double quotes and \. https://github.com/vim/vim/commit/1695f99d08076d77ed3015f1edf09a668a4d449a --- src/nvim/testdir/test_fileformat.vim | 24 +++++++++++++----------- src/nvim/version.c | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_fileformat.vim b/src/nvim/testdir/test_fileformat.vim index 256a7d5b1c..de505d3bd0 100644 --- a/src/nvim/testdir/test_fileformat.vim +++ b/src/nvim/testdir/test_fileformat.vim @@ -17,15 +17,17 @@ func Test_fileformat_after_bw() endfunc func Test_fileformat_autocommand() - let filecnt=['', 'foobar', 'eins', '', 'zwei', 'drei', 'vier', 'fünf', ''] - let ffs=&ffs - call writefile(filecnt, 'Xfile', 'b') - au BufReadPre Xfile set ffs=dos ff=dos - new Xfile - call assert_equal('dos', &l:ff) - call assert_equal('dos', &ffs) - " cleanup - let &ffs=ffs - au! BufReadPre Xfile - bw! + let filecnt = ["\", "foobar\", "eins\", "\", "zwei\", "drei", "vier", "fünf", ""] + let ffs = &ffs + call writefile(filecnt, 'Xfile', 'b') + au BufReadPre Xfile set ffs=dos ff=dos + new Xfile + call assert_equal('dos', &l:ff) + call assert_equal('dos', &ffs) + + " cleanup + call delete('Xfile') + let &ffs = ffs + au! BufReadPre Xfile + bw! endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index c57ca1e815..ae1c85d8e2 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -878,7 +878,7 @@ static const int included_patches[] = { 229, // 228, // 227, - // 226, + 226, // 225, 224, 223, -- cgit From f5d4da0144c97ba13f530ea7dbd50f7b9768cb34 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 10 Nov 2017 22:37:54 +0100 Subject: :checkhealth : validate 'runtimepath' (#7526) --- src/nvim/eval.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 0c0c03c8ed..33bea8ef87 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -22883,11 +22883,15 @@ void ex_checkhealth(exarg_T *eap) const char *vimruntime_env = os_getenv("VIMRUNTIME"); if (vimruntime_env == NULL) { EMSG(_("E5009: $VIMRUNTIME is empty or unset")); - return; } else { - EMSG2(_("E5009: Invalid $VIMRUNTIME: %s"), os_getenv("VIMRUNTIME")); - return; + bool rtp_ok = NULL != strstr((char *)p_rtp, vimruntime_env); + if (rtp_ok) { + EMSG2(_("E5009: Invalid $VIMRUNTIME: %s"), vimruntime_env); + } else { + EMSG(_("E5009: Invalid 'runtimepath'")); + } } + return; } size_t bufsize = STRLEN(eap->arg) + sizeof("call health#check('')"); -- cgit From faa15c5b83d409489c5147ad99e2c44adb3eb37c Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sat, 11 Nov 2017 06:35:55 +0800 Subject: vim-patch:8.0.0218 (#7529) Problem: No command line completion for :cexpr, :cgetexpr, :caddexpr, etc. Solution: Make completion work. (Yegappan Lakshmanan) Add a test. https://github.com/vim/vim/commit/2b2207ba69c6b009e466a36eef0644ca723e16d3 --- src/nvim/ex_docmd.c | 6 ++++++ src/nvim/testdir/test_cmdline.vim | 28 ++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 096187b162..7a2b0328df 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3272,6 +3272,12 @@ const char * set_one_cmd_context( case CMD_echoerr: case CMD_call: case CMD_return: + case CMD_cexpr: + case CMD_caddexpr: + case CMD_cgetexpr: + case CMD_lexpr: + case CMD_laddexpr: + case CMD_lgetexpr: set_context_for_expression(xp, (char_u *)arg, ea.cmdidx); break; diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index c0f04f4730..5abff1838d 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -25,6 +25,34 @@ func Test_complete_wildmenu() set nowildmenu endfunc +func Test_expr_completion() + if !(has('cmdline_compl') && has('eval')) + return + endif + for cmd in [ + \ 'let a = ', + \ 'if', + \ 'elseif', + \ 'while', + \ 'for', + \ 'echo', + \ 'echon', + \ 'execute', + \ 'echomsg', + \ 'echoerr', + \ 'call', + \ 'return', + \ 'cexpr', + \ 'caddexpr', + \ 'cgetexpr', + \ 'lexpr', + \ 'laddexpr', + \ 'lgetexpr'] + call feedkeys(":" . cmd . " getl\\\"\", 'xt') + call assert_equal('"' . cmd . ' getline(', getreg(':')) + endfor +endfunc + func Test_getcompletion() if !has('cmdline_compl') return diff --git a/src/nvim/version.c b/src/nvim/version.c index a31381eddf..7a12e6c38a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -886,7 +886,7 @@ static const int included_patches[] = { // 221 NA // 220, 219, - // 218, + 218, // 217 NA // 216, // 215, -- cgit From 4fa0970519c332350ce7cc687a0cd93ace17f5ca Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sat, 11 Nov 2017 07:00:11 +0800 Subject: vim-patch:8.0.0242 (#7532) Problem: Completion of user defined functions is not covered by tests. Solution: Add tests. Also test various errors of user-defined commands. (Dominique Pelle, closes vim/vim#1413) https://github.com/vim/vim/commit/65c836e6004647196ae0bc18e409a9e7b79207c0 --- src/nvim/testdir/test_usercommands.vim | 104 +++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 2 files changed, 105 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_usercommands.vim b/src/nvim/testdir/test_usercommands.vim index d0864ec64c..db603610da 100644 --- a/src/nvim/testdir/test_usercommands.vim +++ b/src/nvim/testdir/test_usercommands.vim @@ -102,3 +102,107 @@ func Test_CmdUndefined() call assert_fails('Dothat', 'E492:') call assert_equal('yes', g:didnot) endfunc + +func Test_CmdErrors() + call assert_fails('com! docmd :', 'E183:') + call assert_fails('com! \ :', 'E182:') + call assert_fails('com! _ :', 'E182:') + call assert_fails('com! X :', 'E841:') + call assert_fails('com! - DoCmd :', 'E175:') + call assert_fails('com! -xxx DoCmd :', 'E181:') + call assert_fails('com! -addr DoCmd :', 'E179:') + call assert_fails('com! -complete DoCmd :', 'E179:') + call assert_fails('com! -complete=xxx DoCmd :', 'E180:') + call assert_fails('com! -complete=custom DoCmd :', 'E467:') + call assert_fails('com! -complete=customlist DoCmd :', 'E467:') + call assert_fails('com! -complete=behave,CustomComplete DoCmd :', 'E468:') + call assert_fails('com! -nargs=x DoCmd :', 'E176:') + call assert_fails('com! -count=1 -count=2 DoCmd :', 'E177:') + call assert_fails('com! -count=x DoCmd :', 'E178:') + call assert_fails('com! -range=x DoCmd :', 'E178:') + + com! -nargs=0 DoCmd : + call assert_fails('DoCmd x', 'E488:') + + com! -nargs=1 DoCmd : + call assert_fails('DoCmd', 'E471:') + + com! -nargs=+ DoCmd : + call assert_fails('DoCmd', 'E471:') + + call assert_fails('com DoCmd :', 'E174:') + comclear + call assert_fails('delcom DoCmd', 'E184:') +endfunc + +func CustomComplete(A, L, P) + return "January\nFebruary\nMars\n" +endfunc + +func CustomCompleteList(A, L, P) + return [ "Monday", "Tuesday", "Wednesday" ] +endfunc + +func Test_CmdCompletion() + call feedkeys(":com -\\\"\", 'tx') + call assert_equal('"com -addr bang bar buffer complete count nargs range register', @:) + + call feedkeys(":com -nargs=0 -\\\"\", 'tx') + call assert_equal('"com -nargs=0 -addr bang bar buffer complete count nargs range register', @:) + + call feedkeys(":com -nargs=\\\"\", 'tx') + call assert_equal('"com -nargs=* + 0 1 ?', @:) + + call feedkeys(":com -addr=\\\"\", 'tx') + call assert_equal('"com -addr=arguments buffers lines loaded_buffers quickfix tabs windows', @:) + + call feedkeys(":com -complete=co\\\"\", 'tx') + call assert_equal('"com -complete=color command compiler', @:) + + command! DoCmd1 : + command! DoCmd2 : + call feedkeys(":com \\\"\", 'tx') + call assert_equal('"com DoCmd1 DoCmd2', @:) + + call feedkeys(":DoC\\\"\", 'tx') + call assert_equal('"DoCmd1 DoCmd2', @:) + + call feedkeys(":delcom DoC\\\"\", 'tx') + call assert_equal('"delcom DoCmd1 DoCmd2', @:) + + delcom DoCmd1 + call feedkeys(":delcom DoC\\\"\", 'tx') + call assert_equal('"delcom DoCmd2', @:) + + call feedkeys(":com DoC\\\"\", 'tx') + call assert_equal('"com DoCmd2', @:) + + delcom DoCmd2 + call feedkeys(":delcom DoC\\\"\", 'tx') + call assert_equal('"delcom DoC', @:) + + call feedkeys(":com DoC\\\"\", 'tx') + call assert_equal('"com DoC', @:) + + com! -complete=behave DoCmd : + call feedkeys(":DoCmd \\\"\", 'tx') + call assert_equal('"DoCmd mswin xterm', @:) + + " This does not work. Why? + "call feedkeys(":DoCmd x\\\"\", 'tx') + "call assert_equal('"DoCmd xterm', @:) + + com! -complete=custom,CustomComplete DoCmd : + call feedkeys(":DoCmd \\\"\", 'tx') + call assert_equal('"DoCmd January February Mars', @:) + + com! -complete=customlist,CustomCompleteList DoCmd : + call feedkeys(":DoCmd \\\"\", 'tx') + call assert_equal('"DoCmd Monday Tuesday Wednesday', @:) + + com! -complete=custom,CustomCompleteList DoCmd : + call assert_fails("call feedkeys(':DoCmd \', 'tx')", 'E730:') + + com! -complete=customlist,CustomComp DoCmd : + call assert_fails("call feedkeys(':DoCmd \', 'tx')", 'E117:') +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 7a12e6c38a..16a265fed3 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -862,7 +862,7 @@ static const int included_patches[] = { // 245, // 244, 243, - // 242, + 242, // 241 NA // 240 NA // 239 NA -- cgit From a2fdd0a72f9d1f72f2e49e80719902a6f555454e Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sat, 11 Nov 2017 08:26:55 +0800 Subject: vim-patch:8.0.0237 (#7531) Problem: When setting wildoptions=tagfile the completion context is not set correctly. (desjardins) Solution: Check for EXPAND_TAGS_LISTFILES. (Christian Brabandt, closes vim/vim#1399) https://github.com/vim/vim/commit/ba47b51ff88d91c9bb5aa522183e23a656865697 --- src/nvim/ex_getln.c | 4 +++- src/nvim/testdir/test_cmdline.vim | 10 ++++++++++ src/nvim/version.c | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 43e7cf457d..9c9ccbca4d 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -4147,7 +4147,9 @@ addstar ( || context == EXPAND_OWNSYNTAX || context == EXPAND_FILETYPE || context == EXPAND_PACKADD - || (context == EXPAND_TAGS && fname[0] == '/')) + || ((context == EXPAND_TAGS_LISTFILES + || context == EXPAND_TAGS) + && fname[0] == '/')) retval = vim_strnsave(fname, len); else { new_len = len + 2; /* +2 for '^' at start, NUL at end */ diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 5abff1838d..5fc519f822 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -296,3 +296,13 @@ func Test_illegal_address2() call delete('Xtest.vim') endfunc +func Test_cmdline_complete_wildoptions() + help + call feedkeys(":tag /\\\"\", 'tx') + let a = join(sort(split(@:)),' ') + set wildoptions=tagfile + call feedkeys(":tag /\\\"\", 'tx') + let b = join(sort(split(@:)),' ') + call assert_equal(a, b) + bw! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 16a265fed3..05725a59f9 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -867,7 +867,7 @@ static const int included_patches[] = { // 240 NA // 239 NA // 238, - // 237, + 237, // 236, 235, // 234, -- cgit From ea020f2e26f1e5cb89eb632c1b0ee51daf7718b4 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sat, 11 Nov 2017 09:04:48 +0800 Subject: fix lint error --- src/nvim/fileio.c | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 81ac98081d..c3a0a33378 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -307,7 +307,7 @@ readfile ( int try_mac; int try_dos; int try_unix; - int file_rewind = FALSE; + int file_rewind = false; int can_retry; linenr_T conv_error = 0; /* line nr with conversion error */ linenr_T illegal_byte = 0; /* line nr with illegal byte */ @@ -647,39 +647,38 @@ readfile ( int m = msg_scroll; int n = msg_scrolled; - /* - * The file must be closed again, the autocommands may want to change - * the file before reading it. - */ - if (!read_stdin) - close(fd); /* ignore errors */ + // The file must be closed again, the autocommands may want to change + // the file before reading it. + if (!read_stdin) { + close(fd); // ignore errors + } - /* - * The output from the autocommands should not overwrite anything and - * should not be overwritten: Set msg_scroll, restore its value if no - * output was done. - */ - msg_scroll = TRUE; - if (filtering) + // The output from the autocommands should not overwrite anything and + // should not be overwritten: Set msg_scroll, restore its value if no + // output was done. + msg_scroll = true; + if (filtering) { apply_autocmds_exarg(EVENT_FILTERREADPRE, NULL, sfname, - FALSE, curbuf, eap); - else if (read_stdin) + false, curbuf, eap); + } else if (read_stdin) { apply_autocmds_exarg(EVENT_STDINREADPRE, NULL, sfname, - FALSE, curbuf, eap); - else if (newfile) + false, curbuf, eap); + } else if (newfile) { apply_autocmds_exarg(EVENT_BUFREADPRE, NULL, sfname, - FALSE, curbuf, eap); - else + false, curbuf, eap); + } else { apply_autocmds_exarg(EVENT_FILEREADPRE, sfname, sfname, - FALSE, NULL, eap); + false, NULL, eap); + } - // autocommands may have changed it - try_mac = (vim_strchr(p_ffs, 'm') != NULL); - try_dos = (vim_strchr(p_ffs, 'd') != NULL); - try_unix = (vim_strchr(p_ffs, 'x') != NULL); + // autocommands may have changed it + try_mac = (vim_strchr(p_ffs, 'm') != NULL); + try_dos = (vim_strchr(p_ffs, 'd') != NULL); + try_unix = (vim_strchr(p_ffs, 'x') != NULL); - if (msg_scrolled == n) + if (msg_scrolled == n) { msg_scroll = m; + } if (aborting()) { /* autocmds may abort script processing */ --no_wait_return; -- cgit From 1aa6276c29d562a6287519e6755a613eabca5c31 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 12 Nov 2017 00:03:45 +0300 Subject: viml/parser/expressions: Replace lambda-specific WantedNode entries This way code will be easier to adapt to handling (partially) non-expressions like :let lvalue part or :function definitions, and that would be needed in the future both for proper completion support and for the Ex commands parser. --- src/nvim/viml/parser/expressions.c | 101 +++++++++++++++++++------------------ 1 file changed, 52 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 71eda2cdc1..e23c58bfd1 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -73,12 +73,21 @@ typedef enum { /// For unrestricted expressions as well, implies that top item in AST stack /// points to NULL. kENodeValue, - /// Argument: only allows simple argument names. - kENodeArgument, - /// Argument separator: only allows commas. - kENodeArgumentSeparator, } ExprASTWantedNode; +/// Parse type: what is being parsed currently +typedef enum { + /// Parsing regular VimL expression + kEPTExpr = 0, + /// Parsing lambda arguments + /// + /// Just like parsing function arguments, but it is valid to be ended with an + /// arrow only. + kEPTLambdaArguments, +} ExprASTParseType; + +typedef kvec_withinit_t(ExprASTParseType, 4) ExprASTParseTypeStack; + /// Operator priority level typedef enum { kEOpLvlInvalid = 0, @@ -1238,9 +1247,7 @@ static bool viml_pexpr_handle_bop(const ParserState *const pstate, ret = false; } } - *want_node_p = (*want_node_p == kENodeArgumentSeparator - ? kENodeArgument - : kENodeValue); + *want_node_p = kENodeValue; return ret; } @@ -1790,8 +1797,6 @@ static void parse_quoted_string(ParserState *const pstate, static const int want_node_to_lexer_flags[] = { [kENodeValue] = kELFlagIsNotCmp, [kENodeOperator] = kELFlagForbidScope, - [kENodeArgument] = kELFlagIsNotCmp, - [kENodeArgumentSeparator] = kELFlagForbidScope, }; /// Number of characters to highlight as NumberPrefix depending on the base @@ -1827,12 +1832,13 @@ ExprAST viml_pexpr_parse(ParserState *const pstate, const int flags) // (list start) last stack item contains NULL. Otherwise last stack item is // supposed to contain last “finished†value: e.g. "1" or "+(1, 1)" (node // representing "1+1"). - // - // Both kENodeValue and kENodeArgument stand for “value†nodes. ExprASTStack ast_stack; kvi_init(ast_stack); kvi_push(ast_stack, &ast.root); ExprASTWantedNode want_node = kENodeValue; + ExprASTParseTypeStack pt_stack; + kvi_init(pt_stack); + kvi_push(pt_stack, kEPTExpr); LexExprToken prev_token = { .type = kExprLexMissing }; bool highlighted_prev_spacing = false; // Lambda node, valid when parsing lambda arguments only. @@ -1884,8 +1890,7 @@ viml_pexpr_parse_process_token: assert(kv_size(ast_stack) >= 1); ExprASTNode *cur_node = NULL; #ifndef NDEBUG - const bool want_value = ( - want_node == kENodeValue || want_node == kENodeArgument); + const bool want_value = (want_node == kENodeValue); assert(want_value == (*top_node_p == NULL)); assert(kv_A(ast_stack, 0) == &ast.root); // Check that stack item i + 1 points to stack items’ i *last* child. @@ -1933,14 +1938,15 @@ viml_pexpr_parse_process_token: // circumstances, and in any case runtime and not parse time errors. (*kv_Z(ast_stack, 1))->type = kExprNodeConcat; } - if ((want_node == kENodeArgumentSeparator - && tok_type != kExprLexComma - && tok_type != kExprLexArrow) - || (want_node == kENodeArgument - && !(cur_token.type == kExprLexPlainIdentifier - && cur_token.data.var.scope == kExprVarScopeMissing - && !cur_token.data.var.autoload) - && tok_type != kExprLexArrow)) { + if (kv_last(pt_stack) == kEPTLambdaArguments + && ((want_node == kENodeOperator + && tok_type != kExprLexComma + && tok_type != kExprLexArrow) + || (want_node == kENodeValue + && !(cur_token.type == kExprLexPlainIdentifier + && cur_token.data.var.scope == kExprVarScopeMissing + && !cur_token.data.var.autoload) + && tok_type != kExprLexArrow))) { lambda_node->data.fig.type_guesses.allow_lambda = false; if (lambda_node->children != NULL && lambda_node->children->type == kExprNodeComma) { @@ -1956,16 +1962,11 @@ viml_pexpr_parse_process_token: // Else it may appear that possibly-lambda node is actually a dictionary // or curly-braces-name identifier. lambda_node = NULL; - if (want_node == kENodeArgumentSeparator) { - want_node = kENodeOperator; - } else { - want_node = kENodeValue; - } + kv_drop(pt_stack, 1); } } - assert(lambda_node == NULL - || want_node == kENodeArgumentSeparator - || want_node == kENodeArgument); + const ExprASTParseType cur_pt = kv_last(pt_stack); + assert(lambda_node == NULL || cur_pt == kEPTLambdaArguments); switch (tok_type) { case kExprLexMissing: case kExprLexSpacing: @@ -2129,7 +2130,7 @@ viml_pexpr_parse_process_token: break; } case kExprLexComma: { - assert(want_node != kENodeArgument); + assert(!(want_node == kENodeValue && cur_pt == kEPTLambdaArguments)); if (want_node == kENodeValue) { // Value level: comma appearing here is not valid. // Note: in Vim string(,x) will give E116, this is not the case here. @@ -2138,13 +2139,11 @@ viml_pexpr_parse_process_token: NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeMissing); cur_node->len = 0; *top_node_p = cur_node; - want_node = (want_node == kENodeArgument - ? kENodeArgumentSeparator - : kENodeOperator); + want_node = kENodeOperator; } - if (want_node == kENodeArgumentSeparator) { - assert(lambda_node->data.fig.type_guesses.allow_lambda); + if (cur_pt == kEPTLambdaArguments) { assert(lambda_node != NULL); + assert(lambda_node->data.fig.type_guesses.allow_lambda); SELECT_FIGURE_BRACE_TYPE(lambda_node, Lambda, Lambda); } if (kv_size(ast_stack) < 2) { @@ -2156,7 +2155,8 @@ viml_pexpr_parse_process_token: const ExprASTNodeType eastnode_type = (*eastnode_p)->type; const ExprOpLvl eastnode_lvl = node_lvl(**eastnode_p); if (eastnode_type == kExprNodeLambda) { - assert(want_node == kENodeArgumentSeparator); + assert(cur_pt == kEPTLambdaArguments + && want_node == kENodeOperator); break; } else if (eastnode_type == kExprNodeDictLiteral || eastnode_type == kExprNodeListLiteral @@ -2410,9 +2410,6 @@ viml_pexpr_parse_bracket_closing_error: case kExprNodeUnknownFigure: { if (new_top_node->children == NULL) { // No children of curly braces node indicates empty dictionary. - - // Should actually be kENodeArgument, but that was changed - // earlier. assert(want_node == kENodeValue); assert(new_top_node->data.fig.type_guesses.allow_dict); SELECT_FIGURE_BRACE_TYPE(new_top_node, DictLiteral, Dict); @@ -2475,7 +2472,7 @@ viml_pexpr_parse_figure_brace_closing_error: } *top_node_p = cur_node; kvi_push(ast_stack, &cur_node->children); - want_node = kENodeArgument; + kvi_push(pt_stack, kEPTLambdaArguments); lambda_node = cur_node; } else { ADD_IDENT( @@ -2495,9 +2492,12 @@ viml_pexpr_parse_figure_brace_closing_error: break; } case kExprLexArrow: { - if (want_node == kENodeArgumentSeparator - || want_node == kENodeArgument) { - if (want_node == kENodeArgument) { + if (cur_pt == kEPTLambdaArguments) { + kv_drop(pt_stack, 1); + assert(kv_size(pt_stack)); + if (want_node == kENodeValue) { + // Wanting value means trailing comma and NULL at the top of the + // stack. kv_drop(ast_stack, 1); } assert(kv_size(ast_stack) >= 1); @@ -2509,7 +2509,7 @@ viml_pexpr_parse_figure_brace_closing_error: SELECT_FIGURE_BRACE_TYPE(lambda_node, Lambda, Lambda); NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeArrow); if (lambda_node->children == NULL) { - assert(want_node == kENodeArgument); + assert(want_node == kENodeValue); lambda_node->children = cur_node; kvi_push(ast_stack, &lambda_node->children); } else { @@ -2535,10 +2535,8 @@ viml_pexpr_parse_figure_brace_closing_error: const ExprVarScope scope = (cur_token.type == kExprLexInvalid ? kExprVarScopeMissing : cur_token.data.var.scope); - if (want_node == kENodeValue || want_node == kENodeArgument) { - want_node = (want_node == kENodeArgument - ? kENodeArgumentSeparator - : kENodeOperator); + if (want_node == kENodeValue) { + want_node = kENodeOperator; NEW_NODE_WITH_CUR_POS(cur_node, (node_is_key ? kExprNodePlainKey @@ -2755,7 +2753,12 @@ viml_pexpr_parse_cycle_end: viml_parser_advance(pstate, cur_token.len); } while (true); viml_pexpr_parse_end: - if (want_node == kENodeValue) { + assert(kv_size(pt_stack)); + assert(kv_size(ast_stack)); + if (want_node == kENodeValue + // Blacklist some parse type entries as their presence means better error + // message in the other branch. + && kv_last(pt_stack) != kEPTLambdaArguments) { east_set_error(pstate, &ast.err, _("E15: Expected value, got EOC: %.*s"), pstate->pos); } else if (kv_size(ast_stack) != 1) { -- cgit From c7495ebcc0918ffd682083408895451318e41d1f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 12 Nov 2017 02:18:43 +0300 Subject: viml/parser/expressions: Add support for parsing assignments --- src/nvim/api/vim.c | 39 ++++-- src/nvim/syntax.c | 20 ++++ src/nvim/viml/parser/expressions.c | 239 +++++++++++++++++++++++++++++++------ src/nvim/viml/parser/expressions.h | 40 ++++++- 4 files changed, 292 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index bac19ef363..ce554d351c 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -900,14 +900,21 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack; /// Parse a VimL expression /// /// @param[in] expr Expression to parse. Is always treated as a single line. -/// @param[in] flags Flags: "m" if multiple expressions in a row are allowed -/// (only the first one will be parsed), "E" if EOC tokens -/// are not allowed (determines whether they will stop -/// parsing process or be recognized as an operator/space, -/// though also yielding an error). -/// -/// Use only "m" to parse like for "=", only "E" to -/// parse like for ":echo", empty string for ":let". +/// @param[in] flags Flags: +/// +/// - "m" if multiple expressions in a row are allowed (only +/// the first one will be parsed), +/// - "E" if EOC tokens are not allowed (determines whether +/// they will stop parsing process or be recognized as an +/// operator/space, though also yielding an error). +/// - "l" when needing to start parsing with lvalues for +/// ":let" or ":for". +/// +/// Common flag sets: +/// - "m" to parse like for ":echo". +/// - "E" to parse like for "=". +/// - empty string for ":call". +/// - "lm" to parse for ":let". /// @param[in] highlight If true, return value will also include "highlight" /// key containing array of 4-tuples (arrays) (Integer, /// Integer, Integer, String), where first three numbers @@ -964,6 +971,9 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack; /// value names from ExprCaseCompareStrategy, /// stringified without "kCCStrategy" prefix. Only /// present for "Comparison" nodes. +/// "augmentation": String, augmentation type for "Assignment" nodes. +/// Is either an empty string, "Add", "Subtract" or +/// "Concat" for "=", "+=", "-=" or ".=" respectively. /// "invert": Boolean, true if result of comparison needs to be /// inverted. Only present for "Comparison" nodes. /// "ivalue": Integer, integer value for "Integer" nodes. @@ -979,6 +989,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, switch (flags.data[i]) { case 'm': { pflags |= kExprFlagsMulti; break; } case 'E': { pflags |= kExprFlagsDisallowEOC; break; } + case 'l': { pflags |= kExprFlagsParseLet; break; } case NUL: { api_set_error(err, kErrorTypeValidation, "Invalid flag: '\\0' (%u)", (unsigned)flags.data[i]); @@ -1114,6 +1125,7 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, + (node->type == kExprNodeFloat) // "fvalue" + (node->type == kExprNodeDoubleQuotedString || node->type == kExprNodeSingleQuotedString) // "svalue" + + (node->type == kExprNodeAssignment) // "augmentation" + 0); Dictionary ret_node = { .items = xmalloc(ret_node_items_size * sizeof(ret_node.items[0])), @@ -1272,6 +1284,17 @@ Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, }; break; } + case kExprNodeAssignment: { + const ExprAssignmentType asgn_type = node->data.ass.type; + ret_node->items[ret_node->size++] = (KeyValuePair) { + .key = STATIC_CSTR_TO_STRING("augmentation"), + .value = STRING_OBJ( + asgn_type == kExprAsgnPlain + ? (String)STRING_INIT + : cstr_to_string(expr_asgn_type_tab[asgn_type])), + }; + break; + } case kExprNodeMissing: case kExprNodeOpMissing: case kExprNodeTernary: diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index e0bf74567d..9f98b26905 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6021,11 +6021,21 @@ static const char *highlight_init_dark[] = { }; static const char *highlight_init_cmdline[] = { + // XXX When modifying a list modify it in both valid and invalid halfs. + // TODO(ZyX-I): merge valid and invalid groups via a macros. + // NVimInternalError should appear only when highlighter has a bug. "NVimInternalError ctermfg=Red ctermbg=Red guifg=Red guibg=Red", // Highlight groups (links) used by parser: + "default link NVimAssignment Operator", + "default link NVimPlainAssignment NVimAssignment", + "default link NVimAugmentedAssignment NVimAssignment", + "default link NVimAssignmentWithAddition NVimAugmentedAssignment", + "default link NVimAssignmentWithSubtraction NVimAugmentedAssignment", + "default link NVimAssignmentWithConcatenation NVimAugmentedAssignment", + "default link NVimOperator Operator", "default link NVimUnaryOperator NVimOperator", @@ -6113,6 +6123,16 @@ static const char *highlight_init_cmdline[] = { "default link NVimInvalid Error", + "default link NVimInvalidAssignment NVimInvalid", + "default link NVimInvalidPlainAssignment NVimInvalidAssignment", + "default link NVimInvalidAugmentedAssignment NVimInvalidAssignment", + "default link NVimInvalidAssignmentWithAddition " + "NVimInvalidAugmentedAssignment", + "default link NVimInvalidAssignmentWithSubtraction " + "NVimInvalidAugmentedAssignment", + "default link NVimInvalidAssignmentWithConcatenation " + "NVimInvalidAugmentedAssignment", + "default link NVimInvalidOperator NVimInvalid", "default link NVimInvalidUnaryOperator NVimInvalidOperator", diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index e23c58bfd1..13f7131744 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -84,6 +84,10 @@ typedef enum { /// Just like parsing function arguments, but it is valid to be ended with an /// arrow only. kEPTLambdaArguments, + /// Assignment: parsing for :let + kEPTAssignment, + /// Single assignment: used when lists are not allowed (i.e. when nesting) + kEPTSingleAssignment, } ExprASTParseType; typedef kvec_withinit_t(ExprASTParseType, 4) ExprASTParseTypeStack; @@ -93,6 +97,7 @@ typedef enum { kEOpLvlInvalid = 0, kEOpLvlComplexIdentifier, kEOpLvlParens, + kEOpLvlAssignment, kEOpLvlArrow, kEOpLvlComma, kEOpLvlColon, @@ -217,8 +222,6 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) } CHAR(kExprLexQuestion, '?') CHAR(kExprLexColon, ':') - CHAR(kExprLexDot, '.') - CHAR(kExprLexPlus, '+') CHAR(kExprLexComma, ',') #undef CHAR @@ -532,12 +535,8 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) case '!': case '=': { if (pline.size == 1) { -viml_pexpr_next_token_invalid_comparison: - ret.type = (schar == '!' ? kExprLexNot : kExprLexInvalid); - if (ret.type == kExprLexInvalid) { - ret.data.err.msg = _("E15: Expected == or =~: %.*s"); - ret.data.err.type = kExprLexComparison; - } + ret.type = (schar == '!' ? kExprLexNot : kExprLexAssignment); + ret.data.ass.type = kExprAsgnPlain; break; } ret.type = kExprLexComparison; @@ -548,8 +547,11 @@ viml_pexpr_next_token_invalid_comparison: } else if (pline.data[1] == '~') { ret.data.cmp.type = kExprCmpMatches; ret.len++; + } else if (schar == '!') { + ret.type = kExprLexNot; } else { - goto viml_pexpr_next_token_invalid_comparison; + ret.type = kExprLexAssignment; + ret.data.ass.type = kExprAsgnPlain; } GET_CCS(ret, pline); break; @@ -571,17 +573,37 @@ viml_pexpr_next_token_invalid_comparison: break; } - // Minus sign or arrow from lambdas. + // Minus sign, arrow from lambdas or augmented assignment. case '-': { if (pline.size > 1 && pline.data[1] == '>') { ret.len++; ret.type = kExprLexArrow; + } else if (pline.size > 1 && pline.data[1] == '=') { + ret.len++; + ret.type = kExprLexAssignment; + ret.data.ass.type = kExprAsgnSubtract; } else { ret.type = kExprLexMinus; } break; } + // Sign or augmented assignment. +#define CHAR_OR_ASSIGN(ch, ch_type, ass_type) \ + case ch: { \ + if (pline.size > 1 && pline.data[1] == '=') { \ + ret.len++; \ + ret.type = kExprLexAssignment; \ + ret.data.ass.type = ass_type; \ + } else { \ + ret.type = ch_type; \ + } \ + break; \ + } + CHAR_OR_ASSIGN('+', kExprLexPlus, kExprAsgnAdd) + CHAR_OR_ASSIGN('.', kExprLexDot, kExprAsgnConcat) +#undef CHAR_OR_ASSIGN + // Expression end because Ex command ended. case NUL: case NL: { @@ -661,6 +683,7 @@ static const char *const eltkn_type_tab[] = { [kExprLexParenthesis] = "Parenthesis", [kExprLexComma] = "Comma", [kExprLexArrow] = "Arrow", + [kExprLexAssignment] = "Assignment", }; const char *const eltkn_cmp_type_tab[] = { @@ -671,6 +694,13 @@ const char *const eltkn_cmp_type_tab[] = { [kExprCmpIdentical] = "Identical", }; +const char *const expr_asgn_type_tab[] = { + [kExprAsgnPlain] = "Plain", + [kExprAsgnAdd] = "Add", + [kExprAsgnSubtract] = "Subtract", + [kExprAsgnConcat] = "Concat", +}; + const char *const ccs_tab[] = { [kCCStrategyUseOption] = "UseOption", [kCCStrategyMatchCase] = "MatchCase", @@ -732,6 +762,8 @@ const char *viml_pexpr_repr_token(const ParserState *const pstate, (int)token.data.cmp.inv) TKNARGS(kExprLexMultiplication, "(type=%s)", eltkn_mul_type_tab[token.data.mul.type]) + TKNARGS(kExprLexAssignment, "(type=%s)", + expr_asgn_type_tab[token.data.ass.type]) TKNARGS(kExprLexRegister, "(name=%s)", intchar2str(token.data.reg.name)) case kExprLexDoubleQuotedString: TKNARGS(kExprLexSingleQuotedString, "(closed=%i)", @@ -811,6 +843,7 @@ const char *const east_node_type_tab[] = { [kExprNodeMod] = "Mod", [kExprNodeOption] = "Option", [kExprNodeEnvironment] = "Environment", + [kExprNodeAssignment] = "Assignment", }; /// Represent `int` character as a string @@ -933,6 +966,7 @@ const uint8_t node_maxchildren[] = { [kExprNodeMod] = 2, [kExprNodeOption] = 0, [kExprNodeEnvironment] = 0, + [kExprNodeAssignment] = 2, }; /// Free memory occupied by AST @@ -993,6 +1027,7 @@ void viml_pexpr_free_ast(ExprAST ast) case kExprNodeLambda: case kExprNodeDictLiteral: case kExprNodeCurlyBracesIdentifier: + case kExprNodeAssignment: case kExprNodeComma: case kExprNodeColon: case kExprNodeArrow: @@ -1111,6 +1146,8 @@ static struct { [kExprNodeCurlyBracesIdentifier] = { kEOpLvlComplexIdentifier, kEOpAssLeft }, + [kExprNodeAssignment] = { kEOpLvlAssignment, kEOpAssLeft }, + [kExprNodeComplexIdentifier] = { kEOpLvlValue, kEOpAssLeft }, [kExprNodePlainIdentifier] = { kEOpLvlValue, kEOpAssNo }, @@ -1478,6 +1515,17 @@ static inline void east_set_error(const ParserState *const pstate, } \ } while (0) +/// Determine whether given parse type is an assignment +/// +/// @param[in] pt Checked parse type. +/// +/// @return true if parsing an assignment, false otherwise. +static inline bool pt_is_assignment(const ExprASTParseType pt) + FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_CONST FUNC_ATTR_WARN_UNUSED_RESULT +{ + return (pt == kEPTAssignment || pt == kEPTSingleAssignment); +} + /// Structure used to define “string shifts†necessary to map string /// highlighting to actual strings. typedef struct { @@ -1839,6 +1887,9 @@ ExprAST viml_pexpr_parse(ParserState *const pstate, const int flags) ExprASTParseTypeStack pt_stack; kvi_init(pt_stack); kvi_push(pt_stack, kEPTExpr); + if (flags & kExprFlagsParseLet) { + kvi_push(pt_stack, kEPTAssignment); + } LexExprToken prev_token = { .type = kExprLexMissing }; bool highlighted_prev_spacing = false; // Lambda node, valid when parsing lambda arguments only. @@ -1938,33 +1989,83 @@ viml_pexpr_parse_process_token: // circumstances, and in any case runtime and not parse time errors. (*kv_Z(ast_stack, 1))->type = kExprNodeConcat; } - if (kv_last(pt_stack) == kEPTLambdaArguments - && ((want_node == kENodeOperator + // Pop some stack pt_stack items in case of misplaced nodes. + const bool is_single_assignment = kv_last(pt_stack) == kEPTSingleAssignment; + switch (kv_last(pt_stack)) { + case kEPTExpr: { + break; + } + case kEPTLambdaArguments: { + if ((want_node == kENodeOperator && tok_type != kExprLexComma && tok_type != kExprLexArrow) || (want_node == kENodeValue && !(cur_token.type == kExprLexPlainIdentifier && cur_token.data.var.scope == kExprVarScopeMissing && !cur_token.data.var.autoload) - && tok_type != kExprLexArrow))) { - lambda_node->data.fig.type_guesses.allow_lambda = false; - if (lambda_node->children != NULL - && lambda_node->children->type == kExprNodeComma) { - // If lambda has comma child this means that parser has already seen at - // least "{arg1,", so node cannot possibly be anything, but lambda. - - // Vim may give E121 or E720 in this case, but it does not look right to - // have either because both are results of reevaluation possibly-lambda - // node as a dictionary and here this is not going to happen. - ERROR_FROM_TOKEN_AND_MSG( - cur_token, _("E15: Expected lambda arguments list or arrow: %.*s")); - } else { - // Else it may appear that possibly-lambda node is actually a dictionary - // or curly-braces-name identifier. - lambda_node = NULL; - kv_drop(pt_stack, 1); + && tok_type != kExprLexArrow)) { + lambda_node->data.fig.type_guesses.allow_lambda = false; + if (lambda_node->children != NULL + && lambda_node->children->type == kExprNodeComma) { + // If lambda has comma child this means that parser has already seen at + // least "{arg1,", so node cannot possibly be anything, but lambda. + + // Vim may give E121 or E720 in this case, but it does not look right to + // have either because both are results of reevaluation possibly-lambda + // node as a dictionary and here this is not going to happen. + ERROR_FROM_TOKEN_AND_MSG( + cur_token, _("E15: Expected lambda arguments list or arrow: %.*s")); + } else { + // Else it may appear that possibly-lambda node is actually a dictionary + // or curly-braces-name identifier. + lambda_node = NULL; + kv_drop(pt_stack, 1); + } + } + break; + } + case kEPTSingleAssignment: { + if (tok_type == kExprLexBracket && !cur_token.data.brc.closing) { + ERROR_FROM_TOKEN_AND_MSG( + cur_token, + _("E475: Nested lists not allowed when assigning: %.*s")); + kv_drop(pt_stack, 2); + assert(kv_size(pt_stack)); + assert(kv_last(pt_stack) == kEPTExpr); + break; + } + FALLTHROUGH; + } + case kEPTAssignment: { + if (want_node == kENodeValue + && tok_type != kExprLexBracket + && tok_type != kExprLexPlainIdentifier + && (tok_type != kExprLexFigureBrace || cur_token.data.brc.closing) + && !(node_is_key && tok_type == kExprLexNumber) + && tok_type != kExprLexEnv + && tok_type != kExprLexOption + && tok_type != kExprLexRegister) { + ERROR_FROM_TOKEN_AND_MSG( + cur_token, + _("E15: Expected value part of assignment lvalue: %.*s")); + kv_drop(pt_stack, 1); + } else if (want_node == kENodeOperator + && tok_type != kExprLexBracket + && (tok_type != kExprLexFigureBrace + || cur_token.data.brc.closing) + && tok_type != kExprLexDot + && (tok_type != kExprLexComma || !is_single_assignment) + && tok_type != kExprLexAssignment) { + ERROR_FROM_TOKEN_AND_MSG( + cur_token, + _("E15: Expected assignment operator or subscript: %.*s")); + kv_drop(pt_stack, 1); + } + assert(kv_size(pt_stack)); + break; } } + assert(kv_size(pt_stack)); const ExprASTParseType cur_pt = kv_last(pt_stack); assert(lambda_node == NULL || cur_pt == kEPTLambdaArguments); switch (tok_type) { @@ -2339,21 +2440,41 @@ viml_pexpr_parse_bracket_closing_error: } kvi_push(ast_stack, new_top_node_p); want_node = kENodeOperator; + if (cur_pt == kEPTSingleAssignment) { + kv_drop(pt_stack, 1); + } else if (cur_pt == kEPTAssignment) { + assert(ast.err.msg); + } else if (cur_pt == kEPTExpr + && kv_size(pt_stack) > 1 + && pt_is_assignment(kv_Z(pt_stack, 1))) { + kv_drop(pt_stack, 1); + } } else { if (want_node == kENodeValue) { - // Value means list literal. + // Value means list literal or list assignment. HL_CUR_TOKEN(List); NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeListLiteral); *top_node_p = cur_node; kvi_push(ast_stack, &cur_node->children); want_node = kENodeValue; + if (cur_pt == kEPTAssignment) { + // Additional assignment parse type allows to easily forbid nested + // lists. + kvi_push(pt_stack, kEPTSingleAssignment); + } } else { + // Operator means subscript, also in assignment. But in assignment + // subscript may be pretty much any expression, so need to push + // kEPTExpr. if (prev_token.type == kExprLexSpacing) { OP_MISSING; } NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeSubscript); ADD_OP_NODE(cur_node); HL_CUR_TOKEN(SubscriptBracket); + if (pt_is_assignment(cur_pt)) { + kvi_push(pt_stack, kEPTExpr); + } } } break; @@ -2458,15 +2579,31 @@ viml_pexpr_parse_figure_brace_closing_error: } kvi_push(ast_stack, new_top_node_p); want_node = kENodeOperator; + if (cur_pt == kEPTExpr + && kv_size(pt_stack) > 1 + && pt_is_assignment(kv_Z(pt_stack, 1))) { + kv_drop(pt_stack, 1); + } } else { if (want_node == kENodeValue) { HL_CUR_TOKEN(FigureBrace); // Value: may be any of lambda, dictionary literal and curly braces // name. - NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeUnknownFigure); - cur_node->data.fig.type_guesses.allow_lambda = true; - cur_node->data.fig.type_guesses.allow_dict = true; - cur_node->data.fig.type_guesses.allow_ident = true; + + // Though if we are in an assignment this may only be a curly braces + // name. + if (pt_is_assignment(cur_pt)) { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeCurlyBracesIdentifier); + cur_node->data.fig.type_guesses.allow_lambda = false; + cur_node->data.fig.type_guesses.allow_dict = false; + cur_node->data.fig.type_guesses.allow_ident = true; + kvi_push(pt_stack, kEPTExpr); + } else { + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeUnknownFigure); + cur_node->data.fig.type_guesses.allow_lambda = true; + cur_node->data.fig.type_guesses.allow_dict = true; + cur_node->data.fig.type_guesses.allow_ident = true; + } if (pstate->colors) { cur_node->data.fig.opening_hl_idx = kv_size(*pstate->colors) - 1; } @@ -2484,6 +2621,9 @@ viml_pexpr_parse_figure_brace_closing_error: cur_node->data.fig.type_guesses.allow_dict = false; cur_node->data.fig.type_guesses.allow_ident = true; kvi_push(ast_stack, &cur_node->children); + if (pt_is_assignment(cur_pt)) { + kvi_push(pt_stack, kEPTExpr); + } want_node = kENodeValue; } while (0), Curly); @@ -2746,6 +2886,36 @@ viml_pexpr_parse_no_paren_closing_error: {} want_node = kENodeOperator; break; } + case kExprLexAssignment: { + if (cur_pt == kEPTAssignment) { + kv_drop(pt_stack, 1); + } else if (cur_pt == kEPTSingleAssignment) { + kv_drop(pt_stack, 2); + ERROR_FROM_TOKEN_AND_MSG( + cur_token, + _("E475: Expected closing bracket to end list assignment " + "lvalue: %.*s")); + } else { + ERROR_FROM_TOKEN_AND_MSG( + cur_token, _("E15: Misplaced assignment: %.*s")); + } + assert(kv_size(pt_stack)); + assert(kv_last(pt_stack) == kEPTExpr); + ADD_VALUE_IF_MISSING(_("E15: Unexpected assignment: %.*s")); + NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeAssignment); + cur_node->data.ass.type = cur_token.data.ass.type; + switch (cur_token.data.ass.type) { +#define HL_ASGN(asgn, hl) \ + case kExprAsgn##asgn: { HL_CUR_TOKEN(hl); break; } + HL_ASGN(Plain, PlainAssignment) + HL_ASGN(Add, AssignmentWithAddition) + HL_ASGN(Subtract, AssignmentWithSubtraction) + HL_ASGN(Concat, AssignmentWithConcatenation) +#undef HL_ASGN + } + ADD_OP_NODE(cur_node); + break; + } } viml_pexpr_parse_cycle_end: prev_token = cur_token; @@ -2862,6 +3032,7 @@ viml_pexpr_parse_end: // FIXME: Investigate whether above are OK to be present in the stack. break; } + case kExprNodeAssignment: case kExprNodeMod: case kExprNodeDivision: case kExprNodeMultiplication: diff --git a/src/nvim/viml/parser/expressions.h b/src/nvim/viml/parser/expressions.h index 648f8cbc1f..23e172da75 100644 --- a/src/nvim/viml/parser/expressions.h +++ b/src/nvim/viml/parser/expressions.h @@ -51,6 +51,9 @@ typedef enum { kExprLexParenthesis, ///< Parenthesis, either opening or closing. kExprLexComma, ///< Comma. kExprLexArrow, ///< Arrow, like from lambda expressions. + kExprLexAssignment, ///< Assignment: `=` or `{op}=`. + // XXX When modifying this enum you need to also modify eltkn_type_tab in + // expressions.c and tests and, possibly, viml_pexpr_repr_token. } LexExprTokenType; typedef enum { @@ -68,6 +71,14 @@ typedef enum { kExprOptScopeLocal = 'l', } ExprOptScope; +/// All possible assignment types: `=` and `{op}=`. +typedef enum { + kExprAsgnPlain = 0, ///< Plain assignment: `=`. + kExprAsgnAdd, ///< Assignment augmented with addition: `+=`. + kExprAsgnSubtract, ///< Assignment augmented with subtraction: `-=`. + kExprAsgnConcat, ///< Assignment augmented with concatenation: `.=`. +} ExprAssignmentType; + #define EXPR_OPT_SCOPE_LIST \ ((char[]){ kExprOptScopeGlobal, kExprOptScopeLocal }) @@ -147,6 +158,10 @@ typedef struct { uint8_t base; ///< Base: 2, 8, 10 or 16. bool is_float; ///< True if number is a floating-point. } num; ///< For kExprLexNumber + + struct { + ExprAssignmentType type; + } ass; ///< For kExprLexAssignment } data; ///< Additional data, if needed. } LexExprToken; @@ -170,8 +185,8 @@ typedef enum { /// “EOC†is something like "|". It is fine with emitting EOC at the end of /// string still, with or without this flag set. kELFlagForbidEOC = (1 << 4), - // WARNING: whenever you add a new flag, alter klee_assume() statement in - // viml_expressions_lexer.c. + // XXX Whenever you add a new flag, alter klee_assume() statement in + // viml_expressions_lexer.c. } LexExprFlags; /// Expression AST node type @@ -233,6 +248,10 @@ typedef enum { kExprNodeMod, kExprNodeOption, kExprNodeEnvironment, + kExprNodeAssignment, + // XXX When modifying this list also modify east_node_type_tab both in parser + // and in tests, and you most likely will also have to alter list of + // highlight groups stored in highlight_init_cmdline variable. } ExprASTNodeType; typedef struct expr_ast_node ExprASTNode; @@ -301,6 +320,9 @@ struct expr_ast_node { const char *ident; ///< Environment variable name start. size_t ident_len; ///< Environment variable name length. } env; ///< For kExprNodeEnvironment. + struct { + ExprAssignmentType type; + } ass; ///< For kExprNodeAssignment } data; }; @@ -314,8 +336,15 @@ enum { /// When parsing expressions input by user bar is assumed to be a binary /// operator and other two are spacings. kExprFlagsDisallowEOC = (1 << 1), - // WARNING: whenever you add a new flag, alter klee_assume() statement in - // viml_expressions_parser.c. + /// Parse :let argument + /// + /// That mean that top level node must be an assignment and first nodes + /// belong to lvalues. + kExprFlagsParseLet = (1 << 2), + // XXX whenever you add a new flag, alter klee_assume() statement in + // viml_expressions_parser.c, nvim_parse_expression() flags parsing + // alongside with its documentation and flag sets in check_parsing() + // function in expressions parser functional and unit tests. } ExprParserFlags; /// AST error definition @@ -350,6 +379,9 @@ extern const char *const eltkn_cmp_type_tab[]; /// Array mapping ExprCaseCompareStrategy values to their stringified versions extern const char *const ccs_tab[]; +/// Array mapping ExprAssignmentType values to their stringified versions +extern const char *const expr_asgn_type_tab[]; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "viml/parser/expressions.h.generated.h" #endif -- cgit From 45445e2e03f1cbfa25dde76ccf3e24d0d297cabe Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 12 Nov 2017 03:52:26 +0300 Subject: unittests: Add some more edge test cases --- src/nvim/viml/parser/expressions.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 13f7131744..07bac89997 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -40,6 +40,13 @@ // E15: Invalid expression: [1, // // < , just exactly one E697 message. +// 6. Some expressions involving calling parenthesis which are treated +// separately by Vim even when not separated by spaces are treated as one +// expression by Neovim: e.g. ":echo (1)(1)" will yield runtime error after +// failing to call "1", while Vim will echo "1 1". Reasoning is the same: +// type of what is in the first expression is generally not known when +// parsing, so to have separate expressions like this separate them with +// spaces. #include #include -- cgit From 881f9e42d1821214b97732022b406ddb4330b775 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 12 Nov 2017 15:34:04 +0100 Subject: process_close(): uv_unref() detached processes (#7539) Doc for UV_PROCESS_DETACHED in uv.h mentions: > child process will still keep the parent's event loop alive unless > the parent process calls uv_unref() on the child's process handle. ref #3944 --- src/nvim/event/libuv_process.c | 2 +- src/nvim/event/process.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_process.c index f6a567a520..758b35796e 100644 --- a/src/nvim/event/libuv_process.c +++ b/src/nvim/event/libuv_process.c @@ -38,7 +38,7 @@ int libuv_process_spawn(LibuvProcess *uvproc) #endif uvproc->uvopts.exit_cb = exit_cb; uvproc->uvopts.cwd = proc->cwd; - uvproc->uvopts.env = NULL; + uvproc->uvopts.env = NULL; // Inherits the parent (nvim) env. uvproc->uvopts.stdio = uvproc->uvstdio; uvproc->uvopts.stdio_count = 3; uvproc->uvstdio[0].flags = UV_IGNORE; diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index 8371d3cd48..41e793500a 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -324,6 +324,13 @@ static void process_close(Process *proc) } assert(!proc->closed); proc->closed = true; + + if (proc->detach) { + if (proc->type == kProcessTypeUv) { + uv_unref((uv_handle_t *)&(((LibuvProcess *)proc)->uv)); + } + } + switch (proc->type) { case kProcessTypeUv: libuv_process_close((LibuvProcess *)proc); -- cgit From 0407ddb36464c46086b608baebf7eed8a9ab60d5 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 11 Nov 2017 10:48:04 -0500 Subject: Use PRId64 to format Integer when calling api_set_error Integer is a 64-bit type so using %d can produce incorrect results. test/functional/api/highlight_spec.lua @ 35: highlight api nvim_get_hl_by_id ...W7Xi/neovim-0.2.1/test/functional/api/highlight_spec.lua:46: Expected objects to be the same. Passed in: (string) 'Invalid highlight id: 7671724' Expected: (string) 'Invalid highlight id: 30000' --- src/nvim/api/vim.c | 3 ++- src/nvim/syntax.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index e5ec018795..d2b0e329c9 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -89,7 +89,8 @@ Dictionary nvim_get_hl_by_id(Integer hl_id, Boolean rgb, Error *err) { Dictionary dic = ARRAY_DICT_INIT; if (syn_get_final_id((int)hl_id) == 0) { - api_set_error(err, kErrorTypeException, "Invalid highlight id: %d", hl_id); + api_set_error(err, kErrorTypeException, + "Invalid highlight id: %" PRId64, hl_id); return dic; } int attrcode = syn_id2attr((int)hl_id); diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 913fd05482..65490768c4 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -8256,7 +8256,7 @@ Dictionary hl_get_attr_by_id(Integer attr_id, Boolean rgb, Error *err) attrentry_T *aep = syn_cterm_attr2entry((int)attr_id); if (!aep) { api_set_error(err, kErrorTypeException, - "Invalid attribute id: %d", attr_id); + "Invalid attribute id: %" PRId64, attr_id); return dic; } -- cgit From 556451a7f2fd513db33b9d7ac1b653d356b7b915 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 12 Nov 2017 16:59:36 +0300 Subject: unittests,syntax: Check for sanity of highlight_init_cmdline Also fixes some errors found. --- src/nvim/syntax.c | 14 +++++++++----- src/nvim/syntax.h | 3 +++ 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 9f98b26905..c9e99d82f8 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6020,7 +6020,7 @@ static const char *highlight_init_dark[] = { NULL }; -static const char *highlight_init_cmdline[] = { +const char *const highlight_init_cmdline[] = { // XXX When modifying a list modify it in both valid and invalid halfs. // TODO(ZyX-I): merge valid and invalid groups via a macros. @@ -6047,6 +6047,7 @@ static const char *highlight_init_cmdline[] = { "default link NVimComparison NVimBinaryOperator", "default link NVimComparisonModifier NVimComparison", "default link NVimBinaryPlus NVimBinaryOperator", + "default link NVimBinaryMinus NVimBinaryOperator", "default link NVimConcat NVimBinaryOperator", "default link NVimConcatOrSubscript NVimConcat", "default link NVimOr NVimBinaryOperator", @@ -6108,9 +6109,6 @@ static const char *highlight_init_cmdline[] = { "default link NVimDoubleQuote NVimStringQuote", "default link NVimDoubleQuotedBody NVimStringBody", "default link NVimDoubleQuotedEscape NVimStringSpecial", - // Not actually invalid, but we highlight user that he is doing something - // wrong. - "default link NVimDoubleQuotedUnknownEscape NVimInvalidValue", "default link NVimFigureBrace NVimInternalError", "default link NVimSingleQuotedUnknownEscape NVimInternalError", @@ -6144,6 +6142,7 @@ static const char *highlight_init_cmdline[] = { "default link NVimInvalidComparison NVimInvalidBinaryOperator", "default link NVimInvalidComparisonModifier NVimInvalidComparison", "default link NVimInvalidBinaryPlus NVimInvalidBinaryOperator", + "default link NVimInvalidBinaryMinus NVimInvalidBinaryOperator", "default link NVimInvalidConcat NVimInvalidBinaryOperator", "default link NVimInvalidConcatOrSubscript NVimInvalidConcat", "default link NVimInvalidOr NVimInvalidBinaryOperator", @@ -6217,12 +6216,17 @@ static const char *highlight_init_cmdline[] = { "default link NVimInvalidFigureBrace NVimInvalidDelimiter", "default link NVimInvalidSpacing ErrorMsg", + + // Not actually invalid, but we highlight user that he is doing something + // wrong. + "default link NVimDoubleQuotedUnknownEscape NVimInvalidValue", + NULL, }; /// Create default links for NVim* highlight groups used for cmdline coloring void syn_init_cmdline_highlight(bool reset, bool init) { - for (size_t i = 0 ; i < ARRAY_SIZE(highlight_init_cmdline) ; i++) { + for (size_t i = 0 ; highlight_init_cmdline[i] != NULL ; i++) { do_highlight(highlight_init_cmdline[i], reset, init); } } diff --git a/src/nvim/syntax.h b/src/nvim/syntax.h index bb733ead30..c9b0665ec8 100644 --- a/src/nvim/syntax.h +++ b/src/nvim/syntax.h @@ -45,6 +45,9 @@ typedef struct { } color_name_table_T; extern color_name_table_T color_name_table[]; +/// Array of highlight definitions, used for unit testing +extern const char *const highlight_init_cmdline[]; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "syntax.h.generated.h" #endif -- cgit From 342239a9c53cf4857d18c0583d4cab1fdca534fa Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 13 Nov 2017 01:10:39 +0300 Subject: unittests,viml/parser/expressions: Start adding asgn parsing tests --- src/nvim/viml/parser/expressions.c | 50 ++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 07bac89997..4bd3652292 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -1363,7 +1363,6 @@ static inline ParserPosition recol_pos(const ParserPosition pos, } \ } while (0) -// TODO(ZyX-I): actual condition /// Check whether it is possible to have next expression after current /// /// For :echo: `:echo @a @a` is a valid expression. `:echo (@a @a)` is not. @@ -1901,6 +1900,7 @@ ExprAST viml_pexpr_parse(ParserState *const pstate, const int flags) bool highlighted_prev_spacing = false; // Lambda node, valid when parsing lambda arguments only. ExprASTNode *lambda_node = NULL; + size_t asgn_level = 0; do { const bool is_concat_or_subscript = ( want_node == kENodeValue @@ -2063,6 +2063,9 @@ viml_pexpr_parse_process_token: && tok_type != kExprLexDot && (tok_type != kExprLexComma || !is_single_assignment) && tok_type != kExprLexAssignment) { + if (flags & kExprFlagsMulti && MAY_HAVE_NEXT_EXPR) { + goto viml_pexpr_parse_end; + } ERROR_FROM_TOKEN_AND_MSG( cur_token, _("E15: Expected assignment operator or subscript: %.*s")); @@ -2429,6 +2432,10 @@ viml_pexpr_parse_valid_colon: ExprASTNode *new_top_node = *new_top_node_p; switch (new_top_node->type) { case kExprNodeListLiteral: { + if (pt_is_assignment(cur_pt) && new_top_node->children == NULL) { + ERROR_FROM_TOKEN_AND_MSG( + cur_token, _("E475: Unable to assign to empty list: %.*s")); + } HL_CUR_TOKEN(List); break; } @@ -2447,14 +2454,18 @@ viml_pexpr_parse_bracket_closing_error: } kvi_push(ast_stack, new_top_node_p); want_node = kENodeOperator; - if (cur_pt == kEPTSingleAssignment) { - kv_drop(pt_stack, 1); - } else if (cur_pt == kEPTAssignment) { - assert(ast.err.msg); - } else if (cur_pt == kEPTExpr - && kv_size(pt_stack) > 1 - && pt_is_assignment(kv_Z(pt_stack, 1))) { - kv_drop(pt_stack, 1); + if (kv_size(ast_stack) <= asgn_level) { + assert(kv_size(ast_stack) == asgn_level); + asgn_level = 0; + if (cur_pt == kEPTSingleAssignment) { + kv_drop(pt_stack, 1); + } else if (cur_pt == kEPTAssignment) { + assert(ast.err.msg); + } else if (cur_pt == kEPTExpr + && kv_size(pt_stack) > 1 + && pt_is_assignment(kv_Z(pt_stack, 1))) { + kv_drop(pt_stack, 1); + } } } else { if (want_node == kENodeValue) { @@ -2480,6 +2491,7 @@ viml_pexpr_parse_bracket_closing_error: ADD_OP_NODE(cur_node); HL_CUR_TOKEN(SubscriptBracket); if (pt_is_assignment(cur_pt)) { + asgn_level = kv_size(ast_stack); kvi_push(pt_stack, kEPTExpr); } } @@ -2586,10 +2598,14 @@ viml_pexpr_parse_figure_brace_closing_error: } kvi_push(ast_stack, new_top_node_p); want_node = kENodeOperator; - if (cur_pt == kEPTExpr - && kv_size(pt_stack) > 1 - && pt_is_assignment(kv_Z(pt_stack, 1))) { - kv_drop(pt_stack, 1); + if (kv_size(ast_stack) <= asgn_level) { + assert(kv_size(ast_stack) == asgn_level); + if (cur_pt == kEPTExpr + && kv_size(pt_stack) > 1 + && pt_is_assignment(kv_Z(pt_stack, 1))) { + kv_drop(pt_stack, 1); + asgn_level = 0; + } } } else { if (want_node == kENodeValue) { @@ -2635,6 +2651,10 @@ viml_pexpr_parse_figure_brace_closing_error: } while (0), Curly); } + if (pt_is_assignment(cur_pt) + && !pt_is_assignment(kv_last(pt_stack))) { + asgn_level = kv_size(ast_stack); + } } break; } @@ -2755,6 +2775,10 @@ viml_pexpr_parse_figure_brace_closing_error: case kExprLexDot: { ADD_VALUE_IF_MISSING(_("E15: Unexpected dot: %.*s")); if (prev_token.type == kExprLexSpacing) { + if (cur_pt == kEPTAssignment) { + ERROR_FROM_TOKEN_AND_MSG( + cur_token, _("E15: Cannot concatenate in assignments: %.*s")); + } NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeConcat); HL_CUR_TOKEN(Concat); } else { -- cgit From 6b8c34137cf3253616e6a6f861380541537c0bb9 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 13 Nov 2017 06:27:08 +0800 Subject: vim-patch: NA * vim-patch:8.0.0245 Problem: The generated zh_CN.cp936.po message file is not encoded properly. Solution: Instead of using zh_CN.po as input, use zh_CN.UTF-8.po. https://github.com/vim/vim/commit/16038d50c4309e8dee33c70ca2c9e7f73439c4df * vim-patch:8.0.0248 Problem: vim_strcat() cannot handle overlapping arguments. Solution: Use mch_memmove() instead of strcpy(). (Justin M Keyes, closes vim/vim#1415) https://github.com/vim/vim/commit/45600ce8f2bead069882032f992623cd5a799ca0 --- src/nvim/version.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 05725a59f9..8c9bea9a9b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -856,10 +856,10 @@ static const int included_patches[] = { // 251, 250, // 249 NA - // 248, + // 248 NA 247, // 246 NA - // 245, + 245, // 244, 243, 242, -- cgit From e6beb60da517b6d7d7461687bf91f87d097b9563 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 13 Nov 2017 02:06:32 +0100 Subject: :terminal : fix crash on resize (#7547) closes #7538 Fix wrong window references from #7440 Remove some eager resizing. Still mostly doesn't address #4997. --- src/nvim/buffer.c | 7 ------- src/nvim/screen.c | 4 ++-- src/nvim/window.c | 18 ++---------------- 3 files changed, 4 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index f874268910..766003a021 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -64,7 +64,6 @@ #include "nvim/spell.h" #include "nvim/strings.h" #include "nvim/syntax.h" -#include "nvim/terminal.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/version.h" @@ -1464,12 +1463,6 @@ void enter_buffer(buf_T *buf) /* mark cursor position as being invalid */ curwin->w_valid = 0; - if (buf->terminal) { - terminal_resize(buf->terminal, - (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), - (uint16_t)curwin->w_height); - } - /* Make sure the buffer is loaded. */ if (curbuf->b_ml.ml_mfp == NULL) { /* need to load the file */ /* If there is no filetype, allow for detecting one. Esp. useful for diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 41e900eb4c..ed96e98d32 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -696,8 +696,8 @@ static void win_update(win_T *wp) if (buf->terminal) { terminal_resize(buf->terminal, - (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), - (uint16_t)curwin->w_height); + (uint16_t)(MAX(0, wp->w_width - win_col_off(wp))), + (uint16_t)wp->w_height); } } else if (buf->b_mod_set && buf->b_mod_xlines != 0 diff --git a/src/nvim/window.c b/src/nvim/window.c index 2d64409a1c..4e4eb297aa 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1846,12 +1846,6 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, shell_new_rows(); } - if (term) { - // When a window containing a terminal buffer is closed, recalculate its - // size - terminal_resize(term, 0, 0); - } - // Since goto_tabpage_tp above did not trigger *Enter autocommands, do // that now. apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, curbuf); @@ -3745,12 +3739,6 @@ static void win_enter_ext(win_T *wp, bool undo_sync, int curwin_invalid, /* Change directories when the 'acd' option is set. */ do_autochdir(); - - if (curbuf->terminal) { - terminal_resize(curbuf->terminal, - (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), - (uint16_t)curwin->w_height); - } } @@ -4930,9 +4918,7 @@ void scroll_to_fraction(win_T *wp, int prev_height) } } -/* - * Set the width of a window. - */ +/// Set the width of a window. void win_new_width(win_T *wp, int width) { wp->w_width = width; @@ -4949,7 +4935,7 @@ void win_new_width(win_T *wp, int width) if (wp->w_buffer->terminal) { if (wp->w_height != 0) { terminal_resize(wp->w_buffer->terminal, - (uint16_t)(MAX(0, curwin->w_width - win_col_off(curwin))), + (uint16_t)(MAX(0, wp->w_width - win_col_off(wp))), 0); } } -- cgit From 8fff2ef74aae47042c4ee903ae996aa789787fe1 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 13 Nov 2017 08:30:25 +0100 Subject: vim-patch:8.0.0227 (#7548) Problem: Crash when 'fileformat' is forced to "dos" and the first line in the file is empty and does not have a CR character. Solution: Don't check for CR before the start of the buffer. https://github.com/vim/vim/commit/2aa5f696b91a51f29873e340de4bdc182e1e8dd4 --- src/nvim/fileio.c | 3 ++- src/nvim/testdir/test_fileformat.vim | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index a7676e88f0..ae6c3f96e3 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -1622,7 +1622,8 @@ rewind_retry: *ptr = NUL; /* end of line */ len = (colnr_T)(ptr - line_start + 1); if (fileformat == EOL_DOS) { - if (ptr[-1] == CAR) { /* remove CR */ + if (ptr > line_start && ptr[-1] == CAR) { + // remove CR before NL ptr[-1] = NUL; len--; } else if (ff_error != EOL_DOS) { diff --git a/src/nvim/testdir/test_fileformat.vim b/src/nvim/testdir/test_fileformat.vim index de505d3bd0..8dc25f62b1 100644 --- a/src/nvim/testdir/test_fileformat.vim +++ b/src/nvim/testdir/test_fileformat.vim @@ -17,7 +17,7 @@ func Test_fileformat_after_bw() endfunc func Test_fileformat_autocommand() - let filecnt = ["\", "foobar\", "eins\", "\", "zwei\", "drei", "vier", "fünf", ""] + let filecnt = ["", "foobar\", "eins\", "\", "zwei\", "drei", "vier", "fünf", ""] let ffs = &ffs call writefile(filecnt, 'Xfile', 'b') au BufReadPre Xfile set ffs=dos ff=dos -- cgit From 67e45292925daf08d353581c1a9999eb0e2202dd Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 14 Nov 2017 20:55:25 +0100 Subject: defaults: scrollback=10000 (#7556) --- src/nvim/options.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 7cecb16686..29220a6b50 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -1924,7 +1924,7 @@ return { vi_def=true, varname='p_scbk', redraw={'current_buffer'}, - defaults={if_true={vi=1000}} + defaults={if_true={vi=10000}} }, { full_name='scrollbind', abbreviation='scb', -- cgit From ee031eb5256bb83e0d6add2bae6fd943a4186ffe Mon Sep 17 00:00:00 2001 From: Sewoong Park Date: Wed, 15 Nov 2017 15:55:02 +0900 Subject: lint #7562 --- src/nvim/vim.h | 170 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 82 insertions(+), 88 deletions(-) (limited to 'src') diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 62ffc7433e..1db1a073ed 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -4,26 +4,24 @@ #include "nvim/types.h" #include "nvim/pos.h" // for linenr_T, MAXCOL, etc... -/* Some defines from the old feature.h */ +// Some defines from the old feature.h #define SESSION_FILE "Session.vim" #define MAX_MSG_HIST_LEN 200 #define SYS_OPTWIN_FILE "$VIMRUNTIME/optwin.vim" #define RUNTIME_DIRNAME "runtime" -/* end */ + #include "auto/config.h" #define HAVE_PATHDEF -/* - * Check if configure correctly managed to find sizeof(int). If this failed, - * it becomes zero. This is likely a problem of not being able to run the - * test program. Other items from configure may also be wrong then! - */ +// Check if configure correctly managed to find sizeof(int). If this failed, +// it becomes zero. This is likely a problem of not being able to run the +// test program. Other items from configure may also be wrong then! #if (SIZEOF_INT == 0) # error Configure did not run properly. #endif -#include "nvim/os/os_defs.h" /* bring lots of system header files */ +#include "nvim/os/os_defs.h" // bring lots of system header files /// length of a buffer to store a number in ASCII (64 bits binary + NUL) enum { NUMBUFLEN = 65 }; @@ -44,41 +42,41 @@ enum { NUMBUFLEN = 65 }; #include "nvim/gettext.h" -/* special attribute addition: Put message in history */ +// special attribute addition: Put message in history #define MSG_HIST 0x1000 -/* - * values for State - * - * The lower bits up to 0x20 are used to distinguish normal/visual/op_pending - * and cmdline/insert+replace mode. This is used for mapping. If none of - * these bits are set, no mapping is done. - * The upper bits are used to distinguish between other states. - */ -#define NORMAL 0x01 /* Normal mode, command expected */ -#define VISUAL 0x02 /* Visual mode - use get_real_state() */ -#define OP_PENDING 0x04 /* Normal mode, operator is pending - use - get_real_state() */ -#define CMDLINE 0x08 /* Editing command line */ -#define INSERT 0x10 /* Insert mode */ -#define LANGMAP 0x20 /* Language mapping, can be combined with - INSERT and CMDLINE */ - -#define REPLACE_FLAG 0x40 /* Replace mode flag */ + +// values for State +// +// The lower bits up to 0x20 are used to distinguish normal/visual/op_pending +// and cmdline/insert+replace mode. This is used for mapping. If none of +// these bits are set, no mapping is done. +// The upper bits are used to distinguish between other states. + +#define NORMAL 0x01 // Normal mode, command expected +#define VISUAL 0x02 // Visual mode - use get_real_state() +#define OP_PENDING 0x04 // Normal mode, operator is pending - use + // get_real_state() +#define CMDLINE 0x08 // Editing command line +#define INSERT 0x10 // Insert mode +#define LANGMAP 0x20 // Language mapping, can be combined with + // INSERT and CMDLINE + +#define REPLACE_FLAG 0x40 // Replace mode flag #define REPLACE (REPLACE_FLAG + INSERT) -# define VREPLACE_FLAG 0x80 /* Virtual-replace mode flag */ +# define VREPLACE_FLAG 0x80 // Virtual-replace mode flag # define VREPLACE (REPLACE_FLAG + VREPLACE_FLAG + INSERT) #define LREPLACE (REPLACE_FLAG + LANGMAP) -#define NORMAL_BUSY (0x100 + NORMAL) /* Normal mode, busy with a command */ -#define HITRETURN (0x200 + NORMAL) /* waiting for return or command */ -#define ASKMORE 0x300 /* Asking if you want --more-- */ -#define SETWSIZE 0x400 /* window size has changed */ -#define ABBREV 0x500 /* abbreviation instead of mapping */ -#define EXTERNCMD 0x600 /* executing an external command */ -#define SHOWMATCH (0x700 + INSERT) /* show matching paren */ -#define CONFIRM 0x800 /* ":confirm" prompt */ -#define SELECTMODE 0x1000 /* Select mode, only for mappings */ +#define NORMAL_BUSY (0x100 + NORMAL) // Normal mode, busy with a command +#define HITRETURN (0x200 + NORMAL) // waiting for return or command +#define ASKMORE 0x300 // Asking if you want --more-- +#define SETWSIZE 0x400 // window size has changed +#define ABBREV 0x500 // abbreviation instead of mapping +#define EXTERNCMD 0x600 // executing an external command +#define SHOWMATCH (0x700 + INSERT) // show matching paren +#define CONFIRM 0x800 // ":confirm" prompt +#define SELECTMODE 0x1000 // Select mode, only for mappings #define TERM_FOCUS 0x2000 // Terminal focus mode #define CMDPREVIEW 0x4000 // Showing 'inccommand' command "live" preview. @@ -94,13 +92,13 @@ typedef enum { BACKWARD_FILE = (-3), } Direction; -/* return values for functions */ +// return values for functions #if !(defined(OK) && (OK == 1)) -/* OK already defined to 1 in MacOS X curses, skip this */ +// OK already defined to 1 in MacOS X curses, skip this # define OK 1 #endif #define FAIL 0 -#define NOTDONE 2 /* not OK or FAIL but skipped */ +#define NOTDONE 2 // not OK or FAIL but skipped // Type values for type(). #define VAR_TYPE_NUMBER 0 @@ -111,9 +109,9 @@ typedef enum { #define VAR_TYPE_FLOAT 5 #define VAR_TYPE_BOOL 6 -/* - * values for xp_context when doing command line completion - */ + +// values for xp_context when doing command line completion + enum { EXPAND_UNSUCCESSFUL = -2, EXPAND_OK = -1, @@ -169,57 +167,54 @@ enum { +// Minimal size for block 0 of a swap file. +// NOTE: This depends on size of struct block0! It's not done with a sizeof(), +// because struct block0 is defined in memline.c (Sorry). +// The maximal block size is arbitrary. -/* - * Minimal size for block 0 of a swap file. - * NOTE: This depends on size of struct block0! It's not done with a sizeof(), - * because struct block0 is defined in memline.c (Sorry). - * The maximal block size is arbitrary. - */ #define MIN_SWAP_PAGE_SIZE 1048 #define MAX_SWAP_PAGE_SIZE 50000 -/* - * Boolean constants - */ +// Boolean constants + #ifndef TRUE -# define FALSE 0 /* note: this is an int, not a long! */ +# define FALSE 0 // note: this is an int, not a long! # define TRUE 1 #endif -#define MAYBE 2 /* sometimes used for a variant on TRUE */ +#define MAYBE 2 // sometimes used for a variant on TRUE -#define STATUS_HEIGHT 1 /* height of a status line under a window */ -#define QF_WINHEIGHT 10 /* default height for quickfix window */ +#define STATUS_HEIGHT 1 // height of a status line under a window +#define QF_WINHEIGHT 10 // default height for quickfix window + + +// Buffer sizes -/* - * Buffer sizes - */ #ifndef CMDBUFFSIZE -# define CMDBUFFSIZE 256 /* size of the command processing buffer */ +# define CMDBUFFSIZE 256 // size of the command processing buffer #endif -#define LSIZE 512 /* max. size of a line in the tags file */ +#define LSIZE 512 // max. size of a line in the tags file -#define DIALOG_MSG_SIZE 1000 /* buffer size for dialog_msg() */ +#define DIALOG_MSG_SIZE 1000 // buffer size for dialog_msg() enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() -/* - * Maximum length of key sequence to be mapped. - * Must be able to hold an Amiga resize report. - */ + +// Maximum length of key sequence to be mapped. +// Must be able to hold an Amiga resize report. + #define MAXMAPLEN 50 -/* Size in bytes of the hash used in the undo file. */ +// Size in bytes of the hash used in the undo file. #define UNDO_HASH_SIZE 32 -/* - * defines to avoid typecasts from (char_u *) to (char *) and back - * (vim_strchr() and vim_strrchr() are now in alloc.c) - */ + +// defines to avoid typecasts from (char_u *) to (char *) and back +// (vim_strchr() and vim_strrchr() are now in alloc.c) + #define STRLEN(s) strlen((char *)(s)) #define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) #define STRNCPY(d, s, n) strncpy((char *)(d), (char *)(s), (size_t)(n)) @@ -236,7 +231,7 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() # endif #endif -/* Like strcpy() but allows overlapped source and destination. */ +// Like strcpy() but allows overlapped source and destination. #define STRMOVE(d, s) memmove((d), (s), STRLEN(s) + 1) #ifdef HAVE_STRNCASECMP @@ -261,8 +256,8 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() // destination and mess up the screen. #define PERROR(msg) (void) emsgf("%s: %s", msg, strerror(errno)) -#define SHOWCMD_COLS 10 /* columns needed by shown command */ -#define STL_MAX_ITEM 80 /* max nr of % in statusline */ +#define SHOWCMD_COLS 10 // columns needed by shown command +#define STL_MAX_ITEM 80 // max nr of % in statusline /// Compare file names /// @@ -281,28 +276,27 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() (const char *)(y), \ (size_t)(n)) -/* - * Enums need a typecast to be used as array index (for Ultrix). - */ + +// Enums need a typecast to be used as array index (for Ultrix). #define hl_attr(n) highlight_attr[(int)(n)] #define term_str(n) term_strings[(int)(n)] -/* Maximum number of bytes in a multi-byte character. It can be one 32-bit - * character of up to 6 bytes, or one 16-bit character of up to three bytes - * plus six following composing characters of three bytes each. */ +/// Maximum number of bytes in a multi-byte character. It can be one 32-bit +/// character of up to 6 bytes, or one 16-bit character of up to three bytes +/// plus six following composing characters of three bytes each. #define MB_MAXBYTES 21 -/* This has to go after the include of proto.h, as proto/gui.pro declares - * functions of these names. The declarations would break if the defines had - * been seen at that stage. But it must be before globals.h, where error_ga - * is declared. */ +// This has to go after the include of proto.h, as proto/gui.pro declares +// functions of these names. The declarations would break if the defines had +// been seen at that stage. But it must be before globals.h, where error_ga +// is declared. #define mch_errmsg(str) fprintf(stderr, "%s", (str)) #define display_errors() fflush(stderr) #define mch_msg(str) printf("%s", (str)) -#include "nvim/globals.h" /* global variables and messages */ -#include "nvim/buffer_defs.h" /* buffer and windows */ -#include "nvim/ex_cmds_defs.h" /* Ex command defines */ +#include "nvim/globals.h" // global variables and messages +#include "nvim/buffer_defs.h" // buffer and windows +#include "nvim/ex_cmds_defs.h" // Ex command defines # define SET_NO_HLSEARCH(flag) no_hlsearch = (flag); set_vim_var_nr( \ VV_HLSEARCH, !no_hlsearch && p_hls) @@ -324,4 +318,4 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() # define OPEN_CHR_FILES #endif -#endif /* NVIM_VIM_H */ +#endif // NVIM_VIM_H -- cgit From 07931ed1c8cc749222a513cba5bdf300067646bc Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 17 Nov 2017 22:24:01 +0100 Subject: tui: 'guicursor': use DECSCUSR for xterm-likes (#7576) Anything claiming to be an xterm gets DECSCUSR. This is the only reasonable choice unless/until we get more reliable detection (#7490). ref #6997 closes #7550 --- src/nvim/tui/input.c | 2 -- src/nvim/tui/tui.c | 15 ++++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 8bb5971bd4..8e08b77b00 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -14,8 +14,6 @@ #include "nvim/event/rstream.h" #define PASTETOGGLE_KEY "" -#define FOCUSGAINED_KEY "" -#define FOCUSLOST_KEY "" #define KEY_BUFFER_SIZE 0xfff #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 8e0e905bcd..88da634de4 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1453,12 +1453,10 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, data->unibi_ext.set_cursor_style = unibi_find_ext_str(ut, "Ss"); } if (-1 == data->unibi_ext.set_cursor_style) { - // The DECSCUSR sequence to change the cursor shape is widely - // supported by several terminal types and should be in many - // teminfo entries. See - // https://github.com/gnachman/iTerm2/pull/92 for more. - // xterm even has an extended version that has a vertical bar. - if (!konsole && (true_xterm // per xterm ctlseqs doco (since version 282) + // The DECSCUSR sequence to change the cursor shape is widely supported by + // several terminal types. https://github.com/gnachman/iTerm2/pull/92 + // xterm extension: vertical bar + if (!konsole && ((xterm && !vte_version) // anything claiming xterm compat // per MinTTY 0.4.3-1 release notes from 2009 || putty // per https://bugzilla.gnome.org/show_bug.cgi?id=720821 @@ -1470,9 +1468,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // per analysis of VT100Terminal.m || iterm || iterm_pretending_xterm || teraterm // per TeraTerm "Supported Control Functions" doco - // Allows forcing the use of DECSCUSR on linux type terminals, such as - // console-terminal-emulator from the nosh toolset, which does indeed - // implement the xterm extension: + // Some linux-type terminals (such as console-terminal-emulator + // from the nosh toolset) implement implement the xterm extension. || (linuxvt && (xterm_version || (vte_version > 0) || colorterm)))) { data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", "\x1b[%p1%d q"); -- cgit From d135ba99b2945ca18fe3246cbb89a0920868ccf6 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 14 Nov 2017 22:59:58 +0100 Subject: os_open, os_stat: UV_EINVAL on NULL filename EINVAL (instead of EFAULT) because that's what glibc does: https://github.com/bminor/glibc/blob/master/io/open.c#L35 os_nodetype: check for UV_EINVAL explicitly. ref #4370 ref https://github.com/neovim/neovim/issues/4370#issuecomment-344366571 ref ac055d677aa9eff9fca11cecb5ac7f7a4edb0265 ref #4772 --- src/nvim/os/fs.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 78627f8703..c5049acda9 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -172,7 +172,7 @@ int os_nodetype(const char *name) | O_NONBLOCK #endif , 0); - if (fd == -1) { + if (fd == UV_EINVAL) { return NODE_OTHER; // open() failed. } @@ -394,9 +394,11 @@ end: /// @param mode Permissions for the newly-created file (IGNORED if 'flags' is /// not `O_CREAT` or `O_TMPFILE`), subject to the current umask /// @return file descriptor, or libuv error code on failure -int os_open(const char* path, int flags, int mode) - FUNC_ATTR_NONNULL_ALL +int os_open(const char *path, int flags, int mode) { + if (path == NULL) { // uv_fs_open asserts on NULL. #7561 + return UV_EINVAL; + } int r; RUN_UV_FS_FUNC(r, uv_fs_open, path, flags, mode, NULL); return r; @@ -603,12 +605,12 @@ int os_fsync(int fd) /// Get stat information for a file. /// -/// @return libuv return code. +/// @return libuv return code, or -errno static int os_stat(const char *name, uv_stat_t *statbuf) FUNC_ATTR_NONNULL_ARG(2) { if (!name) { - return UV_ENOENT; + return UV_EINVAL; } uv_fs_t request; int result = uv_fs_stat(&fs_loop, &request, name, NULL); -- cgit From bf3f0efb3a98afbcc15020cc3399c71db8f831e7 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 16 Nov 2017 01:00:47 +0100 Subject: os_nodetype: rework Make the Windows impl closer to Vim os_win32.c, and the Unix impl closer to Vim os_unix.c. Outcomes: - Do not send negative fd to close(). ref #4806 #4772 #6860 - Fallback return-value is now correct in (hopefully) all cases. - unix: check S_ISXXX instead of relying on os_open (which can fail for irrelevant reasons). buf_write() expects NODE_WRITABLE for character devices such as /dev/stderr. 96f834a8424e --- src/nvim/os/fs.c | 84 ++++++++++++++++++++++++++------------------------------ 1 file changed, 39 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index c5049acda9..aa28b95c30 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -133,22 +133,12 @@ bool os_isdir(const char_u *name) int os_nodetype(const char *name) FUNC_ATTR_NONNULL_ALL { -#ifdef WIN32 - // Edge case from Vim os_win32.c: - // We can't open a file with a name "\\.\con" or "\\.\prn", trying to read - // from it later will cause Vim to hang. Thus return NODE_WRITABLE here. - if (STRNCMP(name, "\\\\.\\", 4) == 0) { - return NODE_WRITABLE; - } -#endif - +#ifndef WIN32 // Unix uv_stat_t statbuf; if (0 != os_stat(name, &statbuf)) { return NODE_NORMAL; // File doesn't exist. } - -#ifndef WIN32 - // libuv does not handle BLK and DIR in uv_handle_type. + // uv_handle_type does not distinguish BLK and DIR. // Related: https://github.com/joyent/libuv/pull/1421 if (S_ISREG(statbuf.st_mode) || S_ISDIR(statbuf.st_mode)) { return NODE_NORMAL; @@ -156,48 +146,51 @@ int os_nodetype(const char *name) if (S_ISBLK(statbuf.st_mode)) { // block device isn't writable return NODE_OTHER; } -#endif + // Everything else is writable? + // buf_write() expects NODE_WRITABLE for char device /dev/stderr. + return NODE_WRITABLE; +#else // Windows + // Edge case from Vim os_win32.c: + // We can't open a file with a name "\\.\con" or "\\.\prn", trying to read + // from it later will cause Vim to hang. Thus return NODE_WRITABLE here. + if (STRNCMP(name, "\\\\.\\", 4) == 0) { + return NODE_WRITABLE; + } - // Vim os_win32.c:mch_nodetype does this (since patch 7.4.015): - // if (enc_codepage >= 0 && (int)GetACP() != enc_codepage) { - // wn = enc_to_utf16(name, NULL); - // hFile = CreatFile(wn, ...) - // to get a HANDLE. But libuv just calls win32's _get_osfhandle() on the fd we - // give it. uv_fs_open calls fs__capture_path which does a similar dance and - // saves us the hassle. + // Vim os_win32.c:mch_nodetype does (since 7.4.015): + // wn = enc_to_utf16(name, NULL); + // hFile = CreatFile(wn, ...) + // to get a HANDLE. Whereas libuv just calls _get_osfhandle() on the fd we + // give it. But uv_fs_open later calls fs__capture_path which does a similar + // utf8-to-utf16 dance and saves us the hassle. - int nodetype = NODE_WRITABLE; + // macOS: os_open(/dev/stderr) would return UV_EACCES. int fd = os_open(name, O_RDONLY -#ifdef O_NONBLOCK +# ifdef O_NONBLOCK | O_NONBLOCK -#endif +# endif , 0); - if (fd == UV_EINVAL) { - return NODE_OTHER; // open() failed. + if (fd < 0) { // open() failed. + return NODE_NORMAL; + } + int guess = uv_guess_handle(fd); + if (close(fd) == -1) { + ELOG("close(%d) failed. name='%s'", fd, name); } - switch (uv_guess_handle(fd)) { - case UV_TTY: // FILE_TYPE_CHAR - nodetype = NODE_WRITABLE; - break; - case UV_FILE: // FILE_TYPE_DISK - nodetype = NODE_NORMAL; - break; - case UV_NAMED_PIPE: // not handled explicitly in Vim os_win32.c - case UV_UDP: // unix only - case UV_TCP: // unix only + switch (guess) { + case UV_TTY: // FILE_TYPE_CHAR + return NODE_WRITABLE; + case UV_FILE: // FILE_TYPE_DISK + return NODE_NORMAL; + case UV_NAMED_PIPE: // not handled explicitly in Vim os_win32.c + case UV_UDP: // unix only + case UV_TCP: // unix only case UV_UNKNOWN_HANDLE: default: -#ifdef WIN32 - nodetype = NODE_NORMAL; -#else - nodetype = NODE_WRITABLE; // Everything else is writable? -#endif - break; + return NODE_OTHER; // Vim os_win32.c default } - - close(fd); - return nodetype; +#endif } /// Gets the absolute path of the currently running executable. @@ -1080,7 +1073,8 @@ shortcut_end: #endif -int os_translate_sys_error(int sys_errno) { +int os_translate_sys_error(int sys_errno) +{ #ifdef HAVE_UV_TRANSLATE_SYS_ERROR return uv_translate_sys_error(sys_errno); #elif defined(WIN32) -- cgit From a6de144c3e5cc888ab3cb7c2034a762b23566919 Mon Sep 17 00:00:00 2001 From: Eric Roberts Date: Fri, 27 Oct 2017 10:48:24 -0400 Subject: 'viewoptions': add "curdir" flag #7447 The flag enables the current local directory set by ":lcd" to be saved to views which is the current default behaviour. The option can be removed to disable this behaviour. closes #7435 vim-patch:8.0.1289 --- src/nvim/ex_docmd.c | 15 +++++++++------ src/nvim/option_defs.h | 21 +++++++++++---------- src/nvim/options.lua | 2 +- 3 files changed, 21 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 7a2b0328df..5180420eff 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9356,15 +9356,18 @@ put_view ( } } - /* - * Local directory. - */ - if (wp->w_localdir != NULL) { + // + // Local directory, if the current flag is not view options or the "curdir" + // option is included. + // + if (wp->w_localdir != NULL + && (flagp != &vop_flags || (*flagp & SSOP_CURDIR))) { if (fputs("lcd ", fd) < 0 || ses_put_fname(fd, wp->w_localdir, flagp) == FAIL - || put_eol(fd) == FAIL) + || put_eol(fd) == FAIL) { return FAIL; - did_lcd = TRUE; + } + did_lcd = true; } return OK; diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index a2fe90b3c2..1f62490ab9 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -539,7 +539,7 @@ static char *(p_ssop_values[]) = {"buffers", "winpos", "resize", "winsize", "localoptions", "options", "help", "blank", "globals", "slash", "unix", "sesdir", "curdir", "folds", "cursor", - "tabpages", NULL}; + "tabpages", NULL }; # endif # define SSOP_BUFFERS 0x001 # define SSOP_WINPOS 0x002 @@ -557,16 +557,17 @@ static char *(p_ssop_values[]) = {"buffers", "winpos", "resize", "winsize", # define SSOP_FOLDS 0x2000 # define SSOP_CURSOR 0x4000 # define SSOP_TABPAGES 0x8000 -EXTERN char_u *p_sh; /* 'shell' */ -EXTERN char_u *p_shcf; /* 'shellcmdflag' */ -EXTERN char_u *p_sp; /* 'shellpipe' */ -EXTERN char_u *p_shq; /* 'shellquote' */ -EXTERN char_u *p_sxq; /* 'shellxquote' */ -EXTERN char_u *p_sxe; /* 'shellxescape' */ -EXTERN char_u *p_srr; /* 'shellredir' */ -EXTERN int p_stmp; /* 'shelltemp' */ + +EXTERN char_u *p_sh; // 'shell' +EXTERN char_u *p_shcf; // 'shellcmdflag' +EXTERN char_u *p_sp; // 'shellpipe' +EXTERN char_u *p_shq; // 'shellquote' +EXTERN char_u *p_sxq; // 'shellxquote' +EXTERN char_u *p_sxe; // 'shellxescape' +EXTERN char_u *p_srr; // 'shellredir' +EXTERN int p_stmp; // 'shelltemp' #ifdef BACKSLASH_IN_FILENAME -EXTERN int p_ssl; /* 'shellslash' */ +EXTERN int p_ssl; // 'shellslash' #endif EXTERN char_u *p_stl; // 'statusline' EXTERN int p_sr; // 'shiftround' diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 29220a6b50..52e478e78a 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -2610,7 +2610,7 @@ return { deny_duplicates=true, vi_def=true, varname='p_vop', - defaults={if_true={vi="folds,options,cursor"}} + defaults={if_true={vi="folds,options,cursor,curdir"}} }, { full_name='viminfo', abbreviation='vi', -- cgit From f19e5d6530981331fd858bea1f5e0a5273cb5854 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 18 Nov 2017 12:24:11 +0100 Subject: tui: setrgbf/setrgbb: emit semicolons for VTE Severe memory leak observed on gnome-terminal 3.26.2 VTE 0.50.2 when colon-delimited RGB sequences are used. closes #7573 --- src/nvim/tui/tui.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 88da634de4..f35e99840d 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1568,10 +1568,9 @@ static void augment_terminfo(TUIData *data, const char *term, } // Dickey ncurses terminfo does not include the setrgbf and setrgbb - // capabilities, proposed by Rüdiger Sonderfeld on 2013-10-15. So adding - // them to terminal types, that do actually have such control sequences but - // lack the correct definitions in terminfo, is an augmentation, not a - // fixup. See https://gist.github.com/XVilka/8346728 for more about this. + // capabilities, proposed by Rüdiger Sonderfeld on 2013-10-15. Adding + // them here when terminfo lacks them is an augmentation, not a fixup. + // https://gist.github.com/XVilka/8346728 // At this time (2017-07-12) it seems like all terminals that support rgb // color codes can use semicolons in the terminal code and be fine. @@ -1581,8 +1580,8 @@ static void augment_terminfo(TUIData *data, const char *term, // can use colons like ISO 8613-6:1994/ITU T.416:1993 says. bool has_colon_rgb = !tmux && !screen - && ((vte_version >= 3600) // per GNOME bug #685759, #704449 - || iterm || iterm_pretending_xterm // per analysis of VT100Terminal.m + && !vte_version // VTE colon-support has a big memory leak. #7573 + && (iterm || iterm_pretending_xterm // per VT100Terminal.m // per http://invisible-island.net/xterm/xterm.log.html#xterm_282 || true_xterm); -- cgit From 540ed646358f9e3910681add39aa96a937074668 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 19 Nov 2017 19:15:03 +0800 Subject: vim-patch:8.0.0283 Problem: The return value of mode() does not indicate that completion is active in Replace and Insert mode. (Zhen-Huan (Kenny) Hu) Solution: Add "c" or "x" for two kinds of completion. (Yegappan Lakshmanan, closes vim/vim#1397) Test some more modes. https://github.com/vim/vim/commit/e90858d0229444b3cd16b1cd3a8d61a24c435705 --- src/nvim/state.c | 24 +++++++---- src/nvim/testdir/test_functions.vim | 85 +++++++++++++++++++++++++++++++++++++ src/nvim/testdir/test_mapping.vim | 4 +- src/nvim/version.c | 2 +- 4 files changed, 105 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/state.c b/src/nvim/state.c index 4d9032b7a5..44a4de8abb 100644 --- a/src/nvim/state.c +++ b/src/nvim/state.c @@ -14,6 +14,8 @@ #include "nvim/option_defs.h" #include "nvim/ui.h" #include "nvim/os/input.h" +#include "nvim/ex_docmd.h" +#include "nvim/edit.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "state.c.generated.h" @@ -127,19 +129,25 @@ char *get_mode(void) if (State & VREPLACE_FLAG) { buf[0] = 'R'; buf[1] = 'v'; - } else if (State & REPLACE_FLAG) { - buf[0] = 'R'; } else { - buf[0] = 'i'; + if (State & REPLACE_FLAG) { + buf[0] = 'R'; + } else { + buf[0] = 'i'; + } + if (ins_compl_active()) { + buf[1] = 'c'; + } else if (ctrl_x_mode == 1) { + buf[1] = 'x'; + } } - } else if (State & CMDLINE) { + } else if (State & CMDLINE || exmode_active) { buf[0] = 'c'; - if (exmode_active) { + if (exmode_active == EXMODE_VIM) { buf[1] = 'v'; + } else if (exmode_active == EXMODE_NORMAL) { + buf[1] = 'e'; } - } else if (exmode_active) { - buf[0] = 'c'; - buf[1] = 'e'; } else if (State & TERM_FOCUS) { buf[0] = 't'; } else { diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 237a2dc820..59807ca946 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -191,4 +191,89 @@ func Test_toupper() call assert_equal("â±¥ ⱦ", tolower("Ⱥ Ⱦ")) endfunc +" Tests for the mode() function +let current_modes = '' +func! Save_mode() + let g:current_modes = mode(0) . '-' . mode(1) + return '' +endfunc + +func! Test_mode() + new + call append(0, ["Blue Ball Black", "Brown Band Bowl", ""]) + + inoremap =Save_mode() + + normal! 3G + exe "normal i\\" + call assert_equal('i-i', g:current_modes) + exe "normal i\uBa\\\u" + call assert_equal('i-ic', g:current_modes) + exe "normal iBro\\\u" + call assert_equal('i-ic', g:current_modes) + exe "normal iBa\\\u" + call assert_equal('i-ix', g:current_modes) + exe "normal iBa\\\\u" + call assert_equal('i-ic', g:current_modes) + exe "normal iBro\\\\u" + call assert_equal('i-ic', g:current_modes) + exe "normal iBro\\\\\u" + call assert_equal('i-ic', g:current_modes) + exe "normal iCom\\\u" + call assert_equal('i-ic', g:current_modes) + exe "normal iCom\\\\u" + call assert_equal('i-ic', g:current_modes) + + exe "normal RBa\\\u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RBro\\\u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RBa\\\u" + call assert_equal('R-Rx', g:current_modes) + exe "normal RBa\\\\u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RBro\\\\u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RBro\\\\\u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RCom\\\u" + call assert_equal('R-Rc', g:current_modes) + exe "normal RCom\\\\u" + call assert_equal('R-Rc', g:current_modes) + + call assert_equal('n', mode(0)) + call assert_equal('n', mode(1)) + " How to test operator-pending mode? + + call feedkeys("v", 'xt') + call assert_equal('v', mode()) + call assert_equal('v', mode(1)) + call feedkeys("\V", 'xt') + call assert_equal('V', mode()) + call assert_equal('V', mode(1)) + call feedkeys("\\", 'xt') + call assert_equal("\", mode()) + call assert_equal("\", mode(1)) + call feedkeys("\", 'xt') + + call feedkeys("gh", 'xt') + call assert_equal('s', mode()) + call assert_equal('s', mode(1)) + call feedkeys("\gH", 'xt') + call assert_equal('S', mode()) + call assert_equal('S', mode(1)) + call feedkeys("\g\", 'xt') + call assert_equal("\", mode()) + call assert_equal("\", mode(1)) + call feedkeys("\", 'xt') + + call feedkeys(":echo \=Save_mode()\\", 'xt') + call assert_equal('c-c', g:current_modes) + call feedkeys("gQecho \=Save_mode()\\vi\", 'xt') + call assert_equal('c-cv', g:current_modes) + " How to test Ex mode? + + bwipe! + iunmap +endfunc diff --git a/src/nvim/testdir/test_mapping.vim b/src/nvim/testdir/test_mapping.vim index 7f93ddd56e..f5e4c4b90c 100644 --- a/src/nvim/testdir/test_mapping.vim +++ b/src/nvim/testdir/test_mapping.vim @@ -110,6 +110,8 @@ func Test_map_langmap() call feedkeys(":call append(line('$'), '+')\", "xt") call assert_equal('+', getline('$')) + iunmap a + iunmap c set nomodified endfunc @@ -120,7 +122,7 @@ func Test_map_feedkeys() $-1 call feedkeys("0qqdw.ifoo\qj0@q\", "xt") call assert_equal(['fooc d', 'fooc d'], getline(line('$') - 1, line('$'))) - unmap . + nunmap . set nomodified endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 5accf8f1d6..c73cc0d3ee 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -821,7 +821,7 @@ static const int included_patches[] = { // 286, // 285 NA // 284 NA - // 283, + 283, 282, // 281 NA 280, -- cgit From c287893225bad586af486b37546f5982e5b1cd03 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 19 Nov 2017 19:22:54 +0300 Subject: viml/parser/expressions,unittests: Do better testing, fix found issues --- src/nvim/viml/parser/expressions.c | 40 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 4bd3652292..0824b3ca7d 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -2031,18 +2031,7 @@ viml_pexpr_parse_process_token: } break; } - case kEPTSingleAssignment: { - if (tok_type == kExprLexBracket && !cur_token.data.brc.closing) { - ERROR_FROM_TOKEN_AND_MSG( - cur_token, - _("E475: Nested lists not allowed when assigning: %.*s")); - kv_drop(pt_stack, 2); - assert(kv_size(pt_stack)); - assert(kv_last(pt_stack) == kEPTExpr); - break; - } - FALLTHROUGH; - } + case kEPTSingleAssignment: case kEPTAssignment: { if (want_node == kENodeValue && tok_type != kExprLexBracket @@ -2062,7 +2051,13 @@ viml_pexpr_parse_process_token: || cur_token.data.brc.closing) && tok_type != kExprLexDot && (tok_type != kExprLexComma || !is_single_assignment) - && tok_type != kExprLexAssignment) { + && tok_type != kExprLexAssignment + // Curly brace identifiers: will contain plain identifier or + // another curly brace in position where operator is wanted. + && !((tok_type == kExprLexPlainIdentifier + || (tok_type == kExprLexFigureBrace + && !cur_token.data.brc.closing)) + && prev_token.type != kExprLexSpacing)) { if (flags & kExprFlagsMulti && MAY_HAVE_NEXT_EXPR) { goto viml_pexpr_parse_end; } @@ -2457,9 +2452,7 @@ viml_pexpr_parse_bracket_closing_error: if (kv_size(ast_stack) <= asgn_level) { assert(kv_size(ast_stack) == asgn_level); asgn_level = 0; - if (cur_pt == kEPTSingleAssignment) { - kv_drop(pt_stack, 1); - } else if (cur_pt == kEPTAssignment) { + if (cur_pt == kEPTAssignment) { assert(ast.err.msg); } else if (cur_pt == kEPTExpr && kv_size(pt_stack) > 1 @@ -2467,10 +2460,12 @@ viml_pexpr_parse_bracket_closing_error: kv_drop(pt_stack, 1); } } + if (cur_pt == kEPTSingleAssignment && kv_size(ast_stack) == 1) { + kv_drop(pt_stack, 1); + } } else { if (want_node == kENodeValue) { // Value means list literal or list assignment. - HL_CUR_TOKEN(List); NEW_NODE_WITH_CUR_POS(cur_node, kExprNodeListLiteral); *top_node_p = cur_node; kvi_push(ast_stack, &cur_node->children); @@ -2479,7 +2474,12 @@ viml_pexpr_parse_bracket_closing_error: // Additional assignment parse type allows to easily forbid nested // lists. kvi_push(pt_stack, kEPTSingleAssignment); + } else if (cur_pt == kEPTSingleAssignment) { + ERROR_FROM_TOKEN_AND_MSG( + cur_token, + _("E475: Nested lists not allowed when assigning: %.*s")); } + HL_CUR_TOKEN(List); } else { // Operator means subscript, also in assignment. But in assignment // subscript may be pretty much any expression, so need to push @@ -2491,7 +2491,8 @@ viml_pexpr_parse_bracket_closing_error: ADD_OP_NODE(cur_node); HL_CUR_TOKEN(SubscriptBracket); if (pt_is_assignment(cur_pt)) { - asgn_level = kv_size(ast_stack); + assert(want_node == kENodeValue); // Subtract 1 for NULL at top. + asgn_level = kv_size(ast_stack) - 1; kvi_push(pt_stack, kEPTExpr); } } @@ -2653,7 +2654,8 @@ viml_pexpr_parse_figure_brace_closing_error: } if (pt_is_assignment(cur_pt) && !pt_is_assignment(kv_last(pt_stack))) { - asgn_level = kv_size(ast_stack); + assert(want_node == kENodeValue); // Subtract 1 for NULL at top. + asgn_level = kv_size(ast_stack) - 1; } } break; -- cgit From 764cf3251de4f141fa451633dbdb48440ddf218a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 19 Nov 2017 19:27:21 +0300 Subject: charset: Add missing include needed for vim_str2nr --- src/nvim/charset.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/charset.h b/src/nvim/charset.h index 7198c8d405..eb64b6128a 100644 --- a/src/nvim/charset.h +++ b/src/nvim/charset.h @@ -4,6 +4,7 @@ #include "nvim/types.h" #include "nvim/pos.h" #include "nvim/buffer_defs.h" +#include "nvim/eval/typval.h" /// Return the folded-case equivalent of the given character /// -- cgit From f20f97c936f1438589c8176f62ce69c26e255f85 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 19 Nov 2017 21:13:27 +0300 Subject: *: Fix linter errors --- src/nvim/viml/parser/expressions.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 0824b3ca7d..6c7c328b6d 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -2014,17 +2014,20 @@ viml_pexpr_parse_process_token: lambda_node->data.fig.type_guesses.allow_lambda = false; if (lambda_node->children != NULL && lambda_node->children->type == kExprNodeComma) { - // If lambda has comma child this means that parser has already seen at - // least "{arg1,", so node cannot possibly be anything, but lambda. - - // Vim may give E121 or E720 in this case, but it does not look right to - // have either because both are results of reevaluation possibly-lambda - // node as a dictionary and here this is not going to happen. + // If lambda has comma child this means that parser has already seen + // at least "{arg1,", so node cannot possibly be anything, but + // lambda. + + // Vim may give E121 or E720 in this case, but it does not look + // right to have either because both are results of reevaluation + // possibly-lambda node as a dictionary and here this is not going + // to happen. ERROR_FROM_TOKEN_AND_MSG( - cur_token, _("E15: Expected lambda arguments list or arrow: %.*s")); + cur_token, + _("E15: Expected lambda arguments list or arrow: %.*s")); } else { - // Else it may appear that possibly-lambda node is actually a dictionary - // or curly-braces-name identifier. + // Else it may appear that possibly-lambda node is actually + // a dictionary or curly-braces-name identifier. lambda_node = NULL; kv_drop(pt_stack, 1); } -- cgit From 731dc82f8c04e3019ecc3243b6b512535998635b Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 19 Nov 2017 21:21:45 +0300 Subject: ex_getln: Fix memory leak in color_expr_cmdline --- src/nvim/ex_getln.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index e6fb2571c4..cabdda28cf 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2419,6 +2419,7 @@ static void color_expr_cmdline(const CmdlineInfo *const colored_ccline, .attr = 0, })); } + kvi_destroy(colors); } /// Color command-line -- cgit From 6ea3a08fdbb276fe64dda60c5fb934360327ed39 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 19 Nov 2017 21:55:36 +0300 Subject: syntax: Fix duplicate group definitions --- src/nvim/syntax.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index c9e99d82f8..9a537130fd 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6067,7 +6067,6 @@ const char *const highlight_init_cmdline[] = { "default link NVimSubscript NVimParenthesis", "default link NVimSubscriptBracket NVimSubscript", "default link NVimSubscriptColon NVimSubscript", - "default link NVimSubscriptColon NVimSubscript", "default link NVimCurly NVimSubscript", "default link NVimContainer NVimParenthesis", @@ -6164,7 +6163,6 @@ const char *const highlight_init_cmdline[] = { "default link NVimInvalidSubscript NVimInvalidParenthesis", "default link NVimInvalidSubscriptBracket NVimInvalidSubscript", "default link NVimInvalidSubscriptColon NVimInvalidSubscript", - "default link NVimInvalidSubscriptColon NVimInvalidSubscript", "default link NVimInvalidCurly NVimInvalidSubscript", "default link NVimInvalidContainer NVimInvalidParenthesis", -- cgit From df107149913f82e8b3b6b2060d6dbed3d90e68fe Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Sun, 19 Nov 2017 19:55:28 -0500 Subject: server.c: Fix bug in release mode (#7594) When compiling with CMAKE_BUILD_TYPE=RelWithDebInfo, several -Wmaybe-uninitialized warnings are printed. These were thought to be false positives (#5061); there are no control paths that lead to an uninitialized value. However, when gcc is run in -O2 mode, it makes a mistake while generating the necessary logic. Specifically, for the code: ... int = 0; // Index of the server whose address equals addr. for (; i < watchers.ga_len; i++) { watcher = ((SocketWatcher **)watchers.ga_data)[i]; // } if (i >= watchers.ga_len) { ELOG("Not listening on %s", addr); return; } ... Gcc generates: ... <+98>: cmp %ebx, %ebp <+100>: jg 0x530f13 <+102>: cmp %ebp, ebx <+104>: jl 0x530f7e ... Normally, the if statement should catch the only control path where watcher is not assigned: watchers.ga_len <= 0. When compiled, the assembly lines 98 and 100 correspond to checking if i < watchers.ga_len, and the lines 102 and 104 correspond to checking if i >= watchers.ga_len. The assembly seems to compare ebp (which is watchers.ga_len) with ebx (which is i), and jump if greater; then do the same comparison and jump if less. This is where gcc makes a mistake: it flips the order of the cmp instruction. This means that the REAL behavior is first check if i < watchers.ga_len and then check if i < watchers.ga_len. Which means the code inside the if statement is NEVER executed; no combination of i and watchers.ga_len will ever trigger ELOG(). So not only is this a use of an uninitialized value if watchers.ga_len == 0 (or technically, if it's less than zero too), it also clobbers any error detection if the for loop reaches the last entry (which would normally cause i == watchers.ga_len too). This commit fixes this issue by adding a bool to keep track of whether a watcher was found during the loop. This makes gcc generate the correct code, avoiding both bugs. --- src/nvim/msgpack_rpc/server.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/msgpack_rpc/server.c b/src/nvim/msgpack_rpc/server.c index 1e0cc27886..9bf122f4db 100644 --- a/src/nvim/msgpack_rpc/server.c +++ b/src/nvim/msgpack_rpc/server.c @@ -180,6 +180,7 @@ int server_start(const char *endpoint) void server_stop(char *endpoint) { SocketWatcher *watcher; + bool watcher_found = false; char addr[ADDRESS_MAX_SIZE]; // Trim to `ADDRESS_MAX_SIZE` @@ -189,11 +190,12 @@ void server_stop(char *endpoint) for (; i < watchers.ga_len; i++) { watcher = ((SocketWatcher **)watchers.ga_data)[i]; if (strcmp(addr, watcher->addr) == 0) { + watcher_found = true; break; } } - if (i >= watchers.ga_len) { + if (!watcher_found) { ELOG("Not listening on %s", addr); return; } -- cgit From 7d24a95b450c0d97706e2d92a19424d84d51015e Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 20 Nov 2017 09:02:15 +0800 Subject: vim-patch:8.0.0287 (#7590) Problem: Cannot access the arguments of the current function in debug mode. (Luc Hermitte) Solution: use get_funccal(). (Lemonboy, closes vim/vim#1432, closes vim/vim#1352) https://github.com/vim/vim/commit/c7d9eacefa319e5ac3b3b2334fda5acb126b8716 --- src/nvim/eval.c | 2 +- src/nvim/version.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 33bea8ef87..3c58f81d4b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -18732,7 +18732,7 @@ static dictitem_T *find_var_in_ht(hashtab_T *const ht, case 'l': return (current_funccal == NULL ? NULL : (dictitem_T *)¤t_funccal->l_vars_var); case 'a': return (current_funccal == NULL - ? NULL : (dictitem_T *)¤t_funccal->l_avars_var); + ? NULL : (dictitem_T *)&get_funccal()->l_avars_var); } return NULL; } diff --git a/src/nvim/version.c b/src/nvim/version.c index c73cc0d3ee..997db1726b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -817,7 +817,7 @@ static const int included_patches[] = { 290, // 289, // 288 NA - // 287, + 287, // 286, // 285 NA // 284 NA -- cgit From c39140164877ce51d5785405205a570b45cc5f82 Mon Sep 17 00:00:00 2001 From: Hannu Hartikainen Date: Mon, 20 Nov 2017 22:20:01 +0200 Subject: helptags: fix double-free (#7600) closes #7599 Helped-by: oni-link Freeing `dirname` was first introduced by a code refactoring from `ex_helptags()` to `do_helptags()` (`vim-patch:7.4.1551`)(#4648) and later removed by `vim-patch:7.4.1562`(#4660). Only problem with that is, that the patches were not applied in order so the fixing patch was declared `N/A`. So `do_helptags()` should have never freed `dirname`. --- src/nvim/ex_cmds.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 39059a2c80..8616508d88 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -5292,7 +5292,6 @@ static void do_helptags(char_u *dirname, bool add_help_tags) if (!add_pathsep((char *)NameBuff) || STRLCAT(NameBuff, "**", sizeof(NameBuff)) >= MAXPATHL) { EMSG(_(e_fnametoolong)); - xfree(dirname); return; } @@ -5303,7 +5302,6 @@ static void do_helptags(char_u *dirname, bool add_help_tags) EW_FILE|EW_SILENT) == FAIL || filecount == 0) { EMSG2(_("E151: No match: %s"), NameBuff); - xfree(dirname); return; } -- cgit From 8674b0c3d161bd367ff63c6a8fb290fec0122d05 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Mon, 20 Nov 2017 18:04:49 -0500 Subject: syntax.c: Fix maybe-uninitialized warning (#7596) When building in release mode, gcc generated a maybe-initialized warning in get_syn_options. The warning is both right and wrong; there is an execution path where the len variable is not initialized in the code: ... int len; ... for (fidx = ARRAY_SIZE(flagtab); --fidx >= 0; ) { p = flagtab[fidx].name; int i; for (i = 0, len = 0; p[i] != NUL; i += 2, ++len) if (arg[len] != p[i] && arg[len] != p[i + 1]) break; // } ... arg = skipwhite(arg + len); ... The initial for loop will not execute if ARRAY_SIZE(flagtab) == 0, and thus len will never be initialized. flagtab is a local-static variable, initialized to a long array of structured data, so ARRAY_SIZE(flagtab) can't be 0. However, gcc doesn't recognize ARRAY_SIZE(flagtab) as a constant. There are any number of reasons this could happen. In any case, the message can be fixed with a len=0 before the first for loop. In addition to the above warning, I've labeled flagtab and first_letters as const. They should never change. --- src/nvim/syntax.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 65490768c4..d28e996581 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -4009,10 +4009,10 @@ get_syn_options ( { char_u *gname_start, *gname; int syn_id; - int len; + int len = 0; char *p; int fidx; - static struct flag { + static const struct flag { char *name; int argtype; int flags; @@ -4035,7 +4035,7 @@ get_syn_options ( {"cCoOnNtTaAiInNsS", 1, 0}, {"cCoOnNtTaAiInNeEdDiInN", 2, 0}, {"nNeExXtTgGrRoOuUpP", 3, 0},}; - static char *first_letters = "cCoOkKeEtTsSgGdDfFnN"; + static const char *const first_letters = "cCoOkKeEtTsSgGdDfFnN"; if (arg == NULL) /* already detected error */ return NULL; @@ -4055,9 +4055,10 @@ get_syn_options ( for (fidx = ARRAY_SIZE(flagtab); --fidx >= 0; ) { p = flagtab[fidx].name; int i; - for (i = 0, len = 0; p[i] != NUL; i += 2, ++len) + for (i = 0, len = 0; p[i] != NUL; i += 2, ++len) { if (arg[len] != p[i] && arg[len] != p[i + 1]) break; + } if (p[i] == NUL && (ascii_iswhite(arg[len]) || (flagtab[fidx].argtype > 0 ? arg[len] == '=' -- cgit From 7b686881a16a637e4e0a9e202c4b64bafc4eb8e8 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 21 Nov 2017 18:35:51 -0500 Subject: win: default grepprg to findstr.exe (#7611) --- src/nvim/options.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 52e478e78a..cb3e5ad856 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -993,11 +993,11 @@ return { expand=true, varname='p_gp', defaults={ - condition='UNIX', + condition='WIN32', -- Add an extra file name so that grep will always -- insert a file name in the match line. */ - if_true={vi="grep -n $* /dev/null"}, - if_false={vi="grep -n "}, + if_true={vi="findstr /n $* nul"}, + if_false={vi="grep -n $* /dev/null"} } }, { -- cgit From bb7795e82065ef2e8028064c62cb542362568e19 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Wed, 22 Nov 2017 18:57:56 +0800 Subject: vim-patch:8.0.0292 (#7592) Problem: The stat test is a bit slow. Solution: Remove a couple of sleep comments and reduce another. https://github.com/vim/vim/commit/a2f28859bfb3fa52bde14c9d2ca3ab7196a9154a --- src/nvim/testdir/test_stat.vim | 35 +++++++++++++++++++++-------------- src/nvim/version.c | 2 +- 2 files changed, 22 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_stat.vim b/src/nvim/testdir/test_stat.vim index 89ca9ef379..dee0d13e84 100644 --- a/src/nvim/testdir/test_stat.vim +++ b/src/nvim/testdir/test_stat.vim @@ -1,24 +1,24 @@ " Tests for stat functions and checktime func Test_existent_file() - let fname='Xtest.tmp' + let fname = 'Xtest.tmp' - let ts=localtime() - sleep 1 - let fl=['Hello World!'] + let ts = localtime() + let fl = ['Hello World!'] call writefile(fl, fname) - let tf=getftime(fname) - sleep 1 - let te=localtime() + let tf = getftime(fname) + let te = localtime() call assert_true(ts <= tf && tf <= te) call assert_equal(strlen(fl[0] . "\n"), getfsize(fname)) call assert_equal('file', getftype(fname)) call assert_equal('rw-', getfperm(fname)[0:2]) + + call delete(fname) endfunc func Test_existent_directory() - let dname='.' + let dname = '.' call assert_equal(0, getfsize(dname)) call assert_equal('dir', getftype(dname)) @@ -26,22 +26,29 @@ func Test_existent_directory() endfunc func Test_checktime() - let fname='Xtest.tmp' + let fname = 'Xtest.tmp' - let fl=['Hello World!'] + let fl = ['Hello World!'] call writefile(fl, fname) set autoread exec 'e' fname - sleep 2 - let fl=readfile(fname) + " FAT has a granularity of 2 seconds, otherwise it's usually 1 second + if has('win32') + sleep 2 + else + sleep 2 + endif + let fl = readfile(fname) let fl[0] .= ' - checktime' call writefile(fl, fname) checktime call assert_equal(fl[0], getline(1)) + + call delete(fname) endfunc func Test_nonexistent_file() - let fname='Xtest.tmp' + let fname = 'Xtest.tmp' call delete(fname) call assert_equal(-1, getftime(fname)) @@ -55,7 +62,7 @@ func Test_win32_symlink_dir() " So we use an existing symlink for this test. if has('win32') " Check if 'C:\Users\All Users' is a symlink to a directory. - let res=system('dir C:\Users /a') + let res = system('dir C:\Users /a') if match(res, '\C *All Users') >= 0 " Get the filetype of the symlink. call assert_equal('dir', getftype('C:\Users\All Users')) diff --git a/src/nvim/version.c b/src/nvim/version.c index 997db1726b..61cfd99c5d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -812,7 +812,7 @@ static const int included_patches[] = { // 295, 294, // 293, - // 292, + 292, 291, 290, // 289, -- cgit From 9393be477a733183c2a992cc8728e3ebc65a3118 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Wed, 22 Nov 2017 18:59:30 +0800 Subject: vim-patch:8.0.0289 (#7591) Problem: No test for "ga" and :ascii. Solution: Add a test. (Dominique Pelle, closes vim/vim#1429) https://github.com/vim/vim/commit/21d7c9b601f3048e1293ecd6c09b8325a15503cd --- src/nvim/testdir/Makefile | 1 + src/nvim/testdir/test_alot.vim | 1 + src/nvim/testdir/test_ga.vim | 37 +++++++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/nvim/testdir/test_ga.vim (limited to 'src') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index ccf999c7ee..111bd172ef 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -42,6 +42,7 @@ NEW_TESTS ?= \ test_filter_map.res \ test_fnameescape.res \ test_fold.res \ + test_ga.res \ test_glob2regpat.res \ test_gf.res \ test_gn.res \ diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index 535e290a34..c1f6405579 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -12,6 +12,7 @@ source test_filter_cmd.vim source test_filter_map.vim source test_float_func.vim source test_functions.vim +source test_ga.vim source test_goto.vim source test_jumps.vim source test_fileformat.vim diff --git a/src/nvim/testdir/test_ga.vim b/src/nvim/testdir/test_ga.vim new file mode 100644 index 0000000000..f9357ddc87 --- /dev/null +++ b/src/nvim/testdir/test_ga.vim @@ -0,0 +1,37 @@ +" Test ga normal command, and :ascii Ex command. +func Do_ga(c) + call setline(1, a:c) + let l:a = execute("norm 1goga") + let l:b = execute("ascii") + call assert_equal(l:a, l:b) + return l:a +endfunc + +func Test_ga_command() + new + set display=uhex + call assert_equal("\nNUL", Do_ga('')) + call assert_equal("\n<<01>> 1, Hex 01, Octal 001", Do_ga("\x01")) + call assert_equal("\n<<09>> 9, Hex 09, Octal 011", Do_ga("\t")) + + set display= + call assert_equal("\nNUL", Do_ga('')) + call assert_equal("\n<^A> 1, Hex 01, Octal 001", Do_ga("\x01")) + call assert_equal("\n<^I> 9, Hex 09, Octal 011", Do_ga("\t")) + + call assert_equal("\n 101, Hex 65, Octal 145", Do_ga('e')) + + if !has('multi_byte') + return + endif + + " Test a few multi-bytes characters. + call assert_equal("\n<é> 233, Hex 00e9, Octal 351", Do_ga('é')) + call assert_equal("\n<ẻ> 7867, Hex 1ebb, Octal 17273", Do_ga('ẻ')) + + " Test with combining characters. + call assert_equal("\n 101, Hex 65, Octal 145 < Ì> 769, Hex 0301, Octal 1401", Do_ga("e\u0301")) + call assert_equal("\n 101, Hex 65, Octal 145 < Ì> 769, Hex 0301, Octal 1401 < ̱> 817, Hex 0331, Octal 1461", Do_ga("e\u0301\u0331")) + call assert_equal("\n 101, Hex 65, Octal 145 < Ì> 769, Hex 0301, Octal 1401 < ̱> 817, Hex 0331, Octal 1461 < ̸> 824, Hex 0338, Octal 1470", Do_ga("e\u0301\u0331\u0338")) + bwipe! +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 61cfd99c5d..1ceda55cf1 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -815,7 +815,7 @@ static const int included_patches[] = { 292, 291, 290, - // 289, + 289, // 288 NA 287, // 286, -- cgit From dddc609859c3e6e72f091dc25f996e2ca0084c0d Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Sun, 19 Nov 2017 11:19:41 -0800 Subject: menu.c: remove conditional expression that is always true --- src/nvim/menu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 88d968704b..2876ba82a7 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -1417,7 +1417,8 @@ void ex_emenu(exarg_T *eap) idx = MENU_INDEX_NORMAL; } - if (idx != MENU_INDEX_INVALID && menu->strings[idx] != NULL) { + assert(idx != MENU_INDEX_INVALID); + if (menu->strings[idx] != NULL) { /* When executing a script or function execute the commands right now. * Otherwise put them in the typeahead buffer. */ if (current_SID != 0) -- cgit From fdcde7dba34b193e8fdafdf3b5b9c3ce4d430505 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Sun, 19 Nov 2017 21:25:02 -0800 Subject: input.c: replace if/else with switch --- src/nvim/tui/input.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index 8e08b77b00..b76a11cc71 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -199,18 +199,24 @@ static void forward_mouse_event(TermInput *input, TermKeyKey *key) len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Right"); } - if (ev == TERMKEY_MOUSE_PRESS) { - if (button == 4) { - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "ScrollWheelUp"); - } else if (button == 5) { - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "ScrollWheelDown"); - } else { - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Mouse"); - } - } else if (ev == TERMKEY_MOUSE_DRAG) { - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Drag"); - } else if (ev == TERMKEY_MOUSE_RELEASE) { - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Release"); + switch (ev) { + case TERMKEY_MOUSE_PRESS: + if (button == 4) { + len += (size_t)snprintf(buf + len, sizeof(buf) - len, "ScrollWheelUp"); + } else if (button == 5) { + len += (size_t)snprintf(buf + len, sizeof(buf) - len, "ScrollWheelDown"); + } else { + len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Mouse"); + } + break; + case TERMKEY_MOUSE_DRAG: + len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Drag"); + break; + case TERMKEY_MOUSE_RELEASE: + len += (size_t)snprintf(buf + len, sizeof(buf) - len, "Release"); + break; + case TERMKEY_MOUSE_UNKNOWN: + assert(false); } len += (size_t)snprintf(buf + len, sizeof(buf) - len, "><%d,%d>", col, row); -- cgit From c24b74c2291b3949f53abf6cee5b308320283642 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Sun, 19 Nov 2017 23:19:41 -0800 Subject: Fix for pvs V782, pointer access to first element of array --- src/nvim/digraph.c | 2 +- src/nvim/tui/tui.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index bfb1b94738..dbcc8db109 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1696,7 +1696,7 @@ static void printdigraph(digr_T *dp) } } - p = buf; + p = &buf[0]; *p++ = dp->char1; *p++ = dp->char2; *p++ = ' '; diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index f35e99840d..b447b4aae2 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1644,7 +1644,7 @@ static void flush_buf(UI *ui, bool toggle_cursor) { uv_write_t req; uv_buf_t bufs[3]; - uv_buf_t *bufp = bufs; + uv_buf_t *bufp = &bufs[0]; TUIData *data = ui->data; if (data->bufpos <= 0 && data->busy == data->is_invisible) { -- cgit From c030a381684f3491decf5597b16dfa9a21f29500 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Mon, 20 Nov 2017 11:27:06 -0800 Subject: helpers.c: statically assert integer falls within range --- src/nvim/api/private/helpers.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 2944925a9c..6808048ac8 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -12,6 +12,7 @@ #include "nvim/api/private/handle.h" #include "nvim/msgpack_rpc/helpers.h" #include "nvim/ascii.h" +#include "nvim/assert.h" #include "nvim/vim.h" #include "nvim/buffer.h" #include "nvim/window.h" @@ -760,12 +761,9 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err) case kObjectTypeWindow: case kObjectTypeTabpage: case kObjectTypeInteger: - if (obj.data.integer > VARNUMBER_MAX - || obj.data.integer < VARNUMBER_MIN) { - api_set_error(err, kErrorTypeValidation, "Integer value outside range"); - return false; - } - + STATIC_ASSERT(sizeof(obj.data.integer) <= sizeof(varnumber_T), + "Expected integer size to be less than or equal to VimL " + "number size"); tv->v_type = VAR_NUMBER; tv->vval.v_number = (varnumber_T)obj.data.integer; break; -- cgit From 1b94f24d6e5d96937062f02d084249c9054f25f2 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Tue, 21 Nov 2017 10:36:06 -0800 Subject: eval.c: remove nonnullret deadcode The following calls can't return null: * xmalloc * xcalloc * get_buffer_info * get_tabpage_info * get_vim_var_str * get_win_info * tv_get_string * tv_list_alloc * tv_list_alloc_ret * vim_strnsave --- src/nvim/eval.c | 135 ++++++++++++++++++-------------------------------------- 1 file changed, 44 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 3c58f81d4b..39ce1ddcaa 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2206,10 +2206,6 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv, if (len == -1) { // "[key]": get key from "var1" key = (char_u *)tv_get_string(&var1); // is number or string - if (key == NULL) { - tv_clear(&var1); - return NULL; - } } lp->ll_list = NULL; lp->ll_dict = lp->ll_tv->vval.v_dict; @@ -5706,10 +5702,6 @@ static int get_function_args(char_u **argp, char_u endchar, garray_T *newargs, c = *p; *p = NUL; arg = vim_strsave(arg); - if (arg == NULL) { - *p = c; - goto err_ret; - } // Check for duplicate argument name. for (i = 0; i < newargs->ga_len; i++) { @@ -5833,10 +5825,6 @@ static int get_lambda_tv(char_u **arg, typval_T *rettv, bool evaluate) fp = (ufunc_T *)xcalloc(1, sizeof(ufunc_T) + STRLEN(name)); pt = (partial_T *)xcalloc(1, sizeof(partial_T)); - if (pt == NULL) { - xfree(fp); - goto errret; - } ga_init(&newlines, (int)sizeof(char_u *), 1); ga_grow(&newlines, 1); @@ -6222,13 +6210,9 @@ static char_u *fname_trans_sid(const char_u *const name, fname = fname_buf; } else { fname = xmalloc(i + STRLEN(name + llen) + 1); - if (fname == NULL) { - *error = ERROR_OTHER; - } else { - *tofree = fname; - memmove(fname, fname_buf, (size_t)i); - STRCPY(fname + i, name + llen); - } + *tofree = fname; + memmove(fname, fname_buf, (size_t)i); + STRCPY(fname + i, name + llen); } } else { fname = (char_u *)name; @@ -6309,9 +6293,6 @@ call_func( // Make a copy of the name, if it comes from a funcref variable it could // be changed or deleted in the called function. name = vim_strnsave(funcname, len); - if (name == NULL) { - return ret; - } fname = fname_trans_sid(name, fname_buf, &tofree, &error); @@ -7184,8 +7165,7 @@ static void f_bufnr(typval_T *argvars, typval_T *rettv, FunPtr fptr) && argvars[1].v_type != VAR_UNKNOWN && tv_get_number_chk(&argvars[1], &error) != 0 && !error - && (name = tv_get_string_chk(&argvars[0])) != NULL - && !error) { + && (name = tv_get_string_chk(&argvars[0])) != NULL) { buf = buflist_new((char_u *)name, NULL, 1, 0); } @@ -7733,7 +7713,7 @@ static void f_delete(typval_T *argvars, typval_T *rettv, FunPtr fptr) } const char *const name = tv_get_string(&argvars[0]); - if (name == NULL || *name == NUL) { + if (*name == NUL) { EMSG(_(e_invarg)); return; } @@ -8748,8 +8728,7 @@ static void f_foldtext(typval_T *argvars, typval_T *rettv, FunPtr fptr) foldstart = (linenr_T)get_vim_var_nr(VV_FOLDSTART); foldend = (linenr_T)get_vim_var_nr(VV_FOLDEND); dashes = get_vim_var_str(VV_FOLDDASHES); - if (foldstart > 0 && foldend <= curbuf->b_ml.ml_line_count - && dashes != NULL) { + if (foldstart > 0 && foldend <= curbuf->b_ml.ml_line_count) { /* Find first non-empty line in the fold. */ for (lnum = foldstart; lnum < foldend; ++lnum) { if (!linewhite(lnum)) { @@ -8874,10 +8853,8 @@ static void common_function(typval_T *argvars, typval_T *rettv, snprintf(sid_buf, sizeof(sid_buf), "%" PRId64 "_", (int64_t)current_SID); name = xmalloc(STRLEN(sid_buf) + STRLEN(s + off) + 1); - if (name != NULL) { - STRCPY(name, sid_buf); - STRCAT(name, s + off); - } + STRCPY(name, sid_buf); + STRCAT(name, s + off); } else { name = vim_strsave(s); } @@ -8927,11 +8904,6 @@ static void common_function(typval_T *argvars, typval_T *rettv, pt->pt_argc = arg_len + lv_len; pt->pt_argv = xmalloc(sizeof(pt->pt_argv[0]) * pt->pt_argc); - if (pt->pt_argv == NULL) { - xfree(pt); - xfree(name); - goto theend; - } int i = 0; for (; i < arg_len; i++) { tv_copy(&arg_pt->pt_argv[i], &pt->pt_argv[i]); @@ -9197,9 +9169,7 @@ static void f_getbufinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr) } dict_T *const d = get_buffer_info(buf); - if (d != NULL) { - tv_list_append_dict(rettv->vval.v_list, d); - } + tv_list_append_dict(rettv->vval.v_list, d); if (argbuf != NULL) { return; } @@ -9568,13 +9538,11 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr) theend: pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); tv_list_alloc_ret(rettv); - if (pat != NULL) { - ExpandOne(&xpc, pat, NULL, options, WILD_ALL_KEEP); + ExpandOne(&xpc, pat, NULL, options, WILD_ALL_KEEP); - for (int i = 0; i < xpc.xp_numfiles; i++) { - tv_list_append_string(rettv->vval.v_list, (const char *)xpc.xp_files[i], - -1); - } + for (int i = 0; i < xpc.xp_numfiles; i++) { + tv_list_append_string(rettv->vval.v_list, (const char *)xpc.xp_files[i], + -1); } xfree(pat); ExpandCleanup(&xpc); @@ -10136,9 +10104,7 @@ static void f_gettabinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr) continue; } dict_T *const d = get_tabpage_info(tp, tpnr); - if (d != NULL) { - tv_list_append_dict(rettv->vval.v_list, d); - } + tv_list_append_dict(rettv->vval.v_list, d); if (tparg != NULL) { return; } @@ -10240,9 +10206,7 @@ static void f_getwininfo(typval_T *argvars, typval_T *rettv, FunPtr fptr) } winnr++; dict_T *const d = get_win_info(wp, tabnr, winnr); - if (d != NULL) { - tv_list_append_dict(rettv->vval.v_list, d); - } + tv_list_append_dict(rettv->vval.v_list, d); if (wparg != NULL) { // found information about a specific window return; @@ -14803,9 +14767,6 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (di == NULL) { if (s == NULL) { s = tv_list_alloc(); - if (s == NULL) { - return; - } } // match from matchaddpos() @@ -18628,47 +18589,39 @@ void set_selfdict(typval_T *rettv, dict_T *selfdict) // Turn "dict.Func" into a partial for "Func" with "dict". if (fp != NULL && (fp->uf_flags & FC_DICT)) { partial_T *pt = (partial_T *)xcalloc(1, sizeof(partial_T)); - - if (pt != NULL) { - pt->pt_refcount = 1; - pt->pt_dict = selfdict; - (selfdict->dv_refcount)++; - pt->pt_auto = true; - if (rettv->v_type == VAR_FUNC || rettv->v_type == VAR_STRING) { - // Just a function: Take over the function name and use selfdict. - pt->pt_name = rettv->vval.v_string; + pt->pt_refcount = 1; + pt->pt_dict = selfdict; + (selfdict->dv_refcount)++; + pt->pt_auto = true; + if (rettv->v_type == VAR_FUNC || rettv->v_type == VAR_STRING) { + // Just a function: Take over the function name and use selfdict. + pt->pt_name = rettv->vval.v_string; + } else { + partial_T *ret_pt = rettv->vval.v_partial; + int i; + + // Partial: copy the function name, use selfdict and copy + // args. Can't take over name or args, the partial might + // be referenced elsewhere. + if (ret_pt->pt_name != NULL) { + pt->pt_name = vim_strsave(ret_pt->pt_name); + func_ref(pt->pt_name); } else { - partial_T *ret_pt = rettv->vval.v_partial; - int i; - - // Partial: copy the function name, use selfdict and copy - // args. Can't take over name or args, the partial might - // be referenced elsewhere. - if (ret_pt->pt_name != NULL) { - pt->pt_name = vim_strsave(ret_pt->pt_name); - func_ref(pt->pt_name); - } else { - pt->pt_func = ret_pt->pt_func; - func_ptr_ref(pt->pt_func); - } - if (ret_pt->pt_argc > 0) { - size_t arg_size = sizeof(typval_T) * ret_pt->pt_argc; - pt->pt_argv = (typval_T *)xmalloc(arg_size); - if (pt->pt_argv == NULL) { - // out of memory: drop the arguments - pt->pt_argc = 0; - } else { - pt->pt_argc = ret_pt->pt_argc; - for (i = 0; i < pt->pt_argc; i++) { - tv_copy(&ret_pt->pt_argv[i], &pt->pt_argv[i]); - } - } + pt->pt_func = ret_pt->pt_func; + func_ptr_ref(pt->pt_func); + } + if (ret_pt->pt_argc > 0) { + size_t arg_size = sizeof(typval_T) * ret_pt->pt_argc; + pt->pt_argv = (typval_T *)xmalloc(arg_size); + pt->pt_argc = ret_pt->pt_argc; + for (i = 0; i < pt->pt_argc; i++) { + tv_copy(&ret_pt->pt_argv[i], &pt->pt_argv[i]); } - partial_unref(ret_pt); } - rettv->v_type = VAR_PARTIAL; - rettv->vval.v_partial = pt; + partial_unref(ret_pt); } + rettv->v_type = VAR_PARTIAL; + rettv->vval.v_partial = pt; } } -- cgit From fe2546c81a8a7c0be5bbf0737d1169f6cd49bba0 Mon Sep 17 00:00:00 2001 From: Peter Kalauskas Date: Sun, 19 Nov 2017 12:19:09 -0800 Subject: move.c: remove unreachable break statement n > 0 verified by while condition, (--n < 0) always false --- src/nvim/move.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/move.c b/src/nvim/move.c index 9693132846..2debd90337 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -1989,8 +1989,7 @@ void halfpage(bool flag, linenr_T Prenum) while (n > 0 && curwin->w_botline <= curbuf->b_ml.ml_line_count) { if (curwin->w_topfill > 0) { i = 1; - if (--n < 0 && scrolled > 0) - break; + n--; --curwin->w_topfill; } else { i = plines_nofill(curwin->w_topline); @@ -2067,8 +2066,7 @@ void halfpage(bool flag, linenr_T Prenum) while (n > 0 && curwin->w_topline > 1) { if (curwin->w_topfill < diff_check_fill(curwin, curwin->w_topline)) { i = 1; - if (--n < 0 && scrolled > 0) - break; + n--; ++curwin->w_topfill; } else { i = plines_nofill(curwin->w_topline - 1); -- cgit From a4f6cec7a31ff8dbfa089b9e22227afbeb951e9b Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Wed, 22 Nov 2017 22:35:20 +0100 Subject: cmdline: CmdlineEnter and CmdlineLeave autocommands (#7422) vim-patch:fafcf0dd59fd patch 8.0.1206: no autocmd for entering or leaving the command line Problem: No autocmd for entering or leaving the command line. Solution: Add CmdlineEnter and CmdlineLeave. https://github.com/vim/vim/commit/fafcf0dd59fd9c4ef743bb333ae40d1d322b6079 --- src/nvim/auevents.lua | 2 ++ src/nvim/eval/typval.c | 23 ++++++++++++++++ src/nvim/ex_getln.c | 57 ++++++++++++++++++++++++++++++++++++++- src/nvim/globals.h | 2 ++ src/nvim/testdir/test_autocmd.vim | 22 +++++++++++++++ src/nvim/version.c | 1 + 6 files changed, 106 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/auevents.lua b/src/nvim/auevents.lua index 68a47c244f..7dfaf54ff0 100644 --- a/src/nvim/auevents.lua +++ b/src/nvim/auevents.lua @@ -19,6 +19,8 @@ return { 'BufWriteCmd', -- write buffer using command 'BufWritePost', -- after writing a buffer 'BufWritePre', -- before writing a buffer + 'CmdLineEnter', -- after entering cmdline mode + 'CmdLineLeave', -- before leaving cmdline mode 'CmdUndefined', -- command undefined 'CmdWinEnter', -- after entering the cmdline window 'CmdWinLeave', -- before leaving the cmdline window diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index c339a5cdd2..262ea922ef 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1374,6 +1374,29 @@ int tv_dict_add_nr(dict_T *const d, const char *const key, return OK; } +/// Add a special entry to dictionary +/// +/// @param[out] d Dictionary to add entry to. +/// @param[in] key Key to add. +/// @param[in] key_len Key length. +/// @param[in] val SpecialVarValue to add. +/// +/// @return OK in case of success, FAIL when key already exists. +int tv_dict_add_special(dict_T *const d, const char *const key, + const size_t key_len, SpecialVarValue val) +{ + dictitem_T *const item = tv_dict_item_alloc_len(key, key_len); + + item->di_tv.v_lock = VAR_UNLOCKED; + item->di_tv.v_type = VAR_SPECIAL; + item->di_tv.vval.v_special = val; + if (tv_dict_add(d, item) == FAIL) { + tv_dict_item_free(item); + return FAIL; + } + return OK; +} + /// Add a string entry to dictionary /// /// @param[out] d Dictionary to add entry to. diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 9c9ccbca4d..c1500e3121 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -348,8 +348,57 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) got_int = false; s->state.check = command_line_check; s->state.execute = command_line_execute; + + TryState tstate; + Error err = ERROR_INIT; + bool tl_ret = true; + dict_T *dict = get_vim_var_dict(VV_EVENT); + char firstcbuf[2]; + firstcbuf[0] = firstc > 0 ? firstc : '-'; + firstcbuf[1] = 0; + + if (has_event(EVENT_CMDLINEENTER)) { + // set v:event to a dictionary with information about the commandline + tv_dict_add_str(dict, S_LEN("cmdtype"), firstcbuf); + tv_dict_add_nr(dict, S_LEN("cmdlevel"), ccline.level); + tv_dict_set_keys_readonly(dict); + try_enter(&tstate); + + apply_autocmds(EVENT_CMDLINEENTER, (char_u *)firstcbuf, (char_u *)firstcbuf, + false, curbuf); + tv_dict_clear(dict); + + + tl_ret = try_leave(&tstate, &err); + if (!tl_ret && ERROR_SET(&err)) { + msg_putchar('\n'); + msg_printf_attr(hl_attr(HLF_E)|MSG_HIST, (char *)e_autocmd_err, err.msg); + api_clear_error(&err); + redrawcmd(); + } + tl_ret = true; + } + state_enter(&s->state); + if (has_event(EVENT_CMDLINELEAVE)) { + tv_dict_add_str(dict, S_LEN("cmdtype"), firstcbuf); + tv_dict_add_nr(dict, S_LEN("cmdlevel"), ccline.level); + tv_dict_set_keys_readonly(dict); + // not readonly: + tv_dict_add_special(dict, S_LEN("abort"), + s->gotesc ? kSpecialVarTrue : kSpecialVarFalse); + try_enter(&tstate); + apply_autocmds(EVENT_CMDLINELEAVE, (char_u *)firstcbuf, (char_u *)firstcbuf, + false, curbuf); + // error printed below, to avoid redraw issues + tl_ret = try_leave(&tstate, &err); + if (tv_dict_get_number(dict, "abort") != 0) { + s->gotesc = 1; + } + tv_dict_clear(dict); + } + cmdmsg_rl = false; cmd_fkmap = 0; @@ -410,8 +459,14 @@ static uint8_t *command_line_enter(int firstc, long count, int indent) msg_scroll = s->save_msg_scroll; redir_off = false; + if (!tl_ret && ERROR_SET(&err)) { + msg_putchar('\n'); + msg_printf_attr(hl_attr(HLF_E)|MSG_HIST, (char *)e_autocmd_err, err.msg); + api_clear_error(&err); + } + // When the command line was typed, no need for a wait-return prompt. - if (s->some_key_typed) { + if (s->some_key_typed && tl_ret) { need_wait_return = false; } diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 8f804ff888..2b025c2c50 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1167,6 +1167,8 @@ EXTERN char_u e_dirnotf[] INIT(= N_( EXTERN char_u e_unsupportedoption[] INIT(= N_("E519: Option not supported")); EXTERN char_u e_fnametoolong[] INIT(= N_("E856: Filename too long")); EXTERN char_u e_float_as_string[] INIT(= N_("E806: using Float as a String")); +EXTERN char_u e_autocmd_err[] INIT(=N_( + "E920: autocmd has thrown an exception: %s")); EXTERN char top_bot_msg[] INIT(= N_("search hit TOP, continuing at BOTTOM")); diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 835df42a10..82c04abf5b 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -420,3 +420,25 @@ function Test_autocmd_bufwipe_in_SessLoadPost2() call delete(file) endfor endfunc + +func Test_Cmdline() + au! CmdlineEnter : let g:entered = expand('') + au! CmdlineLeave : let g:left = expand('') + let g:entered = 0 + let g:left = 0 + call feedkeys(":echo 'hello'\", 'xt') + call assert_equal(':', g:entered) + call assert_equal(':', g:left) + au! CmdlineEnter + au! CmdlineLeave + + au! CmdlineEnter / let g:entered = expand('') + au! CmdlineLeave / let g:left = expand('') + let g:entered = 0 + let g:left = 0 + call feedkeys("/hello", 'xt') + call assert_equal('/', g:entered) + call assert_equal('/', g:left) + au! CmdlineEnter + au! CmdlineLeave +endfunc diff --git a/src/nvim/version.c b/src/nvim/version.c index 1ceda55cf1..205c25b6cd 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -78,6 +78,7 @@ static char *features[] = { // clang-format off static const int included_patches[] = { + 1206, // 1026, 1025, 1024, -- cgit From 51637f4256353e513f262572bcb786b54d250e11 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 22 Nov 2017 22:47:12 +0100 Subject: tui: move terminfo_is_term_family() --- src/nvim/tui/terminfo.c | 18 +++++++++++++++++- src/nvim/tui/tui.c | 14 -------------- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c index 586fafba97..6b0be50917 100644 --- a/src/nvim/tui/terminfo.c +++ b/src/nvim/tui/terminfo.c @@ -3,10 +3,12 @@ // Built-in fallback terminfo entries. +#include +#include + #include #include "nvim/tui/terminfo.h" -#include "nvim/tui/tui.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "tui/terminfo.c.generated.h" @@ -75,6 +77,20 @@ static const signed char ansi_terminfo[] = { 26, 1, 40, 0, 23, 0, 16, 0, 125, 1, 68, 2, 97, 110, 115, 105, 124, 97, 110, 115, 105, 47, 112, 99, 45, 116, 101, 114, 109, 32, 99, 111, 109, 112, 97, 116, 105, 98, 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, 108, 111, 114, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, 0, 64, 0, 3, 0, 0, 0, 4, 0, 6, 0, -1, -1, 8, 0, 13, 0, 20, 0, 24, 0, 28, 0, -1, -1, 39, 0, 56, 0, 60, 0, -1, -1, 64, 0, -1, -1, -1, -1, 68, 0, -1, -1, 72, 0, -1, -1, 76, 0, 80, 0, -1, -1, -1, -1, 84, 0, 90, 0, 95, 0, -1, -1, -1, -1, -1, -1, -1, -1, 100, 0, -1, -1, 105, 0, 110, 0, 115, 0, 120, 0,-127, 0,-121, 0, -1, -1, -1, -1, -1, -1,-113, 0,-109, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-105, 0, -1, -1,-101, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -99, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -95, 0, -91, 0, -1, -1, -87, 0, -1, -1, -1, -1, -1, -1, -83, 0, -1, -1, -1, -1, -1, -1, -79, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -75, 0, -1, -1, -70, 0, -61, 0, -52, 0, -43, 0, -34, 0, -25, 0, -16, 0, -7, 0, 2, 1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 1, 25, 1, 30, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 1, -1, -1, 61, 1, -1, -1, 63, 1,-107, 1, -1, -1,-104, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-100, 1, -1, -1, -37, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -33, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -28, 1, -17, 1, -12, 1, 7, 2, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 2, 30, 2, -1, -1, -1, -1, -1, -1, 40, 2, 44, 2, 48, 2, 52, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 56, 2, 62, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 27, 91, 66, 0, 27, 91, 72, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 91, 49, 49, 109, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 27, 91, 49, 48, 109, 0, 27, 91, 48, 59, 49, 48, 109, 0, 27, 91, 109, 0, 27, 91, 109, 0, 27, 91, 76, 0, 8, 0, 27, 91, 66, 0, 27, 91, 72, 0, 27, 91, 76, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 27, 91, 83, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 52, 105, 0, 27, 91, 53, 105, 0, 37, 112, 49, 37, 99, 27, 91, 37, 112, 50, 37, 123, 49, 125, 37, 45, 37, 100, 98, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 10, 0, 27, 91, 48, 59, 49, 48, 37, 63, 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 37, 63, 37, 112, 57, 37, 116, 59, 49, 49, 37, 59, 109, 0, 27, 72, 0, 27, 91, 73, 0, 43, 16, 44, 17, 45, 24, 46, 25, 48, -37, 96, 4, 97, -79, 102, -8, 103, -15, 104, -80, 106, -39, 107, -65, 108, -38, 109, -64, 110, -59, 111, 126, 112, -60, 113, -60, 114, -60, 115, 95, 116, -61, 117, -76, 118, -63, 119, -62, 120, -77, 121, -13, 122, -14, 123, -29, 124, -40, 125,-100, 126, -2, 0, 27, 91, 90, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 37, 91, 59, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 93, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 37, 112, 49, 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0, 27, 40, 66, 0, 27, 41, 66, 0, 27, 42, 66, 0, 27, 43, 66, 0, 27, 91, 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 }; +// Per the commentary in terminfo, only a minus sign is a true suffix +// separator. +bool terminfo_is_term_family(const char *term, const char *family) +{ + if (!term) { + return false; + } + size_t tlen = strlen(term); + size_t flen = strlen(family); + return tlen >= flen + && 0 == memcmp(term, family, flen) \ + && ('\0' == term[flen] || '-' == term[flen]); +} + /// Load one of the built-in terminfo entries when unibilium has failed to /// load a terminfo record from an external database, as it does on termcap- /// -only systems. We do not do any fancy recognition of xterm pretenders diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index b447b4aae2..7ff426239a 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -61,20 +61,6 @@ #define UNIBI_SET_NUM_VAR(var, num) (var).i = (num); #endif -// Per the commentary in terminfo, only a minus sign is a true suffix -// separator. -bool terminfo_is_term_family(const char *term, const char *family) -{ - if (!term) { - return false; - } - size_t tlen = strlen(term); - size_t flen = strlen(family); - return tlen >= flen - && 0 == memcmp(term, family, flen) \ - && ('\0' == term[flen] || '-' == term[flen]); -} - typedef struct { int top, bot, left, right; } Rect; -- cgit From d9b3ebfede6439aab4148c4bbf117b8950ed6aa0 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Thu, 23 Nov 2017 07:36:35 +0100 Subject: FIXUP: duplicate error number in #7422 --- src/nvim/globals.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 2b025c2c50..1ff0f7eb89 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1168,7 +1168,7 @@ EXTERN char_u e_unsupportedoption[] INIT(= N_("E519: Option not supported")); EXTERN char_u e_fnametoolong[] INIT(= N_("E856: Filename too long")); EXTERN char_u e_float_as_string[] INIT(= N_("E806: using Float as a String")); EXTERN char_u e_autocmd_err[] INIT(=N_( - "E920: autocmd has thrown an exception: %s")); + "E5500: autocmd has thrown an exception: %s")); EXTERN char top_bot_msg[] INIT(= N_("search hit TOP, continuing at BOTTOM")); -- cgit From 9888a54f15d8b737bdc8c18406d7fccb0186a0b1 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 23 Nov 2017 02:21:04 +0100 Subject: tui: Disable BCE by default. #7624 133ae5eeeff3 implemented BCE (background color erase). That's fine if the system terminfo claims to support it; but our built-in fallback should not assume it. Per https://github.com/kovidgoyal/kitty/issues/160#issuecomment-346470545 terminal support for BCE seems to be (1) optional and (2) inconsistent. So the built-in terminfos should disable it by default. ref #4210 #4421 #7035 #7337 #7381 #7425 #7618 --- src/nvim/tui/terminfo.c | 23 +++++++++++++++-------- src/nvim/tui/tui.c | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c index 6b0be50917..75e9a2d8da 100644 --- a/src/nvim/tui/terminfo.c +++ b/src/nvim/tui/terminfo.c @@ -8,6 +8,7 @@ #include +#include "nvim/log.h" #include "nvim/tui/terminfo.h" #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -77,8 +78,6 @@ static const signed char ansi_terminfo[] = { 26, 1, 40, 0, 23, 0, 16, 0, 125, 1, 68, 2, 97, 110, 115, 105, 124, 97, 110, 115, 105, 47, 112, 99, 45, 116, 101, 114, 109, 32, 99, 111, 109, 112, 97, 116, 105, 98, 108, 101, 32, 119, 105, 116, 104, 32, 99, 111, 108, 111, 114, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 80, 0, 8, 0, 24, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, 0, 64, 0, 3, 0, 0, 0, 4, 0, 6, 0, -1, -1, 8, 0, 13, 0, 20, 0, 24, 0, 28, 0, -1, -1, 39, 0, 56, 0, 60, 0, -1, -1, 64, 0, -1, -1, -1, -1, 68, 0, -1, -1, 72, 0, -1, -1, 76, 0, 80, 0, -1, -1, -1, -1, 84, 0, 90, 0, 95, 0, -1, -1, -1, -1, -1, -1, -1, -1, 100, 0, -1, -1, 105, 0, 110, 0, 115, 0, 120, 0,-127, 0,-121, 0, -1, -1, -1, -1, -1, -1,-113, 0,-109, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-105, 0, -1, -1,-101, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -99, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -95, 0, -91, 0, -1, -1, -87, 0, -1, -1, -1, -1, -1, -1, -83, 0, -1, -1, -1, -1, -1, -1, -79, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -75, 0, -1, -1, -70, 0, -61, 0, -52, 0, -43, 0, -34, 0, -25, 0, -16, 0, -7, 0, 2, 1, 11, 1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 1, 25, 1, 30, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 50, 1, -1, -1, 61, 1, -1, -1, 63, 1,-107, 1, -1, -1,-104, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-100, 1, -1, -1, -37, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -33, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -28, 1, -17, 1, -12, 1, 7, 2, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 20, 2, 30, 2, -1, -1, -1, -1, -1, -1, 40, 2, 44, 2, 48, 2, 52, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 56, 2, 62, 2, 27, 91, 90, 0, 7, 0, 13, 0, 27, 91, 51, 103, 0, 27, 91, 72, 27, 91, 74, 0, 27, 91, 75, 0, 27, 91, 74, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 71, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 59, 37, 112, 50, 37, 100, 72, 0, 27, 91, 66, 0, 27, 91, 72, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 65, 0, 27, 91, 80, 0, 27, 91, 77, 0, 27, 91, 49, 49, 109, 0, 27, 91, 53, 109, 0, 27, 91, 49, 109, 0, 27, 91, 56, 109, 0, 27, 91, 55, 109, 0, 27, 91, 55, 109, 0, 27, 91, 52, 109, 0, 27, 91, 37, 112, 49, 37, 100, 88, 0, 27, 91, 49, 48, 109, 0, 27, 91, 48, 59, 49, 48, 109, 0, 27, 91, 109, 0, 27, 91, 109, 0, 27, 91, 76, 0, 8, 0, 27, 91, 66, 0, 27, 91, 72, 0, 27, 91, 76, 0, 27, 91, 68, 0, 27, 91, 67, 0, 27, 91, 65, 0, 13, 27, 91, 83, 0, 27, 91, 37, 112, 49, 37, 100, 80, 0, 27, 91, 37, 112, 49, 37, 100, 77, 0, 27, 91, 37, 112, 49, 37, 100, 66, 0, 27, 91, 37, 112, 49, 37, 100, 64, 0, 27, 91, 37, 112, 49, 37, 100, 83, 0, 27, 91, 37, 112, 49, 37, 100, 76, 0, 27, 91, 37, 112, 49, 37, 100, 68, 0, 27, 91, 37, 112, 49, 37, 100, 67, 0, 27, 91, 37, 112, 49, 37, 100, 84, 0, 27, 91, 37, 112, 49, 37, 100, 65, 0, 27, 91, 52, 105, 0, 27, 91, 53, 105, 0, 37, 112, 49, 37, 99, 27, 91, 37, 112, 50, 37, 123, 49, 125, 37, 45, 37, 100, 98, 0, 27, 91, 37, 105, 37, 112, 49, 37, 100, 100, 0, 10, 0, 27, 91, 48, 59, 49, 48, 37, 63, 37, 112, 49, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 50, 37, 116, 59, 52, 37, 59, 37, 63, 37, 112, 51, 37, 116, 59, 55, 37, 59, 37, 63, 37, 112, 52, 37, 116, 59, 53, 37, 59, 37, 63, 37, 112, 54, 37, 116, 59, 49, 37, 59, 37, 63, 37, 112, 55, 37, 116, 59, 56, 37, 59, 37, 63, 37, 112, 57, 37, 116, 59, 49, 49, 37, 59, 109, 0, 27, 72, 0, 27, 91, 73, 0, 43, 16, 44, 17, 45, 24, 46, 25, 48, -37, 96, 4, 97, -79, 102, -8, 103, -15, 104, -80, 106, -39, 107, -65, 108, -38, 109, -64, 110, -59, 111, 126, 112, -60, 113, -60, 114, -60, 115, 95, 116, -61, 117, -76, 118, -63, 119, -62, 120, -77, 121, -13, 122, -14, 123, -29, 124, -40, 125,-100, 126, -2, 0, 27, 91, 90, 0, 27, 91, 49, 75, 0, 27, 91, 37, 105, 37, 100, 59, 37, 100, 82, 0, 27, 91, 54, 110, 0, 27, 91, 63, 37, 91, 59, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 93, 99, 0, 27, 91, 99, 0, 27, 91, 51, 57, 59, 52, 57, 109, 0, 27, 91, 51, 37, 112, 49, 37, 100, 109, 0, 27, 91, 52, 37, 112, 49, 37, 100, 109, 0, 27, 40, 66, 0, 27, 41, 66, 0, 27, 42, 66, 0, 27, 43, 66, 0, 27, 91, 49, 49, 109, 0, 27, 91, 49, 48, 109, 0 }; -// Per the commentary in terminfo, only a minus sign is a true suffix -// separator. bool terminfo_is_term_family(const char *term, const char *family) { if (!term) { @@ -88,15 +87,14 @@ bool terminfo_is_term_family(const char *term, const char *family) size_t flen = strlen(family); return tlen >= flen && 0 == memcmp(term, family, flen) \ + // Per the commentary in terminfo, minus sign is the suffix separator. && ('\0' == term[flen] || '-' == term[flen]); } -/// Load one of the built-in terminfo entries when unibilium has failed to -/// load a terminfo record from an external database, as it does on termcap- -/// -only systems. We do not do any fancy recognition of xterm pretenders -/// here. An external terminfo database would not do that, and we want to -/// behave as much like an external terminfo database as possible. -unibi_term *load_builtin_terminfo(const char * term) +/// Loads a built-in terminfo db when we (unibilium) failed to load a terminfo +/// record from the environment (termcap systems, unrecognized $TERM, …). +/// We do not attempt to detect xterm pretenders here. +static unibi_term *terminfo_builtin(const char *term) { if (terminfo_is_term_family(term, "xterm")) { return unibi_from_mem((const char *)xterm_256colour_terminfo, @@ -137,3 +135,12 @@ unibi_term *load_builtin_terminfo(const char * term) sizeof ansi_terminfo); } } + +unibi_term *terminfo_from_builtin(const char *term) +{ + unibi_term *ut = terminfo_builtin(term); + // Disable BCE by default (for built-in terminfos). #7624 + // https://github.com/kovidgoyal/kitty/issues/160#issuecomment-346470545 + unibi_set_bool(ut, unibi_back_color_erase, false); + return ut; +} diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 7ff426239a..3945d400f3 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -194,7 +194,7 @@ static void terminfo_start(UI *ui) const char *term = os_getenv("TERM"); data->ut = unibi_from_env(); if (!data->ut) { - data->ut = load_builtin_terminfo(term); + data->ut = terminfo_from_builtin(term); } // None of the following work over SSH; see :help TERM . const char *colorterm = os_getenv("COLORTERM"); -- cgit From b838ad5b7a2cfeb72a34a534eb4f10787c4c6c8f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 23 Nov 2017 21:21:05 +0100 Subject: tui: Disable BCE almost always. #7624 133ae5eeeff3 implemented BCE (background color erase). But we can't trust terminfo, so it is safer disable BCE if we are not certain. Per https://github.com/kovidgoyal/kitty/issues/160#issuecomment-346470545 terminal support for BCE seems to be (1) optional and (2) inconsistent. ref #4210 #4421 #7035 #7337 #7381 #7425 #7618 --- src/nvim/tui/tui.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 3945d400f3..302354e826 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1234,11 +1234,9 @@ static int unibi_find_ext_str(unibi_term *ut, const char *name) return -1; } -/// Several entries in terminfo are known to be deficient or outright wrong, -/// unfortunately; and several terminal emulators falsely announce incorrect -/// terminal types. So patch the terminfo records after loading from an -/// external or a built-in database. In an ideal world, the real terminfo data -/// would be correct and complete, and this function would be almost empty. +/// Patches the terminfo records after loading from system or built-in db. +/// Several entries in terminfo are known to be deficient or outright wrong; +/// and several terminal emulators falsely announce incorrect terminal types. static void patch_terminfo_bugs(TUIData *data, const char *term, const char *colorterm, long vte_version, bool konsole, bool iterm_env) @@ -1304,6 +1302,11 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } } + if (!true_xterm) { + // Cannot trust terminfo; safer to disable BCE. #7624 + unibi_set_bool(ut, unibi_back_color_erase, false); + } + if (xterm) { // Termit, LXTerminal, GTKTerm2, GNOME Terminal, MATE Terminal, roxterm, // and EvilVTE falsely claim to be xterm and do not support important xterm @@ -1397,11 +1400,9 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, #define XTERM_SETAB_16 \ "\x1b[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e39%;m" - // Terminals where there is actually 256-colour SGR support despite what - // the terminfo record may say. + // Terminals with 256-colour SGR support despite what terminfo says. if (unibi_get_num(ut, unibi_max_colors) < 256) { - // See http://fedoraproject.org/wiki/Features/256_Color_Terminals for - // more on this. + // See http://fedoraproject.org/wiki/Features/256_Color_Terminals if (true_xterm || iterm || iterm_pretending_xterm) { unibi_set_num(ut, unibi_max_colors, 256); unibi_set_str(ut, unibi_set_a_foreground, XTERM_SETAF_256_COLON); @@ -1417,8 +1418,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, unibi_set_str(ut, unibi_set_a_background, XTERM_SETAB_256); } } - // Terminals where there is actually 16-colour SGR support despite what - // the terminfo record may say. + // Terminals with 16-colour SGR support despite what terminfo says. if (unibi_get_num(ut, unibi_max_colors) < 16) { if (colorterm) { unibi_set_num(ut, unibi_max_colors, 16); @@ -1427,9 +1427,8 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } } - // Some terminals can not currently be trusted to report if they support - // DECSCUSR or not. So we need to have a blacklist for when we should not - // trust the reported features. + // Some terminals cannot be trusted to report DECSCUSR support. So we keep + // blacklist for when we should not trust the reported features. if (!((vte_version != 0 && vte_version < 3900) || konsole)) { // Dickey ncurses terminfo has included the Ss and Se capabilities, // pioneered by tmux, since 2011-07-14. So adding them to terminal types, -- cgit From 0b93bab6c22edf7a07cf965ebbbf631b93e1dc1b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 24 Nov 2017 09:53:09 +0100 Subject: tui: update cleared area only if non-default bg This check was removed in 133ae5eeeff3 without explanation. --- src/nvim/tui/tui.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 302354e826..c2e597c36c 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -940,9 +940,10 @@ static void tui_scroll(UI *ui, Integer count) } cursor_goto(ui, saved_row, saved_col); - if (!scroll_clears_to_current_colour) { - // This is required because scrolling will leave wrong background in the - // cleared area on non-bge terminals. + if (!scroll_clears_to_current_colour && grid->bg != -1) { + // Scrolling may leave wrong background in the cleared area on non-bge + // terminals. Update the cleared area of the terminal if its builtin + // scrolling facility was used and bg color is not the default. clear_region(ui, clear_top, clear_bot, grid->left, grid->right); } } else { -- cgit From 3717e2157f2d45ce23dbe4ac03085fea2d956dc4 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 23 Jul 2017 18:04:14 +0200 Subject: Revert channel logging, rebased on new code below --- src/nvim/eval.c | 9 +++------ src/nvim/msgpack_rpc/channel.c | 43 ++++++++++++++---------------------------- 2 files changed, 17 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f414e771d7..b8bae3e293 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -15168,8 +15168,7 @@ static void f_sockconnect(typval_T *argvars, typval_T *rettv, FunPtr fptr) } const char *error = NULL; - eval_format_source_name_line((char *)IObuff, sizeof(IObuff)); - uint64_t id = channel_connect(tcp, address, 50, (char *)IObuff, &error); + uint64_t id = channel_connect(tcp, address, 50, &error); if (error) { EMSG2(_("connection failed: %s"), error); @@ -22488,9 +22487,8 @@ static inline bool common_job_start(TerminalJobData *data, typval_T *rettv) if (data->rpc) { - eval_format_source_name_line((char *)IObuff, sizeof(IObuff)); - // RPC channel takes over the in/out streams. - channel_from_process(proc, data->id, (char *)IObuff); + // the rpc channel takes over the in and out streams + channel_from_process(proc, data->id); } else { wstream_init(proc->in, 0); if (proc->out) { @@ -22855,4 +22853,3 @@ void ex_checkhealth(exarg_T *eap) xfree(buf); } - diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 5efdb9a194..18f6334780 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -115,15 +115,12 @@ void channel_teardown(void) /// Creates an API channel by starting a process and connecting to its /// stdin/stdout. stderr is handled by the job infrastructure. /// -/// @param proc process object -/// @param id (optional) channel id -/// @param source description of source function, rplugin name, TCP addr, etc -/// -/// @return Channel id (> 0), on success. 0, on error. -uint64_t channel_from_process(Process *proc, uint64_t id, char *source) +/// @param argv The argument vector for the process. [consumed] +/// @return The channel id (> 0), on success. +/// 0, on error. +uint64_t channel_from_process(Process *proc, uint64_t id) { - Channel *channel = register_channel(kChannelTypeProc, id, proc->events, - source); + Channel *channel = register_channel(kChannelTypeProc, id, proc->events); incref(channel); // process channels are only closed by the exit_cb channel->data.proc = proc; @@ -142,8 +139,7 @@ uint64_t channel_from_process(Process *proc, uint64_t id, char *source) /// @param watcher The SocketWatcher ready to accept the connection void channel_from_connection(SocketWatcher *watcher) { - Channel *channel = register_channel(kChannelTypeSocket, 0, NULL, - watcher->addr); + Channel *channel = register_channel(kChannelTypeSocket, 0, NULL); socket_watcher_accept(watcher, &channel->data.stream); incref(channel); // close channel only after the stream is closed channel->data.stream.internal_close_cb = close_cb; @@ -156,9 +152,8 @@ void channel_from_connection(SocketWatcher *watcher) &channel->data.stream); } -/// @param source description of source function, rplugin name, TCP addr, etc -uint64_t channel_connect(bool tcp, const char *address, int timeout, - char *source, const char **error) +uint64_t channel_connect(bool tcp, const char *address, + int timeout, const char **error) { if (!tcp) { char *path = fix_fname(address); @@ -170,7 +165,7 @@ uint64_t channel_connect(bool tcp, const char *address, int timeout, xfree(path); } - Channel *channel = register_channel(kChannelTypeSocket, 0, NULL, source); + Channel *channel = register_channel(kChannelTypeSocket, 0, NULL); if (!socket_connect(&main_loop, &channel->data.stream, tcp, address, timeout, error)) { decref(channel); @@ -323,10 +318,11 @@ bool channel_close(uint64_t id) return true; } -/// Creates an API channel from stdin/stdout. Used to embed Nvim. +/// Creates an API channel from stdin/stdout. This is used when embedding +/// Neovim void channel_from_stdio(void) { - Channel *channel = register_channel(kChannelTypeStdio, 0, NULL, NULL); + Channel *channel = register_channel(kChannelTypeStdio, 0, NULL); incref(channel); // stdio channels are only closed on exit // read stream rstream_init_fd(&main_loop, &channel->data.std.in, 0, CHANNEL_BUFFER_SIZE); @@ -342,7 +338,7 @@ void channel_from_stdio(void) /// when an instance connects to its own named pipe. uint64_t channel_create_internal(void) { - Channel *channel = register_channel(kChannelTypeInternal, 0, NULL, NULL); + Channel *channel = register_channel(kChannelTypeInternal, 0, NULL); incref(channel); // internal channel lives until process exit return channel->id; } @@ -778,12 +774,9 @@ static void close_cb(Stream *stream, void *data) decref(data); } -/// @param source description of source function, rplugin name, TCP addr, etc static Channel *register_channel(ChannelType type, uint64_t id, - MultiQueue *events, char *source) + MultiQueue *events) { - // Jobs and channels share the same id namespace. - assert(id == 0 || !pmap_get(uint64_t)(channels, id)); Channel *rv = xmalloc(sizeof(Channel)); rv->events = events ? events : multiqueue_new_child(main_loop.events); rv->type = type; @@ -795,14 +788,6 @@ static Channel *register_channel(ChannelType type, uint64_t id, rv->next_request_id = 1; kv_init(rv->call_stack); pmap_put(uint64_t)(channels, rv->id, rv); - - ILOG("new channel %" PRIu64 " (%s): %s", rv->id, - (type == kChannelTypeProc ? "proc" - : (type == kChannelTypeSocket ? "socket" - : (type == kChannelTypeStdio ? "stdio" - : (type == kChannelTypeInternal ? "internal" : "?")))), - (source ? source : "?")); - return rv; } -- cgit From 5215e3205a07b85e4e4cf1f8a8ca6be2b9556459 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 27 Aug 2017 11:59:33 +0200 Subject: channels: refactor --- src/nvim/api/ui.c | 2 +- src/nvim/api/vim.c | 4 +- src/nvim/channel.c | 61 ++++++ src/nvim/channel.h | 120 +++++++++++ src/nvim/eval.c | 314 +++++++++++------------------ src/nvim/eval/typval.c | 24 +++ src/nvim/event/libuv_process.c | 12 +- src/nvim/event/process.c | 77 +++---- src/nvim/event/process.h | 15 +- src/nvim/event/stream.h | 2 +- src/nvim/globals.h | 7 +- src/nvim/msgpack_rpc/channel.c | 388 ++++++++++++------------------------ src/nvim/msgpack_rpc/channel.h | 2 + src/nvim/msgpack_rpc/channel_defs.h | 36 ++++ src/nvim/os/pty_process_unix.c | 10 +- src/nvim/os/pty_process_win.c | 12 +- src/nvim/os/shell.c | 26 +-- 17 files changed, 580 insertions(+), 532 deletions(-) create mode 100644 src/nvim/channel.c create mode 100644 src/nvim/channel.h create mode 100644 src/nvim/msgpack_rpc/channel_defs.h (limited to 'src') diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index afbee09c1c..a9eaccfac5 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -252,7 +252,7 @@ static void remote_ui_flush(UI *ui) { UIData *data = ui->data; if (data->buffer.size > 0) { - channel_send_event(data->channel_id, "redraw", data->buffer); + rpc_send_event(data->channel_id, "redraw", data->buffer); data->buffer = (Array)ARRAY_DICT_INIT; } } diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index d2b0e329c9..f4ccf07bec 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -721,7 +721,7 @@ void nvim_subscribe(uint64_t channel_id, String event) char e[METHOD_MAXLEN + 1]; memcpy(e, event.data, length); e[length] = NUL; - channel_subscribe(channel_id, e); + rpc_subscribe(channel_id, e); } /// Unsubscribes to event broadcasts @@ -737,7 +737,7 @@ void nvim_unsubscribe(uint64_t channel_id, String event) char e[METHOD_MAXLEN + 1]; memcpy(e, event.data, length); e[length] = NUL; - channel_unsubscribe(channel_id, e); + rpc_unsubscribe(channel_id, e); } Integer nvim_get_color_by_name(String name) diff --git a/src/nvim/channel.c b/src/nvim/channel.c new file mode 100644 index 0000000000..e61ec9c19b --- /dev/null +++ b/src/nvim/channel.c @@ -0,0 +1,61 @@ +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + +#include "nvim/api/ui.h" +#include "nvim/channel.h" +#include "nvim/msgpack_rpc/channel.h" + +PMap(uint64_t) *channels = NULL; + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "channel.c.generated.h" +#endif +/// Teardown the module +void channel_teardown(void) +{ + if (!channels) { + return; + } + + Channel *channel; + + map_foreach_value(channels, channel, { + (void)channel; // close_channel(channel); + }); +} + +/// Initializes the module +void channel_init(void) +{ + channels = pmap_new(uint64_t)(); + rpc_init(); + remote_ui_init(); +} + +void channel_incref(Channel *channel) +{ + channel->refcount++; +} + +void channel_decref(Channel *channel) +{ + if (!(--channel->refcount)) { + multiqueue_put(main_loop.fast_events, free_channel_event, 1, channel); + } +} + +static void free_channel_event(void **argv) +{ + Channel *channel = argv[0]; + if (channel->is_rpc) { + rpc_free(channel); + } + + callback_free(&channel->on_stdout); + callback_free(&channel->on_stderr); + callback_free(&channel->on_exit); + + pmap_del(uint64_t)(channels, channel->id); + multiqueue_free(channel->events); + xfree(channel); +} diff --git a/src/nvim/channel.h b/src/nvim/channel.h new file mode 100644 index 0000000000..b48f508722 --- /dev/null +++ b/src/nvim/channel.h @@ -0,0 +1,120 @@ +#ifndef NVIM_CHANNEL_H +#define NVIM_CHANNEL_H + +#include "nvim/main.h" +#include "nvim/event/socket.h" +#include "nvim/event/process.h" +#include "nvim/os/pty_process.h" +#include "nvim/event/libuv_process.h" +#include "nvim/eval/typval.h" +#include "nvim/msgpack_rpc/channel_defs.h" + +typedef enum { + kChannelStreamProc, + kChannelStreamSocket, + kChannelStreamStdio, + kChannelStreamInternal +} ChannelStreamType; + +typedef struct { + Stream in; + Stream out; +} StdioPair; + +// typedef struct { +// Callback on_out; +// Callback on_close; +// Garray buffer; +// bool buffering; +// } CallbackReader + +#define CallbackReader Callback + +struct Channel { + uint64_t id; + size_t refcount; + MultiQueue *events; + + ChannelStreamType streamtype; + union { + Process proc; + LibuvProcess uv; + PtyProcess pty; + Stream socket; + StdioPair stdio; + } stream; + + bool is_rpc; + RpcState rpc; + Terminal *term; + + CallbackReader on_stdout; + CallbackReader on_stderr; + Callback on_exit; + + varnumber_T *status_ptr; // TODO: refactor? +}; + +EXTERN PMap(uint64_t) *channels; + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "channel.h.generated.h" +#endif + +static inline Channel *channel_alloc(ChannelStreamType type) +{ + Channel *chan = xcalloc(1, sizeof(*chan)); + chan->id = next_chan_id++; + chan->events = multiqueue_new_child(main_loop.events); + chan->refcount = 1; + chan->streamtype = type; + pmap_put(uint64_t)(channels, chan->id, chan); + return chan; +} + +/// @returns Channel with the id or NULL if not found +static inline Channel *find_channel(uint64_t id) +{ + return pmap_get(uint64_t)(channels, id); +} + +static inline Stream *channel_instream(Channel *chan) + FUNC_ATTR_NONNULL_ALL +{ + switch (chan->streamtype) { + case kChannelStreamProc: + return &chan->stream.proc.in; + + case kChannelStreamSocket: + return &chan->stream.socket; + + case kChannelStreamStdio: + return &chan->stream.stdio.in; + + case kChannelStreamInternal: + abort(); + } + abort(); +} + +static inline Stream *channel_outstream(Channel *chan) + FUNC_ATTR_NONNULL_ALL +{ + switch (chan->streamtype) { + case kChannelStreamProc: + return &chan->stream.proc.out; + + case kChannelStreamSocket: + return &chan->stream.socket; + + case kChannelStreamStdio: + return &chan->stream.stdio.out; + + case kChannelStreamInternal: + abort(); + } + abort(); +} + + +#endif // NVIM_CHANNEL_H diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b8bae3e293..013cfce78d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -24,6 +24,7 @@ #endif #include "nvim/eval.h" #include "nvim/buffer.h" +#include "nvim/channel.h" #include "nvim/charset.h" #include "nvim/cursor.h" #include "nvim/diff.h" @@ -437,29 +438,12 @@ static ScopeDictDictItem vimvars_var; #define vimvarht vimvardict.dv_hashtab typedef struct { - union { - LibuvProcess uv; - PtyProcess pty; - } proc; - Stream in, out, err; // Initialized in common_job_start(). - Terminal *term; - bool stopped; - bool exited; - bool rpc; - int refcount; - Callback on_stdout, on_stderr, on_exit; - varnumber_T *status_ptr; - uint64_t id; - MultiQueue *events; -} TerminalJobData; - -typedef struct { - TerminalJobData *data; + Channel *data; Callback *callback; const char *type; list_T *received; int status; -} JobEvent; +} ChannelEvent; typedef struct { TimeWatcher tw; @@ -513,7 +497,6 @@ typedef enum { #define FNE_INCL_BR 1 /* find_name_end(): include [] in name */ #define FNE_CHECK_START 2 /* find_name_end(): check name starts with valid character */ -static PMap(uint64_t) *jobs = NULL; static uint64_t last_timer_id = 0; static PMap(uint64_t) *timers = NULL; @@ -556,7 +539,6 @@ void eval_init(void) { vimvars[VV_VERSION].vv_nr = VIM_VERSION_100; - jobs = pmap_new(uint64_t)(); timers = pmap_new(uint64_t)(); struct vimvar *p; @@ -5141,8 +5123,8 @@ bool garbage_collect(bool testing) // Jobs { - TerminalJobData *data; - map_foreach_value(jobs, data, { + Channel *data; + map_foreach_value(channels, data, { set_ref_in_callback(&data->on_stdout, copyID, NULL, NULL); set_ref_in_callback(&data->on_stderr, copyID, NULL, NULL); set_ref_in_callback(&data->on_exit, copyID, NULL, NULL); @@ -11433,24 +11415,23 @@ static void f_jobclose(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } - TerminalJobData *data = find_job(argvars[0].vval.v_number); + Channel *data = find_job(argvars[0].vval.v_number, true); if (!data) { - EMSG(_(e_invjob)); return; } - Process *proc = (Process *)&data->proc; + Process *proc = (Process *)&data->stream.proc; if (argvars[1].v_type == VAR_STRING) { char *stream = (char *)argvars[1].vval.v_string; if (!strcmp(stream, "stdin")) { - if (data->rpc) { + if (data->is_rpc) { EMSG(_("Invalid stream on rpc job, use jobclose(id, 'rpc')")); } else { process_close_in(proc); } } else if (!strcmp(stream, "stdout")) { - if (data->rpc) { + if (data->is_rpc) { EMSG(_("Invalid stream on rpc job, use jobclose(id, 'rpc')")); } else { process_close_out(proc); @@ -11458,7 +11439,7 @@ static void f_jobclose(typval_T *argvars, typval_T *rettv, FunPtr fptr) } else if (!strcmp(stream, "stderr")) { process_close_err(proc); } else if (!strcmp(stream, "rpc")) { - if (data->rpc) { + if (data->is_rpc) { channel_close(data->id); } else { EMSG(_("Invalid job stream: Not an rpc job")); @@ -11467,13 +11448,13 @@ static void f_jobclose(typval_T *argvars, typval_T *rettv, FunPtr fptr) EMSG2(_("Invalid job stream \"%s\""), stream); } } else { - if (data->rpc) { + if (data->is_rpc) { channel_close(data->id); process_close_err(proc); } else { process_close_streams(proc); if (proc->type == kProcessTypePty) { - pty_process_close_master(&data->proc.pty); + pty_process_close_master(&data->stream.pty); } } } @@ -11494,13 +11475,12 @@ static void f_jobpid(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } - TerminalJobData *data = find_job(argvars[0].vval.v_number); + Channel *data = find_job(argvars[0].vval.v_number, true); if (!data) { - EMSG(_(e_invjob)); return; } - Process *proc = (Process *)&data->proc; + Process *proc = (Process *)&data->stream.proc; rettv->vval.v_number = proc->pid; } @@ -11521,18 +11501,19 @@ static void f_jobsend(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } - TerminalJobData *data = find_job(argvars[0].vval.v_number); + Channel *data = find_channel(argvars[0].vval.v_number); if (!data) { - EMSG(_(e_invjob)); + EMSG(_(e_invchan)); return; } - if (((Process *)&data->proc)->in->closed) { + Stream *in = channel_instream(data); + if (in->closed) { EMSG(_("Can't send data to the job: stdin is closed")); return; } - if (data->rpc) { + if (data->is_rpc) { EMSG(_("Can't send raw data to rpc channel")); return; } @@ -11546,7 +11527,7 @@ static void f_jobsend(typval_T *argvars, typval_T *rettv, FunPtr fptr) } WBuffer *buf = wstream_new_buffer(input, input_len, 1, xfree); - rettv->vval.v_number = wstream_write(data->proc.uv.process.in, buf); + rettv->vval.v_number = wstream_write(in, buf); } // "jobresize(job, width, height)" function @@ -11567,19 +11548,17 @@ static void f_jobresize(typval_T *argvars, typval_T *rettv, FunPtr fptr) } - TerminalJobData *data = find_job(argvars[0].vval.v_number); + Channel *data = find_job(argvars[0].vval.v_number, true); if (!data) { - EMSG(_(e_invjob)); return; } - if (data->proc.uv.process.type != kProcessTypePty) { - EMSG(_(e_jobnotpty)); + if (data->stream.proc.type != kProcessTypePty) { + EMSG(_(e_channotpty)); return; } - pty_process_resize(&data->proc.pty, argvars[1].vval.v_number, - argvars[2].vval.v_number); + pty_process_resize(&data->stream.pty, argvars[1].vval.v_number, argvars[2].vval.v_number); rettv->vval.v_number = 1; } @@ -11697,31 +11676,25 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } - TerminalJobData *data = common_job_init(argv, on_stdout, on_stderr, on_exit, + Channel *data = common_job_init(argv, on_stdout, on_stderr, on_exit, pty, rpc, detach, cwd); - Process *proc = (Process *)&data->proc; if (pty) { + PtyProcess *pty = &data->stream.pty; uint16_t width = (uint16_t)tv_dict_get_number(job_opts, "width"); if (width > 0) { - data->proc.pty.width = width; + pty->width = width; } uint16_t height = (uint16_t)tv_dict_get_number(job_opts, "height"); if (height > 0) { - data->proc.pty.height = height; + pty->height = height; } char *term = tv_dict_get_string(job_opts, "TERM", true); if (term) { - data->proc.pty.term_name = term; + pty->term_name = term; } } - if (!rpc && on_stdout.type == kCallbackNone) { - proc->out = NULL; - } - if (on_stderr.type == kCallbackNone) { - proc->err = NULL; - } common_job_start(data, rettv); } @@ -11742,14 +11715,12 @@ static void f_jobstop(typval_T *argvars, typval_T *rettv, FunPtr fptr) } - TerminalJobData *data = find_job(argvars[0].vval.v_number); + Channel *data = find_job(argvars[0].vval.v_number, true); if (!data) { - EMSG(_(e_invjob)); return; } - process_stop((Process *)&data->proc); - data->stopped = true; + process_stop((Process *)&data->stream.proc); rettv->vval.v_number = 1; } @@ -11778,9 +11749,9 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) // is used to represent an invalid job id, -2 is for a interrupted job and // -1 for jobs that were skipped or timed out. for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { - TerminalJobData *data = NULL; + Channel *data = NULL; if (arg->li_tv.v_type != VAR_NUMBER - || !(data = find_job(arg->li_tv.vval.v_number))) { + || !(data = find_job(arg->li_tv.vval.v_number, false))) { tv_list_append_number(rv, -3); } else { // append the list item and set the status pointer so we'll collect the @@ -11802,16 +11773,16 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) } for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { - TerminalJobData *data = NULL; + Channel *data = NULL; if (remaining == 0) { // timed out break; } if (arg->li_tv.v_type != VAR_NUMBER - || !(data = find_job(arg->li_tv.vval.v_number))) { + || !(data = find_job(arg->li_tv.vval.v_number, false))) { continue; } - int status = process_wait((Process *)&data->proc, remaining, waiting_jobs); + int status = process_wait((Process *)&data->stream.proc, remaining, waiting_jobs); if (status < 0) { // interrupted or timed out, skip remaining jobs. if (status == -2) { @@ -11832,9 +11803,9 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) } for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { - TerminalJobData *data = NULL; + Channel *data = NULL; if (arg->li_tv.v_type != VAR_NUMBER - || !(data = find_job(arg->li_tv.vval.v_number))) { + || !(data = find_job(arg->li_tv.vval.v_number, false))) { continue; } // remove the status pointer because the list may be freed before the @@ -11844,9 +11815,9 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) // restore the parent queue for any jobs still alive for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { - TerminalJobData *data = NULL; + Channel *data = NULL; if (arg->li_tv.v_type != VAR_NUMBER - || !(data = pmap_get(uint64_t)(jobs, arg->li_tv.vval.v_number))) { + || !(data = find_job(arg->li_tv.vval.v_number, false))) { continue; } // restore the parent queue for the job @@ -13803,9 +13774,8 @@ static void f_rpcnotify(typval_T *argvars, typval_T *rettv, FunPtr fptr) ADD(args, vim_to_object(tv)); } - if (!channel_send_event((uint64_t)argvars[0].vval.v_number, - tv_get_string(&argvars[1]), - args)) { + if (!rpc_send_event((uint64_t)argvars[0].vval.v_number, + tv_get_string(&argvars[1]), args)) { EMSG2(_(e_invarg2), "Channel doesn't exist"); return; } @@ -13870,10 +13840,8 @@ static void f_rpcrequest(typval_T *argvars, typval_T *rettv, FunPtr fptr) Error err = ERROR_INIT; - Object result = channel_send_call((uint64_t)argvars[0].vval.v_number, - tv_get_string(&argvars[1]), - args, - &err); + Object result = rpc_send_call((uint64_t)argvars[0].vval.v_number, + tv_get_string(&argvars[1]), args, &err); if (l_provider_call_nesting) { current_SID = save_current_SID; @@ -13954,7 +13922,7 @@ static void f_rpcstart(typval_T *argvars, typval_T *rettv, FunPtr fptr) // The last item of argv must be NULL argv[i] = NULL; - TerminalJobData *data = common_job_init(argv, CALLBACK_NONE, CALLBACK_NONE, + Channel *data = common_job_init(argv, CALLBACK_NONE, CALLBACK_NONE, CALLBACK_NONE, false, true, false, NULL); common_job_start(data, rettv); @@ -13977,10 +13945,11 @@ static void f_rpcstop(typval_T *argvars, typval_T *rettv, FunPtr fptr) } // if called with a job, stop it, else closes the channel - if (pmap_get(uint64_t)(jobs, argvars[0].vval.v_number)) { + uint64_t id = argvars[0].vval.v_number; + if (find_job(id, false)) { // FIXME f_jobstop(argvars, rettv, NULL); } else { - rettv->vval.v_number = channel_close(argvars[0].vval.v_number); + rettv->vval.v_number = channel_close(id); } } @@ -16689,11 +16658,11 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) } uint16_t term_width = MAX(0, curwin->w_width - win_col_off(curwin)); - TerminalJobData *data = common_job_init(argv, on_stdout, on_stderr, on_exit, + Channel *data = common_job_init(argv, on_stdout, on_stderr, on_exit, true, false, false, cwd); - data->proc.pty.width = term_width; - data->proc.pty.height = curwin->w_height; - data->proc.pty.term_name = xstrdup("xterm-256color"); + data->stream.pty.width = term_width; + data->stream.pty.height = curwin->w_height; + data->stream.pty.term_name = xstrdup("xterm-256color"); if (!common_job_start(data, rettv)) { return; } @@ -16705,7 +16674,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) topts.resize_cb = term_resize; topts.close_cb = term_close; - int pid = data->proc.pty.process.pid; + int pid = data->stream.pty.process.pid; char buf[1024]; // format the title with the pid to conform with the term:// URI @@ -16725,7 +16694,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) Terminal *term = terminal_open(topts); data->term = term; - data->refcount++; + channel_incref(data); return; } @@ -16760,30 +16729,6 @@ bool callback_from_typval(Callback *const callback, typval_T *const arg) return true; } -/// Unref/free callback -void callback_free(Callback *const callback) - FUNC_ATTR_NONNULL_ALL -{ - switch (callback->type) { - case kCallbackFuncref: { - func_unref(callback->data.funcref); - xfree(callback->data.funcref); - break; - } - case kCallbackPartial: { - partial_unref(callback->data.partial); - break; - } - case kCallbackNone: { - break; - } - default: { - abort(); - } - } - callback->type = kCallbackNone; -} - bool callback_call(Callback *const callback, const int argcount_in, typval_T *const argvars_in, typval_T *const rettv) FUNC_ATTR_NONNULL_ALL @@ -22402,7 +22347,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, return ret; } -static inline TerminalJobData *common_job_init(char **argv, +static inline Channel *common_job_init(char **argv, Callback on_stdout, Callback on_stderr, Callback on_exit, @@ -22411,25 +22356,18 @@ static inline TerminalJobData *common_job_init(char **argv, bool detach, const char *cwd) { - TerminalJobData *data = xcalloc(1, sizeof(TerminalJobData)); - data->stopped = false; + Channel *data = channel_alloc(kChannelStreamProc); data->on_stdout = on_stdout; data->on_stderr = on_stderr; data->on_exit = on_exit; - data->events = multiqueue_new_child(main_loop.events); - data->rpc = rpc; + data->is_rpc = rpc; if (pty) { - data->proc.pty = pty_process_init(&main_loop, data); + data->stream.pty = pty_process_init(&main_loop, data); } else { - data->proc.uv = libuv_process_init(&main_loop, data); + data->stream.uv = libuv_process_init(&main_loop, data); } - Process *proc = (Process *)&data->proc; + Process *proc = (Process *)&data->stream.proc; proc->argv = argv; - proc->in = &data->in; - proc->out = &data->out; - if (!pty) { - proc->err = &data->err; - } proc->cb = eval_job_process_exit_cb; proc->events = data->events; proc->detach = detach; @@ -22456,80 +22394,66 @@ static inline bool common_job_callbacks(dict_T *vopts, Callback *on_stdout, return false; } -static inline bool common_job_start(TerminalJobData *data, typval_T *rettv) +static inline bool common_job_start(Channel *data, typval_T *rettv) { - Process *proc = (Process *)&data->proc; + Process *proc = (Process *)&data->stream.proc; if (proc->type == kProcessTypePty && proc->detach) { EMSG2(_(e_invarg2), "terminal/pty job cannot be detached"); - xfree(data->proc.pty.term_name); + xfree(data->stream.pty.term_name); shell_free_argv(proc->argv); - free_term_job_data_event((void **)&data); + channel_decref(data); return false; } - data->id = next_chan_id++; - pmap_put(uint64_t)(jobs, data->id, data); - data->refcount++; char *cmd = xstrdup(proc->argv[0]); - int status = process_spawn(proc); + bool has_out, has_err; + if (proc->type == kProcessTypePty) { + has_out = true; + has_err = false; + } else { + has_out = data->is_rpc || data->on_stdout.type != kCallbackNone; + has_err = data->on_stderr.type != kCallbackNone; + } + int status = process_spawn(proc, true, has_out, has_err); if (status) { EMSG3(_(e_jobspawn), os_strerror(status), cmd); xfree(cmd); if (proc->type == kProcessTypePty) { - xfree(data->proc.pty.term_name); + xfree(data->stream.pty.term_name); } rettv->vval.v_number = proc->status; - term_job_data_decref(data); + channel_decref(data); return false; } xfree(cmd); - if (data->rpc) { - // the rpc channel takes over the in and out streams - channel_from_process(proc, data->id); + if (data->is_rpc) { + // the rpc takes over the in and out streams + rpc_start(data); } else { - wstream_init(proc->in, 0); - if (proc->out) { - rstream_init(proc->out, 0); - rstream_start(proc->out, on_job_stdout, data); + wstream_init(&proc->in, 0); + if (has_out) { + rstream_init(&proc->out, 0); + rstream_start(&proc->out, on_job_stdout, data); } } - if (proc->err) { - rstream_init(proc->err, 0); - rstream_start(proc->err, on_job_stderr, data); + if (has_err) { + rstream_init(&proc->err, 0); + rstream_start(&proc->err, on_job_stderr, data); } rettv->vval.v_number = data->id; return true; } -static inline void free_term_job_data_event(void **argv) -{ - TerminalJobData *data = argv[0]; - callback_free(&data->on_stdout); - callback_free(&data->on_stderr); - callback_free(&data->on_exit); - - multiqueue_free(data->events); - pmap_del(uint64_t)(jobs, data->id); - xfree(data); -} - -static inline void free_term_job_data(TerminalJobData *data) -{ - // data->queue may still be used after this function returns(process_wait), so - // only free in the next event loop iteration - multiqueue_put(main_loop.fast_events, free_term_job_data_event, 1, data); -} - // vimscript job callbacks must be executed on Nvim main loop -static inline void process_job_event(TerminalJobData *data, Callback *callback, +static inline void process_job_event(Channel *data, Callback *callback, const char *type, char *buf, size_t count, int status) { - JobEvent event_data; + ChannelEvent event_data; event_data.received = NULL; if (buf) { event_data.received = tv_list_alloc(); @@ -22566,18 +22490,18 @@ static inline void process_job_event(TerminalJobData *data, Callback *callback, static void on_job_stdout(Stream *stream, RBuffer *buf, size_t count, void *job, bool eof) { - TerminalJobData *data = job; + Channel *data = job; on_job_output(stream, job, buf, count, eof, &data->on_stdout, "stdout"); } static void on_job_stderr(Stream *stream, RBuffer *buf, size_t count, void *job, bool eof) { - TerminalJobData *data = job; + Channel *data = job; on_job_output(stream, job, buf, count, eof, &data->on_stderr, "stderr"); } -static void on_job_output(Stream *stream, TerminalJobData *data, RBuffer *buf, +static void on_job_output(Stream *stream, Channel *data, RBuffer *buf, size_t count, bool eof, Callback *callback, const char *type) { @@ -22604,14 +22528,14 @@ static void on_job_output(Stream *stream, TerminalJobData *data, RBuffer *buf, static void eval_job_process_exit_cb(Process *proc, int status, void *d) { - TerminalJobData *data = d; - if (data->term && !data->exited) { - data->exited = true; + Channel *data = d; + if (data->term && !data->stream.proc.exited) { + data->stream.proc.exited = true; char msg[sizeof("\r\n[Process exited ]") + NUMBUFLEN]; snprintf(msg, sizeof msg, "\r\n[Process exited %d]", proc->status); terminal_close(data->term, msg); } - if (data->rpc) { + if (data->is_rpc) { channel_process_exit(data->id, status); } @@ -22621,58 +22545,51 @@ static void eval_job_process_exit_cb(Process *proc, int status, void *d) process_job_event(data, &data->on_exit, "exit", NULL, 0, status); - term_job_data_decref(data); + channel_decref(data); } static void term_write(char *buf, size_t size, void *d) { - TerminalJobData *job = d; - if (job->in.closed) { + Channel *job = d; + if (job->stream.proc.in.closed) { // If the backing stream was closed abruptly, there may be write events // ahead of the terminal close event. Just ignore the writes. ILOG("write failed: stream is closed"); return; } WBuffer *wbuf = wstream_new_buffer(xmemdup(buf, size), size, 1, xfree); - wstream_write(&job->in, wbuf); + wstream_write(&job->stream.proc.in, wbuf); } static void term_resize(uint16_t width, uint16_t height, void *d) { - TerminalJobData *data = d; - pty_process_resize(&data->proc.pty, width, height); + Channel *data = d; + pty_process_resize(&data->stream.pty, width, height); } static inline void term_delayed_free(void **argv) { - TerminalJobData *j = argv[0]; - if (j->in.pending_reqs || j->out.pending_reqs || j->err.pending_reqs) { + Channel *j = argv[0]; + if (j->stream.proc.in.pending_reqs || j->stream.proc.out.pending_reqs) { multiqueue_put(j->events, term_delayed_free, 1, j); return; } terminal_destroy(j->term); - term_job_data_decref(j); + channel_decref(j); } static void term_close(void *d) { - TerminalJobData *data = d; - if (!data->exited) { - data->exited = true; - process_stop((Process *)&data->proc); + Channel *data = d; + if (!data->stream.proc.exited) { + data->stream.proc.exited = true; + process_stop((Process *)&data->stream.proc); } multiqueue_put(data->events, term_delayed_free, 1, data); } -static void term_job_data_decref(TerminalJobData *data) -{ - if (!(--data->refcount)) { - free_term_job_data(data); - } -} - -static void on_job_event(JobEvent *ev) +static void on_job_event(ChannelEvent *ev) { if (!ev->callback) { return; @@ -22704,15 +22621,24 @@ static void on_job_event(JobEvent *ev) tv_clear(&rettv); } -static TerminalJobData *find_job(uint64_t id) +static Channel *find_job(uint64_t id, bool show_error) { - TerminalJobData *data = pmap_get(uint64_t)(jobs, id); - if (!data || data->stopped) { + Channel *data = find_channel(id); + if (!data || data->streamtype != kChannelStreamProc + || process_is_stopped(&data->stream.proc)) { + if (show_error) { + if (data && data->streamtype != kChannelStreamProc) { + EMSG(_(e_invchanjob)); + } else { + EMSG(_(e_invchan)); + } + } return NULL; } return data; } + static void script_host_eval(char *name, typval_T *argvars, typval_T *rettv) { if (check_restricted() || check_secure()) { diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 262ea922ef..99382d2a24 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -847,6 +847,30 @@ bool tv_callback_equal(const Callback *const cb1, const Callback *const cb2) return false; } +/// Unref/free callback +void callback_free(Callback *const callback) + FUNC_ATTR_NONNULL_ALL +{ + switch (callback->type) { + case kCallbackFuncref: { + func_unref(callback->data.funcref); + xfree(callback->data.funcref); + break; + } + case kCallbackPartial: { + partial_unref(callback->data.partial); + break; + } + case kCallbackNone: { + break; + } + default: { + abort(); + } + } + callback->type = kCallbackNone; +} + /// Remove watcher from a dictionary /// /// @param dict Dictionary to remove watcher from. diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_process.c index 758b35796e..c101cb1bb9 100644 --- a/src/nvim/event/libuv_process.c +++ b/src/nvim/event/libuv_process.c @@ -46,22 +46,22 @@ int libuv_process_spawn(LibuvProcess *uvproc) uvproc->uvstdio[2].flags = UV_IGNORE; uvproc->uv.data = proc; - if (proc->in) { + if (!proc->in.closed) { uvproc->uvstdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; uvproc->uvstdio[0].data.stream = STRUCT_CAST(uv_stream_t, - &proc->in->uv.pipe); + &proc->in.uv.pipe); } - if (proc->out) { + if (!proc->out.closed) { uvproc->uvstdio[1].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; uvproc->uvstdio[1].data.stream = STRUCT_CAST(uv_stream_t, - &proc->out->uv.pipe); + &proc->out.uv.pipe); } - if (proc->err) { + if (!proc->err.closed) { uvproc->uvstdio[2].flags = UV_CREATE_PIPE | UV_WRITABLE_PIPE; uvproc->uvstdio[2].data.stream = STRUCT_CAST(uv_stream_t, - &proc->err->uv.pipe); + &proc->err.uv.pipe); } int status; diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index 41e793500a..1bbe4d9cad 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -27,26 +27,33 @@ #define CLOSE_PROC_STREAM(proc, stream) \ do { \ - if (proc->stream && !proc->stream->closed) { \ - stream_close(proc->stream, NULL, NULL); \ + if (!proc->stream.closed) { \ + stream_close(&proc->stream, NULL, NULL); \ } \ } while (0) static bool process_is_tearing_down = false; /// @returns zero on success, or negative error code -int process_spawn(Process *proc) FUNC_ATTR_NONNULL_ALL +int process_spawn(Process *proc, bool in, bool out, bool err) + FUNC_ATTR_NONNULL_ALL { - if (proc->in) { - uv_pipe_init(&proc->loop->uv, &proc->in->uv.pipe, 0); + if (in) { + uv_pipe_init(&proc->loop->uv, &proc->in.uv.pipe, 0); + } else { + proc->in.closed = true; } - if (proc->out) { - uv_pipe_init(&proc->loop->uv, &proc->out->uv.pipe, 0); + if (out) { + uv_pipe_init(&proc->loop->uv, &proc->out.uv.pipe, 0); + } else { + proc->out.closed = true; } - if (proc->err) { - uv_pipe_init(&proc->loop->uv, &proc->err->uv.pipe, 0); + if (err) { + uv_pipe_init(&proc->loop->uv, &proc->err.uv.pipe, 0); + } else { + proc->err.closed = true; } int status; @@ -62,14 +69,14 @@ int process_spawn(Process *proc) FUNC_ATTR_NONNULL_ALL } if (status) { - if (proc->in) { - uv_close((uv_handle_t *)&proc->in->uv.pipe, NULL); + if (in) { + uv_close((uv_handle_t *)&proc->in.uv.pipe, NULL); } - if (proc->out) { - uv_close((uv_handle_t *)&proc->out->uv.pipe, NULL); + if (out) { + uv_close((uv_handle_t *)&proc->out.uv.pipe, NULL); } - if (proc->err) { - uv_close((uv_handle_t *)&proc->err->uv.pipe, NULL); + if (err) { + uv_close((uv_handle_t *)&proc->err.uv.pipe, NULL); } if (proc->type == kProcessTypeUv) { @@ -82,30 +89,30 @@ int process_spawn(Process *proc) FUNC_ATTR_NONNULL_ALL return status; } - if (proc->in) { - stream_init(NULL, proc->in, -1, - STRUCT_CAST(uv_stream_t, &proc->in->uv.pipe)); - proc->in->events = proc->events; - proc->in->internal_data = proc; - proc->in->internal_close_cb = on_process_stream_close; + if (in) { + stream_init(NULL, &proc->in, -1, + STRUCT_CAST(uv_stream_t, &proc->in.uv.pipe)); + proc->in.events = proc->events; + proc->in.internal_data = proc; + proc->in.internal_close_cb = on_process_stream_close; proc->refcount++; } - if (proc->out) { - stream_init(NULL, proc->out, -1, - STRUCT_CAST(uv_stream_t, &proc->out->uv.pipe)); - proc->out->events = proc->events; - proc->out->internal_data = proc; - proc->out->internal_close_cb = on_process_stream_close; + if (out) { + stream_init(NULL, &proc->out, -1, + STRUCT_CAST(uv_stream_t, &proc->out.uv.pipe)); + proc->out.events = proc->events; + proc->out.internal_data = proc; + proc->out.internal_close_cb = on_process_stream_close; proc->refcount++; } - if (proc->err) { - stream_init(NULL, proc->err, -1, - STRUCT_CAST(uv_stream_t, &proc->err->uv.pipe)); - proc->err->events = proc->events; - proc->err->internal_data = proc; - proc->err->internal_close_cb = on_process_stream_close; + if (err) { + stream_init(NULL, &proc->err, -1, + STRUCT_CAST(uv_stream_t, &proc->err.uv.pipe)); + proc->err.events = proc->events; + proc->err.internal_data = proc; + proc->err.internal_close_cb = on_process_stream_close; proc->refcount++; } @@ -395,8 +402,8 @@ static void process_close_handles(void **argv) { Process *proc = argv[0]; - flush_stream(proc, proc->out); - flush_stream(proc, proc->err); + flush_stream(proc, &proc->out); + flush_stream(proc, &proc->err); process_close_streams(proc); process_close(proc); diff --git a/src/nvim/event/process.h b/src/nvim/event/process.h index 5c00e8e7ec..0897563c83 100644 --- a/src/nvim/event/process.h +++ b/src/nvim/event/process.h @@ -23,13 +23,15 @@ struct process { uint64_t stopped_time; const char *cwd; char **argv; - Stream *in, *out, *err; + Stream in, out, err; process_exit_cb cb; internal_process_cb internal_exit_cb, internal_close_cb; + bool exited; // TODO: redundant bool closed, detach; MultiQueue *events; }; + static inline Process process_init(Loop *loop, ProcessType type, void *data) { return (Process) { @@ -43,9 +45,9 @@ static inline Process process_init(Loop *loop, ProcessType type, void *data) .stopped_time = 0, .cwd = NULL, .argv = NULL, - .in = NULL, - .out = NULL, - .err = NULL, + .in = { .closed = false }, + .out = { .closed = false }, + .err = { .closed = false }, .cb = NULL, .closed = false, .internal_close_cb = NULL, @@ -54,6 +56,11 @@ static inline Process process_init(Loop *loop, ProcessType type, void *data) }; } +static inline bool process_is_stopped(Process *proc) +{ + return proc->stopped_time != 0; +} + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "event/process.h.generated.h" #endif diff --git a/src/nvim/event/stream.h b/src/nvim/event/stream.h index d27497e4a4..70a708ff4d 100644 --- a/src/nvim/event/stream.h +++ b/src/nvim/event/stream.h @@ -33,6 +33,7 @@ typedef void (*stream_write_cb)(Stream *stream, void *data, int status); typedef void (*stream_close_cb)(Stream *stream, void *data); struct stream { + bool closed; union { uv_pipe_t pipe; uv_tcp_t tcp; @@ -52,7 +53,6 @@ struct stream { size_t maxmem; size_t pending_reqs; size_t num_bytes; - bool closed; MultiQueue *events; }; diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 1ff0f7eb89..c639dbcf83 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1074,11 +1074,12 @@ EXTERN char_u e_invexpr2[] INIT(= N_("E15: Invalid expression: %s")); EXTERN char_u e_invrange[] INIT(= N_("E16: Invalid range")); EXTERN char_u e_invcmd[] INIT(= N_("E476: Invalid command")); EXTERN char_u e_isadir2[] INIT(= N_("E17: \"%s\" is a directory")); -EXTERN char_u e_invjob[] INIT(= N_("E900: Invalid job id")); +EXTERN char_u e_invchan[] INIT(= N_("E900: Invalid channel id")); +EXTERN char_u e_invchanjob[] INIT(= N_("E900: Invalid channel id: not a job")); EXTERN char_u e_jobtblfull[] INIT(= N_("E901: Job table is full")); EXTERN char_u e_jobspawn[] INIT(= N_( - "E903: Process failed to start: %s: \"%s\"")); -EXTERN char_u e_jobnotpty[] INIT(= N_("E904: Job is not connected to a pty")); + "E903: Process failed to start: %s: \"%s\"")); +EXTERN char_u e_channotpty[] INIT(= N_("E904: channel is not a pty")); EXTERN char_u e_libcall[] INIT(= N_("E364: Library call failed for \"%s()\"")); EXTERN char_u e_mkdir[] INIT(= N_("E739: Cannot create directory %s: %s")); EXTERN char_u e_markinval[] INIT(= N_("E19: Mark has invalid line number")); diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 18f6334780..42b1f63830 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -11,6 +11,7 @@ #include "nvim/api/private/helpers.h" #include "nvim/api/vim.h" #include "nvim/api/ui.h" +#include "nvim/channel.h" #include "nvim/msgpack_rpc/channel.h" #include "nvim/msgpack_rpc/server.h" #include "nvim/event/loop.h" @@ -40,47 +41,6 @@ #define log_server_msg(...) #endif -typedef enum { - kChannelTypeSocket, - kChannelTypeProc, - kChannelTypeStdio, - kChannelTypeInternal -} ChannelType; - -typedef struct { - uint64_t request_id; - bool returned, errored; - Object result; -} ChannelCallFrame; - -typedef struct { - uint64_t id; - size_t refcount; - PMap(cstr_t) *subscribed_events; - bool closed; - ChannelType type; - msgpack_unpacker *unpacker; - union { - Stream stream; // bidirectional (socket) - Process *proc; - struct { - Stream in; - Stream out; - } std; - } data; - uint64_t next_request_id; - kvec_t(ChannelCallFrame *) call_stack; - MultiQueue *events; -} Channel; - -typedef struct { - Channel *channel; - MsgpackRpcRequestHandler handler; - Array args; - uint64_t request_id; -} RequestEvent; - -static PMap(uint64_t) *channels = NULL; static PMap(cstr_t) *event_strings = NULL; static msgpack_sbuffer out_buffer; @@ -88,50 +48,32 @@ static msgpack_sbuffer out_buffer; # include "msgpack_rpc/channel.c.generated.h" #endif -/// Initializes the module -void channel_init(void) +void rpc_init(void) { ch_before_blocking_events = multiqueue_new_child(main_loop.events); - channels = pmap_new(uint64_t)(); event_strings = pmap_new(cstr_t)(); msgpack_sbuffer_init(&out_buffer); - remote_ui_init(); } -/// Teardown the module -void channel_teardown(void) -{ - if (!channels) { - return; - } - - Channel *channel; - map_foreach_value(channels, channel, { - close_channel(channel); - }); -} - -/// Creates an API channel by starting a process and connecting to its -/// stdin/stdout. stderr is handled by the job infrastructure. -/// -/// @param argv The argument vector for the process. [consumed] -/// @return The channel id (> 0), on success. -/// 0, on error. -uint64_t channel_from_process(Process *proc, uint64_t id) +void rpc_start(Channel *channel) { - Channel *channel = register_channel(kChannelTypeProc, id, proc->events); - incref(channel); // process channels are only closed by the exit_cb - channel->data.proc = proc; + channel->is_rpc = true; + RpcState *rpc = &channel->rpc; + rpc->closed = false; + rpc->unpacker = msgpack_unpacker_new(MSGPACK_UNPACKER_INIT_BUFFER_SIZE); + rpc->subscribed_events = pmap_new(cstr_t)(); + rpc->next_request_id = 1; + kv_init(rpc->call_stack); - wstream_init(proc->in, 0); - rstream_init(proc->out, 0); - rstream_start(proc->out, receive_msgpack, channel); + Stream *in = channel_instream(channel); + Stream *out = channel_outstream(channel); - DLOG("ch %" PRIu64 " in-stream=%p out-stream=%p", channel->id, proc->in, - proc->out); + DLOG("rpc ch %" PRIu64 " in-stream=%p out-stream=%p", channel->id, in, out); - return channel->id; + wstream_init(in, 0); + rstream_init(out, CHANNEL_BUFFER_SIZE); + rstream_start(out, receive_msgpack, channel); } /// Creates an API channel from a tcp/pipe socket connection @@ -139,19 +81,15 @@ uint64_t channel_from_process(Process *proc, uint64_t id) /// @param watcher The SocketWatcher ready to accept the connection void channel_from_connection(SocketWatcher *watcher) { - Channel *channel = register_channel(kChannelTypeSocket, 0, NULL); - socket_watcher_accept(watcher, &channel->data.stream); - incref(channel); // close channel only after the stream is closed - channel->data.stream.internal_close_cb = close_cb; - channel->data.stream.internal_data = channel; - wstream_init(&channel->data.stream, 0); - rstream_init(&channel->data.stream, CHANNEL_BUFFER_SIZE); - rstream_start(&channel->data.stream, receive_msgpack, channel); - - DLOG("ch %" PRIu64 " in/out-stream=%p", channel->id, - &channel->data.stream); + Channel *channel = channel_alloc(kChannelStreamSocket); + socket_watcher_accept(watcher, &channel->stream.socket); + channel_incref(channel); // close channel only after the stream is closed + channel->stream.socket.internal_close_cb = close_cb; + channel->stream.socket.internal_data = channel; + rpc_start(channel); } +/// TODO: move to eval.c, also support bytes uint64_t channel_connect(bool tcp, const char *address, int timeout, const char **error) { @@ -165,34 +103,40 @@ uint64_t channel_connect(bool tcp, const char *address, xfree(path); } - Channel *channel = register_channel(kChannelTypeSocket, 0, NULL); - if (!socket_connect(&main_loop, &channel->data.stream, + Channel *channel = channel_alloc(kChannelStreamSocket); + if (!socket_connect(&main_loop, &channel->stream.socket, tcp, address, timeout, error)) { - decref(channel); + channel_decref(channel); return 0; } - incref(channel); // close channel only after the stream is closed - channel->data.stream.internal_close_cb = close_cb; - channel->data.stream.internal_data = channel; - wstream_init(&channel->data.stream, 0); - rstream_init(&channel->data.stream, CHANNEL_BUFFER_SIZE); - rstream_start(&channel->data.stream, receive_msgpack, channel); + channel_incref(channel); // close channel only after the stream is closed + channel->stream.socket.internal_close_cb = close_cb; + channel->stream.socket.internal_data = channel; + rpc_start(channel); return channel->id; } +static Channel *find_rpc_channel(uint64_t id) +{ + Channel *chan = find_channel(id); + if (!chan || !chan->is_rpc || chan->rpc.closed) { + return NULL; + } + return chan; +} + /// Publishes an event to a channel. /// /// @param id Channel id. 0 means "broadcast to all subscribed channels" /// @param name Event name (application-defined) /// @param args Array of event arguments /// @return True if the event was sent successfully, false otherwise. -bool channel_send_event(uint64_t id, const char *name, Array args) +bool rpc_send_event(uint64_t id, const char *name, Array args) { Channel *channel = NULL; - if (id && (!(channel = pmap_get(uint64_t)(channels, id)) - || channel->closed)) { + if (id && (!(channel = find_rpc_channel(id)))) { api_free_array(args); return false; } @@ -213,29 +157,30 @@ bool channel_send_event(uint64_t id, const char *name, Array args) /// @param args Array with method arguments /// @param[out] error True if the return value is an error /// @return Whatever the remote method returned -Object channel_send_call(uint64_t id, - const char *method_name, - Array args, - Error *err) +Object rpc_send_call(uint64_t id, + const char *method_name, + Array args, + Error *err) { Channel *channel = NULL; - if (!(channel = pmap_get(uint64_t)(channels, id)) || channel->closed) { + if (!(channel = find_rpc_channel(id))) { api_set_error(err, kErrorTypeException, "Invalid channel: %" PRIu64, id); api_free_array(args); return NIL; } - incref(channel); - uint64_t request_id = channel->next_request_id++; + channel_incref(channel); + RpcState *rpc = &channel->rpc; + uint64_t request_id = rpc->next_request_id++; // Send the msgpack-rpc request send_request(channel, request_id, method_name, args); // Push the frame ChannelCallFrame frame = { request_id, false, false, NIL }; - kv_push(channel->call_stack, &frame); + kv_push(rpc->call_stack, &frame); LOOP_PROCESS_EVENTS_UNTIL(&main_loop, channel->events, -1, frame.returned); - (void)kv_pop(channel->call_stack); + (void)kv_pop(rpc->call_stack); if (frame.errored) { if (frame.result.type == kObjectTypeString) { @@ -260,7 +205,7 @@ Object channel_send_call(uint64_t id, api_free_object(frame.result); } - decref(channel); + channel_decref(channel); return frame.errored ? NIL : frame.result; } @@ -269,11 +214,11 @@ Object channel_send_call(uint64_t id, /// /// @param id The channel id /// @param event The event type string -void channel_subscribe(uint64_t id, char *event) +void rpc_subscribe(uint64_t id, char *event) { Channel *channel; - if (!(channel = pmap_get(uint64_t)(channels, id)) || channel->closed) { + if (!(channel = find_rpc_channel(id))) { abort(); } @@ -284,18 +229,18 @@ void channel_subscribe(uint64_t id, char *event) pmap_put(cstr_t)(event_strings, event_string, event_string); } - pmap_put(cstr_t)(channel->subscribed_events, event_string, event_string); + pmap_put(cstr_t)(channel->rpc.subscribed_events, event_string, event_string); } /// Unsubscribes to event broadcasts /// /// @param id The channel id /// @param event The event type string -void channel_unsubscribe(uint64_t id, char *event) +void rpc_unsubscribe(uint64_t id, char *event) { Channel *channel; - if (!(channel = pmap_get(uint64_t)(channels, id)) || channel->closed) { + if (!(channel = find_rpc_channel(id))) { abort(); } @@ -310,7 +255,7 @@ bool channel_close(uint64_t id) { Channel *channel; - if (!(channel = pmap_get(uint64_t)(channels, id)) || channel->closed) { + if (!(channel = find_rpc_channel(id))) { return false; } @@ -322,24 +267,22 @@ bool channel_close(uint64_t id) /// Neovim void channel_from_stdio(void) { - Channel *channel = register_channel(kChannelTypeStdio, 0, NULL); - incref(channel); // stdio channels are only closed on exit + Channel *channel = channel_alloc(kChannelStreamStdio); + channel_incref(channel); // stdio channels are only closed on exit // read stream - rstream_init_fd(&main_loop, &channel->data.std.in, 0, CHANNEL_BUFFER_SIZE); - rstream_start(&channel->data.std.in, receive_msgpack, channel); - // write stream - wstream_init_fd(&main_loop, &channel->data.std.out, 1, 0); + rstream_init_fd(&main_loop, &channel->stream.stdio.in, 0, CHANNEL_BUFFER_SIZE); + wstream_init_fd(&main_loop, &channel->stream.stdio.out, 1, 0); - DLOG("ch %" PRIu64 " in-stream=%p out-stream=%p", channel->id, - &channel->data.std.in, &channel->data.std.out); + rpc_start(channel); } /// Creates a loopback channel. This is used to avoid deadlock /// when an instance connects to its own named pipe. uint64_t channel_create_internal(void) { - Channel *channel = register_channel(kChannelTypeInternal, 0, NULL); - incref(channel); // internal channel lives until process exit + Channel *channel = channel_alloc(kChannelStreamInternal); + channel_incref(channel); // internal channel lives until process exit + rpc_start(channel); return channel->id; } @@ -347,8 +290,8 @@ void channel_process_exit(uint64_t id, int status) { Channel *channel = pmap_get(uint64_t)(channels, id); - channel->closed = true; - decref(channel); + // channel_decref(channel); remove?? + channel->rpc.closed = true; } // rstream.c:read_event() invokes this as stream->read_cb(). @@ -356,7 +299,7 @@ static void receive_msgpack(Stream *stream, RBuffer *rbuf, size_t c, void *data, bool eof) { Channel *channel = data; - incref(channel); + channel_incref(channel); if (eof) { close_channel(channel); @@ -367,30 +310,19 @@ static void receive_msgpack(Stream *stream, RBuffer *rbuf, size_t c, goto end; } - if ((chan_wstream(channel) != NULL && chan_wstream(channel)->closed) - || (chan_rstream(channel) != NULL && chan_rstream(channel)->closed)) { - char buf[256]; - snprintf(buf, sizeof(buf), - "ch %" PRIu64 ": stream closed unexpectedly. " - "closing channel", - channel->id); - call_set_error(channel, buf, WARN_LOG_LEVEL); - goto end; - } - size_t count = rbuffer_size(rbuf); - DLOG("ch %" PRIu64 ": parsing %u bytes from msgpack Stream: %p", + DLOG("ch %" PRIu64 ": parsing %zu bytes from msgpack Stream: %p", channel->id, count, stream); // Feed the unpacker with data - msgpack_unpacker_reserve_buffer(channel->unpacker, count); - rbuffer_read(rbuf, msgpack_unpacker_buffer(channel->unpacker), count); - msgpack_unpacker_buffer_consumed(channel->unpacker, count); + msgpack_unpacker_reserve_buffer(channel->rpc.unpacker, count); + rbuffer_read(rbuf, msgpack_unpacker_buffer(channel->rpc.unpacker), count); + msgpack_unpacker_buffer_consumed(channel->rpc.unpacker, count); parse_msgpack(channel); end: - decref(channel); + channel_decref(channel); } static void parse_msgpack(Channel *channel) @@ -400,8 +332,8 @@ static void parse_msgpack(Channel *channel) msgpack_unpack_return result; // Deserialize everything we can. - while ((result = msgpack_unpacker_next(channel->unpacker, &unpacked)) == - MSGPACK_UNPACK_SUCCESS) { + while ((result = msgpack_unpacker_next(channel->rpc.unpacker, &unpacked)) == + MSGPACK_UNPACK_SUCCESS) { bool is_response = is_rpc_response(&unpacked.data); log_client_msg(channel->id, !is_response, unpacked.data); @@ -427,7 +359,7 @@ static void parse_msgpack(Channel *channel) if (result == MSGPACK_UNPACK_NOMEM_ERROR) { mch_errmsg(e_outofmem); mch_errmsg("\n"); - decref(channel); + channel_decref(channel); preserve_exit(); } @@ -492,7 +424,7 @@ static void handle_request(Channel *channel, msgpack_object *request) evdata->handler = handler; evdata->args = args; evdata->request_id = request_id; - incref(channel); + channel_incref(channel); if (handler.async) { bool is_get_mode = handler.fn == handle_nvim_get_mode; @@ -530,66 +462,30 @@ static void on_request_event(void **argv) api_free_object(result); } api_free_array(args); - decref(channel); + channel_decref(channel); xfree(e); api_clear_error(&error); } -/// Returns the Stream that a Channel writes to. -static Stream *chan_wstream(Channel *chan) -{ - switch (chan->type) { - case kChannelTypeSocket: - return &chan->data.stream; - case kChannelTypeProc: - return chan->data.proc->in; - case kChannelTypeStdio: - return &chan->data.std.out; - case kChannelTypeInternal: - return NULL; - } - abort(); -} - -/// Returns the Stream that a Channel reads from. -static Stream *chan_rstream(Channel *chan) -{ - switch (chan->type) { - case kChannelTypeSocket: - return &chan->data.stream; - case kChannelTypeProc: - return chan->data.proc->out; - case kChannelTypeStdio: - return &chan->data.std.in; - case kChannelTypeInternal: - return NULL; - } - abort(); -} - - static bool channel_write(Channel *channel, WBuffer *buffer) { - bool success = false; + bool success; - if (channel->closed) { + if (channel->rpc.closed) { wstream_release_wbuffer(buffer); return false; } - switch (channel->type) { - case kChannelTypeSocket: - case kChannelTypeProc: - case kChannelTypeStdio: - success = wstream_write(chan_wstream(channel), buffer); - break; - case kChannelTypeInternal: - incref(channel); - CREATE_EVENT(channel->events, internal_read_event, 2, channel, buffer); - success = true; - break; + if (channel->streamtype == kChannelStreamInternal) { + channel_incref(channel); + CREATE_EVENT(channel->events, internal_read_event, 2, channel, buffer); + success = true; + } else { + Stream *in = channel_instream(channel); + success = wstream_write(in, buffer); } + if (!success) { // If the write failed for any reason, close the channel char buf[256]; @@ -609,14 +505,14 @@ static void internal_read_event(void **argv) Channel *channel = argv[0]; WBuffer *buffer = argv[1]; - msgpack_unpacker_reserve_buffer(channel->unpacker, buffer->size); - memcpy(msgpack_unpacker_buffer(channel->unpacker), + msgpack_unpacker_reserve_buffer(channel->rpc.unpacker, buffer->size); + memcpy(msgpack_unpacker_buffer(channel->rpc.unpacker), buffer->data, buffer->size); - msgpack_unpacker_buffer_consumed(channel->unpacker, buffer->size); + msgpack_unpacker_buffer_consumed(channel->rpc.unpacker, buffer->size); parse_msgpack(channel); - decref(channel); + channel_decref(channel); wstream_release_wbuffer(buffer); } @@ -665,7 +561,8 @@ static void broadcast_event(const char *name, Array args) Channel *channel; map_foreach_value(channels, channel, { - if (pmap_has(cstr_t)(channel->subscribed_events, name)) { + if (channel->is_rpc + && pmap_has(cstr_t)(channel->rpc.subscribed_events, name)) { kv_push(subscribed, channel); } }); @@ -695,10 +592,11 @@ end: static void unsubscribe(Channel *channel, char *event) { char *event_string = pmap_get(cstr_t)(event_strings, event); - pmap_del(cstr_t)(channel->subscribed_events, event_string); + pmap_del(cstr_t)(channel->rpc.subscribed_events, event_string); map_foreach_value(channels, channel, { - if (pmap_has(cstr_t)(channel->subscribed_events, event_string)) { + if (channel->is_rpc + && pmap_has(cstr_t)(channel->rpc.subscribed_events, event_string)) { return; } }); @@ -709,86 +607,65 @@ static void unsubscribe(Channel *channel, char *event) } /// Close the channel streams/process and free the channel resources. +/// TODO: move to channel.h static void close_channel(Channel *channel) { - if (channel->closed) { + if (channel->rpc.closed) { return; } - channel->closed = true; + channel->rpc.closed = true; - switch (channel->type) { - case kChannelTypeSocket: - stream_close(&channel->data.stream, NULL, NULL); + switch (channel->streamtype) { + case kChannelStreamSocket: + stream_close(&channel->stream.socket, NULL, NULL); break; - case kChannelTypeProc: + case kChannelStreamProc: // Only close the rpc channel part, // there could be an error message on the stderr stream - process_close_in(channel->data.proc); - process_close_out(channel->data.proc); + process_close_in(&channel->stream.proc); + process_close_out(&channel->stream.proc); break; - case kChannelTypeStdio: - stream_close(&channel->data.std.in, NULL, NULL); - stream_close(&channel->data.std.out, NULL, NULL); + case kChannelStreamStdio: + stream_close(&channel->stream.stdio.in, NULL, NULL); + stream_close(&channel->stream.stdio.out, NULL, NULL); multiqueue_put(main_loop.fast_events, exit_event, 1, channel); return; - case kChannelTypeInternal: + case kChannelStreamInternal: // nothing to free. break; } - decref(channel); + channel_decref(channel); } static void exit_event(void **argv) { - decref(argv[0]); + channel_decref(argv[0]); if (!exiting) { mch_exit(0); } } -static void free_channel(Channel *channel) +void rpc_free(Channel *channel) { remote_ui_disconnect(channel->id); - pmap_del(uint64_t)(channels, channel->id); - msgpack_unpacker_free(channel->unpacker); + msgpack_unpacker_free(channel->rpc.unpacker); // Unsubscribe from all events char *event_string; - map_foreach_value(channel->subscribed_events, event_string, { + map_foreach_value(channel->rpc.subscribed_events, event_string, { unsubscribe(channel, event_string); }); - pmap_free(cstr_t)(channel->subscribed_events); - kv_destroy(channel->call_stack); - if (channel->type != kChannelTypeProc) { - multiqueue_free(channel->events); - } - xfree(channel); + pmap_free(cstr_t)(channel->rpc.subscribed_events); + kv_destroy(channel->rpc.call_stack); } static void close_cb(Stream *stream, void *data) { - decref(data); -} - -static Channel *register_channel(ChannelType type, uint64_t id, - MultiQueue *events) -{ - Channel *rv = xmalloc(sizeof(Channel)); - rv->events = events ? events : multiqueue_new_child(main_loop.events); - rv->type = type; - rv->refcount = 1; - rv->closed = false; - rv->unpacker = msgpack_unpacker_new(MSGPACK_UNPACKER_INIT_BUFFER_SIZE); - rv->id = id > 0 ? id : next_chan_id++; - rv->subscribed_events = pmap_new(cstr_t)(); - rv->next_request_id = 1; - kv_init(rv->call_stack); - pmap_put(uint64_t)(channels, rv->id, rv); - return rv; + channel_decref(data); } static bool is_rpc_response(msgpack_object *obj) @@ -803,15 +680,18 @@ static bool is_rpc_response(msgpack_object *obj) static bool is_valid_rpc_response(msgpack_object *obj, Channel *channel) { uint64_t response_id = obj->via.array.ptr[1].via.u64; + if (kv_size(channel->rpc.call_stack) == 0) { + return false; + } + // Must be equal to the frame at the stack's bottom - return kv_size(channel->call_stack) && response_id - == kv_A(channel->call_stack, kv_size(channel->call_stack) - 1)->request_id; + ChannelCallFrame *frame = kv_last(channel->rpc.call_stack); + return response_id == frame->request_id; } static void complete_call(msgpack_object *obj, Channel *channel) { - ChannelCallFrame *frame = kv_A(channel->call_stack, - kv_size(channel->call_stack) - 1); + ChannelCallFrame *frame = kv_last(channel->rpc.call_stack); frame->returned = true; frame->errored = obj->via.array.ptr[2].type != MSGPACK_OBJECT_NIL; @@ -825,8 +705,8 @@ static void complete_call(msgpack_object *obj, Channel *channel) static void call_set_error(Channel *channel, char *msg, int loglevel) { LOG(loglevel, "RPC: %s", msg); - for (size_t i = 0; i < kv_size(channel->call_stack); i++) { - ChannelCallFrame *frame = kv_A(channel->call_stack, i); + for (size_t i = 0; i < kv_size(channel->rpc.call_stack); i++) { + ChannelCallFrame *frame = kv_A(channel->rpc.call_stack, i); frame->returned = true; frame->errored = true; api_free_object(frame->result); @@ -875,18 +755,6 @@ static WBuffer *serialize_response(uint64_t channel_id, return rv; } -static void incref(Channel *channel) -{ - channel->refcount++; -} - -static void decref(Channel *channel) -{ - if (!(--channel->refcount)) { - free_channel(channel); - } -} - #if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL #define REQ "[request] " #define RES "[response] " diff --git a/src/nvim/msgpack_rpc/channel.h b/src/nvim/msgpack_rpc/channel.h index f8fe6f129b..9ff5abdc5f 100644 --- a/src/nvim/msgpack_rpc/channel.h +++ b/src/nvim/msgpack_rpc/channel.h @@ -8,6 +8,7 @@ #include "nvim/event/socket.h" #include "nvim/event/process.h" #include "nvim/vim.h" +#include "nvim/channel.h" #define METHOD_MAXLEN 512 @@ -16,6 +17,7 @@ /// of os_inchar(), so they are processed "just-in-time". MultiQueue *ch_before_blocking_events; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "msgpack_rpc/channel.h.generated.h" #endif diff --git a/src/nvim/msgpack_rpc/channel_defs.h b/src/nvim/msgpack_rpc/channel_defs.h new file mode 100644 index 0000000000..6d8362e8b7 --- /dev/null +++ b/src/nvim/msgpack_rpc/channel_defs.h @@ -0,0 +1,36 @@ +#ifndef NVIM_MSGPACK_RPC_CHANNEL_DEFS_H +#define NVIM_MSGPACK_RPC_CHANNEL_DEFS_H + +#include +#include +#include + +#include "nvim/api/private/defs.h" +#include "nvim/event/socket.h" +#include "nvim/event/process.h" +#include "nvim/vim.h" + +typedef struct Channel Channel; + +typedef struct { + uint64_t request_id; + bool returned, errored; + Object result; +} ChannelCallFrame; + +typedef struct { + Channel *channel; + MsgpackRpcRequestHandler handler; + Array args; + uint64_t request_id; +} RequestEvent; + +typedef struct { + PMap(cstr_t) *subscribed_events; + bool closed; + msgpack_unpacker *unpacker; + uint64_t next_request_id; + kvec_t(ChannelCallFrame *) call_stack; +} RpcState; + +#endif // NVIM_MSGPACK_RPC_CHANNEL_DEFS_H diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c index ee3ab96a83..e39f837c1a 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_process_unix.c @@ -47,7 +47,7 @@ int pty_process_spawn(PtyProcess *ptyproc) int status = 0; // zero or negative error code (libuv convention) Process *proc = (Process *)ptyproc; - assert(!proc->err); + assert(proc->err.closed); uv_signal_start(&proc->loop->children_watcher, chld_handler, SIGCHLD); ptyproc->winsize = (struct winsize){ ptyproc->height, ptyproc->width, 0, 0 }; uv_disable_stdio_inheritance(); @@ -83,12 +83,12 @@ int pty_process_spawn(PtyProcess *ptyproc) goto error; } - if (proc->in - && (status = set_duplicating_descriptor(master, &proc->in->uv.pipe))) { + if (!proc->in.closed + && (status = set_duplicating_descriptor(master, &proc->in.uv.pipe))) { goto error; } - if (proc->out - && (status = set_duplicating_descriptor(master, &proc->out->uv.pipe))) { + if (!proc->out.closed + && (status = set_duplicating_descriptor(master, &proc->out.uv.pipe))) { goto error; } diff --git a/src/nvim/os/pty_process_win.c b/src/nvim/os/pty_process_win.c index ef8a699c56..3c4839a076 100644 --- a/src/nvim/os/pty_process_win.c +++ b/src/nvim/os/pty_process_win.c @@ -44,7 +44,7 @@ int pty_process_spawn(PtyProcess *ptyproc) wchar_t *cwd = NULL; const char *emsg = NULL; - assert(!proc->err); + assert(proc->err.closed); cfg = winpty_config_new(WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION, &err); if (cfg == NULL) { @@ -71,20 +71,20 @@ int pty_process_spawn(PtyProcess *ptyproc) goto cleanup; } - if (proc->in != NULL) { + if (!proc->in.closed) { in_req = xmalloc(sizeof(uv_connect_t)); uv_pipe_connect( in_req, - &proc->in->uv.pipe, + &proc->in.uv.pipe, in_name, pty_process_connect_cb); } - if (proc->out != NULL) { + if (!proc->out.closed) { out_req = xmalloc(sizeof(uv_connect_t)); uv_pipe_connect( out_req, - &proc->out->uv.pipe, + &proc->out.uv.pipe, out_name, pty_process_connect_cb); } @@ -228,7 +228,7 @@ static void wait_eof_timer_cb(uv_timer_t *wait_eof_timer) PtyProcess *ptyproc = wait_eof_timer->data; Process *proc = (Process *)ptyproc; - if (!proc->out || !uv_is_readable(proc->out->uvstream)) { + if (proc->out.closed || !uv_is_readable(proc->out.uvstream)) { uv_timer_stop(&ptyproc->wait_eof_timer); pty_process_finish2(ptyproc); } diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index 32e9a70e57..f54fe412ba 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -207,16 +207,12 @@ static int do_os_system(char **argv, char prog[MAXPATHL]; xstrlcpy(prog, argv[0], MAXPATHL); - Stream in, out, err; LibuvProcess uvproc = libuv_process_init(&main_loop, &buf); Process *proc = &uvproc.process; MultiQueue *events = multiqueue_new_child(main_loop.events); proc->events = events; proc->argv = argv; - proc->in = input != NULL ? &in : NULL; - proc->out = &out; - proc->err = &err; - int status = process_spawn(proc); + int status = process_spawn(proc, input != NULL, true, true); if (status) { loop_poll_events(&main_loop, 0); // Failed, probably 'shell' is not executable. @@ -236,27 +232,27 @@ static int do_os_system(char **argv, // streams while there's still data in the OS buffer (due to the process // exiting before all data is read). if (input != NULL) { - proc->in->events = NULL; - wstream_init(proc->in, 0); + proc->in.events = NULL; + wstream_init(&proc->in, 0); } - proc->out->events = NULL; - rstream_init(proc->out, 0); - rstream_start(proc->out, data_cb, &buf); - proc->err->events = NULL; - rstream_init(proc->err, 0); - rstream_start(proc->err, data_cb, &buf); + proc->out.events = NULL; + rstream_init(&proc->out, 0); + rstream_start(&proc->out, data_cb, &buf); + proc->err.events = NULL; + rstream_init(&proc->err, 0); + rstream_start(&proc->err, data_cb, &buf); // write the input, if any if (input) { WBuffer *input_buffer = wstream_new_buffer((char *) input, len, 1, NULL); - if (!wstream_write(&in, input_buffer)) { + if (!wstream_write(&proc->in, input_buffer)) { // couldn't write, stop the process and tell the user about it process_stop(proc); return -1; } // close the input stream after everything is written - wstream_set_write_cb(&in, shell_write_cb, NULL); + wstream_set_write_cb(&proc->in, shell_write_cb, NULL); } // Invoke busy_start here so LOOP_PROCESS_EVENTS_UNTIL will not change the -- cgit From 1ebc96fe10fbdbec22caa26d5d52a9f095da9687 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Mon, 5 Jun 2017 08:29:10 +0200 Subject: channels: allow bytes sockets and stdio, and buffered bytes output --- src/nvim/channel.c | 417 ++++++++++++++++++++++++++++++++++++++++- src/nvim/channel.h | 36 ++-- src/nvim/eval.c | 359 +++++++++-------------------------- src/nvim/eval.h | 3 + src/nvim/eval.lua | 1 + src/nvim/eval/typval.c | 11 +- src/nvim/event/process.c | 11 +- src/nvim/event/rstream.c | 28 +-- src/nvim/event/stream.h | 6 +- src/nvim/globals.h | 8 +- src/nvim/main.c | 19 +- src/nvim/msgpack_rpc/channel.c | 87 +-------- src/nvim/os/shell.c | 7 +- src/nvim/rbuffer.c | 2 +- 14 files changed, 574 insertions(+), 421 deletions(-) (limited to 'src') diff --git a/src/nvim/channel.c b/src/nvim/channel.c index e61ec9c19b..5ee4e5be09 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -3,10 +3,25 @@ #include "nvim/api/ui.h" #include "nvim/channel.h" +#include "nvim/eval.h" +#include "nvim/event/socket.h" #include "nvim/msgpack_rpc/channel.h" +#include "nvim/msgpack_rpc/server.h" +#include "nvim/os/shell.h" +#include "nvim/path.h" +#include "nvim/ascii.h" +static bool did_stdio = false; PMap(uint64_t) *channels = NULL; +typedef struct { + Channel *data; + Callback *callback; + const char *type; + list_T *received; + int status; +} ChannelEvent; + #ifdef INCLUDE_GENERATED_DECLARATIONS # include "channel.c.generated.h" #endif @@ -32,6 +47,21 @@ void channel_init(void) remote_ui_init(); } +/// Allocates a channel. +/// +/// Channel is allocated with refcount 1, which should be decreased +/// when the underlying stream closes. +static Channel *channel_alloc(ChannelStreamType type) +{ + Channel *chan = xcalloc(1, sizeof(*chan)); + chan->id = type == kChannelStreamStdio ? 1 : next_chan_id++; + chan->events = multiqueue_new_child(main_loop.events); + chan->refcount = 1; + chan->streamtype = type; + pmap_put(uint64_t)(channels, chan->id, chan); + return chan; +} + void channel_incref(Channel *channel) { channel->refcount++; @@ -44,6 +74,21 @@ void channel_decref(Channel *channel) } } +void callback_reader_free(CallbackReader *reader) +{ + callback_free(&reader->cb); + if (reader->buffered) { + ga_clear(&reader->buffer); + } +} + +void callback_reader_start(CallbackReader *reader) +{ + if (reader->buffered) { + ga_init(&reader->buffer, sizeof(char *), 1); + } +} + static void free_channel_event(void **argv) { Channel *channel = argv[0]; @@ -51,11 +96,379 @@ static void free_channel_event(void **argv) rpc_free(channel); } - callback_free(&channel->on_stdout); - callback_free(&channel->on_stderr); + callback_reader_free(&channel->on_stdout); + callback_reader_free(&channel->on_stderr); callback_free(&channel->on_exit); pmap_del(uint64_t)(channels, channel->id); multiqueue_free(channel->events); xfree(channel); } + +static void channel_destroy_early(Channel *chan) +{ + if ((chan->id != --next_chan_id)) { + abort(); + } + + if ((--chan->refcount != 0)) { + abort(); + } + + free_channel_event((void **)&chan); +} + + +static void close_cb(Stream *stream, void *data) +{ + channel_decref(data); +} + +Channel *channel_job_start(char **argv, CallbackReader on_stdout, + CallbackReader on_stderr, Callback on_exit, + bool pty, bool rpc, bool detach, const char *cwd, + uint16_t pty_width, uint16_t pty_height, + char *term_name, varnumber_T *status_out) +{ + Channel *chan = channel_alloc(kChannelStreamProc); + chan->on_stdout = on_stdout; + chan->on_stderr = on_stderr; + chan->on_exit = on_exit; + chan->is_rpc = rpc; + + if (pty) { + if (detach) { + EMSG2(_(e_invarg2), "terminal/pty job cannot be detached"); + shell_free_argv(argv); + xfree(term_name); + channel_destroy_early(chan); + *status_out = 0; + return NULL; + } + chan->stream.pty = pty_process_init(&main_loop, chan); + if (pty_width > 0) { + chan->stream.pty.width = pty_width; + } + if (pty_height > 0) { + chan->stream.pty.height = pty_height; + } + if (term_name) { + chan->stream.pty.term_name = term_name; + } + } else { + chan->stream.uv = libuv_process_init(&main_loop, chan); + } + + Process *proc = (Process *)&chan->stream.proc; + proc->argv = argv; + proc->cb = channel_process_exit_cb; + proc->events = chan->events; + proc->detach = detach; + proc->cwd = cwd; + + char *cmd = xstrdup(proc->argv[0]); + bool has_out, has_err; + if (proc->type == kProcessTypePty) { + has_out = true; + has_err = false; + } else { + has_out = chan->is_rpc || callback_reader_set(chan->on_stdout); + has_err = callback_reader_set(chan->on_stderr); + } + int status = process_spawn(proc, true, has_out, has_err); + if (has_err) { + proc->err.events = chan->events; + } + if (status) { + EMSG3(_(e_jobspawn), os_strerror(status), cmd); + xfree(cmd); + if (proc->type == kProcessTypePty) { + xfree(chan->stream.pty.term_name); + } + channel_destroy_early(chan); + *status_out = proc->status; + return NULL; + } + xfree(cmd); + + wstream_init(&proc->in, 0); + if (has_out) { + rstream_init(&proc->out, 0); + } + + if (chan->is_rpc) { + // the rpc takes over the in and out streams + rpc_start(chan); + } else { + proc->in.events = chan->events; + if (has_out) { + callback_reader_start(&chan->on_stdout); + proc->out.events = chan->events; + rstream_start(&proc->out, on_job_stdout, chan); + } + } + + if (has_err) { + callback_reader_start(&chan->on_stderr); + rstream_init(&proc->err, 0); + rstream_start(&proc->err, on_job_stderr, chan); + } + *status_out = (varnumber_T)chan->id; + return chan; +} + + +uint64_t channel_connect(bool tcp, const char *address, + bool rpc, CallbackReader on_output, + int timeout, const char **error) +{ + if (!tcp && rpc) { + char *path = fix_fname(address); + if (server_owns_pipe_address(path)) { + // avoid deadlock + xfree(path); + return channel_create_internal_rpc(); + } + xfree(path); + } + + Channel *channel = channel_alloc(kChannelStreamSocket); + if (!socket_connect(&main_loop, &channel->stream.socket, + tcp, address, timeout, error)) { + channel_destroy_early(channel); + return 0; + } + + channel_incref(channel); // close channel only after the stream is closed + channel->stream.socket.internal_close_cb = close_cb; + channel->stream.socket.internal_data = channel; + wstream_init(&channel->stream.socket, 0); + rstream_init(&channel->stream.socket, 0); + + if (rpc) { + rpc_start(channel); + } else { + channel->on_stdout = on_output; + callback_reader_start(&channel->on_stdout); + channel->stream.socket.events = channel->events; + rstream_start(&channel->stream.socket, on_socket_output, channel); + } + + return channel->id; +} + +/// Creates an RPC channel from a tcp/pipe socket connection +/// +/// @param watcher The SocketWatcher ready to accept the connection +void channel_from_connection(SocketWatcher *watcher) +{ + Channel *channel = channel_alloc(kChannelStreamSocket); + socket_watcher_accept(watcher, &channel->stream.socket); + channel_incref(channel); // close channel only after the stream is closed + channel->stream.socket.internal_close_cb = close_cb; + channel->stream.socket.internal_data = channel; + wstream_init(&channel->stream.socket, 0); + rstream_init(&channel->stream.socket, 0); + rpc_start(channel); +} + +/// Creates a loopback channel. This is used to avoid deadlock +/// when an instance connects to its own named pipe. +static uint64_t channel_create_internal_rpc(void) +{ + Channel *channel = channel_alloc(kChannelStreamInternal); + channel_incref(channel); // internal channel lives until process exit + rpc_start(channel); + return channel->id; +} + +/// Creates an API channel from stdin/stdout. This is used when embedding +/// Neovim +uint64_t channel_from_stdio(bool rpc, CallbackReader on_output, + const char **error) + FUNC_ATTR_NONNULL_ALL +{ + if (!headless_mode) { + *error = _("can only be opened in headless mode"); + return 0; + } + + if (did_stdio) { + *error = _("channel was already open"); + return 0; + } + did_stdio = true; + + Channel *channel = channel_alloc(kChannelStreamStdio); + + rstream_init_fd(&main_loop, &channel->stream.stdio.in, 0, 0); + wstream_init_fd(&main_loop, &channel->stream.stdio.out, 1, 0); + + if (rpc) { + rpc_start(channel); + } else { + channel->on_stdout = on_output; + callback_reader_start(&channel->on_stdout); + channel->stream.stdio.in.events = channel->events; + channel->stream.stdio.out.events = channel->events; + rstream_start(&channel->stream.stdio.in, on_stdio_input, channel); + } + + return channel->id; +} + +// vimscript job callbacks must be executed on Nvim main loop +static inline void process_channel_event(Channel *chan, Callback *callback, + const char *type, char *buf, + size_t count, int status) +{ + ChannelEvent event_data; + event_data.received = NULL; + if (buf) { + event_data.received = tv_list_alloc(); + char *ptr = buf; + size_t remaining = count; + size_t off = 0; + + while (off < remaining) { + // append the line + if (ptr[off] == NL) { + tv_list_append_string(event_data.received, ptr, (ssize_t)off); + size_t skip = off + 1; + ptr += skip; + remaining -= skip; + off = 0; + continue; + } + if (ptr[off] == NUL) { + // Translate NUL to NL + ptr[off] = NL; + } + off++; + } + tv_list_append_string(event_data.received, ptr, (ssize_t)off); + } else { + event_data.status = status; + } + event_data.data = chan; + event_data.callback = callback; + event_data.type = type; + on_channel_event(&event_data); +} + +void on_job_stdout(Stream *stream, RBuffer *buf, size_t count, + void *data, bool eof) +{ + Channel *chan = data; + on_channel_output(stream, chan, buf, count, eof, &chan->on_stdout, "stdout"); +} + +void on_job_stderr(Stream *stream, RBuffer *buf, size_t count, + void *data, bool eof) +{ + Channel *chan = data; + on_channel_output(stream, chan, buf, count, eof, &chan->on_stderr, "stderr"); +} + +static void on_socket_output(Stream *stream, RBuffer *buf, size_t count, + void *data, bool eof) +{ + Channel *chan = data; + on_channel_output(stream, chan, buf, count, eof, &chan->on_stdout, "data"); +} + +static void on_stdio_input(Stream *stream, RBuffer *buf, size_t count, + void *data, bool eof) +{ + Channel *chan = data; + on_channel_output(stream, chan, buf, count, eof, &chan->on_stdout, "stdin"); +} + +static void on_channel_output(Stream *stream, Channel *chan, RBuffer *buf, + size_t count, bool eof, CallbackReader *reader, + const char *type) +{ + // stub variable, to keep reading consistent with the order of events, only + // consider the count parameter. + size_t r; + char *ptr = rbuffer_read_ptr(buf, &r); + + if (eof) { + if (reader->buffered) { + process_channel_event(chan, &reader->cb, type, reader->buffer.ga_data, + (size_t)reader->buffer.ga_len, 0); + ga_clear(&reader->buffer); + } else if (callback_reader_set(*reader)) { + process_channel_event(chan, &reader->cb, type, ptr, 0, 0); + } + return; + } + + // The order here matters, the terminal must receive the data first because + // process_channel_event will modify the read buffer(convert NULs into NLs) + if (chan->term) { + terminal_receive(chan->term, ptr, count); + } + + rbuffer_consumed(buf, count); + if (reader->buffered) { + ga_concat_len(&reader->buffer, ptr, count); + } else if (callback_reader_set(*reader)) { + process_channel_event(chan, &reader->cb, type, ptr, count, 0); + } +} + +static void channel_process_exit_cb(Process *proc, int status, void *data) +{ + Channel *chan = data; + if (chan->term && !chan->stream.proc.exited) { + chan->stream.proc.exited = true; + char msg[sizeof("\r\n[Process exited ]") + NUMBUFLEN]; + snprintf(msg, sizeof msg, "\r\n[Process exited %d]", proc->status); + terminal_close(chan->term, msg); + } + if (chan->is_rpc) { + channel_process_exit(chan->id, status); + } + + if (chan->status_ptr) { + *chan->status_ptr = status; + } + + process_channel_event(chan, &chan->on_exit, "exit", NULL, 0, status); + + channel_decref(chan); +} + +static void on_channel_event(ChannelEvent *ev) +{ + if (!ev->callback) { + return; + } + + typval_T argv[4]; + + argv[0].v_type = VAR_NUMBER; + argv[0].v_lock = VAR_UNLOCKED; + argv[0].vval.v_number = (varnumber_T)ev->data->id; + + if (ev->received) { + argv[1].v_type = VAR_LIST; + argv[1].v_lock = VAR_UNLOCKED; + argv[1].vval.v_list = ev->received; + argv[1].vval.v_list->lv_refcount++; + } else { + argv[1].v_type = VAR_NUMBER; + argv[1].v_lock = VAR_UNLOCKED; + argv[1].vval.v_number = ev->status; + } + + argv[2].v_type = VAR_STRING; + argv[2].v_lock = VAR_UNLOCKED; + argv[2].vval.v_string = (uint8_t *)ev->type; + + typval_T rettv = TV_INITIAL_VALUE; + callback_call(ev->callback, 3, argv, &rettv); + tv_clear(&rettv); +} + diff --git a/src/nvim/channel.h b/src/nvim/channel.h index b48f508722..8ead6749a6 100644 --- a/src/nvim/channel.h +++ b/src/nvim/channel.h @@ -21,14 +21,19 @@ typedef struct { Stream out; } StdioPair; -// typedef struct { -// Callback on_out; -// Callback on_close; -// Garray buffer; -// bool buffering; -// } CallbackReader - -#define CallbackReader Callback +typedef struct { + Callback cb; + garray_T buffer; + bool buffered; +} CallbackReader; + +#define CALLBACK_READER_INIT ((CallbackReader){ .cb = CALLBACK_NONE, \ + .buffer = GA_EMPTY_INIT_VALUE, \ + .buffered = false }) +static inline bool callback_reader_set(CallbackReader reader) +{ + return reader.cb.type != kCallbackNone; +} struct Channel { uint64_t id; @@ -61,17 +66,6 @@ EXTERN PMap(uint64_t) *channels; # include "channel.h.generated.h" #endif -static inline Channel *channel_alloc(ChannelStreamType type) -{ - Channel *chan = xcalloc(1, sizeof(*chan)); - chan->id = next_chan_id++; - chan->events = multiqueue_new_child(main_loop.events); - chan->refcount = 1; - chan->streamtype = type; - pmap_put(uint64_t)(channels, chan->id, chan); - return chan; -} - /// @returns Channel with the id or NULL if not found static inline Channel *find_channel(uint64_t id) { @@ -89,7 +83,7 @@ static inline Stream *channel_instream(Channel *chan) return &chan->stream.socket; case kChannelStreamStdio: - return &chan->stream.stdio.in; + return &chan->stream.stdio.out; case kChannelStreamInternal: abort(); @@ -108,7 +102,7 @@ static inline Stream *channel_outstream(Channel *chan) return &chan->stream.socket; case kChannelStreamStdio: - return &chan->stream.stdio.out; + return &chan->stream.stdio.in; case kChannelStreamInternal: abort(); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 013cfce78d..c2fd7ac19c 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -437,14 +437,6 @@ static ScopeDictDictItem vimvars_var; /// v: hashtab #define vimvarht vimvardict.dv_hashtab -typedef struct { - Channel *data; - Callback *callback; - const char *type; - list_T *received; - int status; -} ChannelEvent; - typedef struct { TimeWatcher tw; int timer_id; @@ -5121,12 +5113,12 @@ bool garbage_collect(bool testing) // named functions (matters for closures) ABORTING(set_ref_in_functions(copyID)); - // Jobs + // Channels { Channel *data; map_foreach_value(channels, data, { - set_ref_in_callback(&data->on_stdout, copyID, NULL, NULL); - set_ref_in_callback(&data->on_stderr, copyID, NULL, NULL); + set_ref_in_callback_reader(&data->on_stdout, copyID, NULL, NULL); + set_ref_in_callback_reader(&data->on_stderr, copyID, NULL, NULL); set_ref_in_callback(&data->on_exit, copyID, NULL, NULL); }) } @@ -11643,8 +11635,8 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, FunPtr fptr) bool detach = false; bool rpc = false; bool pty = false; - Callback on_stdout = CALLBACK_NONE; - Callback on_stderr = CALLBACK_NONE; + CallbackReader on_stdout = CALLBACK_READER_INIT, + on_stderr = CALLBACK_READER_INIT; Callback on_exit = CALLBACK_NONE; char *cwd = NULL; if (argvars[1].v_type == VAR_DICT) { @@ -11676,26 +11668,17 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } - Channel *data = common_job_init(argv, on_stdout, on_stderr, on_exit, - pty, rpc, detach, cwd); + uint16_t width = 0, height = 0; + char *term_name = NULL; if (pty) { - PtyProcess *pty = &data->stream.pty; - uint16_t width = (uint16_t)tv_dict_get_number(job_opts, "width"); - if (width > 0) { - pty->width = width; - } - uint16_t height = (uint16_t)tv_dict_get_number(job_opts, "height"); - if (height > 0) { - pty->height = height; - } - char *term = tv_dict_get_string(job_opts, "TERM", true); - if (term) { - pty->term_name = term; - } + width = (uint16_t)tv_dict_get_number(job_opts, "width"); + height = (uint16_t)tv_dict_get_number(job_opts, "height"); + term_name = tv_dict_get_string(job_opts, "TERM", true); } - common_job_start(data, rettv); + channel_job_start(argv, on_stdout, on_stderr, on_exit, pty, rpc, detach, + cwd, width, height, term_name, &rettv->vval.v_number); } // "jobstop()" function @@ -11782,7 +11765,8 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) || !(data = find_job(arg->li_tv.vval.v_number, false))) { continue; } - int status = process_wait((Process *)&data->stream.proc, remaining, waiting_jobs); + int status = process_wait((Process *)&data->stream.proc, remaining, + waiting_jobs); if (status < 0) { // interrupted or timed out, skip remaining jobs. if (status == -2) { @@ -13922,10 +13906,9 @@ static void f_rpcstart(typval_T *argvars, typval_T *rettv, FunPtr fptr) // The last item of argv must be NULL argv[i] = NULL; - Channel *data = common_job_init(argv, CALLBACK_NONE, CALLBACK_NONE, - CALLBACK_NONE, false, true, false, - NULL); - common_job_start(data, rettv); + channel_job_start(argv, CALLBACK_READER_INIT, CALLBACK_READER_INIT, + CALLBACK_NONE, false, true, false, NULL, 0, 0, NULL, + &rettv->vval.v_number); } // "rpcstop()" function @@ -13946,7 +13929,7 @@ static void f_rpcstop(typval_T *argvars, typval_T *rettv, FunPtr fptr) // if called with a job, stop it, else closes the channel uint64_t id = argvars[0].vval.v_number; - if (find_job(id, false)) { // FIXME + if (find_job(id, false)) { f_jobstop(argvars, rettv, NULL); } else { rettv->vval.v_number = channel_close(id); @@ -15126,18 +15109,19 @@ static void f_sockconnect(typval_T *argvars, typval_T *rettv, FunPtr fptr) } bool rpc = false; + CallbackReader on_data = CALLBACK_READER_INIT; if (argvars[2].v_type == VAR_DICT) { dict_T *opts = argvars[2].vval.v_dict; rpc = tv_dict_get_number(opts, "rpc") != 0; - } - if (!rpc) { - EMSG2(_(e_invarg2), "rpc option must be true"); - return; + if (!tv_dict_get_callback(opts, S_LEN("on_data"), &on_data.cb)) { + return; + } + on_data.buffered = tv_dict_get_number(opts, "data_buffered"); } const char *error = NULL; - uint64_t id = channel_connect(tcp, address, 50, &error); + uint64_t id = channel_connect(tcp, address, rpc, on_data, 50, &error); if (error) { EMSG2(_("connection failed: %s"), error); @@ -15517,6 +15501,35 @@ static void f_sort(typval_T *argvars, typval_T *rettv, FunPtr fptr) do_sort_uniq(argvars, rettv, true); } +/// "stdioopen()" function +static void f_stdioopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + if (argvars[0].v_type != VAR_DICT) { + EMSG(_(e_invarg)); + return; + } + + + bool rpc = false; + CallbackReader on_stdin = CALLBACK_READER_INIT; + dict_T *opts = argvars[0].vval.v_dict; + rpc = tv_dict_get_number(opts, "rpc") != 0; + + if (!tv_dict_get_callback(opts, S_LEN("on_stdin"), &on_stdin.cb)) { + return; + } + + const char *error; + uint64_t id = channel_from_stdio(rpc, on_stdin, &error); + if (!id) { + EMSG2(e_stdiochan2, error); + } + + + rettv->vval.v_number = (varnumber_T)id; + rettv->v_type = VAR_NUMBER; +} + /// "uniq({list})" function static void f_uniq(typval_T *argvars, typval_T *rettv, FunPtr fptr) { @@ -16633,8 +16646,9 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } - Callback on_stdout = CALLBACK_NONE, on_stderr = CALLBACK_NONE, - on_exit = CALLBACK_NONE; + CallbackReader on_stdout = CALLBACK_READER_INIT, + on_stderr = CALLBACK_READER_INIT; + Callback on_exit = CALLBACK_NONE; dict_T *job_opts = NULL; const char *cwd = "."; if (argvars[1].v_type == VAR_DICT) { @@ -16658,23 +16672,23 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) } uint16_t term_width = MAX(0, curwin->w_width - win_col_off(curwin)); - Channel *data = common_job_init(argv, on_stdout, on_stderr, on_exit, - true, false, false, cwd); - data->stream.pty.width = term_width; - data->stream.pty.height = curwin->w_height; - data->stream.pty.term_name = xstrdup("xterm-256color"); - if (!common_job_start(data, rettv)) { + Channel *chan = channel_job_start(argv, on_stdout, on_stderr, on_exit, + true, false, false, cwd, + term_width, curwin->w_height, + xstrdup("xterm-256color"), + &rettv->vval.v_number); + if (rettv->vval.v_number <= 0) { return; } TerminalOptions topts; - topts.data = data; + topts.data = chan; topts.width = term_width; topts.height = curwin->w_height; topts.write_cb = term_write; topts.resize_cb = term_resize; topts.close_cb = term_close; - int pid = data->stream.pty.process.pid; + int pid = chan->stream.pty.process.pid; char buf[1024]; // format the title with the pid to conform with the term:// URI @@ -16685,16 +16699,19 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) (void)setfname(curbuf, (char_u *)buf, NULL, true); // Save the job id and pid in b:terminal_job_{id,pid} Error err = ERROR_INIT; + dict_set_var(curbuf->b_vars, cstr_as_string("terminal_channel_id"), + INTEGER_OBJ(chan->id), false, false, &err); + // deprecated name: dict_set_var(curbuf->b_vars, cstr_as_string("terminal_job_id"), - INTEGER_OBJ(rettv->vval.v_number), false, false, &err); + INTEGER_OBJ(chan->id), false, false, &err); api_clear_error(&err); dict_set_var(curbuf->b_vars, cstr_as_string("terminal_job_pid"), INTEGER_OBJ(pid), false, false, &err); api_clear_error(&err); Terminal *term = terminal_open(topts); - data->term = term; - channel_incref(data); + chan->term = term; + channel_incref(chan); return; } @@ -16783,6 +16800,13 @@ static bool set_ref_in_callback(Callback *callback, int copyID, return false; } +static bool set_ref_in_callback_reader(CallbackReader *reader, int copyID, + ht_stack_T **ht_stack, + list_stack_T **list_stack) +{ + return set_ref_in_callback(&reader->cb, copyID, ht_stack, list_stack); +} + static void add_timer_info(typval_T *rettv, timer_T *timer) { list_T *list = rettv->vval.v_list; @@ -22347,206 +22371,29 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, return ret; } -static inline Channel *common_job_init(char **argv, - Callback on_stdout, - Callback on_stderr, - Callback on_exit, - bool pty, - bool rpc, - bool detach, - const char *cwd) -{ - Channel *data = channel_alloc(kChannelStreamProc); - data->on_stdout = on_stdout; - data->on_stderr = on_stderr; - data->on_exit = on_exit; - data->is_rpc = rpc; - if (pty) { - data->stream.pty = pty_process_init(&main_loop, data); - } else { - data->stream.uv = libuv_process_init(&main_loop, data); - } - Process *proc = (Process *)&data->stream.proc; - proc->argv = argv; - proc->cb = eval_job_process_exit_cb; - proc->events = data->events; - proc->detach = detach; - proc->cwd = cwd; - return data; -} - /// common code for getting job callbacks for jobstart, termopen and rpcstart /// /// @return true/false on success/failure. -static inline bool common_job_callbacks(dict_T *vopts, Callback *on_stdout, - Callback *on_stderr, Callback *on_exit) +static inline bool common_job_callbacks(dict_T *vopts, + CallbackReader *on_stdout, + CallbackReader *on_stderr, + Callback *on_exit) { - if (tv_dict_get_callback(vopts, S_LEN("on_stdout"), on_stdout) - &&tv_dict_get_callback(vopts, S_LEN("on_stderr"), on_stderr) + if (tv_dict_get_callback(vopts, S_LEN("on_stdout"), &on_stdout->cb) + &&tv_dict_get_callback(vopts, S_LEN("on_stderr"), &on_stderr->cb) && tv_dict_get_callback(vopts, S_LEN("on_exit"), on_exit)) { + on_stdout->buffered = tv_dict_get_number(vopts, "stdout_buffered"); + on_stderr->buffered = tv_dict_get_number(vopts, "stderr_buffered"); vopts->dv_refcount++; return true; } - callback_free(on_stdout); - callback_free(on_stderr); + callback_reader_free(on_stdout); + callback_reader_free(on_stderr); callback_free(on_exit); return false; } -static inline bool common_job_start(Channel *data, typval_T *rettv) -{ - Process *proc = (Process *)&data->stream.proc; - if (proc->type == kProcessTypePty && proc->detach) { - EMSG2(_(e_invarg2), "terminal/pty job cannot be detached"); - xfree(data->stream.pty.term_name); - shell_free_argv(proc->argv); - channel_decref(data); - return false; - } - - data->refcount++; - char *cmd = xstrdup(proc->argv[0]); - bool has_out, has_err; - if (proc->type == kProcessTypePty) { - has_out = true; - has_err = false; - } else { - has_out = data->is_rpc || data->on_stdout.type != kCallbackNone; - has_err = data->on_stderr.type != kCallbackNone; - } - int status = process_spawn(proc, true, has_out, has_err); - if (status) { - EMSG3(_(e_jobspawn), os_strerror(status), cmd); - xfree(cmd); - if (proc->type == kProcessTypePty) { - xfree(data->stream.pty.term_name); - } - rettv->vval.v_number = proc->status; - channel_decref(data); - return false; - } - xfree(cmd); - - - if (data->is_rpc) { - // the rpc takes over the in and out streams - rpc_start(data); - } else { - wstream_init(&proc->in, 0); - if (has_out) { - rstream_init(&proc->out, 0); - rstream_start(&proc->out, on_job_stdout, data); - } - } - - if (has_err) { - rstream_init(&proc->err, 0); - rstream_start(&proc->err, on_job_stderr, data); - } - rettv->vval.v_number = data->id; - return true; -} - -// vimscript job callbacks must be executed on Nvim main loop -static inline void process_job_event(Channel *data, Callback *callback, - const char *type, char *buf, size_t count, - int status) -{ - ChannelEvent event_data; - event_data.received = NULL; - if (buf) { - event_data.received = tv_list_alloc(); - char *ptr = buf; - size_t remaining = count; - size_t off = 0; - - while (off < remaining) { - // append the line - if (ptr[off] == NL) { - tv_list_append_string(event_data.received, ptr, off); - size_t skip = off + 1; - ptr += skip; - remaining -= skip; - off = 0; - continue; - } - if (ptr[off] == NUL) { - // Translate NUL to NL - ptr[off] = NL; - } - off++; - } - tv_list_append_string(event_data.received, ptr, off); - } else { - event_data.status = status; - } - event_data.data = data; - event_data.callback = callback; - event_data.type = type; - on_job_event(&event_data); -} - -static void on_job_stdout(Stream *stream, RBuffer *buf, size_t count, - void *job, bool eof) -{ - Channel *data = job; - on_job_output(stream, job, buf, count, eof, &data->on_stdout, "stdout"); -} - -static void on_job_stderr(Stream *stream, RBuffer *buf, size_t count, - void *job, bool eof) -{ - Channel *data = job; - on_job_output(stream, job, buf, count, eof, &data->on_stderr, "stderr"); -} - -static void on_job_output(Stream *stream, Channel *data, RBuffer *buf, - size_t count, bool eof, Callback *callback, - const char *type) -{ - if (eof) { - return; - } - - // stub variable, to keep reading consistent with the order of events, only - // consider the count parameter. - size_t r; - char *ptr = rbuffer_read_ptr(buf, &r); - - // The order here matters, the terminal must receive the data first because - // process_job_event will modify the read buffer(convert NULs into NLs) - if (data->term) { - terminal_receive(data->term, ptr, count); - } - - rbuffer_consumed(buf, count); - if (callback->type != kCallbackNone) { - process_job_event(data, callback, type, ptr, count, 0); - } -} - -static void eval_job_process_exit_cb(Process *proc, int status, void *d) -{ - Channel *data = d; - if (data->term && !data->stream.proc.exited) { - data->stream.proc.exited = true; - char msg[sizeof("\r\n[Process exited ]") + NUMBUFLEN]; - snprintf(msg, sizeof msg, "\r\n[Process exited %d]", proc->status); - terminal_close(data->term, msg); - } - if (data->is_rpc) { - channel_process_exit(data->id, status); - } - - if (data->status_ptr) { - *data->status_ptr = status; - } - - process_job_event(data, &data->on_exit, "exit", NULL, 0, status); - - channel_decref(data); -} static void term_write(char *buf, size_t size, void *d) { @@ -22589,38 +22436,6 @@ static void term_close(void *d) multiqueue_put(data->events, term_delayed_free, 1, data); } -static void on_job_event(ChannelEvent *ev) -{ - if (!ev->callback) { - return; - } - - typval_T argv[4]; - - argv[0].v_type = VAR_NUMBER; - argv[0].v_lock = 0; - argv[0].vval.v_number = ev->data->id; - - if (ev->received) { - argv[1].v_type = VAR_LIST; - argv[1].v_lock = 0; - argv[1].vval.v_list = ev->received; - argv[1].vval.v_list->lv_refcount++; - } else { - argv[1].v_type = VAR_NUMBER; - argv[1].v_lock = 0; - argv[1].vval.v_number = ev->status; - } - - argv[2].v_type = VAR_STRING; - argv[2].v_lock = 0; - argv[2].vval.v_string = (uint8_t *)ev->type; - - typval_T rettv = TV_INITIAL_VALUE; - callback_call(ev->callback, 3, argv, &rettv); - tv_clear(&rettv); -} - static Channel *find_job(uint64_t id, bool show_error) { Channel *data = find_channel(id); diff --git a/src/nvim/eval.h b/src/nvim/eval.h index 070bc35bd5..7814a086fa 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -7,6 +7,9 @@ #include "nvim/eval/typval.h" #include "nvim/profile.h" #include "nvim/garray.h" +#include "nvim/event/rstream.h" +#include "nvim/event/wstream.h" +#include "nvim/channel.h" #define COPYID_INC 2 #define COPYID_MASK (~0x1) diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 0e359fb61c..3150f26df6 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -273,6 +273,7 @@ return { sockconnect={args={2,3}}, sort={args={1, 3}}, soundfold={args=1}, + stdioopen={args=1}, spellbadword={args={0, 1}}, spellsuggest={args={1, 3}}, split={args={1, 3}}, diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 99382d2a24..4bc3a85efb 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -374,7 +374,7 @@ void tv_list_append_dict(list_T *const list, dict_T *const dict) /// case string is considered to be usual zero-terminated /// string or NULL “empty†string. void tv_list_append_string(list_T *const l, const char *const str, - const ptrdiff_t len) + const ssize_t len) FUNC_ATTR_NONNULL_ARG(1) { if (str == NULL) { @@ -824,7 +824,7 @@ void tv_dict_watcher_add(dict_T *const dict, const char *const key_pattern, /// @param[in] cb2 Second callback to check. /// /// @return True if they are equal, false otherwise. -bool tv_callback_equal(const Callback *const cb1, const Callback *const cb2) +bool tv_callback_equal(const Callback *cb1, const Callback *cb2) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { if (cb1->type != cb2->type) { @@ -843,12 +843,12 @@ bool tv_callback_equal(const Callback *const cb1, const Callback *const cb2) return true; } } - assert(false); + abort(); return false; } /// Unref/free callback -void callback_free(Callback *const callback) +void callback_free(Callback *callback) FUNC_ATTR_NONNULL_ALL { switch (callback->type) { @@ -864,9 +864,6 @@ void callback_free(Callback *const callback) case kCallbackNone: { break; } - default: { - abort(); - } } callback->type = kCallbackNone; } diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index 1bbe4d9cad..8946f049e2 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -92,7 +92,6 @@ int process_spawn(Process *proc, bool in, bool out, bool err) if (in) { stream_init(NULL, &proc->in, -1, STRUCT_CAST(uv_stream_t, &proc->in.uv.pipe)); - proc->in.events = proc->events; proc->in.internal_data = proc; proc->in.internal_close_cb = on_process_stream_close; proc->refcount++; @@ -101,7 +100,6 @@ int process_spawn(Process *proc, bool in, bool out, bool err) if (out) { stream_init(NULL, &proc->out, -1, STRUCT_CAST(uv_stream_t, &proc->out.uv.pipe)); - proc->out.events = proc->events; proc->out.internal_data = proc; proc->out.internal_close_cb = on_process_stream_close; proc->refcount++; @@ -110,7 +108,6 @@ int process_spawn(Process *proc, bool in, bool out, bool err) if (err) { stream_init(NULL, &proc->err, -1, STRUCT_CAST(uv_stream_t, &proc->err.uv.pipe)); - proc->err.events = proc->events; proc->err.internal_data = proc; proc->err.internal_close_cb = on_process_stream_close; proc->refcount++; @@ -382,15 +379,15 @@ static void flush_stream(Process *proc, Stream *stream) // Poll for data and process the generated events. loop_poll_events(proc->loop, 0); - if (proc->events) { - multiqueue_process_events(proc->events); + if (stream->events) { + multiqueue_process_events(stream->events); } // Stream can be closed if it is empty. if (num_bytes == stream->num_bytes) { - if (stream->read_cb) { + if (stream->read_cb && !stream->did_eof) { // Stream callback could miss EOF handling if a child keeps the stream - // open. + // open. But only send EOF if we haven't already. stream->read_cb(stream, stream->buffer, 0, stream->cb_data, true); } break; diff --git a/src/nvim/event/rstream.c b/src/nvim/event/rstream.c index 2c4db08b30..e0500ba828 100644 --- a/src/nvim/event/rstream.c +++ b/src/nvim/event/rstream.c @@ -105,20 +105,20 @@ static void read_cb(uv_stream_t *uvstream, ssize_t cnt, const uv_buf_t *buf) { Stream *stream = uvstream->data; - if (cnt > 0) { - stream->num_bytes += (size_t)cnt; - } - if (cnt <= 0) { - if (cnt != UV_ENOBUFS - // cnt == 0 means libuv asked for a buffer and decided it wasn't needed: - // http://docs.libuv.org/en/latest/stream.html#c.uv_read_start. - // - // We don't need to do anything with the RBuffer because the next call - // to `alloc_cb` will return the same unused pointer(`rbuffer_produced` - // won't be called) - && cnt != 0) { - DLOG("closing Stream: %p: %s (%s)", stream, + // cnt == 0 means libuv asked for a buffer and decided it wasn't needed: + // http://docs.libuv.org/en/latest/stream.html#c.uv_read_start. + // + // We don't need to do anything with the RBuffer because the next call + // to `alloc_cb` will return the same unused pointer(`rbuffer_produced` + // won't be called) + if (cnt == UV_ENOBUFS || cnt == 0) { + return; + } else if (cnt == UV_EOF && uvstream->type == UV_TTY) { + // The TTY driver might signal TTY without closing the stream + invoke_read_cb(stream, 0, true); + } else { + DLOG("Closing Stream (%p): %s (%s)", stream, uv_err_name((int)cnt), os_strerror((int)cnt)); // Read error or EOF, either way stop the stream and invoke the callback // with eof == true @@ -130,6 +130,7 @@ static void read_cb(uv_stream_t *uvstream, ssize_t cnt, const uv_buf_t *buf) // at this point we're sure that cnt is positive, no error occurred size_t nread = (size_t)cnt; + stream->num_bytes += nread; // Data was already written, so all we need is to update 'wpos' to reflect // the space actually used in the buffer. rbuffer_produced(stream->buffer, nread); @@ -187,6 +188,7 @@ static void read_event(void **argv) if (stream->read_cb) { size_t count = (uintptr_t)argv[1]; bool eof = (uintptr_t)argv[2]; + stream->did_eof = eof; stream->read_cb(stream, stream->buffer, count, stream->cb_data, eof); } stream->pending_reqs--; diff --git a/src/nvim/event/stream.h b/src/nvim/event/stream.h index 70a708ff4d..e713323f5c 100644 --- a/src/nvim/event/stream.h +++ b/src/nvim/event/stream.h @@ -14,10 +14,7 @@ typedef struct stream Stream; /// /// @param stream The Stream instance /// @param rbuffer The associated RBuffer instance -/// @param count Number of bytes to read. This must be respected if keeping -/// the order of events is a requirement. This is because events -/// may be queued and only processed later when more data is copied -/// into to the buffer, so one read may starve another. +/// @param count Number of bytes that was read. /// @param data User-defined data /// @param eof If the stream reached EOF. typedef void (*stream_read_cb)(Stream *stream, RBuffer *buf, size_t count, @@ -34,6 +31,7 @@ typedef void (*stream_close_cb)(Stream *stream, void *data); struct stream { bool closed; + bool did_eof; union { uv_pipe_t pipe; uv_tcp_t tcp; diff --git a/src/nvim/globals.h b/src/nvim/globals.h index c639dbcf83..d21cfe7ab6 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1080,6 +1080,8 @@ EXTERN char_u e_jobtblfull[] INIT(= N_("E901: Job table is full")); EXTERN char_u e_jobspawn[] INIT(= N_( "E903: Process failed to start: %s: \"%s\"")); EXTERN char_u e_channotpty[] INIT(= N_("E904: channel is not a pty")); +EXTERN char_u e_stdiochan2[] INIT(= N_( + "E905: Couldn't open stdio channel: %s")); EXTERN char_u e_libcall[] INIT(= N_("E364: Library call failed for \"%s()\"")); EXTERN char_u e_mkdir[] INIT(= N_("E739: Cannot create directory %s: %s")); EXTERN char_u e_markinval[] INIT(= N_("E19: Mark has invalid line number")); @@ -1190,9 +1192,13 @@ EXTERN char *ignoredp; // If a msgpack-rpc channel should be started over stdin/stdout EXTERN bool embedded_mode INIT(= false); +// Dont try to start an user interface +// or read/write to stdio (unless embedding) +EXTERN bool headless_mode INIT(= false); /// next free id for a job or rpc channel -EXTERN uint64_t next_chan_id INIT(= 1); +/// 1 is reserved for stdio channel +EXTERN uint64_t next_chan_id INIT(= 2); /// Used to track the status of external functions. /// Currently only used for iconv(). diff --git a/src/nvim/main.c b/src/nvim/main.c index 93afe11f3a..9059644fc0 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -103,7 +103,6 @@ typedef struct { bool input_isatty; // stdin is a terminal bool output_isatty; // stdout is a terminal bool err_isatty; // stderr is a terminal - bool headless; // Do not start the builtin UI. int no_swap_file; // "-n" argument used int use_debug_break_level; int window_count; /* number of windows to use */ @@ -299,7 +298,7 @@ int main(int argc, char **argv) cmdline_row = (int)(Rows - p_ch); msg_row = cmdline_row; screenalloc(false); /* allocate screen buffers */ - set_init_2(params.headless); + set_init_2(headless_mode); TIME_MSG("inits 2"); msg_scroll = TRUE; @@ -311,7 +310,7 @@ int main(int argc, char **argv) /* Set the break level after the terminal is initialized. */ debug_break_level = params.use_debug_break_level; - bool reading_input = !params.headless && (params.input_isatty + bool reading_input = !headless_mode && (params.input_isatty || params.output_isatty || params.err_isatty); if (reading_input) { @@ -448,7 +447,7 @@ int main(int argc, char **argv) wait_return(TRUE); } - if (!params.headless) { + if (!headless_mode) { // Stop reading from input stream, the UI layer will take over now. input_stop(); ui_builtin_start(); @@ -809,11 +808,14 @@ static void command_line_scan(mparm_T *parmp) } mch_exit(0); } else if (STRICMP(argv[0] + argv_idx, "headless") == 0) { - parmp->headless = true; + headless_mode = true; } else if (STRICMP(argv[0] + argv_idx, "embed") == 0) { embedded_mode = true; - parmp->headless = true; - channel_from_stdio(); + headless_mode = true; + const char *err; + if (!channel_from_stdio(true, CALLBACK_READER_INIT, &err)) { + abort(); + } } else if (STRNICMP(argv[0] + argv_idx, "literal", 7) == 0) { #if !defined(UNIX) parmp->literal = TRUE; @@ -1216,7 +1218,6 @@ static void init_params(mparm_T *paramp, int argc, char **argv) memset(paramp, 0, sizeof(*paramp)); paramp->argc = argc; paramp->argv = argv; - paramp->headless = false; paramp->want_full_screen = true; paramp->use_debug_break_level = -1; paramp->window_count = -1; @@ -1387,7 +1388,7 @@ static void handle_tag(char_u *tagname) // When starting in Ex mode and commands come from a file, set Silent mode. static void check_tty(mparm_T *parmp) { - if (parmp->headless) { + if (headless_mode) { return; } diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 42b1f63830..56af4fa791 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -13,7 +13,6 @@ #include "nvim/api/ui.h" #include "nvim/channel.h" #include "nvim/msgpack_rpc/channel.h" -#include "nvim/msgpack_rpc/server.h" #include "nvim/event/loop.h" #include "nvim/event/libuv_process.h" #include "nvim/event/rstream.h" @@ -30,12 +29,9 @@ #include "nvim/map.h" #include "nvim/log.h" #include "nvim/misc1.h" -#include "nvim/path.h" #include "nvim/lib/kvec.h" #include "nvim/os/input.h" -#define CHANNEL_BUFFER_SIZE 0xffff - #if MIN_LOG_LEVEL > DEBUG_LOG_LEVEL #define log_client_msg(...) #define log_server_msg(...) @@ -66,57 +62,18 @@ void rpc_start(Channel *channel) rpc->next_request_id = 1; kv_init(rpc->call_stack); - Stream *in = channel_instream(channel); - Stream *out = channel_outstream(channel); - - DLOG("rpc ch %" PRIu64 " in-stream=%p out-stream=%p", channel->id, in, out); - - wstream_init(in, 0); - rstream_init(out, CHANNEL_BUFFER_SIZE); - rstream_start(out, receive_msgpack, channel); -} - -/// Creates an API channel from a tcp/pipe socket connection -/// -/// @param watcher The SocketWatcher ready to accept the connection -void channel_from_connection(SocketWatcher *watcher) -{ - Channel *channel = channel_alloc(kChannelStreamSocket); - socket_watcher_accept(watcher, &channel->stream.socket); - channel_incref(channel); // close channel only after the stream is closed - channel->stream.socket.internal_close_cb = close_cb; - channel->stream.socket.internal_data = channel; - rpc_start(channel); -} - -/// TODO: move to eval.c, also support bytes -uint64_t channel_connect(bool tcp, const char *address, - int timeout, const char **error) -{ - if (!tcp) { - char *path = fix_fname(address); - if (server_owns_pipe_address(path)) { - // avoid deadlock - xfree(path); - return channel_create_internal(); - } - xfree(path); - } + if (channel->streamtype != kChannelStreamInternal) { + Stream *out = channel_outstream(channel); +#if MIN_LOG_LEVEL <= DEBUG_LOG_LEVEL + Stream *in = channel_instream(channel); + DLOG("rpc ch %" PRIu64 " in-stream=%p out-stream=%p", channel->id, in, out); +#endif - Channel *channel = channel_alloc(kChannelStreamSocket); - if (!socket_connect(&main_loop, &channel->stream.socket, - tcp, address, timeout, error)) { - channel_decref(channel); - return 0; + rstream_start(out, receive_msgpack, channel); } - - channel_incref(channel); // close channel only after the stream is closed - channel->stream.socket.internal_close_cb = close_cb; - channel->stream.socket.internal_data = channel; - rpc_start(channel); - return channel->id; } + static Channel *find_rpc_channel(uint64_t id) { Channel *chan = find_channel(id); @@ -263,29 +220,6 @@ bool channel_close(uint64_t id) return true; } -/// Creates an API channel from stdin/stdout. This is used when embedding -/// Neovim -void channel_from_stdio(void) -{ - Channel *channel = channel_alloc(kChannelStreamStdio); - channel_incref(channel); // stdio channels are only closed on exit - // read stream - rstream_init_fd(&main_loop, &channel->stream.stdio.in, 0, CHANNEL_BUFFER_SIZE); - wstream_init_fd(&main_loop, &channel->stream.stdio.out, 1, 0); - - rpc_start(channel); -} - -/// Creates a loopback channel. This is used to avoid deadlock -/// when an instance connects to its own named pipe. -uint64_t channel_create_internal(void) -{ - Channel *channel = channel_alloc(kChannelStreamInternal); - channel_incref(channel); // internal channel lives until process exit - rpc_start(channel); - return channel->id; -} - void channel_process_exit(uint64_t id, int status) { Channel *channel = pmap_get(uint64_t)(channels, id); @@ -663,11 +597,6 @@ void rpc_free(Channel *channel) kv_destroy(channel->rpc.call_stack); } -static void close_cb(Stream *stream, void *data) -{ - channel_decref(data); -} - static bool is_rpc_response(msgpack_object *obj) { return obj->type == MSGPACK_OBJECT_ARRAY diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index f54fe412ba..ec2ebb9d19 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -227,18 +227,15 @@ static int do_os_system(char **argv, return -1; } - // We want to deal with stream events as fast a possible while queueing - // process events, so reset everything to NULL. It prevents closing the + // Note: unlike process events, stream events are not queued, as we want to + // deal with stream events as fast a possible. It prevents closing the // streams while there's still data in the OS buffer (due to the process // exiting before all data is read). if (input != NULL) { - proc->in.events = NULL; wstream_init(&proc->in, 0); } - proc->out.events = NULL; rstream_init(&proc->out, 0); rstream_start(&proc->out, data_cb, &buf); - proc->err.events = NULL; rstream_init(&proc->err, 0); rstream_start(&proc->err, data_cb, &buf); diff --git a/src/nvim/rbuffer.c b/src/nvim/rbuffer.c index 18d453cbe9..df9394fbb2 100644 --- a/src/nvim/rbuffer.c +++ b/src/nvim/rbuffer.c @@ -121,7 +121,7 @@ char *rbuffer_read_ptr(RBuffer *buf, size_t *read_count) FUNC_ATTR_NONNULL_ALL { if (!buf->size) { *read_count = 0; - return NULL; + return buf->read_ptr; } if (buf->read_ptr < buf->write_ptr) { -- cgit From 3e59c1e20d605315d299e17ac9a059ccedd7e9d5 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 16 Jul 2017 14:29:04 +0200 Subject: channels: move away term code from eval.c --- src/nvim/buffer_defs.h | 1 + src/nvim/channel.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++-- src/nvim/eval.c | 61 +++------------------------------------------- src/nvim/event/process.h | 1 - src/nvim/option.c | 6 +++++ src/nvim/option_defs.h | 1 + src/nvim/options.lua | 8 ++++++ 7 files changed, 81 insertions(+), 60 deletions(-) (limited to 'src') diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 559dffb945..f1cbcb2627 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -603,6 +603,7 @@ struct file_buffer { char_u *b_p_bt; ///< 'buftype' int b_has_qf_entry; ///< quickfix exists for buffer int b_p_bl; ///< 'buflisted' + long b_p_channel; ///< 'channel' int b_p_cin; ///< 'cindent' char_u *b_p_cino; ///< 'cinoptions' char_u *b_p_cink; ///< 'cinkeys' diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 5ee4e5be09..c6db2b7b7a 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -421,12 +421,12 @@ static void on_channel_output(Stream *stream, Channel *chan, RBuffer *buf, static void channel_process_exit_cb(Process *proc, int status, void *data) { Channel *chan = data; - if (chan->term && !chan->stream.proc.exited) { - chan->stream.proc.exited = true; + if (chan->term) { char msg[sizeof("\r\n[Process exited ]") + NUMBUFLEN]; snprintf(msg, sizeof msg, "\r\n[Process exited %d]", proc->status); terminal_close(chan->term, msg); } + if (chan->is_rpc) { channel_process_exit(chan->id, status); } @@ -472,3 +472,62 @@ static void on_channel_event(ChannelEvent *ev) tv_clear(&rettv); } + +/// Open terminal for channel +/// +/// Channel `chan` is assumed to be an open pty channel, +/// and curbuf is assumed to be a new, unmodified buffer. +void channel_terminal_open(Channel *chan) +{ + TerminalOptions topts; + topts.data = chan; + topts.width = chan->stream.pty.width; + topts.height = chan->stream.pty.height; + topts.write_cb = term_write; + topts.resize_cb = term_resize; + topts.close_cb = term_close; + curbuf->b_p_channel = (long)chan->id; // 'channel' option + Terminal *term = terminal_open(topts); + chan->term = term; + channel_incref(chan); +} + +static void term_write(char *buf, size_t size, void *data) +{ + Channel *chan = data; + if (chan->stream.proc.in.closed) { + // If the backing stream was closed abruptly, there may be write events + // ahead of the terminal close event. Just ignore the writes. + ILOG("write failed: stream is closed"); + return; + } + WBuffer *wbuf = wstream_new_buffer(xmemdup(buf, size), size, 1, xfree); + wstream_write(&chan->stream.proc.in, wbuf); +} + +static void term_resize(uint16_t width, uint16_t height, void *data) +{ + Channel *chan = data; + pty_process_resize(&chan->stream.pty, width, height); +} + +static inline void term_delayed_free(void **argv) +{ + Channel *chan = argv[0]; + if (chan->stream.proc.in.pending_reqs || chan->stream.proc.out.pending_reqs) { + multiqueue_put(chan->events, term_delayed_free, 1, chan); + return; + } + + terminal_destroy(chan->term); + chan->term = NULL; + channel_decref(chan); +} + +static void term_close(void *data) +{ + Channel *chan = data; + process_stop(&chan->stream.proc); + multiqueue_put(chan->events, term_delayed_free, 1, data); +} + diff --git a/src/nvim/eval.c b/src/nvim/eval.c index c2fd7ac19c..6899474577 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -11550,7 +11550,8 @@ static void f_jobresize(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } - pty_process_resize(&data->stream.pty, argvars[1].vval.v_number, argvars[2].vval.v_number); + pty_process_resize(&data->stream.pty, argvars[1].vval.v_number, + argvars[2].vval.v_number); rettv->vval.v_number = 1; } @@ -16680,13 +16681,6 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (rettv->vval.v_number <= 0) { return; } - TerminalOptions topts; - topts.data = chan; - topts.width = term_width; - topts.height = curwin->w_height; - topts.write_cb = term_write; - topts.resize_cb = term_resize; - topts.close_cb = term_close; int pid = chan->stream.pty.process.pid; @@ -16699,9 +16693,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) (void)setfname(curbuf, (char_u *)buf, NULL, true); // Save the job id and pid in b:terminal_job_{id,pid} Error err = ERROR_INIT; - dict_set_var(curbuf->b_vars, cstr_as_string("terminal_channel_id"), - INTEGER_OBJ(chan->id), false, false, &err); - // deprecated name: + // deprecated: use 'channel' buffer option dict_set_var(curbuf->b_vars, cstr_as_string("terminal_job_id"), INTEGER_OBJ(chan->id), false, false, &err); api_clear_error(&err); @@ -16709,11 +16701,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) INTEGER_OBJ(pid), false, false, &err); api_clear_error(&err); - Terminal *term = terminal_open(topts); - chan->term = term; - channel_incref(chan); - - return; + channel_terminal_open(chan); } // "test_garbagecollect_now()" function @@ -22395,47 +22383,6 @@ static inline bool common_job_callbacks(dict_T *vopts, } -static void term_write(char *buf, size_t size, void *d) -{ - Channel *job = d; - if (job->stream.proc.in.closed) { - // If the backing stream was closed abruptly, there may be write events - // ahead of the terminal close event. Just ignore the writes. - ILOG("write failed: stream is closed"); - return; - } - WBuffer *wbuf = wstream_new_buffer(xmemdup(buf, size), size, 1, xfree); - wstream_write(&job->stream.proc.in, wbuf); -} - -static void term_resize(uint16_t width, uint16_t height, void *d) -{ - Channel *data = d; - pty_process_resize(&data->stream.pty, width, height); -} - -static inline void term_delayed_free(void **argv) -{ - Channel *j = argv[0]; - if (j->stream.proc.in.pending_reqs || j->stream.proc.out.pending_reqs) { - multiqueue_put(j->events, term_delayed_free, 1, j); - return; - } - - terminal_destroy(j->term); - channel_decref(j); -} - -static void term_close(void *d) -{ - Channel *data = d; - if (!data->stream.proc.exited) { - data->stream.proc.exited = true; - process_stop((Process *)&data->stream.proc); - } - multiqueue_put(data->events, term_delayed_free, 1, data); -} - static Channel *find_job(uint64_t id, bool show_error) { Channel *data = find_channel(id); diff --git a/src/nvim/event/process.h b/src/nvim/event/process.h index 0897563c83..a8d066c291 100644 --- a/src/nvim/event/process.h +++ b/src/nvim/event/process.h @@ -26,7 +26,6 @@ struct process { Stream in, out, err; process_exit_cb cb; internal_process_cb internal_exit_cb, internal_close_cb; - bool exited; // TODO: redundant bool closed, detach; MultiQueue *events; }; diff --git a/src/nvim/option.c b/src/nvim/option.c index f6f334f432..65ab7a54a6 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -115,6 +115,7 @@ static int p_bomb; static char_u *p_bh; static char_u *p_bt; static int p_bl; +static long p_channel; static int p_ci; static int p_cin; static char_u *p_cink; @@ -4193,6 +4194,9 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, curbuf->b_p_imsearch = B_IMODE_NONE; } p_imsearch = curbuf->b_p_imsearch; + } else if (pp == &p_channel || pp == &curbuf->b_p_channel) { + errmsg = e_invarg; + *pp = old_value; } /* if 'titlelen' has changed, redraw the title */ else if (pp == &p_titlelen) { @@ -5472,6 +5476,7 @@ static char_u *get_varp(vimoption_T *p) case PV_BH: return (char_u *)&(curbuf->b_p_bh); case PV_BT: return (char_u *)&(curbuf->b_p_bt); case PV_BL: return (char_u *)&(curbuf->b_p_bl); + case PV_CHANNEL:return (char_u *)&(curbuf->b_p_channel); case PV_CI: return (char_u *)&(curbuf->b_p_ci); case PV_CIN: return (char_u *)&(curbuf->b_p_cin); case PV_CINK: return (char_u *)&(curbuf->b_p_cink); @@ -5773,6 +5778,7 @@ void buf_copy_options(buf_T *buf, int flags) buf->b_p_nf = vim_strsave(p_nf); buf->b_p_mps = vim_strsave(p_mps); buf->b_p_si = p_si; + buf->b_p_channel = 0; buf->b_p_ci = p_ci; buf->b_p_cin = p_cin; buf->b_p_cink = vim_strsave(p_cink); diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 1f62490ab9..b16f222705 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -695,6 +695,7 @@ enum { , BV_BIN , BV_BL , BV_BOMB + , BV_CHANNEL , BV_CI , BV_CIN , BV_CINK diff --git a/src/nvim/options.lua b/src/nvim/options.lua index cb3e5ad856..dd28a765fd 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -294,6 +294,14 @@ return { varname='p_cedit', defaults={if_true={vi="", vim=macros('CTRL_F_STR')}} }, + { + full_name='channel', + type='number', scope={'buffer'}, + no_mkrc=true, + nodefault=true, + varname='p_channel', + defaults={if_true={vi=0}} + }, { full_name='charconvert', abbreviation='ccv', type='string', scope={'global'}, -- cgit From 90e5cc5484ceeb410ae2a2706e09ed475cade4a5 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Thu, 8 Jun 2017 17:15:53 +0200 Subject: channels: generalize jobclose() --- src/nvim/channel.c | 98 ++++++++++++++++++++++++++++++++++--- src/nvim/channel.h | 9 ++++ src/nvim/eval.c | 107 +++++++++++++++++------------------------ src/nvim/eval.lua | 3 +- src/nvim/event/process.c | 34 +++---------- src/nvim/event/stream.c | 7 +++ src/nvim/globals.h | 3 ++ src/nvim/msgpack_rpc/channel.c | 62 ++++-------------------- src/nvim/os/shell.c | 4 -- 9 files changed, 172 insertions(+), 155 deletions(-) (limited to 'src') diff --git a/src/nvim/channel.c b/src/nvim/channel.c index c6db2b7b7a..416e0a1fb6 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -35,10 +35,99 @@ void channel_teardown(void) Channel *channel; map_foreach_value(channels, channel, { - (void)channel; // close_channel(channel); + channel_close(channel->id, kChannelPartAll, NULL); }); } +/// Closes a channel +/// +/// @param id The channel id +/// @return true if successful, false otherwise +bool channel_close(uint64_t id, ChannelPart part, const char **error) +{ + Channel *chan; + Process *proc; + + const char *dummy; + if (!error) { + error = &dummy; + } + + if (!(chan = find_channel(id))) { + if (id < next_chan_id) { + // allow double close, even though we can't say what parts was valid. + return true; + } + *error = (const char *)e_invchan; + return false; + } + + bool close_main = false; + if (part == kChannelPartRpc || part == kChannelPartAll) { + close_main = true; + if (chan->is_rpc) { + rpc_close(chan); + } else if (part == kChannelPartRpc) { + *error = (const char *)e_invstream; + return false; + } + } else if ((part == kChannelPartStdin || part == kChannelPartStdout) + && chan->is_rpc) { + // EMSG(_("Invalid stream on rpc job, use jobclose(id, 'rpc')")); + *error = (const char *)e_invstreamrpc; + return false; + } + + switch (chan->streamtype) { + case kChannelStreamSocket: + if (!close_main) { + *error = (const char *)e_invstream; + return false; + } + stream_may_close(&chan->stream.socket); + break; + + case kChannelStreamProc: + proc = (Process *)&chan->stream.proc; + if (part == kChannelPartStdin || close_main) { + stream_may_close(&proc->in); + } + if (part == kChannelPartStdout || close_main) { + stream_may_close(&proc->out); + } + if (part == kChannelPartStderr || part == kChannelPartAll) { + stream_may_close(&proc->err); + } + if (proc->type == kProcessTypePty && part == kChannelPartAll) { + pty_process_close_master(&chan->stream.pty); + } + + break; + + case kChannelStreamStdio: + if (part == kChannelPartStdin || close_main) { + stream_may_close(&chan->stream.stdio.in); + } + if (part == kChannelPartStdout || close_main) { + stream_may_close(&chan->stream.stdio.out); + } + if (part == kChannelPartStderr) { + *error = (const char *)e_invstream; + return false; + } + break; + + case kChannelStreamInternal: + if (!close_main) { + *error = (const char *)e_invstream; + return false; + } + break; + } + + return true; +} + /// Initializes the module void channel_init(void) { @@ -239,7 +328,6 @@ uint64_t channel_connect(bool tcp, const char *address, return 0; } - channel_incref(channel); // close channel only after the stream is closed channel->stream.socket.internal_close_cb = close_cb; channel->stream.socket.internal_data = channel; wstream_init(&channel->stream.socket, 0); @@ -264,7 +352,6 @@ void channel_from_connection(SocketWatcher *watcher) { Channel *channel = channel_alloc(kChannelStreamSocket); socket_watcher_accept(watcher, &channel->stream.socket); - channel_incref(channel); // close channel only after the stream is closed channel->stream.socket.internal_close_cb = close_cb; channel->stream.socket.internal_data = channel; wstream_init(&channel->stream.socket, 0); @@ -277,7 +364,6 @@ void channel_from_connection(SocketWatcher *watcher) static uint64_t channel_create_internal_rpc(void) { Channel *channel = channel_alloc(kChannelStreamInternal); - channel_incref(channel); // internal channel lives until process exit rpc_start(channel); return channel->id; } @@ -427,10 +513,6 @@ static void channel_process_exit_cb(Process *proc, int status, void *data) terminal_close(chan->term, msg); } - if (chan->is_rpc) { - channel_process_exit(chan->id, status); - } - if (chan->status_ptr) { *chan->status_ptr = status; } diff --git a/src/nvim/channel.h b/src/nvim/channel.h index 8ead6749a6..eaf0fd92d0 100644 --- a/src/nvim/channel.h +++ b/src/nvim/channel.h @@ -16,6 +16,15 @@ typedef enum { kChannelStreamInternal } ChannelStreamType; +typedef enum { + kChannelPartStdin, + kChannelPartStdout, + kChannelPartStderr, + kChannelPartRpc, + kChannelPartAll +} ChannelPart; + + typedef struct { Stream in; Stream out; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 6899474577..ba356f28b9 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -7322,6 +7322,45 @@ static void f_changenr(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->vval.v_number = curbuf->b_u_seq_cur; } +// "chanclose(id[, stream])" function +static void f_chanclose(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + rettv->v_type = VAR_NUMBER; + rettv->vval.v_number = 0; + + if (check_restricted() || check_secure()) { + return; + } + + if (argvars[0].v_type != VAR_NUMBER || (argvars[1].v_type != VAR_STRING + && argvars[1].v_type != VAR_UNKNOWN)) { + EMSG(_(e_invarg)); + return; + } + + ChannelPart part = kChannelPartAll; + if (argvars[1].v_type == VAR_STRING) { + char *stream = (char *)argvars[1].vval.v_string; + if (!strcmp(stream, "stdin")) { + part = kChannelPartStdin; + } else if (!strcmp(stream, "stdout")) { + part = kChannelPartStdout; + } else if (!strcmp(stream, "stderr")) { + part = kChannelPartStderr; + } else if (!strcmp(stream, "rpc")) { + part = kChannelPartRpc; + } else { + EMSG2(_("Invalid channel stream \"%s\""), stream); + return; + } + } + const char *error; + rettv->vval.v_number = channel_close(argvars[0].vval.v_number, part, &error); + if (!rettv->vval.v_number) { + EMSG(error); + } +} + /* * "char2nr(string)" function */ @@ -11391,67 +11430,6 @@ static void f_items(typval_T *argvars, typval_T *rettv, FunPtr fptr) dict_list(argvars, rettv, 2); } -// "jobclose(id[, stream])" function -static void f_jobclose(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ - rettv->v_type = VAR_NUMBER; - rettv->vval.v_number = 0; - - if (check_restricted() || check_secure()) { - return; - } - - if (argvars[0].v_type != VAR_NUMBER || (argvars[1].v_type != VAR_STRING - && argvars[1].v_type != VAR_UNKNOWN)) { - EMSG(_(e_invarg)); - return; - } - - Channel *data = find_job(argvars[0].vval.v_number, true); - if (!data) { - return; - } - - Process *proc = (Process *)&data->stream.proc; - - if (argvars[1].v_type == VAR_STRING) { - char *stream = (char *)argvars[1].vval.v_string; - if (!strcmp(stream, "stdin")) { - if (data->is_rpc) { - EMSG(_("Invalid stream on rpc job, use jobclose(id, 'rpc')")); - } else { - process_close_in(proc); - } - } else if (!strcmp(stream, "stdout")) { - if (data->is_rpc) { - EMSG(_("Invalid stream on rpc job, use jobclose(id, 'rpc')")); - } else { - process_close_out(proc); - } - } else if (!strcmp(stream, "stderr")) { - process_close_err(proc); - } else if (!strcmp(stream, "rpc")) { - if (data->is_rpc) { - channel_close(data->id); - } else { - EMSG(_("Invalid job stream: Not an rpc job")); - } - } else { - EMSG2(_("Invalid job stream \"%s\""), stream); - } - } else { - if (data->is_rpc) { - channel_close(data->id); - process_close_err(proc); - } else { - process_close_streams(proc); - if (proc->type == kProcessTypePty) { - pty_process_close_master(&data->stream.pty); - } - } - } -} - // "jobpid(id)" function static void f_jobpid(typval_T *argvars, typval_T *rettv, FunPtr fptr) { @@ -13933,7 +13911,12 @@ static void f_rpcstop(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (find_job(id, false)) { f_jobstop(argvars, rettv, NULL); } else { - rettv->vval.v_number = channel_close(id); + const char *error; + rettv->vval.v_number = channel_close(argvars[0].vval.v_number, + kChannelPartRpc, &error); + if (!rettv->vval.v_number) { + EMSG(error); + } } } diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 3150f26df6..bb03691fd4 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -55,6 +55,7 @@ return { call={args={2, 3}}, ceil={args=1, func="float_op_wrapper", data="&ceil"}, changenr={}, + chanclose={args={1, 2}}, char2nr={args={1, 2}}, cindent={args=1}, clearmatches={}, @@ -173,7 +174,7 @@ return { islocked={args=1}, id={args=1}, items={args=1}, - jobclose={args={1, 2}}, + jobclose={args={1, 2}, func="f_chanclose"}, jobpid={args=1}, jobresize={args=3}, jobsend={args=2}, diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index 8946f049e2..34be291aef 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -25,13 +25,6 @@ // For pty processes SIGTERM is sent first (in case SIGHUP was not enough). #define KILL_TIMEOUT_MS 2000 -#define CLOSE_PROC_STREAM(proc, stream) \ - do { \ - if (!proc->stream.closed) { \ - stream_close(&proc->stream, NULL, NULL); \ - } \ - } while (0) - static bool process_is_tearing_down = false; /// @returns zero on success, or negative error code @@ -140,27 +133,11 @@ void process_teardown(Loop *loop) FUNC_ATTR_NONNULL_ALL pty_process_teardown(loop); } -// Wrappers around `stream_close` that protect against double-closing. void process_close_streams(Process *proc) FUNC_ATTR_NONNULL_ALL { - process_close_in(proc); - process_close_out(proc); - process_close_err(proc); -} - -void process_close_in(Process *proc) FUNC_ATTR_NONNULL_ALL -{ - CLOSE_PROC_STREAM(proc, in); -} - -void process_close_out(Process *proc) FUNC_ATTR_NONNULL_ALL -{ - CLOSE_PROC_STREAM(proc, out); -} - -void process_close_err(Process *proc) FUNC_ATTR_NONNULL_ALL -{ - CLOSE_PROC_STREAM(proc, err); + stream_may_close(&proc->in); + stream_may_close(&proc->out); + stream_may_close(&proc->err); } /// Synchronously wait for a process to finish @@ -237,8 +214,9 @@ void process_stop(Process *proc) FUNC_ATTR_NONNULL_ALL switch (proc->type) { case kProcessTypeUv: // Close the process's stdin. If the process doesn't close its own - // stdout/stderr, they will be closed when it exits (voluntarily or not). - process_close_in(proc); + // stdout/stderr, they will be closed when it exits(possibly due to being + // terminated after a timeout) + stream_may_close(&proc->in); ILOG("Sending SIGTERM to pid %d", proc->pid); uv_kill(proc->pid, SIGTERM); break; diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c index 7c865bfe1e..ba25b76ec7 100644 --- a/src/nvim/event/stream.c +++ b/src/nvim/event/stream.c @@ -92,6 +92,13 @@ void stream_close(Stream *stream, stream_close_cb on_stream_close, void *data) } } +void stream_may_close(Stream *stream) +{ + if (!stream->closed) { + stream_close(stream, NULL, NULL); + } +} + void stream_close_handle(Stream *stream) FUNC_ATTR_NONNULL_ALL { diff --git a/src/nvim/globals.h b/src/nvim/globals.h index d21cfe7ab6..d1b0ad0ed3 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1082,6 +1082,9 @@ EXTERN char_u e_jobspawn[] INIT(= N_( EXTERN char_u e_channotpty[] INIT(= N_("E904: channel is not a pty")); EXTERN char_u e_stdiochan2[] INIT(= N_( "E905: Couldn't open stdio channel: %s")); +EXTERN char_u e_invstream[] INIT(= N_("E906: invalid stream for channel")); +EXTERN char_u e_invstreamrpc[] INIT(= N_( + "E906: invalid stream for rpc channel, use 'rpc'")); EXTERN char_u e_libcall[] INIT(= N_("E364: Library call failed for \"%s()\"")); EXTERN char_u e_mkdir[] INIT(= N_("E739: Cannot create directory %s: %s")); EXTERN char_u e_markinval[] INIT(= N_("E19: Mark has invalid line number")); diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 56af4fa791..32781cf4d9 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -54,6 +54,7 @@ void rpc_init(void) void rpc_start(Channel *channel) { + channel_incref(channel); channel->is_rpc = true; RpcState *rpc = &channel->rpc; rpc->closed = false; @@ -204,31 +205,6 @@ void rpc_unsubscribe(uint64_t id, char *event) unsubscribe(channel, event); } -/// Closes a channel -/// -/// @param id The channel id -/// @return true if successful, false otherwise -bool channel_close(uint64_t id) -{ - Channel *channel; - - if (!(channel = find_rpc_channel(id))) { - return false; - } - - close_channel(channel); - return true; -} - -void channel_process_exit(uint64_t id, int status) -{ - Channel *channel = pmap_get(uint64_t)(channels, id); - - // channel_decref(channel); remove?? - channel->rpc.closed = true; -} - -// rstream.c:read_event() invokes this as stream->read_cb(). static void receive_msgpack(Stream *stream, RBuffer *rbuf, size_t c, void *data, bool eof) { @@ -236,7 +212,7 @@ static void receive_msgpack(Stream *stream, RBuffer *rbuf, size_t c, channel_incref(channel); if (eof) { - close_channel(channel); + channel_close(channel->id, kChannelPartRpc, NULL); char buf[256]; snprintf(buf, sizeof(buf), "ch %" PRIu64 " was closed by the client", channel->id); @@ -540,43 +516,25 @@ static void unsubscribe(Channel *channel, char *event) xfree(event_string); } -/// Close the channel streams/process and free the channel resources. -/// TODO: move to channel.h -static void close_channel(Channel *channel) + +/// Mark rpc state as closed, and release its reference to the channel. +/// Don't call this directly, call channel_close(id, kChannelPartRpc, &error) +void rpc_close(Channel *channel) { if (channel->rpc.closed) { return; } channel->rpc.closed = true; + channel_decref(channel); - switch (channel->streamtype) { - case kChannelStreamSocket: - stream_close(&channel->stream.socket, NULL, NULL); - break; - case kChannelStreamProc: - // Only close the rpc channel part, - // there could be an error message on the stderr stream - process_close_in(&channel->stream.proc); - process_close_out(&channel->stream.proc); - break; - case kChannelStreamStdio: - stream_close(&channel->stream.stdio.in, NULL, NULL); - stream_close(&channel->stream.stdio.out, NULL, NULL); - multiqueue_put(main_loop.fast_events, exit_event, 1, channel); - return; - case kChannelStreamInternal: - // nothing to free. - break; + if (channel->streamtype == kChannelStreamStdio) { + multiqueue_put(main_loop.fast_events, exit_event, 0); } - - channel_decref(channel); } static void exit_event(void **argv) { - channel_decref(argv[0]); - if (!exiting) { mch_exit(0); } @@ -642,7 +600,7 @@ static void call_set_error(Channel *channel, char *msg, int loglevel) frame->result = STRING_OBJ(cstr_to_string(msg)); } - close_channel(channel); + channel_close(channel->id, kChannelPartRpc, NULL); } static WBuffer *serialize_request(uint64_t channel_id, diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c index ec2ebb9d19..e32c6e05d2 100644 --- a/src/nvim/os/shell.c +++ b/src/nvim/os/shell.c @@ -677,10 +677,6 @@ static void shell_write_cb(Stream *stream, void *data, int status) msg_schedule_emsgf(_("E5677: Error writing input to shell-command: %s"), uv_err_name(status)); } - if (stream->closed) { // Process may have exited before this write. - WLOG("stream was already closed"); - return; - } stream_close(stream, NULL, NULL); } -- cgit From 5af47031773fc647de867444693d1598d0da458d Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Fri, 9 Jun 2017 08:40:24 +0200 Subject: channels: stderr channel --- src/nvim/channel.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++-- src/nvim/channel.h | 11 ++++++++ src/nvim/eval.c | 79 +++++++++++++++++++++++------------------------------- src/nvim/eval.h | 1 + src/nvim/eval.lua | 3 ++- src/nvim/globals.h | 4 --- src/nvim/main.c | 7 ++--- 7 files changed, 120 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 416e0a1fb6..4d9304472b 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -14,6 +14,12 @@ static bool did_stdio = false; PMap(uint64_t) *channels = NULL; +/// next free id for a job or rpc channel +/// 1 is reserved for stdio channel +/// 2 is reserved for stderr channel +static uint64_t next_chan_id = CHAN_STDERR+1; + + typedef struct { Channel *data; Callback *callback; @@ -73,7 +79,6 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error) } } else if ((part == kChannelPartStdin || part == kChannelPartStdout) && chan->is_rpc) { - // EMSG(_("Invalid stream on rpc job, use jobclose(id, 'rpc')")); *error = (const char *)e_invstreamrpc; return false; } @@ -117,6 +122,21 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error) } break; + case kChannelStreamStderr: + if (part != kChannelPartAll && part != kChannelPartStderr) { + *error = (const char *)e_invstream; + return false; + } + if (!chan->stream.err.closed) { + chan->stream.err.closed = true; + // Don't close on exit, in case late error messages + if (!exiting) { + fclose(stderr); + } + channel_decref(chan); + } + break; + case kChannelStreamInternal: if (!close_main) { *error = (const char *)e_invstream; @@ -132,6 +152,7 @@ bool channel_close(uint64_t id, ChannelPart part, const char **error) void channel_init(void) { channels = pmap_new(uint64_t)(); + channel_alloc(kChannelStreamStderr); rpc_init(); remote_ui_init(); } @@ -143,7 +164,13 @@ void channel_init(void) static Channel *channel_alloc(ChannelStreamType type) { Channel *chan = xcalloc(1, sizeof(*chan)); - chan->id = type == kChannelStreamStdio ? 1 : next_chan_id++; + if (type == kChannelStreamStdio) { + chan->id = CHAN_STDIO; + } else if (type == kChannelStreamStderr) { + chan->id = CHAN_STDERR; + } else { + chan->id = next_chan_id++; + } chan->events = multiqueue_new_child(main_loop.events); chan->refcount = 1; chan->streamtype = type; @@ -403,6 +430,46 @@ uint64_t channel_from_stdio(bool rpc, CallbackReader on_output, return channel->id; } +/// @param data will be consumed +size_t channel_send(uint64_t id, char *data, size_t len, const char **error) +{ + Channel *chan = find_channel(id); + if (!chan) { + EMSG(_(e_invchan)); + goto err; + } + + if (chan->streamtype == kChannelStreamStderr) { + if (chan->stream.err.closed) { + *error = _("Can't send data to closed stream"); + goto err; + } + // unbuffered write + size_t written = fwrite(data, len, 1, stderr); + xfree(data); + return len * written; + } + + + Stream *in = channel_instream(chan); + if (in->closed) { + *error = _("Can't send data to closed stream"); + goto err; + } + + if (chan->is_rpc) { + *error = _("Can't send raw data to rpc channel"); + goto err; + } + + WBuffer *buf = wstream_new_buffer(data, len, 1, xfree); + return wstream_write(in, buf) ? len : 0; + +err: + xfree(data); + return 0; +} + // vimscript job callbacks must be executed on Nvim main loop static inline void process_channel_event(Channel *chan, Callback *callback, const char *type, char *buf, diff --git a/src/nvim/channel.h b/src/nvim/channel.h index eaf0fd92d0..ee119756c0 100644 --- a/src/nvim/channel.h +++ b/src/nvim/channel.h @@ -9,10 +9,14 @@ #include "nvim/eval/typval.h" #include "nvim/msgpack_rpc/channel_defs.h" +#define CHAN_STDIO 1 +#define CHAN_STDERR 2 + typedef enum { kChannelStreamProc, kChannelStreamSocket, kChannelStreamStdio, + kChannelStreamStderr, kChannelStreamInternal } ChannelStreamType; @@ -30,6 +34,10 @@ typedef struct { Stream out; } StdioPair; +typedef struct { + bool closed; +} StderrState; + typedef struct { Callback cb; garray_T buffer; @@ -56,6 +64,7 @@ struct Channel { PtyProcess pty; Stream socket; StdioPair stdio; + StderrState err; } stream; bool is_rpc; @@ -95,6 +104,7 @@ static inline Stream *channel_instream(Channel *chan) return &chan->stream.stdio.out; case kChannelStreamInternal: + case kChannelStreamStderr: abort(); } abort(); @@ -114,6 +124,7 @@ static inline Stream *channel_outstream(Channel *chan) return &chan->stream.stdio.in; case kChannelStreamInternal: + case kChannelStreamStderr: abort(); } abort(); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index ba356f28b9..f92e2d8d65 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -366,6 +366,7 @@ static struct vimvar { VV(VV_DYING, "dying", VAR_NUMBER, VV_RO), VV(VV_EXCEPTION, "exception", VAR_STRING, VV_RO), VV(VV_THROWPOINT, "throwpoint", VAR_STRING, VV_RO), + VV(VV_STDERR, "stderr", VAR_NUMBER, VV_RO), VV(VV_REG, "register", VAR_STRING, VV_RO), VV(VV_CMDBANG, "cmdbang", VAR_NUMBER, VV_RO), VV(VV_INSERTMODE, "insertmode", VAR_STRING, VV_RO), @@ -586,6 +587,7 @@ void eval_init(void) v_event->dv_lock = VAR_FIXED; set_vim_var_dict(VV_EVENT, v_event); set_vim_var_list(VV_ERRORS, tv_list_alloc()); + set_vim_var_nr(VV_STDERR, CHAN_STDERR); set_vim_var_nr(VV_SEARCHFORWARD, 1L); set_vim_var_nr(VV_HLSEARCH, 1L); set_vim_var_nr(VV_COUNT1, 1); @@ -7361,6 +7363,37 @@ static void f_chanclose(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } +// "chansend(id, data)" function +static void f_chansend(typval_T *argvars, typval_T *rettv, FunPtr fptr) +{ + rettv->v_type = VAR_NUMBER; + rettv->vval.v_number = 0; + + if (check_restricted() || check_secure()) { + return; + } + + if (argvars[0].v_type != VAR_NUMBER || argvars[1].v_type == VAR_UNKNOWN) { + // First argument is the channel id and second is the data to write + EMSG(_(e_invarg)); + return; + } + + ptrdiff_t input_len = 0; + char *input = save_tv_as_string(&argvars[1], &input_len, false); + if (!input) { + // Either the error has been handled by save_tv_as_string(), + // or there is no input to send. + return; + } + uint64_t id = argvars[0].vval.v_number; + const char *error = NULL; + rettv->vval.v_number = channel_send(id, input, input_len, &error); + if (error) { + EMSG(error); + } +} + /* * "char2nr(string)" function */ @@ -11454,52 +11487,6 @@ static void f_jobpid(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->vval.v_number = proc->pid; } -// "jobsend()" function -static void f_jobsend(typval_T *argvars, typval_T *rettv, FunPtr fptr) -{ - rettv->v_type = VAR_NUMBER; - rettv->vval.v_number = 0; - - if (check_restricted() || check_secure()) { - return; - } - - if (argvars[0].v_type != VAR_NUMBER || argvars[1].v_type == VAR_UNKNOWN) { - // First argument is the job id and second is the string or list to write - // to the job's stdin - EMSG(_(e_invarg)); - return; - } - - Channel *data = find_channel(argvars[0].vval.v_number); - if (!data) { - EMSG(_(e_invchan)); - return; - } - - Stream *in = channel_instream(data); - if (in->closed) { - EMSG(_("Can't send data to the job: stdin is closed")); - return; - } - - if (data->is_rpc) { - EMSG(_("Can't send raw data to rpc channel")); - return; - } - - ptrdiff_t input_len = 0; - char *input = save_tv_as_string(&argvars[1], &input_len, false); - if (!input) { - // Either the error has been handled by save_tv_as_string(), or there is no - // input to send. - return; - } - - WBuffer *buf = wstream_new_buffer(input, input_len, 1, xfree); - rettv->vval.v_number = wstream_write(in, buf); -} - // "jobresize(job, width, height)" function static void f_jobresize(typval_T *argvars, typval_T *rettv, FunPtr fptr) { diff --git a/src/nvim/eval.h b/src/nvim/eval.h index 7814a086fa..0c0a6881f6 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -56,6 +56,7 @@ typedef enum { VV_DYING, VV_EXCEPTION, VV_THROWPOINT, + VV_STDERR, VV_REG, VV_CMDBANG, VV_INSERTMODE, diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index bb03691fd4..54cbc54d78 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -56,6 +56,7 @@ return { ceil={args=1, func="float_op_wrapper", data="&ceil"}, changenr={}, chanclose={args={1, 2}}, + chansend={args=2}, char2nr={args={1, 2}}, cindent={args=1}, clearmatches={}, @@ -177,7 +178,7 @@ return { jobclose={args={1, 2}, func="f_chanclose"}, jobpid={args=1}, jobresize={args=3}, - jobsend={args=2}, + jobsend={args=2, func="f_chansend"}, jobstart={args={1, 2}}, jobstop={args=1}, jobwait={args={1, 2}}, diff --git a/src/nvim/globals.h b/src/nvim/globals.h index d1b0ad0ed3..dcb8b40973 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1199,10 +1199,6 @@ EXTERN bool embedded_mode INIT(= false); // or read/write to stdio (unless embedding) EXTERN bool headless_mode INIT(= false); -/// next free id for a job or rpc channel -/// 1 is reserved for stdio channel -EXTERN uint64_t next_chan_id INIT(= 2); - /// Used to track the status of external functions. /// Currently only used for iconv(). typedef enum { diff --git a/src/nvim/main.c b/src/nvim/main.c index 9059644fc0..aa57913f7c 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -297,7 +297,7 @@ int main(int argc, char **argv) assert(p_ch >= 0 && Rows >= p_ch && Rows - p_ch <= INT_MAX); cmdline_row = (int)(Rows - p_ch); msg_row = cmdline_row; - screenalloc(false); /* allocate screen buffers */ + screenalloc(false); // allocate screen buffers set_init_2(headless_mode); TIME_MSG("inits 2"); @@ -310,8 +310,9 @@ int main(int argc, char **argv) /* Set the break level after the terminal is initialized. */ debug_break_level = params.use_debug_break_level; - bool reading_input = !headless_mode && (params.input_isatty - || params.output_isatty || params.err_isatty); + bool reading_input = !headless_mode + && (params.input_isatty || params.output_isatty + || params.err_isatty); if (reading_input) { // One of the startup commands (arguments, sourced scripts or plugins) may -- cgit From 5517d2323ba359d5ed0cb9f0e9abdfc2a9871894 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 23 Jul 2017 19:23:02 +0200 Subject: channels: reimplement logging (as stub for proper event) --- src/nvim/channel.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/nvim/eval.c | 19 +++++++++++++----- 2 files changed, 73 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 4d9304472b..e2ac79794f 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -178,6 +178,62 @@ static Channel *channel_alloc(ChannelStreamType type) return chan; } +/// Not implemented, only logging for now +void channel_create_event(Channel *chan, char *ext_source) +{ +#if MIN_LOG_LEVEL <= INFO_LOG_LEVEL + char *stream_desc, *mode_desc, *source; + + switch (chan->streamtype) { + case kChannelStreamProc: + if (chan->stream.proc.type == kProcessTypePty) { + stream_desc = "pty job"; + } else { + stream_desc = "job"; + } + break; + + case kChannelStreamStdio: + stream_desc = "stdio"; + break; + + case kChannelStreamSocket: + stream_desc = "socket"; + break; + + case kChannelStreamInternal: + stream_desc = "socket (internal)"; + break; + + default: + stream_desc = "?"; + } + + if (chan->is_rpc) { + mode_desc = ", rpc"; + } else if (chan->term) { + mode_desc = ", terminal"; + } else { + mode_desc = ""; + } + + if (ext_source) { + // TODO(bfredl): in a future improved traceback solution, + // external events should be included. + source = ext_source; + } else { + eval_format_source_name_line((char *)IObuff, sizeof(IObuff)); + source = (char *)IObuff; + } + + ILOG("new channel %" PRIu64 " (%s%s): %s", chan->id, stream_desc, + mode_desc, source); +#else + (void)chan; + (void)ext_source; +#endif +} + void channel_incref(Channel *channel) { channel->refcount++; @@ -329,6 +385,7 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, rstream_init(&proc->err, 0); rstream_start(&proc->err, on_job_stderr, chan); } + *status_out = (varnumber_T)chan->id; return chan; } @@ -369,6 +426,7 @@ uint64_t channel_connect(bool tcp, const char *address, rstream_start(&channel->stream.socket, on_socket_output, channel); } + channel_create_event(channel, NULL); return channel->id; } @@ -384,6 +442,7 @@ void channel_from_connection(SocketWatcher *watcher) wstream_init(&channel->stream.socket, 0); rstream_init(&channel->stream.socket, 0); rpc_start(channel); + channel_create_event(channel, watcher->addr); } /// Creates a loopback channel. This is used to avoid deadlock diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f92e2d8d65..40ee3545b6 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -11643,8 +11643,12 @@ static void f_jobstart(typval_T *argvars, typval_T *rettv, FunPtr fptr) term_name = tv_dict_get_string(job_opts, "TERM", true); } - channel_job_start(argv, on_stdout, on_stderr, on_exit, pty, rpc, detach, - cwd, width, height, term_name, &rettv->vval.v_number); + Channel *chan = channel_job_start(argv, on_stdout, on_stderr, on_exit, pty, + rpc, detach, cwd, width, height, term_name, + &rettv->vval.v_number); + if (chan) { + channel_create_event(chan, NULL); + } } // "jobstop()" function @@ -13872,9 +13876,13 @@ static void f_rpcstart(typval_T *argvars, typval_T *rettv, FunPtr fptr) // The last item of argv must be NULL argv[i] = NULL; - channel_job_start(argv, CALLBACK_READER_INIT, CALLBACK_READER_INIT, - CALLBACK_NONE, false, true, false, NULL, 0, 0, NULL, - &rettv->vval.v_number); + Channel *chan = channel_job_start(argv, CALLBACK_READER_INIT, + CALLBACK_READER_INIT, CALLBACK_NONE, + false, true, false, NULL, 0, 0, NULL, + &rettv->vval.v_number); + if (chan) { + channel_create_event(chan, NULL); + } } // "rpcstop()" function @@ -16672,6 +16680,7 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) api_clear_error(&err); channel_terminal_open(chan); + channel_create_event(chan, NULL); } // "test_garbagecollect_now()" function -- cgit From f629f8312d2a830ce7999a6612203977ec83daf8 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 25 Jul 2017 11:59:08 +0200 Subject: channels: refactor jobwait --- src/nvim/channel.c | 8 +++--- src/nvim/channel.h | 2 -- src/nvim/eval.c | 71 ++++++++++++++++++++++-------------------------- src/nvim/event/process.c | 11 ++++---- src/nvim/event/process.h | 2 +- 5 files changed, 43 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/nvim/channel.c b/src/nvim/channel.c index e2ac79794f..019bd1545f 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -639,12 +639,12 @@ static void channel_process_exit_cb(Process *proc, int status, void *data) terminal_close(chan->term, msg); } - if (chan->status_ptr) { - *chan->status_ptr = status; + // if status is -1 the process did not really exit, + // we just closed the handle onto a detached process + if (status >= 0) { + process_channel_event(chan, &chan->on_exit, "exit", NULL, 0, status); } - process_channel_event(chan, &chan->on_exit, "exit", NULL, 0, status); - channel_decref(chan); } diff --git a/src/nvim/channel.h b/src/nvim/channel.h index ee119756c0..48c21e37f8 100644 --- a/src/nvim/channel.h +++ b/src/nvim/channel.h @@ -74,8 +74,6 @@ struct Channel { CallbackReader on_stdout; CallbackReader on_stderr; Callback on_exit; - - varnumber_T *status_ptr; // TODO: refactor? }; EXTERN PMap(uint64_t) *channels; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 40ee3545b6..5fa92cedbd 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -11693,28 +11693,31 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } + list_T *args = argvars[0].vval.v_list; - list_T *rv = tv_list_alloc(); + Channel **jobs = xcalloc(args->lv_len, sizeof(*jobs)); ui_busy_start(); MultiQueue *waiting_jobs = multiqueue_new_parent(loop_on_put, &main_loop); // For each item in the input list append an integer to the output list. -3 // is used to represent an invalid job id, -2 is for a interrupted job and // -1 for jobs that were skipped or timed out. - for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { - Channel *data = NULL; + + int i = 0; + for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next, i++) { + Channel *chan = NULL; if (arg->li_tv.v_type != VAR_NUMBER - || !(data = find_job(arg->li_tv.vval.v_number, false))) { - tv_list_append_number(rv, -3); + || !(chan = find_job(arg->li_tv.vval.v_number, false))) { + jobs[i] = NULL; } else { - // append the list item and set the status pointer so we'll collect the - // status code when the job exits - tv_list_append_number(rv, -1); - data->status_ptr = &rv->lv_last->li_tv.vval.v_number; - // Process any pending events for the job because we'll temporarily - // replace the parent queue - multiqueue_process_events(data->events); - multiqueue_replace_parent(data->events, waiting_jobs); + jobs[i] = chan; + channel_incref(chan); + if (chan->stream.proc.status < 0) { + // Process any pending events for the job because we'll temporarily + // replace the parent queue + multiqueue_process_events(chan->events); + multiqueue_replace_parent(chan->events, waiting_jobs); + } } } @@ -11725,25 +11728,21 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) before = os_hrtime(); } - for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { - Channel *data = NULL; + for (i = 0; i < args->lv_len; i++) { if (remaining == 0) { // timed out break; } - if (arg->li_tv.v_type != VAR_NUMBER - || !(data = find_job(arg->li_tv.vval.v_number, false))) { + + // if the job already exited, but wasn't freed yet + if (jobs[i] == NULL || jobs[i]->stream.proc.status >= 0) { continue; } - int status = process_wait((Process *)&data->stream.proc, remaining, + + int status = process_wait(&jobs[i]->stream.proc, remaining, waiting_jobs); if (status < 0) { // interrupted or timed out, skip remaining jobs. - if (status == -2) { - // set the status so the user can distinguish between interrupted and - // skipped/timeout jobs. - *data->status_ptr = -2; - } break; } if (remaining > 0) { @@ -11756,30 +11755,24 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } - for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { - Channel *data = NULL; - if (arg->li_tv.v_type != VAR_NUMBER - || !(data = find_job(arg->li_tv.vval.v_number, false))) { - continue; - } - // remove the status pointer because the list may be freed before the - // job exits - data->status_ptr = NULL; - } + list_T *rv = tv_list_alloc(); // restore the parent queue for any jobs still alive - for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { - Channel *data = NULL; - if (arg->li_tv.v_type != VAR_NUMBER - || !(data = find_job(arg->li_tv.vval.v_number, false))) { + for (i = 0; i < args->lv_len; i++) { + if (jobs[i] == NULL) { + tv_list_append_number(rv, -3); continue; } // restore the parent queue for the job - multiqueue_process_events(data->events); - multiqueue_replace_parent(data->events, main_loop.events); + multiqueue_process_events(jobs[i]->events); + multiqueue_replace_parent(jobs[i]->events, main_loop.events); + + tv_list_append_number(rv, jobs[i]->stream.proc.status); + channel_decref(jobs[i]); } multiqueue_free(waiting_jobs); + xfree(jobs); ui_busy_stop(); rv->lv_refcount++; rettv->v_type = VAR_LIST; diff --git a/src/nvim/event/process.c b/src/nvim/event/process.c index 34be291aef..4eb2dd0baf 100644 --- a/src/nvim/event/process.c +++ b/src/nvim/event/process.c @@ -145,16 +145,15 @@ void process_close_streams(Process *proc) FUNC_ATTR_NONNULL_ALL /// @param process Process instance /// @param ms Time in milliseconds to wait for the process. /// 0 for no wait. -1 to wait until the process quits. -/// @return Exit code of the process. +/// @return Exit code of the process. proc->status will have the same value. /// -1 if the timeout expired while the process is still running. /// -2 if the user interruped the wait. int process_wait(Process *proc, int ms, MultiQueue *events) FUNC_ATTR_NONNULL_ARG(1) { - int status = -1; // default bool interrupted = false; if (!proc->refcount) { - status = proc->status; + int status = proc->status; LOOP_PROCESS_EVENTS(proc->loop, proc->events, 0); return status; } @@ -190,7 +189,9 @@ int process_wait(Process *proc, int ms, MultiQueue *events) if (proc->refcount == 1) { // Job exited, collect status and manually invoke close_cb to free the job // resources - status = interrupted ? -2 : proc->status; + if (interrupted) { + proc->status = -2; + } decref(proc); if (events) { // the decref call created an exit event, process it now @@ -200,7 +201,7 @@ int process_wait(Process *proc, int ms, MultiQueue *events) proc->refcount--; } - return status; + return proc->status; } /// Ask a process to terminate and eventually kill if it doesn't respond diff --git a/src/nvim/event/process.h b/src/nvim/event/process.h index a8d066c291..033ce3604b 100644 --- a/src/nvim/event/process.h +++ b/src/nvim/event/process.h @@ -39,7 +39,7 @@ static inline Process process_init(Loop *loop, ProcessType type, void *data) .loop = loop, .events = NULL, .pid = 0, - .status = 0, + .status = -1, .refcount = 0, .stopped_time = 0, .cwd = NULL, -- cgit From fee367a74f3269fd0543bae128c8aaee21f5e592 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 27 Aug 2017 12:42:26 +0200 Subject: channels: more consistent event handling terminal: libvterm now receives data in async context. This was "almost" safe already, as redraws were queued anyway. --- src/nvim/channel.c | 45 ++++++++++++++++++++------------------------- src/nvim/terminal.c | 5 ++--- 2 files changed, 22 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 019bd1545f..1c34b2ffce 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -21,7 +21,7 @@ static uint64_t next_chan_id = CHAN_STDERR+1; typedef struct { - Channel *data; + Channel *chan; Callback *callback; const char *type; list_T *received; @@ -348,9 +348,6 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, has_err = callback_reader_set(chan->on_stderr); } int status = process_spawn(proc, true, has_out, has_err); - if (has_err) { - proc->err.events = chan->events; - } if (status) { EMSG3(_(e_jobspawn), os_strerror(status), cmd); xfree(cmd); @@ -372,10 +369,8 @@ Channel *channel_job_start(char **argv, CallbackReader on_stdout, // the rpc takes over the in and out streams rpc_start(chan); } else { - proc->in.events = chan->events; if (has_out) { callback_reader_start(&chan->on_stdout); - proc->out.events = chan->events; rstream_start(&proc->out, on_job_stdout, chan); } } @@ -422,7 +417,6 @@ uint64_t channel_connect(bool tcp, const char *address, } else { channel->on_stdout = on_output; callback_reader_start(&channel->on_stdout); - channel->stream.socket.events = channel->events; rstream_start(&channel->stream.socket, on_socket_output, channel); } @@ -481,8 +475,6 @@ uint64_t channel_from_stdio(bool rpc, CallbackReader on_output, } else { channel->on_stdout = on_output; callback_reader_start(&channel->on_stdout); - channel->stream.stdio.in.events = channel->events; - channel->stream.stdio.out.events = channel->events; rstream_start(&channel->stream.stdio.in, on_stdio_input, channel); } @@ -534,10 +526,11 @@ static inline void process_channel_event(Channel *chan, Callback *callback, const char *type, char *buf, size_t count, int status) { - ChannelEvent event_data; - event_data.received = NULL; + assert(callback); + ChannelEvent *event_data = xmalloc(sizeof(*event_data)); + event_data->received = NULL; if (buf) { - event_data.received = tv_list_alloc(); + event_data->received = tv_list_alloc(); char *ptr = buf; size_t remaining = count; size_t off = 0; @@ -545,7 +538,7 @@ static inline void process_channel_event(Channel *chan, Callback *callback, while (off < remaining) { // append the line if (ptr[off] == NL) { - tv_list_append_string(event_data.received, ptr, (ssize_t)off); + tv_list_append_string(event_data->received, ptr, (ssize_t)off); size_t skip = off + 1; ptr += skip; remaining -= skip; @@ -558,14 +551,16 @@ static inline void process_channel_event(Channel *chan, Callback *callback, } off++; } - tv_list_append_string(event_data.received, ptr, (ssize_t)off); + tv_list_append_string(event_data->received, ptr, (ssize_t)off); } else { - event_data.status = status; + event_data->status = status; } - event_data.data = chan; - event_data.callback = callback; - event_data.type = type; - on_channel_event(&event_data); + channel_incref(chan); // Hold on ref to callback + event_data->chan = chan; + event_data->callback = callback; + event_data->type = type; + + multiqueue_put(chan->events, on_channel_event, 1, event_data); } void on_job_stdout(Stream *stream, RBuffer *buf, size_t count, @@ -608,7 +603,7 @@ static void on_channel_output(Stream *stream, Channel *chan, RBuffer *buf, if (eof) { if (reader->buffered) { process_channel_event(chan, &reader->cb, type, reader->buffer.ga_data, - (size_t)reader->buffer.ga_len, 0); + (size_t)reader->buffer.ga_len, 0); ga_clear(&reader->buffer); } else if (callback_reader_set(*reader)) { process_channel_event(chan, &reader->cb, type, ptr, 0, 0); @@ -648,17 +643,15 @@ static void channel_process_exit_cb(Process *proc, int status, void *data) channel_decref(chan); } -static void on_channel_event(ChannelEvent *ev) +static void on_channel_event(void **args) { - if (!ev->callback) { - return; - } + ChannelEvent *ev = (ChannelEvent *)args[0]; typval_T argv[4]; argv[0].v_type = VAR_NUMBER; argv[0].v_lock = VAR_UNLOCKED; - argv[0].vval.v_number = (varnumber_T)ev->data->id; + argv[0].vval.v_number = (varnumber_T)ev->chan->id; if (ev->received) { argv[1].v_type = VAR_LIST; @@ -678,6 +671,8 @@ static void on_channel_event(ChannelEvent *ev) typval_T rettv = TV_INITIAL_VALUE; callback_call(ev->callback, 3, argv, &rettv); tv_clear(&rettv); + channel_decref(ev->chan); + xfree(ev); } diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c index 1dac9c69bd..dfa758f41e 100644 --- a/src/nvim/terminal.c +++ b/src/nvim/terminal.c @@ -1094,11 +1094,12 @@ static void refresh_terminal(Terminal *term) // Calls refresh_terminal() on all invalidated_terminals. static void refresh_timer_cb(TimeWatcher *watcher, void *data) { + refresh_pending = false; if (exiting // Cannot redraw (requires event loop) during teardown/exit. // WM_LIST (^D) is not redrawn, unlike the normal wildmenu. So we must // skip redraws to keep it visible. || wild_menu_showing == WM_LIST) { - goto end; + return; } Terminal *term; void *stub; (void)(stub); @@ -1113,8 +1114,6 @@ static void refresh_timer_cb(TimeWatcher *watcher, void *data) if (any_visible) { redraw(true); } -end: - refresh_pending = false; } static void refresh_size(Terminal *term, buf_T *buf) -- cgit From a97cdff14df1bb788a4b659e0db94e2b2ba1f539 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Sun, 17 Sep 2017 16:23:39 +0200 Subject: channels: improvements to buffering --- src/nvim/channel.c | 70 +++++++++++++++++++++++++++++++++--------------------- src/nvim/channel.h | 4 +++- src/nvim/eval.c | 25 ++++++++++++++++++- 3 files changed, 70 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 1c34b2ffce..40af470bde 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -257,7 +257,8 @@ void callback_reader_free(CallbackReader *reader) void callback_reader_start(CallbackReader *reader) { if (reader->buffered) { - ga_init(&reader->buffer, sizeof(char *), 1); + ga_init(&reader->buffer, sizeof(char *), 32); + ga_grow(&reader->buffer, 32); } } @@ -521,6 +522,34 @@ err: return 0; } +/// NB: mutates buf in place! +static list_T *buffer_to_tv_list(char *buf, size_t count) +{ + list_T *ret = tv_list_alloc(); + char *ptr = buf; + size_t remaining = count; + size_t off = 0; + + while (off < remaining) { + // append the line + if (ptr[off] == NL) { + tv_list_append_string(ret, ptr, (ssize_t)off); + size_t skip = off + 1; + ptr += skip; + remaining -= skip; + off = 0; + continue; + } + if (ptr[off] == NUL) { + // Translate NUL to NL + ptr[off] = NL; + } + off++; + } + tv_list_append_string(ret, ptr, (ssize_t)off); + return ret; +} + // vimscript job callbacks must be executed on Nvim main loop static inline void process_channel_event(Channel *chan, Callback *callback, const char *type, char *buf, @@ -530,28 +559,7 @@ static inline void process_channel_event(Channel *chan, Callback *callback, ChannelEvent *event_data = xmalloc(sizeof(*event_data)); event_data->received = NULL; if (buf) { - event_data->received = tv_list_alloc(); - char *ptr = buf; - size_t remaining = count; - size_t off = 0; - - while (off < remaining) { - // append the line - if (ptr[off] == NL) { - tv_list_append_string(event_data->received, ptr, (ssize_t)off); - size_t skip = off + 1; - ptr += skip; - remaining -= skip; - off = 0; - continue; - } - if (ptr[off] == NUL) { - // Translate NUL to NL - ptr[off] = NL; - } - off++; - } - tv_list_append_string(event_data->received, ptr, (ssize_t)off); + event_data->received = buffer_to_tv_list(buf, count); } else { event_data->status = status; } @@ -602,10 +610,18 @@ static void on_channel_output(Stream *stream, Channel *chan, RBuffer *buf, if (eof) { if (reader->buffered) { - process_channel_event(chan, &reader->cb, type, reader->buffer.ga_data, - (size_t)reader->buffer.ga_len, 0); - ga_clear(&reader->buffer); - } else if (callback_reader_set(*reader)) { + if (reader->cb.type != kCallbackNone) { + process_channel_event(chan, &reader->cb, type, reader->buffer.ga_data, + (size_t)reader->buffer.ga_len, 0); + ga_clear(&reader->buffer); + } else if (reader->self) { + list_T *data = buffer_to_tv_list(reader->buffer.ga_data, + (size_t)reader->buffer.ga_len); + tv_dict_add_list(reader->self, type, strlen(type), data); + } else { + abort(); + } + } else if (reader->cb.type != kCallbackNone) { process_channel_event(chan, &reader->cb, type, ptr, 0, 0); } return; diff --git a/src/nvim/channel.h b/src/nvim/channel.h index 48c21e37f8..b856d197f1 100644 --- a/src/nvim/channel.h +++ b/src/nvim/channel.h @@ -40,16 +40,18 @@ typedef struct { typedef struct { Callback cb; + dict_T *self; garray_T buffer; bool buffered; } CallbackReader; #define CALLBACK_READER_INIT ((CallbackReader){ .cb = CALLBACK_NONE, \ + .self = NULL, \ .buffer = GA_EMPTY_INIT_VALUE, \ .buffered = false }) static inline bool callback_reader_set(CallbackReader reader) { - return reader.cb.type != kCallbackNone; + return reader.cb.type != kCallbackNone || reader.self; } struct Channel { diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 5fa92cedbd..577aa67c60 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -15090,6 +15090,9 @@ static void f_sockconnect(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } on_data.buffered = tv_dict_get_number(opts, "data_buffered"); + if (on_data.buffered && on_data.cb.type == kCallbackNone) { + on_data.self = opts; + } } const char *error = NULL; @@ -15490,6 +15493,10 @@ static void f_stdioopen(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (!tv_dict_get_callback(opts, S_LEN("on_stdin"), &on_stdin.cb)) { return; } + on_stdin.buffered = tv_dict_get_number(opts, "stdin_buffered"); + if (on_stdin.buffered && on_stdin.cb.type == kCallbackNone) { + on_stdin.self = opts; + } const char *error; uint64_t id = channel_from_stdio(rpc, on_stdin, &error); @@ -16764,7 +16771,17 @@ static bool set_ref_in_callback_reader(CallbackReader *reader, int copyID, ht_stack_T **ht_stack, list_stack_T **list_stack) { - return set_ref_in_callback(&reader->cb, copyID, ht_stack, list_stack); + if (set_ref_in_callback(&reader->cb, copyID, ht_stack, list_stack)) { + return true; + } + + if (reader->self) { + typval_T tv; + tv.v_type = VAR_DICT; + tv.vval.v_dict = reader->self; + return set_ref_in_item(&tv, copyID, ht_stack, list_stack); + } + return false; } static void add_timer_info(typval_T *rettv, timer_T *timer) @@ -22344,6 +22361,12 @@ static inline bool common_job_callbacks(dict_T *vopts, && tv_dict_get_callback(vopts, S_LEN("on_exit"), on_exit)) { on_stdout->buffered = tv_dict_get_number(vopts, "stdout_buffered"); on_stderr->buffered = tv_dict_get_number(vopts, "stderr_buffered"); + if (on_stdout->buffered && on_stdout->cb.type == kCallbackNone) { + on_stdout->self = vopts; + } + if (on_stderr->buffered && on_stderr->cb.type == kCallbackNone) { + on_stderr->self = vopts; + } vopts->dv_refcount++; return true; } -- cgit From 9acd7bfe25b5ea2b31ffbbdbd201f5f09afc4237 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 10 Jul 2017 01:58:54 +0200 Subject: tui: job-control: use saved termios for pty jobs On startup, if running in a terminal, save the termios properties. Use the saved termios for `:terminal` and `jobstart()` pty jobs. This won't affect nvim spawned outside of a terminal. questions: - This affects `:terminal` and `jobstart({'pty':v:true})`. Should we be more conservative for `jobstart({'pty':v:true})` (e.g. pass NULL to forkpty() and let the OS defaults prevail)? - Note: `iutf8` would not be set in that case. --- src/nvim/main.c | 11 +++++++++++ src/nvim/os/pty_process_unix.c | 21 +++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index aa57913f7c..0346414697 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -73,6 +73,9 @@ #include "nvim/api/private/helpers.h" #include "nvim/api/private/handle.h" #include "nvim/api/private/dispatch.h" +#ifndef WIN32 +# include "nvim/os/pty_process_unix.h" +#endif /* Maximum number of commands from + or -c arguments. */ #define MAX_ARG_CMDS 10 @@ -1247,6 +1250,14 @@ static void check_and_set_isatty(mparm_T *paramp) stdout_isatty = paramp->output_isatty = os_isatty(fileno(stdout)); paramp->err_isatty = os_isatty(fileno(stderr)); + int tty_fd = paramp->input_isatty + ? OS_STDIN_FILENO + : (paramp->output_isatty + ? OS_STDOUT_FILENO + : (paramp->err_isatty ? OS_STDERR_FILENO : -1)); +#ifndef WIN32 + pty_process_save_termios(tty_fd); +#endif TIME_MSG("window checked"); } diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c index e39f837c1a..53301e4b53 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_process_unix.c @@ -36,13 +36,26 @@ # include "os/pty_process_unix.c.generated.h" #endif +/// termios saved at startup (for TUI) or initialized by pty_process_spawn(). +static struct termios termios_default; + +/// Saves the termios properties associated with `tty_fd`. +/// +/// @param tty_fd TTY file descriptor, or -1 if not in a terminal. +void pty_process_save_termios(int tty_fd) +{ + if (tty_fd == -1 || tcgetattr(tty_fd, &termios_default) != 0) { + return; + } +} + /// @returns zero on success, or negative error code int pty_process_spawn(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL { - static struct termios termios; - if (!termios.c_cflag) { - init_termios(&termios); + if (!termios_default.c_cflag) { + // TODO(jkeyes): We could pass NULL to forkpty() instead ... + init_termios(&termios_default); } int status = 0; // zero or negative error code (libuv convention) @@ -52,7 +65,7 @@ int pty_process_spawn(PtyProcess *ptyproc) ptyproc->winsize = (struct winsize){ ptyproc->height, ptyproc->width, 0, 0 }; uv_disable_stdio_inheritance(); int master; - int pid = forkpty(&master, NULL, &termios, &ptyproc->winsize); + int pid = forkpty(&master, NULL, &termios_default, &ptyproc->winsize); if (pid < 0) { status = -errno; -- cgit From 85bc6630c0a8259c713383c8787e65f92e24e600 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Wed, 6 Sep 2017 08:16:59 +0200 Subject: input: only change mode of input fd if there is an input fd --- src/nvim/if_cscope.c | 1 - src/nvim/misc1.c | 5 ++++- src/nvim/os/input.c | 2 +- src/nvim/os_unix.c | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 0f9ecdf2d7..6834e7a802 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -778,7 +778,6 @@ err_closing: if (execl("/bin/sh", "sh", "-c", cmd, (char *)NULL) == -1) PERROR(_("cs_create_connection exec failed")); - stream_set_blocking(input_global_fd(), true); // normalize stream (#2598) exit(127); /* NOTREACHED */ default: /* parent. */ diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 137de84953..f7ee2950ef 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -2622,7 +2622,10 @@ void preserve_exit(void) // Prevent repeated calls into this method. if (really_exiting) { - stream_set_blocking(input_global_fd(), true); //normalize stream (#2598) + if (input_global_fd() >= 0) { + // normalize stream (#2598) + stream_set_blocking(input_global_fd(), true); + } exit(2); } diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c index 31e06ce404..7d6f2abd7f 100644 --- a/src/nvim/os/input.c +++ b/src/nvim/os/input.c @@ -37,7 +37,7 @@ typedef enum { static Stream read_stream = {.closed = true}; static RBuffer *input_buffer = NULL; static bool input_eof = false; -static int global_fd = 0; +static int global_fd = -1; static int events_enabled = 0; static bool blocking = false; diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c index 692bcc97f4..d7ba675b68 100644 --- a/src/nvim/os_unix.c +++ b/src/nvim/os_unix.c @@ -144,7 +144,9 @@ void mch_exit(int r) FUNC_ATTR_NORETURN if (!event_teardown() && r == 0) { r = 1; // Exit with error if main_loop did not teardown gracefully. } - stream_set_blocking(input_global_fd(), true); // normalize stream (#2598) + if (input_global_fd() >= 0) { + stream_set_blocking(input_global_fd(), true); // normalize stream (#2598) + } #ifdef EXITFREE free_all_mem(); -- cgit From 0f9c90e0edd27d2db04d48e7bd98bb46d2c4a918 Mon Sep 17 00:00:00 2001 From: Matt Widmann Date: Sat, 25 Nov 2017 13:59:07 -0800 Subject: io: retry fgets on EINTR (#7632) The calls to `fgets` in `src/nvim/if_cscope.c` (and elsewhere) can show communication errors to the user if a signal is delivered during its system calls. For plugins that proxy subprocess output into cscope requests, a `SIGCHLD` might *always* interfere with calls into `fgets`. To see this in a debugger, put a breakpoint on `cs_reading_emsg` and watch signals come in (with lldb, using `process handle --notify true --pass true`). Next, run a subcommand from neovim that calls through cscope when it returns. A tag picker plugin, like vim-picker and fzy, with `cscopetag` and `cscopetagorder=0` set, reproduced this reliably. The breakpoint will hit after a `SIGCHLD` is delivered, and `errno` will be set to 4, `EINTR`. The caller of `fgets` should retry when `NULL` is returned with `errno` set to `EINTR`. --- src/nvim/ex_cmds2.c | 6 ++++++ src/nvim/fileio.c | 5 +++++ src/nvim/if_cscope.c | 17 +++++++++++++++-- src/nvim/quickfix.c | 20 +++++++++++++++++--- 4 files changed, 43 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 9b8e463aee..ec4ce63e17 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -3199,8 +3199,14 @@ static char_u *get_one_sourceline(struct source_cookie *sp) ga_grow(&ga, 120); buf = (char_u *)ga.ga_data; +retry: + errno = 0; if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len, sp->fp) == NULL) { + if (errno == EINTR) { + goto retry; + } + break; } len = ga.ga_len + (int)STRLEN(buf + ga.ga_len); diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index ae6c3f96e3..9214e1e644 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -4448,7 +4448,12 @@ bool vim_fgets(char_u *buf, int size, FILE *fp) FUNC_ATTR_NONNULL_ALL char tbuf[FGETS_SIZE]; buf[size - 2] = NUL; +retry: + errno = 0; eof = fgets((char *)buf, size, fp); + if (eof == NULL && errno == EINTR) { + goto retry; + } if (buf[size - 2] != NUL && buf[size - 2] != '\n') { buf[size - 1] = NUL; /* Truncate the line */ diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 0f9ecdf2d7..21e4b84074 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -553,9 +553,15 @@ static int cs_cnt_matches(size_t idx) char *buf = xmalloc(CSREAD_BUFSIZE); for (;; ) { + errno = 0; if (!fgets(buf, CSREAD_BUFSIZE, csinfo[idx].fr_fp)) { - if (feof(csinfo[idx].fr_fp)) + if (errno == EINTR) { + continue; + } + + if (feof(csinfo[idx].fr_fp)) { errno = EIO; + } cs_reading_emsg(idx); @@ -1381,9 +1387,16 @@ static char *cs_parse_results(size_t cnumber, char *buf, int bufsize, char *p; char *name; +retry: + errno = 0; if (fgets(buf, bufsize, csinfo[cnumber].fr_fp) == NULL) { - if (feof(csinfo[cnumber].fr_fp)) + if (errno == EINTR) { + goto retry; + } + + if (feof(csinfo[cnumber].fr_fp)) { errno = EIO; + } cs_reading_emsg(cnumber); diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index b9228e15b9..1fc585f0c9 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -570,7 +570,12 @@ static int qf_get_next_file_line(qfstate_T *state) { size_t growbuflen; +retry: + errno = 0; if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL) { + if (errno == EINTR) { + goto retry; + } return QF_END_OF_INPUT; } @@ -590,8 +595,12 @@ static int qf_get_next_file_line(qfstate_T *state) growbuflen = state->linelen; for (;;) { + errno = 0; if (fgets((char *)state->growbuf + growbuflen, (int)(state->growbufsiz - growbuflen), state->fd) == NULL) { + if (errno == EINTR) { + continue; + } break; } state->linelen = STRLEN(state->growbuf + growbuflen); @@ -612,9 +621,14 @@ static int qf_get_next_file_line(qfstate_T *state) while (discard) { // The current line is longer than LINE_MAXLEN, continue reading but // discard everything until EOL or EOF is reached. - if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL - || STRLEN(IObuff) < IOSIZE - 1 - || IObuff[IOSIZE - 1] == '\n') { + errno = 0; + if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL) { + if (errno == EINTR) { + continue; + } + break; + } + if (STRLEN(IObuff) < IOSIZE - 1 || IObuff[IOSIZE - 1] == '\n') { break; } } -- cgit From bab2f8200aea09ad32bbcb2e83404bbd4076a227 Mon Sep 17 00:00:00 2001 From: Matt Widmann Date: Sat, 25 Nov 2017 13:27:59 -0800 Subject: io: fix handling EOF in vim_fgets If an EOF is returned from `fgets`, `vim_fgets` might spin forever, as it tries to consume the current line. A `NULL` return value from `fgets` should break out of the function (unless `errno` is `EINTR`), and then `feof` should be used to check for the EOF condition on the stream. --- src/nvim/fileio.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 9214e1e644..1f4cd22754 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -4443,27 +4443,32 @@ char *modname(const char *fname, const char *ext, bool prepend_dot) /// @return true for end-of-file. bool vim_fgets(char_u *buf, int size, FILE *fp) FUNC_ATTR_NONNULL_ALL { - char *eof; -#define FGETS_SIZE 200 - char tbuf[FGETS_SIZE]; + char *retval; + assert(size > 0); buf[size - 2] = NUL; -retry: - errno = 0; - eof = fgets((char *)buf, size, fp); - if (eof == NULL && errno == EINTR) { - goto retry; - } + + do { + errno = 0; + retval = fgets((char *)buf, size, fp); + } while (retval == NULL && errno == EINTR); + if (buf[size - 2] != NUL && buf[size - 2] != '\n') { - buf[size - 1] = NUL; /* Truncate the line */ + char tbuf[200]; + + buf[size - 1] = NUL; // Truncate the line. - /* Now throw away the rest of the line: */ + // Now throw away the rest of the line: do { - tbuf[FGETS_SIZE - 2] = NUL; - ignoredp = fgets((char *)tbuf, FGETS_SIZE, fp); - } while (tbuf[FGETS_SIZE - 2] != NUL && tbuf[FGETS_SIZE - 2] != '\n'); + tbuf[sizeof(tbuf) - 2] = NUL; + errno = 0; + retval = fgets((char *)tbuf, sizeof(tbuf), fp); + if (retval == NULL && errno != EINTR) { + break; + } + } while (tbuf[sizeof(tbuf) - 2] != NUL && tbuf[sizeof(tbuf) - 2] != '\n'); } - return eof == NULL; + return retval ? false : feof(fp); } /// Read 2 bytes from "fd" and turn them into an int, MSB first. -- cgit From b1a4db0b69e4744f9a4b4e4844021bb9026f03a6 Mon Sep 17 00:00:00 2001 From: nate Date: Thu, 9 Nov 2017 13:33:37 -0800 Subject: :highlight : avoid redraw on error do_highlight() should not redraw if a validation error occurred. closes #7489 --- src/nvim/syntax.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index d28e996581..bc7362af72 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6648,7 +6648,7 @@ do_highlight(char_u *line, int forceit, int init) { if (error && idx == highlight_ga.ga_len) { syn_unadd_group(); } else { - if (is_normal_group) { + if (!error && is_normal_group) { // Need to update all groups, because they might be using "bg" and/or // "fg", which have been changed now. highlight_attr_set_all(); -- cgit From 17077b68133a62d0dc1b84cb48779464c117e028 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 26 Nov 2017 16:08:53 +0300 Subject: viml/parser/expressions: Make $ENV not depend on &isident --- src/nvim/api/vim.c | 2 +- src/nvim/viml/parser/expressions.c | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 7838f9faa3..a0816dbc8e 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -983,7 +983,7 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack; /// "DoubleQuotedString" nodes. Dictionary nvim_parse_expression(String expr, String flags, Boolean highlight, Error *err) - FUNC_API_SINCE(4) + FUNC_API_SINCE(4) FUNC_API_ASYNC { int pflags = 0; for (size_t i = 0 ; i < flags.size ; i++) { diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 6c7c328b6d..63ad6bab35 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -47,6 +47,8 @@ // type of what is in the first expression is generally not known when // parsing, so to have separate expressions like this separate them with // spaces. +// 7. 'isident' no longer applies to environment variables, they always include +// ASCII alphanumeric characters and underscore and nothing except this. #include #include @@ -383,10 +385,14 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) break; } +#define ISWORD_OR_AUTOLOAD(x) \ + (ASCII_ISALNUM(x) || (x) == AUTOLOAD_CHAR || (x) == '_') +#define ISWORD(x) \ + (ASCII_ISALNUM(x) || (x) == '_') + // Environment variable. case '$': { - // FIXME: Parser function can’t be thread-safe with vim_isIDc. - CHARREG(kExprLexEnv, vim_isIDc); + CHARREG(kExprLexEnv, ISWORD); break; } @@ -400,10 +406,6 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) case 'O': case 'P': case 'Q': case 'R': case 'S': case 'T': case 'U': case 'V': case 'W': case 'X': case 'Y': case 'Z': case '_': { -#define ISWORD_OR_AUTOLOAD(x) \ - (ASCII_ISALNUM(x) || (x) == AUTOLOAD_CHAR || (x) == '_') -#define ISWORD(x) \ - (ASCII_ISALNUM(x) || (x) == '_') ret.data.var.scope = 0; ret.data.var.autoload = false; CHARREG(kExprLexPlainIdentifier, ISWORD); @@ -441,9 +443,10 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) CHARREG(kExprLexPlainIdentifier, ISWORD_OR_AUTOLOAD); } break; -#undef ISWORD_OR_AUTOLOAD -#undef ISWORD } + +#undef ISWORD +#undef ISWORD_OR_AUTOLOAD #undef CHARREG // Option. -- cgit From cddf84c3982b8225f1592b6a61b63f8d1883ca94 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 26 Nov 2017 16:45:29 +0300 Subject: functests: Add some more tests --- src/nvim/syntax.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 8e5a119b1f..55ff49d160 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6170,18 +6170,18 @@ const char *const highlight_init_cmdline[] = { "default link NVimInvalidDict NVimInvalidContainer", "default link NVimInvalidList NVimInvalidContainer", - "default link NVimInvalidIdentifier Identifier", - "default link NVimInvalidIdentifierScope NVimIdentifier", - "default link NVimInvalidIdentifierScopeDelimiter NVimIdentifier", - "default link NVimInvalidIdentifierName NVimIdentifier", - "default link NVimInvalidIdentifierKey NVimIdentifier", + "default link NVimInvalidValue NVimInvalid", + + "default link NVimInvalidIdentifier NVimInvalidValue", + "default link NVimInvalidIdentifierScope NVimInvalidIdentifier", + "default link NVimInvalidIdentifierScopeDelimiter NVimInvalidIdentifier", + "default link NVimInvalidIdentifierName NVimInvalidIdentifier", + "default link NVimInvalidIdentifierKey NVimInvalidIdentifier", "default link NVimInvalidColon NVimInvalidDelimiter", "default link NVimInvalidComma NVimInvalidDelimiter", "default link NVimInvalidArrow NVimInvalidDelimiter", - "default link NVimInvalidValue NVimInvalid", - "default link NVimInvalidRegister NVimInvalidValue", "default link NVimInvalidNumber NVimInvalidValue", "default link NVimInvalidFloat NVimInvalidNumber", @@ -6199,7 +6199,7 @@ const char *const highlight_init_cmdline[] = { // Invalid string bodies and specials are still highlighted as valid ones to // minimize the red area. "default link NVimInvalidString NVimInvalidValue", - "default link NVimInvalidStringBody NVimString", + "default link NVimInvalidStringBody NVimStringBody", "default link NVimInvalidStringQuote NVimInvalidString", "default link NVimInvalidStringSpecial NVimStringSpecial", -- cgit From 36a4f3a259ffa282129b18358cce4130397077c5 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 26 Nov 2017 16:57:42 +0300 Subject: viml/parser/expressions: Make sure that listed nodes may be present With the new test leaving `assert(false);` for any of the cases makes tests crash. --- src/nvim/viml/parser/expressions.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 63ad6bab35..9773e60bbd 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -3065,12 +3065,9 @@ viml_pexpr_parse_end: // to be caught later. break; } + case kExprNodeSubscript: case kExprNodeConcatOrSubscript: case kExprNodeComplexIdentifier: - case kExprNodeSubscript: { - // FIXME: Investigate whether above are OK to be present in the stack. - break; - } case kExprNodeAssignment: case kExprNodeMod: case kExprNodeDivision: -- cgit From 944e3c06193f6d10baa9ba3021e01626337dd884 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 26 Nov 2017 23:15:17 +0100 Subject: tui: expose terminal type in 'term' option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since "builtin" terminfo definitions were implemented (7cbf52db1bdf), the decisions made by tui.c and terminfo.c are more relevant. Exposing that decision in the 'term' option helps with troubleshooting. Also: remove code that allowed setting t_Co. `:set t_Co=…` has never worked; the highlight_spec test asserting that nvim_set_option('t_Co') _does_ work makes no sense, and should not have worked. --- src/nvim/option.c | 73 ++++++++++++++++++++++++++++--------------------- src/nvim/tui/terminfo.c | 28 +++++++++++++++++-- src/nvim/tui/tui.c | 22 +++++++++++++-- 3 files changed, 86 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 65ab7a54a6..07114c9507 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -105,6 +105,9 @@ typedef enum { */ #define VAR_WIN ((char_u *)-1) +static char *p_term = NULL; +static char *p_ttytype = NULL; + /* * These are the global values for options which are also local to a buffer. * Only to be used in option.c! @@ -4530,13 +4533,17 @@ int findoption_len(const char *const arg, const size_t len) bool is_tty_option(const char *name) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT { - return (name[0] == 't' && name[1] == '_') || strcmp(name, "term") == 0; + return (name[0] == 't' && name[1] == '_') + || strequal(name, "term") + || strequal(name, "ttytype"); } #define TCO_BUFFER_SIZE 8 +/// @param name TUI-related option +/// @param[out,allocated] value option string value bool get_tty_option(char *name, char **value) { - if (!strcmp(name, "t_Co")) { + if (strequal(name, "t_Co")) { if (value) { if (t_colors <= 1) { *value = xstrdup(""); @@ -4548,9 +4555,16 @@ bool get_tty_option(char *name, char **value) return true; } - if (!strcmp(name, "term") || !strcmp(name, "ttytype")) { + if (strequal(name, "term")) { if (value) { - *value = xstrdup("nvim"); + *value = p_term ? xstrdup(p_term) : xstrdup("nvim"); + } + return true; + } + + if (strequal(name, "ttytype")) { + if (value) { + *value = p_ttytype ? xstrdup(p_ttytype) : xstrdup("nvim"); } return true; } @@ -4566,25 +4580,25 @@ bool get_tty_option(char *name, char **value) return false; } -bool set_tty_option(const char *name, const char *value) +bool set_tty_option(const char *name, char *value) { - if (!strcmp(name, "t_Co")) { - int colors = atoi(value); - - // Only reinitialize colors if t_Co value has really changed to - // avoid expensive reload of colorscheme if t_Co is set to the - // same value multiple times - if (colors != t_colors) { - t_colors = colors; - // We now have a different color setup, initialize it again. - init_highlight(true, false); + if (strequal(name, "term")) { + if (p_term) { + xfree(p_term); } + p_term = value; + return true; + } + if (strequal(name, "ttytype")) { + if (p_ttytype) { + xfree(p_ttytype); + } + p_ttytype = value; return true; } - return (is_tty_option(name) || !strcmp(name, "term") - || !strcmp(name, "ttytype")); + return false; } /// Find index for an option @@ -4597,18 +4611,15 @@ static int findoption(const char *const arg) return findoption_len(arg, strlen(arg)); } -/* - * Get the value for an option. - * - * Returns: - * Number or Toggle option: 1, *numval gets value. - * String option: 0, *stringval gets allocated string. - * Hidden Number or Toggle option: -1. - * hidden String option: -2. - * unknown option: -3. - */ -int -get_option_value ( +/// Gets the value for an option. +/// +/// @returns: +/// Number or Toggle option: 1, *numval gets value. +/// String option: 0, *stringval gets allocated string. +/// Hidden Number or Toggle option: -1. +/// hidden String option: -2. +/// unknown option: -3. +int get_option_value ( char_u *name, long *numval, char_u **stringval, /* NULL when only checking existence */ @@ -4791,8 +4802,8 @@ char *set_option_value(const char *const name, const long number, const char *const string, const int opt_flags) FUNC_ATTR_NONNULL_ARG(1) { - if (set_tty_option(name, string)) { - return NULL; + if (is_tty_option(name)) { + return NULL; // Fail silently; many old vimrcs set t_xx options. } int opt_idx; diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c index 75e9a2d8da..fdc33f0a77 100644 --- a/src/nvim/tui/terminfo.c +++ b/src/nvim/tui/terminfo.c @@ -9,6 +9,7 @@ #include #include "nvim/log.h" +#include "nvim/memory.h" #include "nvim/tui/terminfo.h" #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -94,51 +95,72 @@ bool terminfo_is_term_family(const char *term, const char *family) /// Loads a built-in terminfo db when we (unibilium) failed to load a terminfo /// record from the environment (termcap systems, unrecognized $TERM, …). /// We do not attempt to detect xterm pretenders here. -static unibi_term *terminfo_builtin(const char *term) +/// +/// @param term $TERM value +/// @param[out,allocated] termname decided builtin 'term' name +/// @return [allocated] terminfo structure +static unibi_term *terminfo_builtin(const char *term, char **termname) { if (terminfo_is_term_family(term, "xterm")) { + *termname = xstrdup("builtin_xterm"); return unibi_from_mem((const char *)xterm_256colour_terminfo, sizeof xterm_256colour_terminfo); } else if (terminfo_is_term_family(term, "screen")) { + *termname = xstrdup("builtin_screen"); return unibi_from_mem((const char *)screen_256colour_terminfo, sizeof screen_256colour_terminfo); } else if (terminfo_is_term_family(term, "tmux")) { + *termname = xstrdup("builtin_tmux"); return unibi_from_mem((const char *)tmux_256colour_terminfo, sizeof tmux_256colour_terminfo); } else if (terminfo_is_term_family(term, "rxvt")) { + *termname = xstrdup("builtin_rxvt"); return unibi_from_mem((const char *)rxvt_256colour_terminfo, sizeof rxvt_256colour_terminfo); } else if (terminfo_is_term_family(term, "putty")) { + *termname = xstrdup("builtin_putty"); return unibi_from_mem((const char *)putty_256colour_terminfo, sizeof putty_256colour_terminfo); } else if (terminfo_is_term_family(term, "linux")) { + *termname = xstrdup("builtin_linux"); return unibi_from_mem((const char *)linux_16colour_terminfo, sizeof linux_16colour_terminfo); } else if (terminfo_is_term_family(term, "interix")) { + *termname = xstrdup("builtin_interix"); return unibi_from_mem((const char *)interix_8colour_terminfo, sizeof interix_8colour_terminfo); } else if (terminfo_is_term_family(term, "iterm") || terminfo_is_term_family(term, "iterm2") || terminfo_is_term_family(term, "iTerm.app") || terminfo_is_term_family(term, "iTerm2.app")) { + *termname = xstrdup("builtin_iterm"); return unibi_from_mem((const char *)iterm_256colour_terminfo, sizeof iterm_256colour_terminfo); } else if (terminfo_is_term_family(term, "st")) { + *termname = xstrdup("builtin_st"); return unibi_from_mem((const char *)st_256colour_terminfo, sizeof st_256colour_terminfo); } else if (terminfo_is_term_family(term, "gnome") || terminfo_is_term_family(term, "vte")) { + *termname = xstrdup("builtin_vte"); return unibi_from_mem((const char *)vte_256colour_terminfo, sizeof vte_256colour_terminfo); } else { + *termname = xstrdup("builtin_ansi"); return unibi_from_mem((const char *)ansi_terminfo, sizeof ansi_terminfo); } } -unibi_term *terminfo_from_builtin(const char *term) +/// @param term $TERM value +/// @param[out,allocated] termname decided builtin 'term' name +/// @return [allocated] terminfo structure +unibi_term *terminfo_from_builtin(const char *term, char **termname) { - unibi_term *ut = terminfo_builtin(term); + unibi_term *ut = terminfo_builtin(term, termname); + if (*termname == NULL) { + *termname = xstrdup("builtin_?"); + } // Disable BCE by default (for built-in terminfos). #7624 // https://github.com/kovidgoyal/kitty/issues/160#issuecomment-346470545 unibi_set_bool(ut, unibi_back_color_erase, false); diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index c2e597c36c..732a86d0fb 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -23,6 +23,7 @@ #include "nvim/map.h" #include "nvim/main.h" #include "nvim/memory.h" +#include "nvim/option.h" #include "nvim/api/vim.h" #include "nvim/api/private/helpers.h" #include "nvim/event/loop.h" @@ -166,6 +167,13 @@ static size_t unibi_pre_fmt_str(TUIData *data, unsigned int unibi_index, return unibi_run(str, data->params, buf, len); } +static void termname_set_event(void **argv) +{ + char *termname = argv[0]; + set_tty_option("term", termname); + // Do not free termname, it is freed by set_tty_option. +} + static void terminfo_start(UI *ui) { TUIData *data = ui->data; @@ -190,12 +198,20 @@ static void terminfo_start(UI *ui) data->unibi_ext.reset_cursor_style = -1; data->out_fd = 1; data->out_isatty = os_isatty(data->out_fd); - // setup unibilium + + // Set up unibilium/terminfo. const char *term = os_getenv("TERM"); data->ut = unibi_from_env(); + char *termname = NULL; if (!data->ut) { - data->ut = terminfo_from_builtin(term); + data->ut = terminfo_from_builtin(term, &termname); + } else { + termname = xstrdup(term); } + // Update 'term' option. + loop_schedule_deferred(&main_loop, + event_create(termname_set_event, 1, termname)); + // None of the following work over SSH; see :help TERM . const char *colorterm = os_getenv("COLORTERM"); const char *termprg = os_getenv("TERM_PROGRAM"); @@ -344,7 +360,7 @@ static void tui_scheduler(Event event, void *d) { UI *ui = d; TUIData *data = ui->data; - loop_schedule(data->loop, event); + loop_schedule(data->loop, event); // `tui_loop` local to tui_main(). } #ifdef UNIX -- cgit From 6cf186edb5dec13bc7f4cd57be726d124af578de Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 27 Nov 2017 09:33:12 +0100 Subject: lint --- src/nvim/option.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 07114c9507..913d27d508 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -4619,10 +4619,10 @@ static int findoption(const char *const arg) /// Hidden Number or Toggle option: -1. /// hidden String option: -2. /// unknown option: -3. -int get_option_value ( +int get_option_value( char_u *name, long *numval, - char_u **stringval, /* NULL when only checking existence */ + char_u **stringval, ///< NULL when only checking existence int opt_flags ) { @@ -4630,32 +4630,31 @@ int get_option_value ( return 0; } - int opt_idx; - char_u *varp; - - opt_idx = findoption((const char *)name); + int opt_idx = findoption((const char *)name); if (opt_idx < 0) { // Unknown option. return -3; } - varp = get_varp_scope(&(options[opt_idx]), opt_flags); + char_u *varp = get_varp_scope(&(options[opt_idx]), opt_flags); if (options[opt_idx].flags & P_STRING) { - if (varp == NULL) /* hidden option */ + if (varp == NULL) { // hidden option return -2; + } if (stringval != NULL) { *stringval = vim_strsave(*(char_u **)(varp)); } return 0; } - if (varp == NULL) /* hidden option */ + if (varp == NULL) { // hidden option return -1; - if (options[opt_idx].flags & P_NUM) + } + if (options[opt_idx].flags & P_NUM) { *numval = *(long *)varp; - else { - /* Special case: 'modified' is b_changed, but we also want to consider - * it set when 'ff' or 'fenc' changed. */ + } else { + // Special case: 'modified' is b_changed, but we also want to consider + // it set when 'ff' or 'fenc' changed. if ((int *)varp == &curbuf->b_changed) { *numval = curbufIsChanged(); } else { -- cgit From 27a70fec48f5ca6c6b91aa3402eb0d1591021024 Mon Sep 17 00:00:00 2001 From: Michael Schupikov Date: Sat, 23 Sep 2017 12:44:37 +0200 Subject: version.c: mark NA patches - channels: vim-patch:8.0.0018 - GUI: vim-patch:8.0.0021 - Different recursive function implementation: vim-patch:8.0.0141 - JSON handling: vim-patch:8.0.0166, vim-patch:8.0.0169, vim-patch:8.0.0170, vim-patch:8.0.0171, vim-patch:8.0.0180 Mark vim-patch:8.0.0096 applied, since it was added in 860ecd705588470b52094b7036c016b2af15f8c9. [ci skip] --- src/nvim/version.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 205c25b6cd..286fcc2391 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -803,7 +803,7 @@ static const int included_patches[] = { 305, // 304, // 303, - // 302, NA + // 302 NA // 301, 300, // 299, @@ -925,7 +925,7 @@ static const int included_patches[] = { // 183 NA 182, 181, - // 180, + // 180 NA 179, 178, 177, @@ -935,11 +935,11 @@ static const int included_patches[] = { // 173 NA 172, // 171, - // 170, - // 169, + // 170 NA + // 169 NA 168, 167, - // 166, + // 166 NA 165, 164, // 163 NA @@ -964,7 +964,7 @@ static const int included_patches[] = { // 144 NA 143, 142, - // 141, + // 141 NA 140, // 139 NA // 138 NA @@ -1009,7 +1009,7 @@ static const int included_patches[] = { 99, // 98 NA // 97 NA - // 96, + 96, // 95 NA // 94 NA // 93 NA @@ -1084,10 +1084,10 @@ static const int included_patches[] = { // 24 NA 23, // 22 NA - // 21, + // 21 NA 20, 19, - // 18, + // 18 NA 17, // 16 NA // 15 NA -- cgit From 20bde8866e6a310f6fee6a6fcdb7546bac335944 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 26 Nov 2017 12:28:12 -0500 Subject: Add OpenBSD as an expected OS for opening char devices Closes #7542 --- src/nvim/vim.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 1db1a073ed..88014c8ae8 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -314,7 +314,7 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() // Lowest number used for window ID. Cannot have this many windows per tab. #define LOWEST_WIN_ID 1000 -#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && defined(S_ISCHR) +#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)) && defined(S_ISCHR) # define OPEN_CHR_FILES #endif -- cgit From 8f91f2c9b47e6705e29da2fdbc9519092c757ba5 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 26 Nov 2017 21:26:56 -0500 Subject: Use defined(BSD) check when defining OPEN_CHR_FILES Rather than enumerate predefines for all BSD systems, just rely on the fact that they all "#define BSD" in sys/param.h. Debian's GNU/kFreeBSD still requires its own check, since it isn't using the BSD userspace. References: OpenBSD - https://github.com/openbsd/src/blob/210ebf9df0460bbdad02da9bbd5d859b61f57462/sys/sys/param.h#L40 FreeBSD - https://github.com/freebsd/freebsd/blob/f5d95e1f8d32db4ccccfd5ad9cecb21ed07a695d/sys/sys/param.h#L43 NetBSD - https://github.com/NetBSD/src/blob/ea620980793cf2011e5424f4a537b0488e3ffb4d/sys/sys/param.h#L49 DragonFlyBSD - https://github.com/DragonFlyBSD/DragonFlyBSD/blob/94ecf1295bb42b59772448d58ff40dd75c4a3ef8/sys/sys/param.h#L41 vim-patch:8.0.1357 --- src/nvim/os/os_defs.h | 1 + src/nvim/version.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/nvim/vim.h | 3 +- 3 files changed, 154 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/os/os_defs.h b/src/nvim/os/os_defs.h index 923a362b41..87f8d214bd 100644 --- a/src/nvim/os/os_defs.h +++ b/src/nvim/os/os_defs.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/src/nvim/version.c b/src/nvim/version.c index 286fcc2391..a09574a73e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -78,6 +78,157 @@ static char *features[] = { // clang-format off static const int included_patches[] = { + 1357, + // 1356, + // 1355, + // 1354, + // 1353, + // 1352, + // 1351, + // 1350, + // 1349, + // 1348, + // 1347, + // 1346, + // 1345, + // 1344, + // 1343, + // 1342, + // 1341, + // 1340, + // 1339, + // 1338, + // 1337, + // 1336, + // 1335, + // 1334, + // 1333, + // 1332, + // 1331, + // 1330, + // 1329, + // 1328, + // 1327, + // 1326, + // 1325, + // 1324, + // 1323, + // 1322, + // 1321, + // 1320, + // 1319, + // 1318, + // 1317, + // 1316, + // 1315, + // 1314, + // 1313, + // 1312, + // 1311, + // 1310, + // 1309, + // 1308, + // 1307, + // 1306, + // 1305, + // 1304, + // 1303, + // 1302, + // 1301, + // 1300, + // 1299, + // 1298, + // 1297, + // 1296, + // 1295, + // 1294, + // 1293, + // 1292, + // 1291, + // 1290, + // 1289, + // 1288, + // 1287, + // 1286, + // 1285, + // 1284, + // 1283, + // 1282, + // 1281, + // 1280, + // 1279, + // 1278, + // 1277, + // 1276, + // 1275, + // 1274, + // 1273, + // 1272, + // 1271, + // 1270, + // 1269, + // 1268, + // 1267, + // 1266, + // 1265, + // 1264, + // 1263, + // 1262, + // 1261, + // 1260, + // 1259, + // 1258, + // 1257, + // 1256, + // 1255, + // 1254, + // 1253, + // 1252, + // 1251, + // 1250, + // 1249, + // 1248, + // 1247, + // 1246, + // 1245, + // 1244, + // 1243, + // 1242, + // 1241, + // 1240, + // 1239, + // 1238, + // 1237, + // 1236, + // 1235, + // 1234, + // 1233, + // 1232, + // 1231, + // 1230, + // 1229, + // 1228, + // 1227, + // 1226, + // 1225, + // 1224, + // 1223, + // 1222, + // 1221, + // 1220, + // 1219, + // 1218, + // 1217, + // 1216, + // 1215, + // 1214, + // 1213, + // 1212, + // 1211, + // 1210, + // 1209, + // 1208, + // 1207, 1206, // 1026, 1025, diff --git a/src/nvim/vim.h b/src/nvim/vim.h index 88014c8ae8..7da3c8246f 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -314,7 +314,8 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext() // Lowest number used for window ID. Cannot have this many windows per tab. #define LOWEST_WIN_ID 1000 -#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)) && defined(S_ISCHR) +// BSD is supposed to cover FreeBSD and similar systems. +#if (defined(BSD) || defined(__FreeBSD_kernel__)) && defined(S_ISCHR) # define OPEN_CHR_FILES #endif -- cgit From 4618c9c43b2fe052332329b347ac10b4b1db94b5 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 29 Nov 2017 23:41:41 +0100 Subject: Revert "tui: update cleared area only if non-default bg" Reverts 0b93bab6c22edf7a07cf965ebbbf631b93e1dc1b. This change was counter-productive to the other changes which intended to reduce the role of BCE. ref #7624 --- src/nvim/tui/tui.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 732a86d0fb..724d59b15a 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -956,10 +956,9 @@ static void tui_scroll(UI *ui, Integer count) } cursor_goto(ui, saved_row, saved_col); - if (!scroll_clears_to_current_colour && grid->bg != -1) { - // Scrolling may leave wrong background in the cleared area on non-bge - // terminals. Update the cleared area of the terminal if its builtin - // scrolling facility was used and bg color is not the default. + if (!scroll_clears_to_current_colour) { + // Scrolling will leave wrong background in the cleared area on non-BCE + // terminals. Update the cleared area. clear_region(ui, clear_top, clear_bot, grid->left, grid->right); } } else { -- cgit From de45ec0146486c49719ff6f6dcceb4914b471c7a Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 30 Nov 2017 02:01:49 +0300 Subject: keymap: Do not use vim_isIDc in keymap.c Note: there are three changes to ascii_isident. Reverting first two (in find_special_key and first in get_special_key_code) normally fails the new test with empty &isident, but reverting the third does not. Hence adding `>` to &isident. Ref vim/vim#2389. --- src/nvim/ascii.h | 13 +++++++++++++ src/nvim/keymap.c | 6 +++--- src/nvim/viml/parser/expressions.c | 9 +++------ 3 files changed, 19 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/ascii.h b/src/nvim/ascii.h index adde91f9ec..9ccb70764d 100644 --- a/src/nvim/ascii.h +++ b/src/nvim/ascii.h @@ -3,6 +3,7 @@ #include +#include "nvim/macros.h" #include "nvim/func_attr.h" #include "nvim/os/os_defs.h" @@ -98,6 +99,10 @@ static inline bool ascii_isxdigit(int) REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; +static inline bool ascii_isident(int) + REAL_FATTR_CONST + REAL_FATTR_ALWAYS_INLINE; + static inline bool ascii_isbdigit(int) REAL_FATTR_CONST REAL_FATTR_ALWAYS_INLINE; @@ -138,6 +143,14 @@ static inline bool ascii_isxdigit(int c) || (c >= 'A' && c <= 'F'); } +/// Checks if `c` is an “identifier†character +/// +/// That is, whether it is alphanumeric character or underscore. +static inline bool ascii_isident(const int c) +{ + return ASCII_ISALNUM(c) || c == '_'; +} + /// Checks if `c` is a binary digit, that is, 0-1. /// /// @see {ascii_isdigit} diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index aca21c20a5..0eb5a41b1e 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -567,7 +567,7 @@ int find_special_key(const char_u **srcp, const size_t src_len, int *const modp, // Find end of modifier list last_dash = src; - for (bp = src + 1; bp <= end && (*bp == '-' || vim_isIDc(*bp)); bp++) { + for (bp = src + 1; bp <= end && (*bp == '-' || ascii_isident(*bp)); bp++) { if (*bp == '-') { last_dash = bp; if (bp + 1 <= end) { @@ -721,12 +721,12 @@ int get_special_key_code(const char_u *name) for (int i = 0; key_names_table[i].name != NULL; i++) { const char *const table_name = key_names_table[i].name; int j; - for (j = 0; vim_isIDc(name[j]) && table_name[j] != NUL; j++) { + for (j = 0; ascii_isident(name[j]) && table_name[j] != NUL; j++) { if (TOLOWER_ASC(table_name[j]) != TOLOWER_ASC(name[j])) { break; } } - if (!vim_isIDc(name[j]) && table_name[j] == NUL) { + if (!ascii_isident(name[j]) && table_name[j] == NUL) { return key_names_table[i].key; } } diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index 9773e60bbd..cfcde6bb38 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -386,13 +386,11 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) } #define ISWORD_OR_AUTOLOAD(x) \ - (ASCII_ISALNUM(x) || (x) == AUTOLOAD_CHAR || (x) == '_') -#define ISWORD(x) \ - (ASCII_ISALNUM(x) || (x) == '_') + (ascii_isident(x) || (x) == AUTOLOAD_CHAR) // Environment variable. case '$': { - CHARREG(kExprLexEnv, ISWORD); + CHARREG(kExprLexEnv, ascii_isident); break; } @@ -408,7 +406,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) case '_': { ret.data.var.scope = 0; ret.data.var.autoload = false; - CHARREG(kExprLexPlainIdentifier, ISWORD); + CHARREG(kExprLexPlainIdentifier, ascii_isident); // "is" and "isnot" operators. if (!(flags & kELFlagIsNotCmp) && ((ret.len == 2 && memcmp(pline.data, "is", 2) == 0) @@ -445,7 +443,6 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags) break; } -#undef ISWORD #undef ISWORD_OR_AUTOLOAD #undef CHARREG -- cgit From 10c3b206cbf394d7b67bff95242b7033a1ce1d63 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 29 Nov 2017 20:43:07 -0500 Subject: version.c: Mark 8.0.0171 as NA [ci skip] --- src/nvim/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index a09574a73e..b228b8909d 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1085,7 +1085,7 @@ static const int included_patches[] = { 174, // 173 NA 172, - // 171, + // 171 NA // 170 NA // 169 NA 168, -- cgit From 5ab0f988caffad5e8c87a075cbd3f91f0f7e002c Mon Sep 17 00:00:00 2001 From: ZyX Date: Thu, 30 Nov 2017 11:53:25 +0300 Subject: *: Replace all occurrences of NVim with Nvim --- src/nvim/syntax.c | 364 ++++++++++++++++++------------------- src/nvim/viml/parser/expressions.c | 4 +- 2 files changed, 184 insertions(+), 184 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 55ff49d160..d1a5f0bd1c 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -6025,204 +6025,204 @@ const char *const highlight_init_cmdline[] = { // XXX When modifying a list modify it in both valid and invalid halfs. // TODO(ZyX-I): merge valid and invalid groups via a macros. - // NVimInternalError should appear only when highlighter has a bug. - "NVimInternalError ctermfg=Red ctermbg=Red guifg=Red guibg=Red", + // NvimInternalError should appear only when highlighter has a bug. + "NvimInternalError ctermfg=Red ctermbg=Red guifg=Red guibg=Red", // Highlight groups (links) used by parser: - "default link NVimAssignment Operator", - "default link NVimPlainAssignment NVimAssignment", - "default link NVimAugmentedAssignment NVimAssignment", - "default link NVimAssignmentWithAddition NVimAugmentedAssignment", - "default link NVimAssignmentWithSubtraction NVimAugmentedAssignment", - "default link NVimAssignmentWithConcatenation NVimAugmentedAssignment", - - "default link NVimOperator Operator", - - "default link NVimUnaryOperator NVimOperator", - "default link NVimUnaryPlus NVimUnaryOperator", - "default link NVimUnaryMinus NVimUnaryOperator", - "default link NVimNot NVimUnaryOperator", - - "default link NVimBinaryOperator NVimOperator", - "default link NVimComparison NVimBinaryOperator", - "default link NVimComparisonModifier NVimComparison", - "default link NVimBinaryPlus NVimBinaryOperator", - "default link NVimBinaryMinus NVimBinaryOperator", - "default link NVimConcat NVimBinaryOperator", - "default link NVimConcatOrSubscript NVimConcat", - "default link NVimOr NVimBinaryOperator", - "default link NVimAnd NVimBinaryOperator", - "default link NVimMultiplication NVimBinaryOperator", - "default link NVimDivision NVimBinaryOperator", - "default link NVimMod NVimBinaryOperator", - - "default link NVimTernary NVimOperator", - "default link NVimTernaryColon NVimTernary", - - "default link NVimParenthesis Delimiter", - "default link NVimLambda NVimParenthesis", - "default link NVimNestingParenthesis NVimParenthesis", - "default link NVimCallingParenthesis NVimParenthesis", - - "default link NVimSubscript NVimParenthesis", - "default link NVimSubscriptBracket NVimSubscript", - "default link NVimSubscriptColon NVimSubscript", - "default link NVimCurly NVimSubscript", - - "default link NVimContainer NVimParenthesis", - "default link NVimDict NVimContainer", - "default link NVimList NVimContainer", - - "default link NVimIdentifier Identifier", - "default link NVimIdentifierScope NVimIdentifier", - "default link NVimIdentifierScopeDelimiter NVimIdentifier", - "default link NVimIdentifierName NVimIdentifier", - "default link NVimIdentifierKey NVimIdentifier", - - "default link NVimColon Delimiter", - "default link NVimComma Delimiter", - "default link NVimArrow Delimiter", - - "default link NVimRegister SpecialChar", - "default link NVimNumber Number", - "default link NVimFloat NVimNumber", - "default link NVimNumberPrefix Type", - - "default link NVimOptionSigil Type", - "default link NVimOptionName NVimIdentifier", - "default link NVimOptionScope NVimIdentifierScope", - "default link NVimOptionScopeDelimiter NVimIdentifierScopeDelimiter", - - "default link NVimEnvironmentSigil NVimOptionSigil", - "default link NVimEnvironmentName NVimIdentifier", - - "default link NVimString String", - "default link NVimStringBody NVimString", - "default link NVimStringQuote NVimString", - "default link NVimStringSpecial SpecialChar", - - "default link NVimSingleQuote NVimStringQuote", - "default link NVimSingleQuotedBody NVimStringBody", - "default link NVimSingleQuotedQuote NVimStringSpecial", - - "default link NVimDoubleQuote NVimStringQuote", - "default link NVimDoubleQuotedBody NVimStringBody", - "default link NVimDoubleQuotedEscape NVimStringSpecial", - - "default link NVimFigureBrace NVimInternalError", - "default link NVimSingleQuotedUnknownEscape NVimInternalError", - - "default link NVimSpacing Normal", - - // NVimInvalid groups: - - "default link NVimInvalidSingleQuotedUnknownEscape NVimInternalError", - - "default link NVimInvalid Error", - - "default link NVimInvalidAssignment NVimInvalid", - "default link NVimInvalidPlainAssignment NVimInvalidAssignment", - "default link NVimInvalidAugmentedAssignment NVimInvalidAssignment", - "default link NVimInvalidAssignmentWithAddition " - "NVimInvalidAugmentedAssignment", - "default link NVimInvalidAssignmentWithSubtraction " - "NVimInvalidAugmentedAssignment", - "default link NVimInvalidAssignmentWithConcatenation " - "NVimInvalidAugmentedAssignment", - - "default link NVimInvalidOperator NVimInvalid", - - "default link NVimInvalidUnaryOperator NVimInvalidOperator", - "default link NVimInvalidUnaryPlus NVimInvalidUnaryOperator", - "default link NVimInvalidUnaryMinus NVimInvalidUnaryOperator", - "default link NVimInvalidNot NVimInvalidUnaryOperator", - - "default link NVimInvalidBinaryOperator NVimInvalidOperator", - "default link NVimInvalidComparison NVimInvalidBinaryOperator", - "default link NVimInvalidComparisonModifier NVimInvalidComparison", - "default link NVimInvalidBinaryPlus NVimInvalidBinaryOperator", - "default link NVimInvalidBinaryMinus NVimInvalidBinaryOperator", - "default link NVimInvalidConcat NVimInvalidBinaryOperator", - "default link NVimInvalidConcatOrSubscript NVimInvalidConcat", - "default link NVimInvalidOr NVimInvalidBinaryOperator", - "default link NVimInvalidAnd NVimInvalidBinaryOperator", - "default link NVimInvalidMultiplication NVimInvalidBinaryOperator", - "default link NVimInvalidDivision NVimInvalidBinaryOperator", - "default link NVimInvalidMod NVimInvalidBinaryOperator", - - "default link NVimInvalidTernary NVimInvalidOperator", - "default link NVimInvalidTernaryColon NVimInvalidTernary", - - "default link NVimInvalidDelimiter NVimInvalid", - - "default link NVimInvalidParenthesis NVimInvalidDelimiter", - "default link NVimInvalidLambda NVimInvalidParenthesis", - "default link NVimInvalidNestingParenthesis NVimInvalidParenthesis", - "default link NVimInvalidCallingParenthesis NVimInvalidParenthesis", - - "default link NVimInvalidSubscript NVimInvalidParenthesis", - "default link NVimInvalidSubscriptBracket NVimInvalidSubscript", - "default link NVimInvalidSubscriptColon NVimInvalidSubscript", - "default link NVimInvalidCurly NVimInvalidSubscript", - - "default link NVimInvalidContainer NVimInvalidParenthesis", - "default link NVimInvalidDict NVimInvalidContainer", - "default link NVimInvalidList NVimInvalidContainer", - - "default link NVimInvalidValue NVimInvalid", - - "default link NVimInvalidIdentifier NVimInvalidValue", - "default link NVimInvalidIdentifierScope NVimInvalidIdentifier", - "default link NVimInvalidIdentifierScopeDelimiter NVimInvalidIdentifier", - "default link NVimInvalidIdentifierName NVimInvalidIdentifier", - "default link NVimInvalidIdentifierKey NVimInvalidIdentifier", - - "default link NVimInvalidColon NVimInvalidDelimiter", - "default link NVimInvalidComma NVimInvalidDelimiter", - "default link NVimInvalidArrow NVimInvalidDelimiter", - - "default link NVimInvalidRegister NVimInvalidValue", - "default link NVimInvalidNumber NVimInvalidValue", - "default link NVimInvalidFloat NVimInvalidNumber", - "default link NVimInvalidNumberPrefix NVimInvalidNumber", - - "default link NVimInvalidOptionSigil NVimInvalidIdentifier", - "default link NVimInvalidOptionName NVimInvalidIdentifier", - "default link NVimInvalidOptionScope NVimInvalidIdentifierScope", - "default link NVimInvalidOptionScopeDelimiter " - "NVimInvalidIdentifierScopeDelimiter", - - "default link NVimInvalidEnvironmentSigil NVimInvalidOptionSigil", - "default link NVimInvalidEnvironmentName NVimInvalidIdentifier", + "default link NvimAssignment Operator", + "default link NvimPlainAssignment NvimAssignment", + "default link NvimAugmentedAssignment NvimAssignment", + "default link NvimAssignmentWithAddition NvimAugmentedAssignment", + "default link NvimAssignmentWithSubtraction NvimAugmentedAssignment", + "default link NvimAssignmentWithConcatenation NvimAugmentedAssignment", + + "default link NvimOperator Operator", + + "default link NvimUnaryOperator NvimOperator", + "default link NvimUnaryPlus NvimUnaryOperator", + "default link NvimUnaryMinus NvimUnaryOperator", + "default link NvimNot NvimUnaryOperator", + + "default link NvimBinaryOperator NvimOperator", + "default link NvimComparison NvimBinaryOperator", + "default link NvimComparisonModifier NvimComparison", + "default link NvimBinaryPlus NvimBinaryOperator", + "default link NvimBinaryMinus NvimBinaryOperator", + "default link NvimConcat NvimBinaryOperator", + "default link NvimConcatOrSubscript NvimConcat", + "default link NvimOr NvimBinaryOperator", + "default link NvimAnd NvimBinaryOperator", + "default link NvimMultiplication NvimBinaryOperator", + "default link NvimDivision NvimBinaryOperator", + "default link NvimMod NvimBinaryOperator", + + "default link NvimTernary NvimOperator", + "default link NvimTernaryColon NvimTernary", + + "default link NvimParenthesis Delimiter", + "default link NvimLambda NvimParenthesis", + "default link NvimNestingParenthesis NvimParenthesis", + "default link NvimCallingParenthesis NvimParenthesis", + + "default link NvimSubscript NvimParenthesis", + "default link NvimSubscriptBracket NvimSubscript", + "default link NvimSubscriptColon NvimSubscript", + "default link NvimCurly NvimSubscript", + + "default link NvimContainer NvimParenthesis", + "default link NvimDict NvimContainer", + "default link NvimList NvimContainer", + + "default link NvimIdentifier Identifier", + "default link NvimIdentifierScope NvimIdentifier", + "default link NvimIdentifierScopeDelimiter NvimIdentifier", + "default link NvimIdentifierName NvimIdentifier", + "default link NvimIdentifierKey NvimIdentifier", + + "default link NvimColon Delimiter", + "default link NvimComma Delimiter", + "default link NvimArrow Delimiter", + + "default link NvimRegister SpecialChar", + "default link NvimNumber Number", + "default link NvimFloat NvimNumber", + "default link NvimNumberPrefix Type", + + "default link NvimOptionSigil Type", + "default link NvimOptionName NvimIdentifier", + "default link NvimOptionScope NvimIdentifierScope", + "default link NvimOptionScopeDelimiter NvimIdentifierScopeDelimiter", + + "default link NvimEnvironmentSigil NvimOptionSigil", + "default link NvimEnvironmentName NvimIdentifier", + + "default link NvimString String", + "default link NvimStringBody NvimString", + "default link NvimStringQuote NvimString", + "default link NvimStringSpecial SpecialChar", + + "default link NvimSingleQuote NvimStringQuote", + "default link NvimSingleQuotedBody NvimStringBody", + "default link NvimSingleQuotedQuote NvimStringSpecial", + + "default link NvimDoubleQuote NvimStringQuote", + "default link NvimDoubleQuotedBody NvimStringBody", + "default link NvimDoubleQuotedEscape NvimStringSpecial", + + "default link NvimFigureBrace NvimInternalError", + "default link NvimSingleQuotedUnknownEscape NvimInternalError", + + "default link NvimSpacing Normal", + + // NvimInvalid groups: + + "default link NvimInvalidSingleQuotedUnknownEscape NvimInternalError", + + "default link NvimInvalid Error", + + "default link NvimInvalidAssignment NvimInvalid", + "default link NvimInvalidPlainAssignment NvimInvalidAssignment", + "default link NvimInvalidAugmentedAssignment NvimInvalidAssignment", + "default link NvimInvalidAssignmentWithAddition " + "NvimInvalidAugmentedAssignment", + "default link NvimInvalidAssignmentWithSubtraction " + "NvimInvalidAugmentedAssignment", + "default link NvimInvalidAssignmentWithConcatenation " + "NvimInvalidAugmentedAssignment", + + "default link NvimInvalidOperator NvimInvalid", + + "default link NvimInvalidUnaryOperator NvimInvalidOperator", + "default link NvimInvalidUnaryPlus NvimInvalidUnaryOperator", + "default link NvimInvalidUnaryMinus NvimInvalidUnaryOperator", + "default link NvimInvalidNot NvimInvalidUnaryOperator", + + "default link NvimInvalidBinaryOperator NvimInvalidOperator", + "default link NvimInvalidComparison NvimInvalidBinaryOperator", + "default link NvimInvalidComparisonModifier NvimInvalidComparison", + "default link NvimInvalidBinaryPlus NvimInvalidBinaryOperator", + "default link NvimInvalidBinaryMinus NvimInvalidBinaryOperator", + "default link NvimInvalidConcat NvimInvalidBinaryOperator", + "default link NvimInvalidConcatOrSubscript NvimInvalidConcat", + "default link NvimInvalidOr NvimInvalidBinaryOperator", + "default link NvimInvalidAnd NvimInvalidBinaryOperator", + "default link NvimInvalidMultiplication NvimInvalidBinaryOperator", + "default link NvimInvalidDivision NvimInvalidBinaryOperator", + "default link NvimInvalidMod NvimInvalidBinaryOperator", + + "default link NvimInvalidTernary NvimInvalidOperator", + "default link NvimInvalidTernaryColon NvimInvalidTernary", + + "default link NvimInvalidDelimiter NvimInvalid", + + "default link NvimInvalidParenthesis NvimInvalidDelimiter", + "default link NvimInvalidLambda NvimInvalidParenthesis", + "default link NvimInvalidNestingParenthesis NvimInvalidParenthesis", + "default link NvimInvalidCallingParenthesis NvimInvalidParenthesis", + + "default link NvimInvalidSubscript NvimInvalidParenthesis", + "default link NvimInvalidSubscriptBracket NvimInvalidSubscript", + "default link NvimInvalidSubscriptColon NvimInvalidSubscript", + "default link NvimInvalidCurly NvimInvalidSubscript", + + "default link NvimInvalidContainer NvimInvalidParenthesis", + "default link NvimInvalidDict NvimInvalidContainer", + "default link NvimInvalidList NvimInvalidContainer", + + "default link NvimInvalidValue NvimInvalid", + + "default link NvimInvalidIdentifier NvimInvalidValue", + "default link NvimInvalidIdentifierScope NvimInvalidIdentifier", + "default link NvimInvalidIdentifierScopeDelimiter NvimInvalidIdentifier", + "default link NvimInvalidIdentifierName NvimInvalidIdentifier", + "default link NvimInvalidIdentifierKey NvimInvalidIdentifier", + + "default link NvimInvalidColon NvimInvalidDelimiter", + "default link NvimInvalidComma NvimInvalidDelimiter", + "default link NvimInvalidArrow NvimInvalidDelimiter", + + "default link NvimInvalidRegister NvimInvalidValue", + "default link NvimInvalidNumber NvimInvalidValue", + "default link NvimInvalidFloat NvimInvalidNumber", + "default link NvimInvalidNumberPrefix NvimInvalidNumber", + + "default link NvimInvalidOptionSigil NvimInvalidIdentifier", + "default link NvimInvalidOptionName NvimInvalidIdentifier", + "default link NvimInvalidOptionScope NvimInvalidIdentifierScope", + "default link NvimInvalidOptionScopeDelimiter " + "NvimInvalidIdentifierScopeDelimiter", + + "default link NvimInvalidEnvironmentSigil NvimInvalidOptionSigil", + "default link NvimInvalidEnvironmentName NvimInvalidIdentifier", // Invalid string bodies and specials are still highlighted as valid ones to // minimize the red area. - "default link NVimInvalidString NVimInvalidValue", - "default link NVimInvalidStringBody NVimStringBody", - "default link NVimInvalidStringQuote NVimInvalidString", - "default link NVimInvalidStringSpecial NVimStringSpecial", + "default link NvimInvalidString NvimInvalidValue", + "default link NvimInvalidStringBody NvimStringBody", + "default link NvimInvalidStringQuote NvimInvalidString", + "default link NvimInvalidStringSpecial NvimStringSpecial", - "default link NVimInvalidSingleQuote NVimInvalidStringQuote", - "default link NVimInvalidSingleQuotedBody NVimInvalidStringBody", - "default link NVimInvalidSingleQuotedQuote NVimInvalidStringSpecial", + "default link NvimInvalidSingleQuote NvimInvalidStringQuote", + "default link NvimInvalidSingleQuotedBody NvimInvalidStringBody", + "default link NvimInvalidSingleQuotedQuote NvimInvalidStringSpecial", - "default link NVimInvalidDoubleQuote NVimInvalidStringQuote", - "default link NVimInvalidDoubleQuotedBody NVimInvalidStringBody", - "default link NVimInvalidDoubleQuotedEscape NVimInvalidStringSpecial", - "default link NVimInvalidDoubleQuotedUnknownEscape NVimInvalidValue", + "default link NvimInvalidDoubleQuote NvimInvalidStringQuote", + "default link NvimInvalidDoubleQuotedBody NvimInvalidStringBody", + "default link NvimInvalidDoubleQuotedEscape NvimInvalidStringSpecial", + "default link NvimInvalidDoubleQuotedUnknownEscape NvimInvalidValue", - "default link NVimInvalidFigureBrace NVimInvalidDelimiter", + "default link NvimInvalidFigureBrace NvimInvalidDelimiter", - "default link NVimInvalidSpacing ErrorMsg", + "default link NvimInvalidSpacing ErrorMsg", // Not actually invalid, but we highlight user that he is doing something // wrong. - "default link NVimDoubleQuotedUnknownEscape NVimInvalidValue", + "default link NvimDoubleQuotedUnknownEscape NvimInvalidValue", NULL, }; -/// Create default links for NVim* highlight groups used for cmdline coloring +/// Create default links for Nvim* highlight groups used for cmdline coloring void syn_init_cmdline_highlight(bool reset, bool init) { for (size_t i = 0 ; highlight_init_cmdline[i] != NULL ; i++) { diff --git a/src/nvim/viml/parser/expressions.c b/src/nvim/viml/parser/expressions.c index cfcde6bb38..4196ecb9d2 100644 --- a/src/nvim/viml/parser/expressions.c +++ b/src/nvim/viml/parser/expressions.c @@ -1326,7 +1326,7 @@ static inline ParserPosition recol_pos(const ParserPosition pos, } /// Get highlight group name -#define HL(g) (is_invalid ? "NVimInvalid" #g : "NVim" #g) +#define HL(g) (is_invalid ? "NvimInvalid" #g : "Nvim" #g) /// Highlight current token with the given group #define HL_CUR_TOKEN(g) \ @@ -2570,7 +2570,7 @@ viml_pexpr_parse_bracket_closing_error: new_top_node, _("E15: Don't know what figure brace means: %.*s")); if (pstate->colors) { - // Will reset to NVimInvalidFigureBrace. + // Will reset to NvimInvalidFigureBrace. kv_A(*pstate->colors, new_top_node->data.fig.opening_hl_idx).group = ( HL(FigureBrace)); -- cgit From 62993323494d846190590606d37aff1136421671 Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 1 Dec 2017 00:34:16 +0300 Subject: fix! set lsan options --- src/nvim/eval/encode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index ef647b3ee4..650f11a989 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -316,7 +316,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, #define TYPVAL_ENCODE_CONV_FLOAT(tv, flt) \ do { \ const float_T flt_ = (flt); \ - switch (fpclassify(flt_)) { \ + switch (fpclassify((double)flt_)) { \ case FP_NAN: { \ ga_concat(gap, (char_u *) "str2float('nan')"); \ break; \ -- cgit From 3d0ee17c916eca85ee28b8e716b6203f6d7fbf1c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 1 Dec 2017 04:12:59 +0100 Subject: tui/rxvt: enable focus-reporting closes #7578 --- src/nvim/tui/tui.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 724d59b15a..56a81a1c36 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1620,9 +1620,8 @@ static void augment_terminfo(TUIData *data, const char *term, ut, NULL, "\033]12;#%p1%06x\007"); } - /// Terminals generally ignore private modes that they do not recognize, - /// and there is no known ambiguity with these modes from terminal type to - /// terminal type, so we can afford to just set these unconditionally. + /// Terminals usually ignore unrecognized private modes, and there is no + /// known ambiguity with these. So we just set them unconditionally. data->unibi_ext.enable_lr_margin = (int)unibi_add_ext_str(ut, NULL, "\x1b[?69h"); data->unibi_ext.disable_lr_margin = (int)unibi_add_ext_str(ut, NULL, @@ -1632,9 +1631,9 @@ static void augment_terminfo(TUIData *data, const char *term, data->unibi_ext.disable_bracketed_paste = (int)unibi_add_ext_str(ut, NULL, "\x1b[?2004l"); data->unibi_ext.enable_focus_reporting = (int)unibi_add_ext_str(ut, NULL, - "\x1b[?1004h"); + rxvt ? "\x1b]777;focus;on\x7" : "\x1b[?1004h"); data->unibi_ext.disable_focus_reporting = (int)unibi_add_ext_str(ut, NULL, - "\x1b[?1004l"); + rxvt ? "\x1b]777;focus;off\x7" : "\x1b[?1004l"); data->unibi_ext.enable_mouse = (int)unibi_add_ext_str(ut, NULL, "\x1b[?1002h\x1b[?1006h"); data->unibi_ext.disable_mouse = (int)unibi_add_ext_str(ut, NULL, -- cgit From 27f9b1c7b029d8f61723fd261bed76ea7a01e68d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 1 Dec 2017 04:18:34 +0100 Subject: tui: emit some termcodes later (after startup) (#7664) For some reason, enabling focus reporting during terminal setup, causes slow rendering during Nvim startup on tmux 2.3 with the tmux `focus-events` option enabled. To workaround that issue, this commit defers the request. closes #7649 init.vim: call plug#begin('~/.config/nvim/plugged') Plug 'morhetz/gruvbox' call plug#end() set background=light " background light just to see the effect more quickly colorscheme gruvbox .tmux.conf: set -g focus-events on set-option -ga terminal-overrides ",xterm-256color:Tc" set-option -g default-terminal "screen-256color" Using `script` to record the terminal session (and `vterm-dump` to post-process the result): BEFORE this commit: ./build/bin/nvim -u NONE{CR}{LF} {DECSM 1049}{DECSM 1}{ESC =} {CUP *}{ED 2}{DECSM 2004}{DECSM 1004}{CSI 8,44,156 t}{CSI * r} {CUP 1,1} {CUP *}{ED 2}{DECSM 25} {DECRM 25}{CSI 2 q}{CSI 2 q} {CUP *}{ED 2}{LF} {ESC (B}{SGR *}{SGR 94}~ {CR}{LF} ~ {CR}{LF} AFTER this commit: ./build/bin/nvim -u NONE{CR}{LF} {DECSM 1049}{DECSM 1}{ESC =} {CUP *}{ED 2}{CSI 8,44,156 t}{CSI * r} {CUP 1,1} {CUP *}{ED 2}{DECSM 2004}{DECSM 1004}{DECSM 25} {DECRM 25}{CSI 2 q}{CSI 2 q} {CUP *}{ED 2}{LF} {ESC (B}{SGR *}{SGR 94}~ {CR}{LF} ~ {CR}{LF} ... --- src/nvim/tui/tui.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 56a81a1c36..9bd3364a43 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -167,6 +167,18 @@ static size_t unibi_pre_fmt_str(TUIData *data, unsigned int unibi_index, return unibi_run(str, data->params, buf, len); } +/// Emits some termcodes after Nvim startup, which were observed to slowdown +/// rendering during startup in tmux 2.3 (+focus-events). #7649 +static void terminfo_start_event(void **argv) +{ + UI *ui = argv[0]; + TUIData *data = ui->data; + // Enable bracketed paste + unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste); + // Enable focus reporting + unibi_out_ext(ui, data->unibi_ext.enable_focus_reporting); +} + static void termname_set_event(void **argv) { char *termname = argv[0]; @@ -244,10 +256,6 @@ static void terminfo_start(UI *ui) unibi_out(ui, unibi_enter_ca_mode); unibi_out(ui, unibi_keypad_xmit); unibi_out(ui, unibi_clear_screen); - // Enable bracketed paste - unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste); - // Enable focus reporting - unibi_out_ext(ui, data->unibi_ext.enable_focus_reporting); uv_loop_init(&data->write_loop); if (data->out_isatty) { uv_tty_init(&data->write_loop, &data->output_handle.tty, data->out_fd, 0); @@ -296,6 +304,8 @@ static void tui_terminal_start(UI *ui) update_size(ui); signal_watcher_start(&data->winch_handle, sigwinch_cb, SIGWINCH); term_input_start(&data->input); + loop_schedule_deferred(data->loop, + event_create(terminfo_start_event, 1, ui)); } static void tui_terminal_stop(UI *ui) -- cgit From 585d664b7b0d5032082bdc3ca8a17bc7fa34a4e8 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sat, 2 Dec 2017 15:25:24 +0800 Subject: vim-patch:8.0.0298 Problem: Ex command range with repeated search does not work. (Bruce DeVisser) Solution: Skip over \/, \? and \&. https://github.com/vim/vim/commit/cbf20fbcd3e9bb006f694bcc35da859930fb12a2 --- src/nvim/ex_docmd.c | 10 ++++++++-- src/nvim/testdir/test_cmdline.vim | 25 +++++++++++++++++++++++++ src/nvim/version.c | 2 +- 3 files changed, 34 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 5180420eff..801979a9cb 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3484,8 +3484,14 @@ char_u *skip_range( { unsigned delim; - while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;", *cmd) != NULL) { - if (*cmd == '\'') { + while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL) { + if (*cmd == '\\') { + if (cmd[1] == '?' || cmd[1] == '/' || cmd[1] == '&') { + cmd++; + } else { + break; + } + } else if (*cmd == '\'') { if (*++cmd == NUL && ctx != NULL) *ctx = EXPAND_NOTHING; } else if (*cmd == '/' || *cmd == '?') { diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 5fc519f822..ac44e09a5a 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -306,3 +306,28 @@ func Test_cmdline_complete_wildoptions() call assert_equal(a, b) bw! endfunc + +" using a leading backslash here +set cpo+=C + +func Test_cmdline_search_range() + new + call setline(1, ['a', 'b', 'c', 'd']) + /d + 1,\/s/b/B/ + call assert_equal('B', getline(2)) + + /a + $ + \?,4s/c/C/ + call assert_equal('C', getline(3)) + + call setline(1, ['a', 'b', 'c', 'd']) + %s/c/c/ + 1,\&s/b/B/ + call assert_equal('B', getline(2)) + + bwipe! +endfunc + +set cpo& diff --git a/src/nvim/version.c b/src/nvim/version.c index b228b8909d..0f058c751b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -958,7 +958,7 @@ static const int included_patches[] = { // 301, 300, // 299, - // 298, + 298, 297, // 296, // 295, -- cgit From 7ab36403e1abce45c688a33e2909c04e54da62e5 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sat, 2 Dec 2017 15:45:19 +0800 Subject: fix lint error --- src/nvim/ex_docmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 801979a9cb..e11788531b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3492,8 +3492,9 @@ char_u *skip_range( break; } } else if (*cmd == '\'') { - if (*++cmd == NUL && ctx != NULL) + if (*++cmd == NUL && ctx != NULL) { *ctx = EXPAND_NOTHING; + } } else if (*cmd == '/' || *cmd == '?') { delim = *cmd++; while (*cmd != NUL && *cmd != delim) -- cgit From 4b83f3791257c0aecff6c35dbe9a644a1a72418c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 2 Dec 2017 03:53:23 +0100 Subject: tui.c: request focus-reporting (fix regression) #7670 ref #7649 ref #7664 27f9b1c7b029d8 caused a regression: it uses loop_schedule_deferred() to defer emitting the "enable focus reporting" termcode. tui_main() never processes `tui_loop.events` (which loop_schedule_deferred() depends on), so the event was never actually processed. But fixing that (by processing `tui_loop.events`) would bring back the problem 27f9b1c7b029 tried to fix: it still emits the event too soon. Instead, do a little dance: schedule the event on `main_loop` and then forward it to `tui_loop`. NOTE: after this commit, in tmux 2.3 with `focus-events` enabled, FocusGained is fired on startup and when resuming from suspend. Using `script` to record the terminal session (and `vterm-dump` to post-process the result): BEFORE: {DECSM 1049}{DECSM 1}{ESC =} {CUP *}{ED *}{DECSM 2004}{DECSM 1004}{CSI 1,43 r} {CUP 1,1} {CUP *}{ED *}{SM 34}{DECSM 25} {DECRM 25}{CSI 2 q}{CSI 2 q} {CUP *}{ED *}{LF} {SGR *}{LS1}{SGR 94}~ ... AFTER: {CUP *}{ED *}{CSI 1,43 r} {CUP 1,1} {CUP *}{ED *}{SM 34}{DECSM 25} {DECRM 25}{CSI 2 q}{CSI 2 q} {CUP *}{ED *}{DECSM 2004}{DECSM 1004}{LF} {SGR *}{LS1}{SGR 94}~ ... --- src/nvim/event/loop.h | 9 ++++----- src/nvim/tui/tui.c | 15 +++++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/event/loop.h b/src/nvim/event/loop.h index b0ddc59469..d1a40d5cc9 100644 --- a/src/nvim/event/loop.h +++ b/src/nvim/event/loop.h @@ -19,12 +19,11 @@ typedef struct loop { MultiQueue *events; MultiQueue *thread_events; // Immediate events: - // "Events that should be processed after exiting uv_run() (to avoid - // recursion), but before returning from loop_poll_events()." - // 502aee690c980fcb3cfcb3f211dcfad06103db46 - // Practical consequence: these events are processed by + // "Processed after exiting uv_run() (to avoid recursion), but before + // returning from loop_poll_events()." 502aee690c98 + // Practical consequence (for main_loop): these events are processed by // state_enter()..os_inchar() - // whereas "regular" (main_loop.events) events are processed by + // whereas "regular" events (main_loop.events) are processed by // state_enter()..VimState.execute() // But state_enter()..os_inchar() can be "too early" if you want the event // to trigger UI updates and other user-activity-related side-effects. diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 9bd3364a43..2436295ad4 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -169,10 +169,16 @@ static size_t unibi_pre_fmt_str(TUIData *data, unsigned int unibi_index, /// Emits some termcodes after Nvim startup, which were observed to slowdown /// rendering during startup in tmux 2.3 (+focus-events). #7649 -static void terminfo_start_event(void **argv) +static void terminfo_after_startup_event(void **argv) { UI *ui = argv[0]; + bool defer = argv[1] != NULL; // clever(?) boolean without malloc() dance. TUIData *data = ui->data; + if (defer) { // We're on the main-loop. Now forward to the TUI loop. + loop_schedule(data->loop, + event_create(terminfo_after_startup_event, 2, ui, NULL)); + return; + } // Enable bracketed paste unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste); // Enable focus reporting @@ -268,6 +274,9 @@ static void terminfo_start(UI *ui) uv_pipe_init(&data->write_loop, &data->output_handle.pipe, 0); uv_pipe_open(&data->output_handle.pipe, data->out_fd); } + + loop_schedule(&main_loop, + event_create(terminfo_after_startup_event, 2, ui, ui)); } static void terminfo_stop(UI *ui) @@ -304,8 +313,6 @@ static void tui_terminal_start(UI *ui) update_size(ui); signal_watcher_start(&data->winch_handle, sigwinch_cb, SIGWINCH); term_input_start(&data->input); - loop_schedule_deferred(data->loop, - event_create(terminfo_start_event, 1, ui)); } static void tui_terminal_stop(UI *ui) @@ -352,7 +359,7 @@ static void tui_main(UIBridgeData *bridge, UI *ui) CONTINUE(bridge); while (!data->stop) { - loop_poll_events(&tui_loop, -1); + loop_poll_events(&tui_loop, -1); // tui_loop.events is never processed } ui_bridge_stopped(bridge); -- cgit From 7a4c9dc1c22c8cafba9c33cb7c085b7d0b467226 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 3 Dec 2017 00:14:18 +0800 Subject: vim-patch:8.0.0295 (#7671) Problem: test_viml hangs. Solution: Put resetting 'more' before sourcing the script. https://github.com/vim/vim/commit/7a073549a3b1e72037a4e98ceb406d057ac9ba50 --- src/nvim/testdir/runtest.vim | 1 - src/nvim/version.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/runtest.vim b/src/nvim/testdir/runtest.vim index 39ffabc024..4de1345679 100644 --- a/src/nvim/testdir/runtest.vim +++ b/src/nvim/testdir/runtest.vim @@ -203,7 +203,6 @@ let s:flaky = [ \ ] " Locate Test_ functions and execute them. -set nomore redir @q silent function /^Test_ redir END diff --git a/src/nvim/version.c b/src/nvim/version.c index b228b8909d..96161c91ff 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -961,7 +961,7 @@ static const int included_patches[] = { // 298, 297, // 296, - // 295, + 295, 294, // 293, 292, -- cgit From 44421a22c0d9e8e2181d9338a36d1a4ec1f329be Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 3 Dec 2017 00:25:50 +0800 Subject: vim-patch:8.0.0306 (#7675) Problem: mode() not sufficiently tested. Solution: Add more tests. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/e971df39a5aac5d9b7e8033247dc18b12daa0eb8 --- src/nvim/testdir/test_functions.vim | 34 ++++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 59807ca946..0ce034b63e 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -207,39 +207,73 @@ func! Test_mode() normal! 3G exe "normal i\\" call assert_equal('i-i', g:current_modes) + " i_CTRL-P: Multiple matches exe "normal i\uBa\\\u" call assert_equal('i-ic', g:current_modes) + " i_CTRL-P: Single match exe "normal iBro\\\u" call assert_equal('i-ic', g:current_modes) + " i_CTRL-X exe "normal iBa\\\u" call assert_equal('i-ix', g:current_modes) + " i_CTRL-X CTRL-P: Multiple matches exe "normal iBa\\\\u" call assert_equal('i-ic', g:current_modes) + " i_CTRL-X CTRL-P: Single match exe "normal iBro\\\\u" call assert_equal('i-ic', g:current_modes) + " i_CTRL-X CTRL-P + CTRL-P: Single match exe "normal iBro\\\\\u" call assert_equal('i-ic', g:current_modes) + " i_CTRL-X CTRL-L: Multiple matches + exe "normal i\\\\u" + call assert_equal('i-ic', g:current_modes) + " i_CTRL-X CTRL-L: Single match + exe "normal iBlu\\\\u" + call assert_equal('i-ic', g:current_modes) + " i_CTRL-P: No match exe "normal iCom\\\u" call assert_equal('i-ic', g:current_modes) + " i_CTRL-X CTRL-P: No match exe "normal iCom\\\\u" call assert_equal('i-ic', g:current_modes) + " i_CTRL-X CTRL-L: No match + exe "normal iabc\\\\u" + call assert_equal('i-ic', g:current_modes) + " R_CTRL-P: Multiple matches exe "normal RBa\\\u" call assert_equal('R-Rc', g:current_modes) + " R_CTRL-P: Single match exe "normal RBro\\\u" call assert_equal('R-Rc', g:current_modes) + " R_CTRL-X exe "normal RBa\\\u" call assert_equal('R-Rx', g:current_modes) + " R_CTRL-X CTRL-P: Multiple matches exe "normal RBa\\\\u" call assert_equal('R-Rc', g:current_modes) + " R_CTRL-X CTRL-P: Single match exe "normal RBro\\\\u" call assert_equal('R-Rc', g:current_modes) + " R_CTRL-X CTRL-P + CTRL-P: Single match exe "normal RBro\\\\\u" call assert_equal('R-Rc', g:current_modes) + " R_CTRL-X CTRL-L: Multiple matches + exe "normal R\\\\u" + call assert_equal('R-Rc', g:current_modes) + " R_CTRL-X CTRL-L: Single match + exe "normal RBlu\\\\u" + call assert_equal('R-Rc', g:current_modes) + " R_CTRL-P: No match exe "normal RCom\\\u" call assert_equal('R-Rc', g:current_modes) + " R_CTRL-X CTRL-P: No match exe "normal RCom\\\\u" call assert_equal('R-Rc', g:current_modes) + " R_CTRL-X CTRL-L: No match + exe "normal Rabc\\\\u" + call assert_equal('R-Rc', g:current_modes) call assert_equal('n', mode(0)) call assert_equal('n', mode(1)) diff --git a/src/nvim/version.c b/src/nvim/version.c index 24ee7ddffc..8d85855c6e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -950,7 +950,7 @@ static const int included_patches[] = { // 309, 308, 307, - // 306, + 306, 305, // 304, // 303, -- cgit From 6bc54832efcb8c269875dfa4eecd89e1984ead69 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 3 Dec 2017 16:53:29 +0300 Subject: Revert "fix! set lsan options" This reverts commit 62993323494d846190590606d37aff1136421671. --- src/nvim/eval/encode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 650f11a989..ef647b3ee4 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -316,7 +316,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, #define TYPVAL_ENCODE_CONV_FLOAT(tv, flt) \ do { \ const float_T flt_ = (flt); \ - switch (fpclassify((double)flt_)) { \ + switch (fpclassify(flt_)) { \ case FP_NAN: { \ ga_concat(gap, (char_u *) "str2float('nan')"); \ break; \ -- cgit From d763d2fe7aae1c531c72c1d542cad2b19719929b Mon Sep 17 00:00:00 2001 From: FlorianGit Date: Thu, 9 Nov 2017 21:31:17 +0100 Subject: Viml: Make filter and map handle null list correct filter('v:_null_list, 'v:val') should return v:_null_list and a similar statement should hold for map. Changes after review * Test inserted in legacy test suite has been removed by reverting the commit adding it. * Change the fix to tv_copy the argument before returning. * Readd the two tests on crashes, and modified their expected return value. * Move the test from 'incorrect behaviour' section to 'correct behaviour section' * Add analogous tests for v:_null_dict Always copy list or dictionary to return variable If the type of input is correct (i.e. either a list or a dictionary), this should also be returned. --- src/nvim/eval.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 577aa67c60..56aedb1b4e 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8457,11 +8457,13 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map) int idx = 0; if (argvars[0].v_type == VAR_LIST) { + tv_copy(&argvars[0], rettv); if ((l = argvars[0].vval.v_list) == NULL || (!map && tv_check_lock(l->lv_lock, arg_errmsg, TV_TRANSLATE))) { return; } } else if (argvars[0].v_type == VAR_DICT) { + tv_copy(&argvars[0], rettv); if ((d = argvars[0].vval.v_dict) == NULL || (!map && tv_check_lock(d->dv_lock, arg_errmsg, TV_TRANSLATE))) { return; @@ -8542,8 +8544,6 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map) did_emsg |= save_did_emsg; } - - tv_copy(&argvars[0], rettv); } static int filter_map_one(typval_T *tv, typval_T *expr, int map, int *remp) -- cgit From 3aa24042a8f7d591b8091b437fc9cdb03497bc7a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 27 Nov 2017 00:35:09 +0100 Subject: tui: dump termcap info if -V3 ('verbose' >= 3) Get terminal debugging info by starting Nvim with 'verbose' level 3: nvim -V3log This is like Vim's `:set termcap`, which was removed in Nvim (and would be very awkward to restore because of the decoupled UI). --- src/nvim/README.md | 35 +++++++++++++++++++- src/nvim/option.c | 11 +++---- src/nvim/tui/terminfo.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++ src/nvim/tui/tui.c | 21 ++++++++++-- src/nvim/ui_bridge.c | 3 +- 5 files changed, 147 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/README.md b/src/nvim/README.md index 0caf71e2c5..da87a0208e 100644 --- a/src/nvim/README.md +++ b/src/nvim/README.md @@ -32,6 +32,39 @@ The source files use extensions to hint about their purpose. - `*.h.generated.h` - exported functions’ declarations. - `*.c.generated.h` - static functions’ declarations. +TUI debugging +------------- + +### TUI troubleshoot + +Nvim logs its internal terminfo state at 'verbose' level 3. This makes it +possible to see exactly what terminfo values Nvim is using on any system. + + nvim -V3log + +### TUI trace + +The ancient `script` command is still the "state of the art" for tracing +terminal behavior. The libvterm `vterm-dump` utility formats the result for +human-readability. + +Record a Nvim terminal session and format it with `vterm-dump`: + + script foo + ./build/bin/nvim -u NONE + # Exit the script session with CTRL-d + + # Use `vterm-dump` utility to format the result. + ./.deps/usr/bin/vterm-dump foo > bar + +Then you can compare `bar` with another session, to debug TUI behavior. + +### Terminal reference + +- `man terminfo` +- http://bazaar.launchpad.net/~libvterm/libvterm/trunk/view/head:/doc/seqs.txt +- http://invisible-island.net/xterm/ctlseqs/ctlseqs.html + Nvim lifecycle -------------- @@ -39,7 +72,7 @@ Following describes how Nvim processes input. Consider a typical Vim-like editing session: -01. Vim dispays the welcome screen +01. Vim displays the welcome screen 02. User types: `:` 03. Vim enters command-line mode 04. User types: `edit README.txt` diff --git a/src/nvim/option.c b/src/nvim/option.c index 913d27d508..37c4233142 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -4906,15 +4906,14 @@ showoptions ( vimoption_T **items = xmalloc(sizeof(vimoption_T *) * PARAM_COUNT); - /* Highlight title */ - if (all == 2) - MSG_PUTS_TITLE(_("\n--- Terminal codes ---")); - else if (opt_flags & OPT_GLOBAL) + // Highlight title + if (opt_flags & OPT_GLOBAL) { MSG_PUTS_TITLE(_("\n--- Global option values ---")); - else if (opt_flags & OPT_LOCAL) + } else if (opt_flags & OPT_LOCAL) { MSG_PUTS_TITLE(_("\n--- Local option values ---")); - else + } else { MSG_PUTS_TITLE(_("\n--- Options ---")); + } /* * do the loop two times: diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c index fdc33f0a77..492c1c5e9c 100644 --- a/src/nvim/tui/terminfo.c +++ b/src/nvim/tui/terminfo.c @@ -9,7 +9,10 @@ #include #include "nvim/log.h" +#include "nvim/globals.h" #include "nvim/memory.h" +#include "nvim/message.h" +#include "nvim/option.h" #include "nvim/tui/terminfo.h" #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -166,3 +169,87 @@ unibi_term *terminfo_from_builtin(const char *term, char **termname) unibi_set_bool(ut, unibi_back_color_erase, false); return ut; } + +/// Dumps termcap info to the messages area. +/// Serves a similar purpose as Vim `:set termcap` (removed in Nvim). +/// +/// @note adapted from unibilium unibi-dump.c +void terminfo_info_msg(const unibi_term *const ut) +{ + if (exiting) { + return; + } + msg_puts_title("\n\n--- Terminal info --- {{{\n"); + + char *term; + get_tty_option("term", &term); + msg_printf_attr(0, "&term: %s\n", term); + msg_printf_attr(0, "Description: %s\n", unibi_get_name(ut)); + const char **a = unibi_get_aliases(ut); + if (*a) { + msg_puts("Aliases: "); + do { + msg_printf_attr(0, "%s%s\n", *a, a[1] ? " | " : ""); + a++; + } while (*a); + } + + msg_puts("Boolean capabilities:\n"); + for (enum unibi_boolean i = unibi_boolean_begin_ + 1; + i < unibi_boolean_end_; i++) { + msg_printf_attr(0, " %-25s %-10s = %s\n", unibi_name_bool(i), + unibi_short_name_bool(i), + unibi_get_bool(ut, i) ? "true" : "false"); + } + + msg_puts("Numeric capabilities:\n"); + for (enum unibi_numeric i = unibi_numeric_begin_ + 1; + i < unibi_numeric_end_; i++) { + int n = unibi_get_num(ut, i); // -1 means "empty" + msg_printf_attr(0, " %-25s %-10s = %hd\n", unibi_name_num(i), + unibi_short_name_num(i), n); + } + + msg_puts("String capabilities:\n"); + for (enum unibi_string i = unibi_string_begin_ + 1; + i < unibi_string_end_; i++) { + const char *s = unibi_get_str(ut, i); + if (s) { + msg_printf_attr(0, " %-25s %-10s = ", unibi_name_str(i), + unibi_short_name_str(i)); + // Most of these strings will contain escape sequences. + msg_outtrans_special((char_u *)s, false); + msg_putchar('\n'); + } + } + + if (unibi_count_ext_bool(ut)) { + msg_puts("Extended boolean capabilities:\n"); + for (size_t i = 0; i < unibi_count_ext_bool(ut); i++) { + msg_printf_attr(0, " %-25s = %s\n", + unibi_get_ext_bool_name(ut, i), + unibi_get_ext_bool(ut, i) ? "true" : "false"); + } + } + + if (unibi_count_ext_num(ut)) { + msg_puts("Extended numeric capabilities:\n"); + for (size_t i = 0; i < unibi_count_ext_num(ut); i++) { + msg_printf_attr(0, " %-25s = %hd\n", + unibi_get_ext_num_name(ut, i), + unibi_get_ext_num(ut, i)); + } + } + + if (unibi_count_ext_str(ut)) { + msg_puts("Extended string capabilities:\n"); + for (size_t i = 0; i < unibi_count_ext_str(ut); i++) { + msg_printf_attr(0, " %-25s = ", unibi_get_ext_str_name(ut, i)); + msg_outtrans_special((char_u *)unibi_get_ext_str(ut, i), false); + msg_putchar('\n'); + } + } + + msg_puts("}}}\n"); + xfree(term); +} diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 2436295ad4..739f3d18d2 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -354,10 +354,12 @@ static void tui_main(UIBridgeData *bridge, UI *ui) tui_terminal_start(ui); data->stop = false; - // allow the main thread to continue, we are ready to start handling UI - // callbacks + // Allow main thread to continue, we are ready to handle UI callbacks. CONTINUE(bridge); + loop_schedule_deferred(&main_loop, + event_create(show_termcap_event, 1, data->ut)); + while (!data->stop) { loop_poll_events(&tui_loop, -1); // tui_loop.events is never processed } @@ -1061,6 +1063,21 @@ static void tui_flush(UI *ui) flush_buf(ui, true); } +/// Dumps termcap info to the messages area, if 'verbose' >= 3. +static void show_termcap_event(void **argv) +{ + if (p_verbose < 3) { + return; + } + const unibi_term *const ut = argv[0]; + if (!ut) { + abort(); + } + // XXX: (future) if unibi_term is modified (e.g. after a terminal + // query-response) this is a race condition. + terminfo_info_msg(ut); +} + #ifdef UNIX static void suspend_event(void **argv) { diff --git a/src/nvim/ui_bridge.c b/src/nvim/ui_bridge.c index 5585886612..7573fa1653 100644 --- a/src/nvim/ui_bridge.c +++ b/src/nvim/ui_bridge.c @@ -82,6 +82,7 @@ UI *ui_bridge_attach(UI *ui, ui_main_fn ui_main, event_scheduler scheduler) abort(); } + // Suspend the main thread until CONTINUE is called by the UI thread. while (!rv->ready) { uv_cond_wait(&rv->cond, &rv->mutex); } @@ -149,7 +150,7 @@ static void ui_bridge_suspend(UI *b) uv_mutex_lock(&data->mutex); UI_BRIDGE_CALL(b, suspend, 1, b); data->ready = false; - // suspend the main thread until CONTINUE is called by the UI thread + // Suspend the main thread until CONTINUE is called by the UI thread. while (!data->ready) { uv_cond_wait(&data->cond, &data->mutex); } -- cgit From 9d689d639d71ab3d60cb88544619b8cef9510217 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 29 Nov 2017 03:01:16 +0100 Subject: tui: set descriptions on termcap extensions --- src/nvim/tui/tui.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 739f3d18d2..2cdd1979af 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1594,11 +1594,13 @@ static void augment_terminfo(TUIData *data, const char *term, || konsole // per commentary in VT102Emulation.cpp || teraterm // per TeraTerm "Supported Control Functions" doco || rxvt) { // per command.C - data->unibi_ext.resize_screen = (int)unibi_add_ext_str(ut, NULL, + data->unibi_ext.resize_screen = (int)unibi_add_ext_str(ut, + "ext.resize_screen", "\x1b[8;%p1%d;%p2%dt"); } if (putty || xterm || rxvt) { - data->unibi_ext.reset_scroll_region = (int)unibi_add_ext_str(ut, NULL, + data->unibi_ext.reset_scroll_region = (int)unibi_add_ext_str(ut, + "ext.reset_scroll_region", "\x1b[r"); } @@ -1656,21 +1658,29 @@ static void augment_terminfo(TUIData *data, const char *term, /// Terminals usually ignore unrecognized private modes, and there is no /// known ambiguity with these. So we just set them unconditionally. - data->unibi_ext.enable_lr_margin = (int)unibi_add_ext_str(ut, NULL, + data->unibi_ext.enable_lr_margin = (int)unibi_add_ext_str(ut, + "ext.enable_lr_margin", "\x1b[?69h"); - data->unibi_ext.disable_lr_margin = (int)unibi_add_ext_str(ut, NULL, + data->unibi_ext.disable_lr_margin = (int)unibi_add_ext_str(ut, + "ext.disable_lr_margin", "\x1b[?69l"); - data->unibi_ext.enable_bracketed_paste = (int)unibi_add_ext_str(ut, NULL, + data->unibi_ext.enable_bracketed_paste = (int)unibi_add_ext_str(ut, + "ext.enable_bpaste", "\x1b[?2004h"); - data->unibi_ext.disable_bracketed_paste = (int)unibi_add_ext_str(ut, NULL, + data->unibi_ext.disable_bracketed_paste = (int)unibi_add_ext_str(ut, + "ext.disable_bpaste", "\x1b[?2004l"); - data->unibi_ext.enable_focus_reporting = (int)unibi_add_ext_str(ut, NULL, + data->unibi_ext.enable_focus_reporting = (int)unibi_add_ext_str(ut, + "ext.enable_focus", rxvt ? "\x1b]777;focus;on\x7" : "\x1b[?1004h"); - data->unibi_ext.disable_focus_reporting = (int)unibi_add_ext_str(ut, NULL, + data->unibi_ext.disable_focus_reporting = (int)unibi_add_ext_str(ut, + "ext.disable_focus", rxvt ? "\x1b]777;focus;off\x7" : "\x1b[?1004l"); - data->unibi_ext.enable_mouse = (int)unibi_add_ext_str(ut, NULL, + data->unibi_ext.enable_mouse = (int)unibi_add_ext_str(ut, + "ext.enable_mouse", "\x1b[?1002h\x1b[?1006h"); - data->unibi_ext.disable_mouse = (int)unibi_add_ext_str(ut, NULL, + data->unibi_ext.disable_mouse = (int)unibi_add_ext_str(ut, + "ext.disable_mouse", "\x1b[?1002l\x1b[?1006l"); } -- cgit From 586dafee2f4824b6cd4e0be80d597fbb810a647e Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 27 Nov 2017 10:20:06 +0100 Subject: str2specialbuf(): fix comparison regression by 832c158a663c --- src/nvim/message.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/message.c b/src/nvim/message.c index b90c475ede..806de5e116 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1307,7 +1307,7 @@ char *str2special_save(const char *const str, const bool replace_spaces, return (char *)ga.ga_data; } -/// Convert character, replacing key one key code with printable representation +/// Convert character, replacing key with printable representation. /// /// @param[in,out] sp String to convert. Is advanced to the next key code. /// @param[in] replace_spaces Convert spaces into , normally used for @@ -1392,7 +1392,7 @@ void str2specialbuf(const char *sp, char *buf, size_t len) while (*sp) { const char *s = str2special(&sp, false, false); const size_t s_len = strlen(s); - if (s_len <= len) { + if (len <= s_len) { break; } memcpy(buf, s, s_len); -- cgit From 5de1eae4f2353de1dc4cdeb3e5bad0a908faf9c8 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 29 Nov 2017 02:54:19 +0100 Subject: msg_outtrans_special(): `const` some strings --- src/nvim/message.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/nvim/message.c b/src/nvim/message.c index 806de5e116..907a2472c8 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1237,27 +1237,24 @@ void msg_make(char_u *arg) } } -/* - * Output the string 'str' upto a NUL character. - * Return the number of characters it takes on the screen. - * - * If K_SPECIAL is encountered, then it is taken in conjunction with the - * following character and shown as , etc. Any other character - * which is not printable shown in <> form. - * If 'from' is TRUE (lhs of a mapping), a space is shown as . - * If a character is displayed in one of these special ways, is also - * highlighted (its highlight name is '8' in the p_hl variable). - * Otherwise characters are not highlighted. - * This function is used to show mappings, where we want to see how to type - * the character/string -- webb - */ -int -msg_outtrans_special ( - char_u *strstart, - int from /* TRUE for lhs of a mapping */ +/// Output the string 'str' upto a NUL character. +/// Return the number of characters it takes on the screen. +/// +/// If K_SPECIAL is encountered, then it is taken in conjunction with the +/// following character and shown as , etc. Any other character +/// which is not printable shown in <> form. +/// If 'from' is TRUE (lhs of a mapping), a space is shown as . +/// If a character is displayed in one of these special ways, is also +/// highlighted (its highlight name is '8' in the p_hl variable). +/// Otherwise characters are not highlighted. +/// This function is used to show mappings, where we want to see how to type +/// the character/string -- webb +int msg_outtrans_special( + const char_u *strstart, + int from ///< true for LHS of a mapping ) { - char_u *str = strstart; + const char_u *str = strstart; int retval = 0; int attr; -- cgit From 1cae99b4bf6517d559ff222b968c314198923260 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 2 Dec 2017 18:55:54 +0100 Subject: msg_outtrans_special(): handle NULL This is convenient for terminfo_info_msg(). --- src/nvim/message.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/message.c b/src/nvim/message.c index 907a2472c8..5c8f0655bf 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1254,11 +1254,13 @@ int msg_outtrans_special( int from ///< true for LHS of a mapping ) { + if (strstart == NULL) { + return 0; // Do nothing. + } const char_u *str = strstart; int retval = 0; - int attr; + int attr = hl_attr(HLF_8); - attr = hl_attr(HLF_8); while (*str != NUL) { const char *string; // Leading and trailing spaces need to be displayed in <> form. -- cgit From 2d4abc1caedf67487e100f5cef5eca78da68b3e7 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 4 Dec 2017 23:31:50 +0100 Subject: tui: flush -V3 ('verbose' >= 3) info ASAP --- src/nvim/tui/tui.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 2cdd1979af..9f2ae20fe3 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1073,9 +1073,12 @@ static void show_termcap_event(void **argv) if (!ut) { abort(); } + verbose_enter(); // XXX: (future) if unibi_term is modified (e.g. after a terminal // query-response) this is a race condition. terminfo_info_msg(ut); + verbose_leave(); + verbose_stop(); // flush now } #ifdef UNIX -- cgit From 90dd2b1473cf19a6467838dbae078eea4bdc3c61 Mon Sep 17 00:00:00 2001 From: Florian Larysch Date: Wed, 29 Nov 2017 18:43:02 +0100 Subject: tui: never flush buffers in midst of unibilium output e83845285 fixed an issue where long (true color) escape sequences got interrupted by the cursor visibility toggling caused by buffer flushes. cdfaecb25 introduces a new issue which causes similar problems: While the old buffer flushing code appended the cursor visibility escapes to the buffer before/after flushing, the new code effectively prepends the sequences. Assume the following sequence of events occurs: - A long escape code is issued using unibi_out when the buffer is almost full - out() gets called for a prefix of that escape code, causing the buffer to fill up - flush_buf(ui, false) is called and (correctly) does not insert any cursor toggling escapes - The rest of the escape code is written into the now empty buffer - At some later point, some other part of nvim calls flush_buf(ui, true), which then toggles the cursor, corrupting the escape code This could possibly also be fixed by tracking the state of the buffer (i.e. does it contain a partially output escape code?), but this seems fragile in the same way e83845285 turned out to be. The root cause for all these problems is the mismatch between nvim's (implicit) assumption that the buffer is flushable at any point in time and the non-atomicity of unibilium's character based callback interface. The proper fix (without modifying unibilium) is to ensure nvim's assumption about the buffer state holds at all times. To that end, add a "cork" flag which ensures one unibi_out-call never splits its output across a buffer flush; if an escape code does not fit into the current buffer, flush it without any part of the escape code in it and insert the whole escape code in the emptied buffer. This is a little more complex because it modifies the buffer in place rather than printing into another buffer, checking the remaining space in the terminal buffer and then memcpy'ing it. --- src/nvim/tui/tui.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 2436295ad4..d07eb9a923 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -96,6 +96,7 @@ typedef struct { bool immediate_wrap_after_last_column; bool mouse_enabled; bool busy, is_invisible; + bool cork, overflow; cursorentry_T cursor_shapes[SHAPE_IDX_COUNT]; HlAttrs print_attrs; bool default_attr; @@ -200,6 +201,8 @@ static void terminfo_start(UI *ui) data->default_attr = false; data->is_invisible = true; data->busy = false; + data->cork = false; + data->overflow = false; data->showing_mode = SHAPE_IDX_N; data->unibi_ext.enable_mouse = -1; data->unibi_ext.disable_mouse = -1; @@ -1219,8 +1222,18 @@ static void unibi_goto(UI *ui, int row, int col) } \ if (str) { \ unibi_var_t vars[26 + 26]; \ + size_t orig_pos = data->bufpos; \ + \ memset(&vars, 0, sizeof(vars)); \ + data->cork = true; \ +retry: \ unibi_format(vars, vars + 26, str, data->params, out, ui, NULL, NULL); \ + if (data->overflow) { \ + data->bufpos = orig_pos; \ + flush_buf(ui, true); \ + goto retry; \ + } \ + data->cork = false; \ } \ } while (0) static void unibi_out(UI *ui, int unibi_index) @@ -1239,8 +1252,17 @@ static void out(void *ctx, const char *str, size_t len) TUIData *data = ui->data; size_t available = sizeof(data->buf) - data->bufpos; + if (data->cork && data->overflow) { + return; + } + if (len > available) { - flush_buf(ui, false); + if (data->cork) { + data->overflow = true; + return; + } else { + flush_buf(ui, true); + } } memcpy(data->buf + data->bufpos, str, len); @@ -1696,6 +1718,7 @@ static void flush_buf(UI *ui, bool toggle_cursor) bufs, (unsigned)(bufp - bufs), NULL); uv_run(&data->write_loop, UV_RUN_DEFAULT); data->bufpos = 0; + data->overflow = false; } #if TERMKEY_VERSION_MAJOR > 0 || TERMKEY_VERSION_MINOR > 18 -- cgit From 54087d80f3603165c0bdeab9f14c9aba2ddb6c67 Mon Sep 17 00:00:00 2001 From: Florian Larysch Date: Tue, 5 Dec 2017 21:18:30 +0100 Subject: tui: always hide cursor when flushing The previous commit ensures that we can never flush the buffer in a state where toggling cursor visibility can corrupt other escape codes. Thus, we can remove the workaround added as part of e838452, simplyfing the code and hiding the cursor on more occasions. --- src/nvim/tui/tui.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index d07eb9a923..61d3bde450 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -297,7 +297,7 @@ static void terminfo_stop(UI *ui) unibi_out_ext(ui, data->unibi_ext.disable_bracketed_paste); // Disable focus reporting unibi_out_ext(ui, data->unibi_ext.disable_focus_reporting); - flush_buf(ui, true); + flush_buf(ui); uv_tty_reset_mode(); uv_close((uv_handle_t *)&data->output_handle, NULL); uv_run(&data->write_loop, UV_RUN_DEFAULT); @@ -1061,7 +1061,7 @@ static void tui_flush(UI *ui) cursor_goto(ui, saved_row, saved_col); - flush_buf(ui, true); + flush_buf(ui); } #ifdef UNIX @@ -1230,7 +1230,7 @@ retry: \ unibi_format(vars, vars + 26, str, data->params, out, ui, NULL, NULL); \ if (data->overflow) { \ data->bufpos = orig_pos; \ - flush_buf(ui, true); \ + flush_buf(ui); \ goto retry; \ } \ data->cork = false; \ @@ -1261,7 +1261,7 @@ static void out(void *ctx, const char *str, size_t len) data->overflow = true; return; } else { - flush_buf(ui, true); + flush_buf(ui); } } @@ -1679,7 +1679,7 @@ static void augment_terminfo(TUIData *data, const char *term, "\x1b[?1002l\x1b[?1006l"); } -static void flush_buf(UI *ui, bool toggle_cursor) +static void flush_buf(UI *ui) { uv_write_t req; uv_buf_t bufs[3]; @@ -1690,7 +1690,7 @@ static void flush_buf(UI *ui, bool toggle_cursor) return; } - if (toggle_cursor && !data->is_invisible) { + if (!data->is_invisible) { // cursor is visible. Write a "cursor invisible" command before writing the // buffer. bufp->base = data->invis; @@ -1705,7 +1705,7 @@ static void flush_buf(UI *ui, bool toggle_cursor) bufp++; } - if (toggle_cursor && !data->busy && data->is_invisible) { + if (!data->busy && data->is_invisible) { // not busy and the cursor is invisible. Write a "cursor normal" command // after writing the buffer. bufp->base = data->norm; -- cgit From ba7d6a9e6b3c42f1996d05cec471b4842eeb8b66 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 5 Dec 2017 13:27:06 +0100 Subject: ui: fix glitch with both ext_cmdline and cmd_wildmenu --- src/nvim/ex_getln.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index c1500e3121..99330c177c 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -3455,8 +3455,10 @@ nextwild ( return FAIL; } - MSG_PUTS("..."); /* show that we are busy */ - ui_flush(); + if (!ui_is_external(kUIWildmenu)) { + MSG_PUTS("..."); // show that we are busy + ui_flush(); + } i = (int)(xp->xp_pattern - ccline.cmdbuff); xp->xp_pattern_len = ccline.cmdpos - i; -- cgit From 5cbd3b383c09539fed7a7c41f882996bf3d0f8ad Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 6 Dec 2017 10:42:26 +0100 Subject: tui: ignore st terminfo cursor shape (Se, Ss) entries closes #7641 --- src/nvim/tui/tui.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 9f2ae20fe3..99433924f6 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1480,19 +1480,18 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, } } - // Some terminals cannot be trusted to report DECSCUSR support. So we keep - // blacklist for when we should not trust the reported features. - if (!((vte_version != 0 && vte_version < 3900) || konsole)) { - // Dickey ncurses terminfo has included the Ss and Se capabilities, - // pioneered by tmux, since 2011-07-14. So adding them to terminal types, - // that do actually have such control sequences but lack the correct - // definitions in terminfo, is a fixup, not an augmentation. + // Blacklist of terminals that cannot be trusted to report DECSCUSR support. + if (!(st || (vte_version != 0 && vte_version < 3900) || konsole)) { data->unibi_ext.reset_cursor_style = unibi_find_ext_str(ut, "Se"); data->unibi_ext.set_cursor_style = unibi_find_ext_str(ut, "Ss"); } + + // Dickey ncurses terminfo includes Ss/Se capabilities since 2011-07-14. So + // adding them to terminal types, that have such control sequences but lack + // the correct terminfo entries, is a fixup, not an augmentation. if (-1 == data->unibi_ext.set_cursor_style) { - // The DECSCUSR sequence to change the cursor shape is widely supported by - // several terminal types. https://github.com/gnachman/iTerm2/pull/92 + // DECSCUSR (cursor shape) sequence is widely supported by several terminal + // types. https://github.com/gnachman/iTerm2/pull/92 // xterm extension: vertical bar if (!konsole && ((xterm && !vte_version) // anything claiming xterm compat // per MinTTY 0.4.3-1 release notes from 2009 @@ -1502,6 +1501,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, || tmux // per tmux manual page // https://lists.gnu.org/archive/html/screen-devel/2013-03/msg00000.html || screen + || st // #7641 || rxvt // per command.C // per analysis of VT100Terminal.m || iterm || iterm_pretending_xterm -- cgit From ddce5bca03067ce7adf70496a3493cf12c016364 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 00:08:44 +0300 Subject: eval/typval: Add functions useful for hiding list implementation --- src/nvim/eval/typval.h | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'src') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index c44b85644d..9caf3f7b60 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -284,6 +284,54 @@ typedef struct list_stack_S { #define TV_DICT_HI2DI(hi) \ ((dictitem_T *)((hi)->hi_key - offsetof(dictitem_T, di_key))) +static inline void tv_list_ref(list_T *const l) + REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; + +/// Increase reference count for a given list +/// +/// Does nothing for NULL lists. +/// +/// @param[in] l List to modify. +static inline void tv_list_ref(list_T *const l) +{ + if (l == NULL) { + return; + } + l->lv_refcount++; +} + +static inline VarLockStatus tv_list_locked(const list_T *const l) + REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; + +/// Get list lock status +/// +/// Returns VAR_FIXED for NULL lists. +/// +/// @param[in] l List to check. +static inline VarLockStatus tv_list_locked(const list_T *const l) +{ + if (l == NULL) { + return VAR_FIXED; + } + return l->lv_lock; +} + +/// Set list lock status +/// +/// May only “set†VAR_FIXED for NULL lists. +/// +/// @param[out] l List to modify. +/// @param[in] lock New lock status. +static inline void tv_list_set_lock(list_T *const l, + const VarLockStatus lock) +{ + if (l == NULL) { + assert(lock == VAR_FIXED); + return; + } + l->lv_lock = lock; +} + static inline long tv_list_len(const list_T *const l) REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; @@ -298,6 +346,22 @@ static inline long tv_list_len(const list_T *const l) return l->lv_len; } +static inline listitem_T *tv_list_first(const list_T *const l) + REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; + +/// Get first list item +/// +/// @param[in] l List to get item from. +/// +/// @return List item or NULL in case of an empty list. +static inline listitem_T *tv_list_first(const list_T *const l) +{ + if (l == NULL) { + return NULL; + } + return l->lv_first; +} + static inline long tv_dict_len(const dict_T *const d) REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; @@ -352,6 +416,46 @@ extern const char *const tv_empty_string; /// Specifies that free_unref_items() function has (not) been entered extern bool tv_in_free_unref_items; +/// Iterate over a list +/// +/// @param modifier Modifier: expected to be const or nothing, volatile should +/// also work if you have any uses for the volatile list. +/// @param[in] l List to iterate over. +/// @param li Name of the variable with current listitem_T entry. +/// @param code Cycle body. +#define _TV_LIST_ITER_MOD(modifier, l, li, code) \ + do { \ + modifier list_T *const l_ = (l); \ + if (l_ != NULL) { \ + for (modifier listitem_T *const li = l_->lv_first; \ + li != NULL; li = li->li_next) { \ + code \ + } \ + } \ + } while (0) + +/// Iterate over a list +/// +/// To be used when you need to modify list or values you iterate over, use +/// #TV_LIST_ITER_CONST if you don’t. +/// +/// @param[in] l List to iterate over. +/// @param li Name of the variable with current listitem_T entry. +/// @param code Cycle body. +#define TV_LIST_ITER(l, li, code) \ + _TV_LIST_ITER_MOD(, l, li, code) + +/// Iterate over a list +/// +/// To be used when you don’t need to modify list or values you iterate over, +/// use #TV_LIST_ITER if you do. +/// +/// @param[in] l List to iterate over. +/// @param li Name of the variable with current listitem_T entry. +/// @param code Cycle body. +#define TV_LIST_ITER_CONST(l, li, code) \ + _TV_LIST_ITER_MOD(const, l, li, code) + /// Iterate over a dictionary /// /// @param[in] d Dictionary to iterate over. -- cgit From 49dd615693c9f6d86a180371abcd09d32ac8aeca Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 00:20:05 +0300 Subject: eval/typval: Add macros useful for hiding list item implementation --- src/nvim/eval/typval.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 9caf3f7b60..b00f43f625 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -456,6 +456,35 @@ extern bool tv_in_free_unref_items; #define TV_LIST_ITER_CONST(l, li, code) \ _TV_LIST_ITER_MOD(const, l, li, code) +// Below macros are macros to avoid duplicating code for functionally identical +// const and non-const function variants. + +/// Get typval_T out of list item +/// +/// @param[in] li List item to get typval_T from, must not be NULL. +/// +/// @return Pointer to typval_T. +#define TV_LIST_ITEM_TV(li) (&(li)->li_tv) + +/// Get next list item given the current one +/// +/// @param[in] l List to get item from. +/// @param[in] li List item to get typval_T from. +/// +/// @return Pointer to the next item or NULL. +#define TV_LIST_ITEM_NEXT(l, li) ((li)->li_next) + +/// Get previous list item given the current one +/// +/// @param[in] l List to get item from. +/// @param[in] li List item to get typval_T from. +/// +/// @return Pointer to the previous item or NULL. +#define TV_LIST_ITEM_PREV(l, li) ((li)->li_prev) +// List argument is not used currently, but it is a must for lists implemented +// as a pair (size(in list), array) without terminator - basically for lists on +// top of kvec. + /// Iterate over a dictionary /// /// @param[in] d Dictionary to iterate over. -- cgit From 274f32d42e61e6f6c76b9ca499f5b79f256a481a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 03:39:51 +0300 Subject: *: Start hiding list implementation Most of files, except for eval.c and eval/* were only processed by perl. --- src/nvim/api/private/helpers.c | 2 +- src/nvim/channel.c | 2 +- src/nvim/eval.c | 845 +++++++++++++++++++++-------------------- src/nvim/eval/decode.c | 16 +- src/nvim/eval/typval.c | 131 +++---- src/nvim/eval/typval.h | 33 +- src/nvim/lua/converter.c | 2 +- src/nvim/ops.c | 2 +- 8 files changed, 541 insertions(+), 492 deletions(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 629873998e..e5a1e150f9 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -798,7 +798,7 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err) tv_list_append(list, li); } - list->lv_refcount++; + tv_list_ref(list); tv->v_type = VAR_LIST; tv->vval.v_list = list; diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 40af470bde..ff8dbd3d33 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -673,7 +673,7 @@ static void on_channel_event(void **args) argv[1].v_type = VAR_LIST; argv[1].v_lock = VAR_UNLOCKED; argv[1].vval.v_list = ev->received; - argv[1].vval.v_list->lv_refcount++; + tv_list_ref(argv[1].vval.v_list); } else { argv[1].v_type = VAR_NUMBER; argv[1].v_lock = VAR_UNLOCKED; diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 56aedb1b4e..edf016fc41 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -564,8 +564,8 @@ void eval_init(void) dict_T *const msgpack_types_dict = tv_dict_alloc(); for (size_t i = 0; i < ARRAY_SIZE(msgpack_type_names); i++) { list_T *const type_list = tv_list_alloc(); - type_list->lv_lock = VAR_FIXED; - type_list->lv_refcount = 1; + tv_list_set_lock(type_list, VAR_FIXED); + tv_list_ref(type_list); dictitem_T *const di = tv_dict_item_alloc(msgpack_type_names[i]); di->di_flags |= DI_FLAGS_RO|DI_FLAGS_FIX; di->di_tv = (typval_T) { @@ -1014,7 +1014,7 @@ char_u *eval_to_string(char_u *arg, char_u **nextcmd, int convert) ga_init(&ga, (int)sizeof(char), 80); if (tv.vval.v_list != NULL) { tv_list_join(&ga, tv.vval.v_list, "\n"); - if (tv.vval.v_list->lv_len > 0) { + if (tv_list_len(tv.vval.v_list) > 0) { ga_append(&ga, NL); } } @@ -1143,27 +1143,31 @@ list_T *eval_spell_expr(char_u *badword, char_u *expr) return list; } -/* - * "list" is supposed to contain two items: a word and a number. Return the - * word in "pp" and the number as the return value. - * Return -1 if anything isn't right. - * Used to get the good word and score from the eval_spell_expr() result. - */ -int get_spellword(list_T *list, const char **pp) +/// Get spell word from an entry from spellsuggest=expr: +/// +/// Entry in question is supposed to be a list (to be checked by the caller) +/// with two items: a word and a score represented as an unsigned number +/// (whether it actually is unsigned is not checked). +/// +/// Used to get the good word and score from the eval_spell_expr() result. +/// +/// @param[in] list List to get values from. +/// @param[out] ret_word Suggested word. Not initialized if return value is +/// -1. +/// +/// @return -1 in case of error, score otherwise. +int get_spellword(list_T *const list, const char **ret_word) { - listitem_T *li; - - li = list->lv_first; - if (li == NULL) { + if (tv_list_len(list) != 2) { + EMSG(_("E5700: Expression from 'spellsuggest' must yield lists with " + "exactly two values")); return -1; } - *pp = tv_get_string(&li->li_tv); - - li = li->li_next; - if (li == NULL) { + *ret_word = tv_list_find_str(list, 0); + if (*ret_word == NULL) { return -1; } - return tv_get_number(&li->li_tv); + return tv_list_find_nr(list, -1, NULL); } @@ -1504,9 +1508,7 @@ ex_let_vars ( ) { char_u *arg = arg_start; - list_T *l; int i; - listitem_T *item; typval_T ltv; if (*arg != '[') { @@ -1518,13 +1520,12 @@ ex_let_vars ( return OK; } - /* - * ":let [v1, v2] = list" or ":for [v1, v2] in listlist" - */ - if (tv->v_type != VAR_LIST || (l = tv->vval.v_list) == NULL) { + // ":let [v1, v2] = list" or ":for [v1, v2] in listlist" + if (tv->v_type != VAR_LIST) { EMSG(_(e_listreq)); return FAIL; } + list_T *const l = tv->vval.v_list; i = tv_list_len(l); if (semicolon == 0 && var_count < i) { @@ -1535,29 +1536,33 @@ ex_let_vars ( EMSG(_("E688: More targets than List items")); return FAIL; } + // l may actually be NULL, but it should fail with E688 or even earlier if you + // try to do ":let [] = v:_null_list". + assert(l != NULL); - item = l->lv_first; + listitem_T *item = tv_list_first(l); while (*arg != ']') { arg = skipwhite(arg + 1); - arg = ex_let_one(arg, &item->li_tv, TRUE, (char_u *)",;]", nextchars); - item = item->li_next; - if (arg == NULL) + arg = ex_let_one(arg, TV_LIST_ITEM_TV(item), TRUE, (char_u *)",;]", nextchars); + item = TV_LIST_ITEM_NEXT(l, item); + if (arg == NULL) { return FAIL; + } arg = skipwhite(arg); if (*arg == ';') { /* Put the rest of the list (may be empty) in the var after ';'. * Create a new list for this. */ - l = tv_list_alloc(); + list_T *const rest_list = tv_list_alloc(); while (item != NULL) { - tv_list_append_tv(l, &item->li_tv); - item = item->li_next; + tv_list_append_tv(rest_list, TV_LIST_ITEM_TV(item)); + item = TV_LIST_ITEM_NEXT(l, item); } ltv.v_type = VAR_LIST; ltv.v_lock = 0; - ltv.vval.v_list = l; - l->lv_refcount = 1; + ltv.vval.v_list = rest_list; + tv_list_ref(rest_list); arg = ex_let_one(skipwhite(arg + 1), <v, false, (char_u *)"]", nextchars); @@ -2310,7 +2315,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv, } } - lp->ll_tv = &lp->ll_li->li_tv; + lp->ll_tv = TV_LIST_ITEM_TV(lp->ll_li); } } @@ -2375,45 +2380,49 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, int ll_n1 = lp->ll_n1; // Check whether any of the list items is locked - for (listitem_T *ri = rettv->vval.v_list->lv_first; + for (listitem_T *ri = tv_list_first(rettv->vval.v_list); ri != NULL && ll_li != NULL; ) { - if (tv_check_lock(ll_li->li_tv.v_lock, (const char *)lp->ll_name, + if (tv_check_lock(TV_LIST_ITEM_TV(ll_li)->v_lock, + (const char *)lp->ll_name, TV_CSTRING)) { return; } - ri = ri->li_next; + ri = TV_LIST_ITEM_NEXT(rettv->vval.v_list, ri); if (ri == NULL || (!lp->ll_empty2 && lp->ll_n2 == ll_n1)) { break; } - ll_li = ll_li->li_next; + ll_li = TV_LIST_ITEM_NEXT(lp->ll_list, ll_li); ll_n1++; } /* * Assign the List values to the list items. */ - for (ri = rettv->vval.v_list->lv_first; ri != NULL; ) { + for (ri = tv_list_first(rettv->vval.v_list); ri != NULL; ) { if (op != NULL && *op != '=') { - eexe_mod_op(&lp->ll_li->li_tv, &ri->li_tv, (const char *)op); + eexe_mod_op(TV_LIST_ITEM_TV(lp->ll_li), TV_LIST_ITEM_TV(ri), + (const char *)op); } else { - tv_clear(&lp->ll_li->li_tv); - tv_copy(&ri->li_tv, &lp->ll_li->li_tv); + tv_clear(TV_LIST_ITEM_TV(lp->ll_li)); + tv_copy(TV_LIST_ITEM_TV(ri), TV_LIST_ITEM_TV(lp->ll_li)); } - ri = ri->li_next; - if (ri == NULL || (!lp->ll_empty2 && lp->ll_n2 == lp->ll_n1)) + ri = TV_LIST_ITEM_NEXT(rettv->vval.v_list, ri); + if (ri == NULL || (!lp->ll_empty2 && lp->ll_n2 == lp->ll_n1)) { break; - if (lp->ll_li->li_next == NULL) { + } + if (TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li) == NULL) { // Need to add an empty item. tv_list_append_number(lp->ll_list, 0); - assert(lp->ll_li->li_next); + assert(TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li)); } - lp->ll_li = lp->ll_li->li_next; - ++lp->ll_n1; + lp->ll_li = TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li); + lp->ll_n1++; } if (ri != NULL) EMSG(_("E710: List value has more items than target")); else if (lp->ll_empty2 - ? (lp->ll_li != NULL && lp->ll_li->li_next != NULL) + ? (lp->ll_li != NULL + && TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li) != NULL) : lp->ll_n1 != lp->ll_n2) EMSG(_("E711: List value has not enough items")); } else { @@ -2514,7 +2523,7 @@ void *eval_for_line(const char_u *arg, bool *errp, char_u **nextcmdp, int skip) * list being used in "tv". */ fi->fi_list = l; tv_list_watch_add(l, &fi->fi_lw); - fi->fi_lw.lw_item = l->lv_first; + fi->fi_lw.lw_item = tv_list_first(l); } } } @@ -2532,21 +2541,18 @@ void *eval_for_line(const char_u *arg, bool *errp, char_u **nextcmdp, int skip) * Return TRUE when a valid item was found, FALSE when at end of list or * something wrong. */ -int next_for_item(void *fi_void, char_u *arg) +bool next_for_item(void *fi_void, char_u *arg) { - forinfo_T *fi = (forinfo_T *)fi_void; - int result; - listitem_T *item; + forinfo_T *fi = (forinfo_T *)fi_void; - item = fi->fi_lw.lw_item; - if (item == NULL) - result = FALSE; - else { - fi->fi_lw.lw_item = item->li_next; - result = (ex_let_vars(arg, &item->li_tv, TRUE, - fi->fi_semicolon, fi->fi_varcount, NULL) == OK); + listitem_T *item = fi->fi_lw.lw_item; + if (item == NULL) { + return false; + } else { + fi->fi_lw.lw_item = TV_LIST_ITEM_NEXT(fi->fi_list, item); + return (ex_let_vars(arg, TV_LIST_ITEM_TV(item), true, + fi->fi_semicolon, fi->fi_varcount, NULL) == OK); } - return result; } // TODO(ZyX-I): move to eval/ex_cmds @@ -2869,9 +2875,9 @@ static int do_unlet_var(lval_T *const lp, char_u *const name_end, int forceit) ret = FAIL; } *name_end = cc; - } else if ((lp->ll_list != NULL - && tv_check_lock(lp->ll_list->lv_lock, (const char *)lp->ll_name, - lp->ll_name_len)) + } else if (tv_check_lock(tv_list_locked(lp->ll_list), + (const char *)lp->ll_name, + lp->ll_name_len) || (lp->ll_dict != NULL && tv_check_lock(lp->ll_dict->dv_lock, (const char *)lp->ll_name, @@ -2883,8 +2889,9 @@ static int do_unlet_var(lval_T *const lp, char_u *const name_end, int forceit) int ll_n1 = lp->ll_n1; while (ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= ll_n1)) { - li = ll_li->li_next; - if (tv_check_lock(ll_li->li_tv.v_lock, (const char *)lp->ll_name, + li = TV_LIST_ITEM_NEXT(lp->ll_list, ll_li); + if (tv_check_lock(TV_LIST_ITEM_TV(ll_li)->v_lock, + (const char *)lp->ll_name, lp->ll_name_len)) { return false; } @@ -2892,12 +2899,12 @@ static int do_unlet_var(lval_T *const lp, char_u *const name_end, int forceit) ll_n1++; } - /* Delete a range of List items. */ + // Delete a range of List items. while (lp->ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= lp->ll_n1)) { - li = lp->ll_li->li_next; + li = TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li); tv_list_item_remove(lp->ll_list, lp->ll_li); lp->ll_li = li; - ++lp->ll_n1; + lp->ll_n1++; } } else { if (lp->ll_list != NULL) { @@ -3043,13 +3050,13 @@ static int do_lock_var(lval_T *lp, char_u *const name_end, const int deep, /* (un)lock a range of List items. */ while (li != NULL && (lp->ll_empty2 || lp->ll_n2 >= lp->ll_n1)) { - tv_item_lock(&li->li_tv, deep, lock); - li = li->li_next; - ++lp->ll_n1; + tv_item_lock(TV_LIST_ITEM_TV(li), deep, lock); + li = TV_LIST_ITEM_NEXT(lp->ll_list, li); + lp->ll_n1++; } } else if (lp->ll_list != NULL) { // (un)lock a List item. - tv_item_lock(&lp->ll_li->li_tv, deep, lock); + tv_item_lock(TV_LIST_ITEM_TV(lp->ll_li), deep, lock); } else { // (un)lock a Dictionary item. tv_item_lock(&lp->ll_di->di_tv, deep, lock); @@ -4511,15 +4518,15 @@ eval_index ( l = tv_list_alloc(); item = tv_list_find(rettv->vval.v_list, n1); while (n1++ <= n2) { - tv_list_append_tv(l, &item->li_tv); - item = item->li_next; + tv_list_append_tv(l, TV_LIST_ITEM_TV(item)); + item = TV_LIST_ITEM_NEXT(l, item); } tv_clear(rettv); rettv->v_type = VAR_LIST; rettv->vval.v_list = l; - l->lv_refcount++; + tv_list_ref(l); } else { - tv_copy(&tv_list_find(rettv->vval.v_list, n1)->li_tv, &var1); + tv_copy(TV_LIST_ITEM_TV(tv_list_find(rettv->vval.v_list, n1)), &var1); tv_clear(rettv); *rettv = var1; } @@ -4877,22 +4884,23 @@ static int get_list_tv(char_u **arg, typval_T *rettv, int evaluate) goto failret; if (evaluate) { item = tv_list_item_alloc(); - item->li_tv = tv; - item->li_tv.v_lock = 0; + *TV_LIST_ITEM_TV(item) = tv; + TV_LIST_ITEM_TV(item)->v_lock = VAR_UNLOCKED; tv_list_append(l, item); } - if (**arg == ']') + if (**arg == ']') { break; + } if (**arg != ',') { - EMSG2(_("E696: Missing comma in List: %s"), *arg); + emsgf(_("E696: Missing comma in List: %s"), *arg); goto failret; } *arg = skipwhite(*arg + 1); } if (**arg != ']') { - EMSG2(_("E697: Missing end of List ']': %s"), *arg); + emsgf(_("E697: Missing end of List ']': %s"), *arg); failret: if (evaluate) { tv_list_free(l); @@ -4904,7 +4912,7 @@ failret: if (evaluate) { rettv->v_type = VAR_LIST; rettv->vval.v_list = l; - ++l->lv_refcount; + tv_list_ref(l); } return OK; @@ -5260,6 +5268,7 @@ static int free_unref_items(int copyID) for (ll = gc_first_list; ll != NULL; ll = ll_next) { ll_next = ll->lv_used_next; if ((ll->lv_copyID & COPYID_MASK) != (copyID & COPYID_MASK) + // FIXME: Abstract away lv_watch. && ll->lv_watch == NULL) { // Free the List and ordinary items it contains, but don't recurse // into Lists and Dictionaries, they will be in the list of dicts @@ -5329,10 +5338,13 @@ bool set_ref_in_list(list_T *l, int copyID, ht_stack_T **ht_stack) // Mark each item in the list. If the item contains a hashtab // it is added to ht_stack, if it contains a list it is added to // list_stack. - for (listitem_T *li = cur_l->lv_first; !abort && li != NULL; - li = li->li_next) { - abort = set_ref_in_item(&li->li_tv, copyID, ht_stack, &list_stack); - } + TV_LIST_ITER(cur_l, li, { + abort = set_ref_in_item(TV_LIST_ITEM_TV(li), copyID, ht_stack, + &list_stack); + if (abort) { + break; + } + }); } if (list_stack == NULL) { @@ -6535,7 +6547,7 @@ static void f_add(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->vval.v_number = 1; /* Default: Failed */ if (argvars[0].v_type == VAR_LIST) { if ((l = argvars[0].vval.v_list) != NULL - && !tv_check_lock(l->lv_lock, "add() argument", TV_TRANSLATE)) { + && !tv_check_lock(tv_list_locked(l), "add() argument", TV_TRANSLATE)) { tv_list_append_tv(l, &argvars[1]); tv_copy(&argvars[0], rettv); } @@ -6586,9 +6598,10 @@ static void f_append(typval_T *argvars, typval_T *rettv, FunPtr fptr) && u_save(lnum, lnum + 1) == OK) { if (argvars[1].v_type == VAR_LIST) { l = argvars[1].vval.v_list; - if (l == NULL) + if (l == NULL) { return; - li = l->lv_first; + } + li = tv_list_first(l); } for (;; ) { if (l == NULL) { @@ -6596,7 +6609,7 @@ static void f_append(typval_T *argvars, typval_T *rettv, FunPtr fptr) } else if (li == NULL) { break; // End of list. } else { - tv = &li->li_tv; // Append item from list. + tv = TV_LIST_ITEM_TV(li); // Append item from list. } const char *const line = tv_get_string_chk(tv); if (line == NULL) { // Type error. @@ -6608,7 +6621,7 @@ static void f_append(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (l == NULL) { break; } - li = li->li_next; + li = TV_LIST_ITEM_NEXT(l, li); } appended_lines_mark(lnum, added); @@ -7247,30 +7260,26 @@ static void f_byteidxcomp(typval_T *argvars, typval_T *rettv, FunPtr fptr) int func_call(char_u *name, typval_T *args, partial_T *partial, dict_T *selfdict, typval_T *rettv) { - listitem_T *item; typval_T argv[MAX_FUNC_ARGS + 1]; int argc = 0; int dummy; int r = 0; - for (item = args->vval.v_list->lv_first; item != NULL; - item = item->li_next) { + TV_LIST_ITER(args->vval.v_list, item, { if (argc == MAX_FUNC_ARGS - (partial == NULL ? 0 : partial->pt_argc)) { EMSG(_("E699: Too many arguments")); - break; + goto func_call_skip_call; } - /* Make a copy of each argument. This is needed to be able to set - * v_lock to VAR_FIXED in the copy without changing the original list. - */ - tv_copy(&item->li_tv, &argv[argc++]); - } + // Make a copy of each argument. This is needed to be able to set + // v_lock to VAR_FIXED in the copy without changing the original list. + tv_copy(TV_LIST_ITEM_TV(item), &argv[argc++]); + }); - if (item == NULL) { - r = call_func(name, (int)STRLEN(name), rettv, argc, argv, NULL, - curwin->w_cursor.lnum, curwin->w_cursor.lnum, - &dummy, true, partial, selfdict); - } + r = call_func(name, (int)STRLEN(name), rettv, argc, argv, NULL, + curwin->w_cursor.lnum, curwin->w_cursor.lnum, + &dummy, true, partial, selfdict); +func_call_skip_call: // Free the arguments. while (argc > 0) { tv_clear(&argv[--argc]); @@ -7595,7 +7604,7 @@ static void f_count(typval_T *argvars, typval_T *rettv, FunPtr fptr) long idx; if ((l = argvars[0].vval.v_list) != NULL) { - li = l->lv_first; + li = tv_list_first(l); if (argvars[2].v_type != VAR_UNKNOWN) { bool error = false; @@ -7613,9 +7622,11 @@ static void f_count(typval_T *argvars, typval_T *rettv, FunPtr fptr) li = NULL; } - for (; li != NULL; li = li->li_next) - if (tv_equal(&li->li_tv, &argvars[1], ic, FALSE)) - ++n; + for (; li != NULL; li = TV_LIST_ITEM_NEXT(l, li)) { + if (tv_equal(TV_LIST_ITEM_TV(li), &argvars[1], ic, false)) { + n++; + } + } } } else if (argvars[0].v_type == VAR_DICT) { int todo; @@ -7933,34 +7944,51 @@ static void f_empty(typval_T *argvars, typval_T *rettv, FunPtr fptr) bool n = true; switch (argvars[0].v_type) { - case VAR_STRING: - case VAR_FUNC: - n = argvars[0].vval.v_string == NULL - || *argvars[0].vval.v_string == NUL; - break; - case VAR_PARTIAL: - n = false; - break; - case VAR_NUMBER: - n = argvars[0].vval.v_number == 0; - break; - case VAR_FLOAT: - n = argvars[0].vval.v_float == 0.0; - break; - case VAR_LIST: - n = argvars[0].vval.v_list == NULL - || argvars[0].vval.v_list->lv_first == NULL; - break; - case VAR_DICT: - n = argvars[0].vval.v_dict == NULL - || argvars[0].vval.v_dict->dv_hashtab.ht_used == 0; - break; - case VAR_SPECIAL: - n = argvars[0].vval.v_special != kSpecialVarTrue; - break; - case VAR_UNKNOWN: - EMSG2(_(e_intern2), "f_empty(UNKNOWN)"); - break; + case VAR_STRING: + case VAR_FUNC: { + n = argvars[0].vval.v_string == NULL + || *argvars[0].vval.v_string == NUL; + break; + } + case VAR_PARTIAL: { + n = false; + break; + } + case VAR_NUMBER: { + n = argvars[0].vval.v_number == 0; + break; + } + case VAR_FLOAT: { + n = argvars[0].vval.v_float == 0.0; + break; + } + case VAR_LIST: { + n = (tv_list_len(argvars[0].vval.v_list) == 0); + break; + } + case VAR_DICT: { + n = (tv_dict_len(argvars[0].vval.v_dict) == 0); + break; + } + case VAR_SPECIAL: { + // Using switch to get warning if SpecialVarValue receives more values. + switch (argvars[0].vval.v_special) { + case kSpecialVarTrue: { + n = false; + break; + } + case kSpecialVarFalse: + case kSpecialVarNull: { + n = true; + break; + } + } + break; + } + case VAR_UNKNOWN: { + EMSG2(_(e_intern2), "f_empty(UNKNOWN)"); + break; + } } rettv->vval.v_number = n; @@ -8024,17 +8052,22 @@ static void f_executable(typval_T *argvars, typval_T *rettv, FunPtr fptr) && os_can_exe((const char_u *)name, NULL, false))); } +typedef struct { + const list_T *const l; + const listitem_T *li; +} GetListLineCookie; + static char_u *get_list_line(int c, void *cookie, int indent) { - const listitem_T **const p = (const listitem_T **)cookie; - const listitem_T *item = *p; + GetListLineCookie *const p = (GetListLineCookie *)cookie; + const listitem_T *const item = p->li; if (item == NULL) { return NULL; } char buf[NUMBUFLEN]; - const char *const s = tv_get_string_buf_chk(&item->li_tv, buf); - *p = item->li_next; + const char *const s = tv_get_string_buf_chk(TV_LIST_ITEM_TV(item), buf); + p->li = TV_LIST_ITEM_NEXT(p->l, item); return (char_u *)(s == NULL ? NULL : xstrdup(s)); } @@ -8076,11 +8109,14 @@ static void f_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr) do_cmdline_cmd(tv_get_string(&argvars[0])); } else if (argvars[0].vval.v_list != NULL) { list_T *const list = argvars[0].vval.v_list; - list->lv_refcount++; - listitem_T *const item = list->lv_first; - do_cmdline(NULL, get_list_line, (void *)&item, + tv_list_ref(list); + GetListLineCookie cookie = { + .l = list, + .li = tv_list_first(list), + }; + do_cmdline(NULL, get_list_line, (void *)&cookie, DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT|DOCMD_KEYTYPED); - list->lv_refcount--; + tv_list_unref(list); } msg_silent = save_msg_silent; emsg_silent = save_emsg_silent; @@ -8262,14 +8298,7 @@ static void f_extend(typval_T *argvars, typval_T *rettv, FunPtr fptr) list_T *const l1 = argvars[0].vval.v_list; list_T *const l2 = argvars[1].vval.v_list; - if (l1 == NULL) { - const bool locked = tv_check_lock(VAR_FIXED, arg_errmsg, TV_TRANSLATE); - (void)locked; - assert(locked == true); - } else if (l2 == NULL) { - // Do nothing - tv_copy(&argvars[0], rettv); - } else if (!tv_check_lock(l1->lv_lock, arg_errmsg, TV_TRANSLATE)) { + if (!tv_check_lock(tv_list_locked(l1), arg_errmsg, TV_TRANSLATE)) { listitem_T *item; if (argvars[2].v_type != VAR_UNKNOWN) { before = (long)tv_get_number_chk(&argvars[2], &error); @@ -8277,7 +8306,7 @@ static void f_extend(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; // Type error; errmsg already given. } - if (before == l1->lv_len) { + if (before == tv_list_len(l1)) { item = NULL; } else { item = tv_list_find(l1, before); @@ -8286,8 +8315,9 @@ static void f_extend(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } } - } else + } else { item = NULL; + } tv_list_extend(l1, l2, item); tv_copy(&argvars[0], rettv); @@ -8459,7 +8489,8 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map) if (argvars[0].v_type == VAR_LIST) { tv_copy(&argvars[0], rettv); if ((l = argvars[0].vval.v_list) == NULL - || (!map && tv_check_lock(l->lv_lock, arg_errmsg, TV_TRANSLATE))) { + || (!map && tv_check_lock(tv_list_locked(l), arg_errmsg, + TV_TRANSLATE))) { return; } } else if (argvars[0].v_type == VAR_DICT) { @@ -8522,14 +8553,15 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map) } else { vimvars[VV_KEY].vv_type = VAR_NUMBER; - for (li = l->lv_first; li != NULL; li = nli) { + for (li = tv_list_first(l); li != NULL; li = nli) { if (map - && tv_check_lock(li->li_tv.v_lock, arg_errmsg, TV_TRANSLATE)) { + && tv_check_lock(TV_LIST_ITEM_TV(li)->v_lock, arg_errmsg, + TV_TRANSLATE)) { break; } - nli = li->li_next; + nli = TV_LIST_ITEM_NEXT(l, li); vimvars[VV_KEY].vv_nr = idx; - if (filter_map_one(&li->li_tv, expr, map, &rem) == FAIL + if (filter_map_one(TV_LIST_ITEM_TV(li), expr, map, &rem) == FAIL || did_emsg) break; if (!map && rem) { @@ -8935,7 +8967,7 @@ static void common_function(typval_T *argvars, typval_T *rettv, goto theend; } list = argvars[arg_idx].vval.v_list; - if (list == NULL || list->lv_len == 0) { + if (list == NULL || tv_list_len(list) == 0) { arg_idx = 0; } } @@ -8946,7 +8978,7 @@ static void common_function(typval_T *argvars, typval_T *rettv, // result is a VAR_PARTIAL if (arg_idx > 0 || (arg_pt != NULL && arg_pt->pt_argc > 0)) { const int arg_len = (arg_pt == NULL ? 0 : arg_pt->pt_argc); - const int lv_len = (list == NULL ? 0 : list->lv_len); + const int lv_len = tv_list_len(list); pt->pt_argc = arg_len + lv_len; pt->pt_argv = xmalloc(sizeof(pt->pt_argv[0]) * pt->pt_argc); @@ -8955,11 +8987,9 @@ static void common_function(typval_T *argvars, typval_T *rettv, tv_copy(&arg_pt->pt_argv[i], &pt->pt_argv[i]); } if (lv_len > 0) { - for (listitem_T *li = list->lv_first; - li != NULL; - li = li->li_next) { - tv_copy(&li->li_tv, &pt->pt_argv[i++]); - } + TV_LIST_ITER(list, li, { + tv_copy(TV_LIST_ITEM_TV(li), &pt->pt_argv[i++]); + }); } } @@ -9045,7 +9075,7 @@ static void f_get(typval_T *argvars, typval_T *rettv, FunPtr fptr) li = tv_list_find(l, tv_get_number_chk(&argvars[1], &error)); if (!error && li != NULL) { - tv = &li->li_tv; + tv = TV_LIST_ITEM_TV(li); } } } else if (argvars[0].v_type == VAR_DICT) { @@ -10067,7 +10097,7 @@ static void f_getreg(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (rettv->vval.v_list == NULL) { rettv->vval.v_list = tv_list_alloc(); } - rettv->vval.v_list->lv_refcount++; + tv_list_ref(rettv->vval.v_list); } else { rettv->v_type = VAR_STRING; rettv->vval.v_string = get_reg_contents(regname, arg2 ? kGRegExprSrc : 0); @@ -11024,39 +11054,40 @@ static void f_indent(typval_T *argvars, typval_T *rettv, FunPtr fptr) */ static void f_index(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - list_T *l; - listitem_T *item; long idx = 0; - int ic = FALSE; + bool ic = false; rettv->vval.v_number = -1; if (argvars[0].v_type != VAR_LIST) { EMSG(_(e_listreq)); return; } - l = argvars[0].vval.v_list; + list_T *const l = argvars[0].vval.v_list; if (l != NULL) { - item = l->lv_first; + listitem_T *item = tv_list_first(l); if (argvars[2].v_type != VAR_UNKNOWN) { bool error = false; // Start at specified item. Use the cached index that tv_list_find() // sets, so that a negative number also works. - item = tv_list_find(l, tv_get_number_chk(&argvars[2], &error)); - idx = l->lv_idx; - if (argvars[3].v_type != VAR_UNKNOWN) { - ic = tv_get_number_chk(&argvars[3], &error); - } - if (error) { + idx = tv_list_uidx(l, tv_get_number_chk(&argvars[2], &error)); + if (error || idx == -1) { item = NULL; + } else { + item = tv_list_find(l, idx); + assert(item != NULL); + } + if (argvars[3].v_type != VAR_UNKNOWN) { + ic = !!tv_get_number_chk(&argvars[3], &error); } } - for (; item != NULL; item = item->li_next, ++idx) - if (tv_equal(&item->li_tv, &argvars[1], ic, FALSE)) { + for (; item != NULL; item = TV_LIST_ITEM_NEXT(l, item), idx++) { + if (tv_equal(TV_LIST_ITEM_TV(item), &argvars[1], ic, false)) { rettv->vval.v_number = idx; break; } + } } } @@ -11220,7 +11251,6 @@ static void f_inputdialog(typval_T *argvars, typval_T *rettv, FunPtr fptr) */ static void f_inputlist(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - listitem_T *li; int selected; int mouse_used; @@ -11235,15 +11265,16 @@ static void f_inputlist(typval_T *argvars, typval_T *rettv, FunPtr fptr) msg_scroll = TRUE; msg_clr_eos(); - for (li = argvars[0].vval.v_list->lv_first; li != NULL; li = li->li_next) { - msg_puts(tv_get_string(&li->li_tv)); + TV_LIST_ITER_CONST(argvars[0].vval.v_list, li, { + msg_puts(tv_get_string(TV_LIST_ITEM_TV(li))); msg_putchar('\n'); - } + }); - /* Ask for choice. */ + // Ask for choice. selected = prompt_for_number(&mouse_used); - if (mouse_used) + if (mouse_used) { selected -= lines_left; + } rettv->vval.v_number = selected; } @@ -11299,9 +11330,8 @@ static void f_insert(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (argvars[0].v_type != VAR_LIST) { EMSG2(_(e_listarg), "insert()"); - } else if ((l = argvars[0].vval.v_list) != NULL - && !tv_check_lock(l->lv_lock, N_("insert() argument"), - TV_TRANSLATE)) { + } else if (!tv_check_lock(tv_list_locked((l = argvars[0].vval.v_list)), + N_("insert() argument"), TV_TRANSLATE)) { long before = 0; if (argvars[2].v_type != VAR_UNKNOWN) { before = tv_get_number_chk(&argvars[2], &error); @@ -11312,7 +11342,7 @@ static void f_insert(typval_T *argvars, typval_T *rettv, FunPtr fptr) } listitem_T *item = NULL; - if (before != l->lv_len) { + if (before != tv_list_len(l)) { item = tv_list_find(l, before); if (item == NULL) { EMSGN(_(e_listidx), before); @@ -11376,7 +11406,7 @@ static void f_islocked(typval_T *argvars, typval_T *rettv, FunPtr fptr) EMSG2(_(e_dictkey), lv.ll_newkey); } else if (lv.ll_list != NULL) { // List item. - rettv->vval.v_number = tv_islocked(&lv.ll_li->li_tv); + rettv->vval.v_number = tv_islocked(TV_LIST_ITEM_TV(lv.ll_li)); } else { // Dictionary item. rettv->vval.v_number = tv_islocked(&lv.ll_di->di_tv); @@ -11413,32 +11443,32 @@ static void dict_list(typval_T *const tv, typval_T *const rettv, switch (what) { case kDictListKeys: { - li->li_tv.v_type = VAR_STRING; - li->li_tv.v_lock = VAR_UNLOCKED; - li->li_tv.vval.v_string = vim_strsave(di->di_key); + TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; + TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; + TV_LIST_ITEM_TV(li)->vval.v_string = vim_strsave(di->di_key); break; } case kDictListValues: { - tv_copy(&di->di_tv, &li->li_tv); + tv_copy(&di->di_tv, TV_LIST_ITEM_TV(li)); break; } case kDictListItems: { // items() list_T *const sub_l = tv_list_alloc(); - li->li_tv.v_type = VAR_LIST; - li->li_tv.v_lock = VAR_UNLOCKED; - li->li_tv.vval.v_list = sub_l; - sub_l->lv_refcount++; + TV_LIST_ITEM_TV(li)->v_type = VAR_LIST; + TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; + TV_LIST_ITEM_TV(li)->vval.v_list = sub_l; + tv_list_ref(sub_l); listitem_T *sub_li = tv_list_item_alloc(); tv_list_append(sub_l, sub_li); - sub_li->li_tv.v_type = VAR_STRING; - sub_li->li_tv.v_lock = VAR_UNLOCKED; - sub_li->li_tv.vval.v_string = vim_strsave(di->di_key); + TV_LIST_ITEM_TV(sub_li)->v_type = VAR_STRING; + TV_LIST_ITEM_TV(sub_li)->v_lock = VAR_UNLOCKED; + TV_LIST_ITEM_TV(sub_li)->vval.v_string = vim_strsave(di->di_key); sub_li = tv_list_item_alloc(); tv_list_append(sub_l, sub_li); - tv_copy(&di->di_tv, &sub_li->li_tv); + tv_copy(&di->di_tv, TV_LIST_ITEM_TV(sub_li)); break; } } @@ -11536,15 +11566,13 @@ static char **tv_to_argv(typval_T *cmd_tv, const char **cmd, bool *executable) } list_T *argl = cmd_tv->vval.v_list; - int argc = argl->lv_len; + int argc = tv_list_len(argl); if (!argc) { EMSG(_(e_invarg)); // List must have at least one item. return NULL; } - assert(argl->lv_first); - - const char *exe = tv_get_string_chk(&argl->lv_first->li_tv); + const char *exe = tv_get_string_chk(TV_LIST_ITEM_TV(tv_list_first(argl))); if (!exe || !os_can_exe((const char_u *)exe, NULL, true)) { if (exe && executable) { *executable = false; @@ -11559,15 +11587,15 @@ static char **tv_to_argv(typval_T *cmd_tv, const char **cmd, bool *executable) // Build the argument vector int i = 0; char **argv = xcalloc(argc + 1, sizeof(char *)); - for (listitem_T *arg = argl->lv_first; arg != NULL; arg = arg->li_next) { - const char *a = tv_get_string_chk(&arg->li_tv); + TV_LIST_ITER_CONST(argl, arg, { + const char *a = tv_get_string_chk(TV_LIST_ITEM_TV(arg)); if (!a) { // Did emsg in tv_get_string_chk; just deallocate argv. shell_free_argv(argv); return NULL; } argv[i++] = xstrdup(a); - } + }); return argv; } @@ -11695,7 +11723,7 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) list_T *args = argvars[0].vval.v_list; - Channel **jobs = xcalloc(args->lv_len, sizeof(*jobs)); + Channel **jobs = xcalloc(tv_list_len(args), sizeof(*jobs)); ui_busy_start(); MultiQueue *waiting_jobs = multiqueue_new_parent(loop_on_put, &main_loop); @@ -11704,10 +11732,10 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) // -1 for jobs that were skipped or timed out. int i = 0; - for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next, i++) { + TV_LIST_ITER_CONST(args, arg, { Channel *chan = NULL; - if (arg->li_tv.v_type != VAR_NUMBER - || !(chan = find_job(arg->li_tv.vval.v_number, false))) { + if (TV_LIST_ITEM_TV(arg)->v_type != VAR_NUMBER + || !(chan = find_job(TV_LIST_ITEM_TV(arg)->vval.v_number, false))) { jobs[i] = NULL; } else { jobs[i] = chan; @@ -11719,7 +11747,8 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) multiqueue_replace_parent(chan->events, waiting_jobs); } } - } + i++; + }); int remaining = -1; uint64_t before = 0; @@ -11728,7 +11757,7 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) before = os_hrtime(); } - for (i = 0; i < args->lv_len; i++) { + for (i = 0; i < tv_list_len(args); i++) { if (remaining == 0) { // timed out break; @@ -11758,7 +11787,7 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) list_T *rv = tv_list_alloc(); // restore the parent queue for any jobs still alive - for (i = 0; i < args->lv_len; i++) { + for (i = 0; i < tv_list_len(args); i++) { if (jobs[i] == NULL) { tv_list_append_number(rv, -3); continue; @@ -11774,7 +11803,7 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) multiqueue_free(waiting_jobs); xfree(jobs); ui_busy_stop(); - rv->lv_refcount++; + tv_list_ref(rv); rettv->v_type = VAR_LIST; rettv->vval.v_list = rv; } @@ -11788,9 +11817,6 @@ static void f_join(typval_T *argvars, typval_T *rettv, FunPtr fptr) EMSG(_(e_listreq)); return; } - if (argvars[0].vval.v_list == NULL) { - return; - } const char *const sep = (argvars[1].v_type == VAR_UNKNOWN ? " " : tv_get_string_chk(&argvars[1])); @@ -12200,7 +12226,7 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) if (argvars[0].v_type == VAR_LIST) { if ((l = argvars[0].vval.v_list) == NULL) goto theend; - li = l->lv_first; + li = tv_list_first(l); } else { expr = str = (char_u *)tv_get_string(&argvars[0]); len = (long)STRLEN(str); @@ -12220,11 +12246,11 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) goto theend; } if (l != NULL) { - li = tv_list_find(l, start); + idx = tv_list_uidx(l, start); + li = tv_list_find(l, idx); if (li == NULL) { goto theend; } - idx = l->lv_idx; // Use the cached index. } else { if (start < 0) start = 0; @@ -12260,7 +12286,8 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) break; } xfree(tofree); - tofree = expr = str = (char_u *)encode_tv2echo(&li->li_tv, NULL); + tofree = expr = str = (char_u *)encode_tv2echo(TV_LIST_ITEM_TV(li), + NULL); if (str == NULL) { break; } @@ -12275,8 +12302,8 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) /* Advance to just after the match. */ if (l != NULL) { - li = li->li_next; - ++idx; + li = TV_LIST_ITEM_NEXT(l, li); + idx++; } else { startcol = (colnr_T)(regmatch.startp[0] + (*mb_ptr2len)(regmatch.startp[0]) - str); @@ -12289,18 +12316,22 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) if (match) { if (type == 4) { - listitem_T *li1 = rettv->vval.v_list->lv_first; - listitem_T *li2 = li1->li_next; - listitem_T *li3 = li2->li_next; - listitem_T *li4 = li3->li_next; - xfree(li1->li_tv.vval.v_string); - - int rd = (int)(regmatch.endp[0] - regmatch.startp[0]); - li1->li_tv.vval.v_string = vim_strnsave(regmatch.startp[0], rd); - li3->li_tv.vval.v_number = (varnumber_T)(regmatch.startp[0] - expr); - li4->li_tv.vval.v_number = (varnumber_T)(regmatch.endp[0] - expr); + list_T *const ret_l = rettv->vval.v_list; + listitem_T *li1 = tv_list_first(ret_l); + listitem_T *li2 = TV_LIST_ITEM_NEXT(ret_l, li1); + listitem_T *li3 = TV_LIST_ITEM_NEXT(ret_l, li2); + listitem_T *li4 = TV_LIST_ITEM_NEXT(ret_l, li3); + xfree(TV_LIST_ITEM_TV(li1)->vval.v_string); + + const size_t rd = (size_t)(regmatch.endp[0] - regmatch.startp[0]); + TV_LIST_ITEM_TV(li1)->vval.v_string = xmemdupz( + (const char *)regmatch.startp[0], rd); + TV_LIST_ITEM_TV(li3)->vval.v_number = (varnumber_T)( + regmatch.startp[0] - expr); + TV_LIST_ITEM_TV(li4)->vval.v_number = (varnumber_T)( + regmatch.endp[0] - expr); if (l != NULL) { - li2->li_tv.vval.v_number = (varnumber_T)idx; + TV_LIST_ITEM_TV(li2)->vval.v_number = (varnumber_T)idx; } } else if (type == 3) { int i; @@ -12318,7 +12349,7 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) } else if (type == 2) { // Return matched string. if (l != NULL) { - tv_copy(&li->li_tv, rettv); + tv_copy(TV_LIST_ITEM_TV(li), rettv); } else { rettv->vval.v_string = (char_u *)xmemdupz( (const char *)regmatch.startp[0], @@ -12342,8 +12373,8 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) if (type == 4 && l == NULL) { // matchstrpos() without a list: drop the second item - tv_list_item_remove(rettv->vval.v_list, - rettv->vval.v_list->lv_first->li_next); + list_T *const ret_l = rettv->vval.v_list; + tv_list_item_remove(ret_l, TV_LIST_ITEM_NEXT(ret_l, tv_list_first(ret_l))); } theend: @@ -12539,41 +12570,41 @@ static void max_min(const typval_T *const tv, typval_T *const rettv, const bool domax) FUNC_ATTR_NONNULL_ALL { - varnumber_T n = 0; bool error = false; + rettv->vval.v_number = 0; + varnumber_T n = (domax ? VARNUMBER_MIN : VARNUMBER_MAX); if (tv->v_type == VAR_LIST) { - const list_T *const l = tv->vval.v_list; - if (tv_list_len(l) != 0) { - n = tv_get_number_chk(&l->lv_first->li_tv, &error); - for (const listitem_T *li = l->lv_first->li_next; li != NULL && !error; - li = li->li_next) { - const varnumber_T i = tv_get_number_chk(&li->li_tv, &error); - if (domax ? i > n : i < n) { - n = i; - } - } + if (tv_list_len(tv->vval.v_list) == 0) { + return; } + TV_LIST_ITER_CONST(tv->vval.v_list, li, { + const varnumber_T i = tv_get_number_chk(TV_LIST_ITEM_TV(li), &error); + if (error) { + return; + } + if (domax ? i > n : i < n) { + n = i; + } + }); } else if (tv->v_type == VAR_DICT) { - if (tv->vval.v_dict != NULL) { - bool first = true; - TV_DICT_ITER(tv->vval.v_dict, di, { - const varnumber_T i = tv_get_number_chk(&di->di_tv, &error); - if (error) { - break; - } - if (first) { - n = i; - first = true; - } else if (domax ? i > n : i < n) { - n = i; - } - }); + if (tv_dict_len(tv->vval.v_dict) == 0) { + return; } + TV_DICT_ITER(tv->vval.v_dict, di, { + const varnumber_T i = tv_get_number_chk(&di->di_tv, &error); + if (error) { + return; + } + if (domax ? i > n : i < n) { + n = i; + } + }); } else { EMSG2(_(e_listdictarg), domax ? "max()" : "min()"); + return; } - rettv->vval.v_number = error ? 0 : n; + rettv->vval.v_number = n; } /* @@ -12659,22 +12690,19 @@ static void f_msgpackdump(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } list_T *ret_list = tv_list_alloc_ret(rettv); - const list_T *list = argvars[0].vval.v_list; - if (list == NULL) { - return; - } + list_T *list = argvars[0].vval.v_list; msgpack_packer *lpacker = msgpack_packer_new(ret_list, &encode_list_write); const char *const msg = _("msgpackdump() argument, index %i"); // Assume that translation will not take more then 4 times more space char msgbuf[sizeof("msgpackdump() argument, index ") * 4 + NUMBUFLEN]; int idx = 0; - for (listitem_T *li = list->lv_first; li != NULL; li = li->li_next) { - vim_snprintf(msgbuf, sizeof(msgbuf), (char *) msg, idx); + TV_LIST_ITER(list, li, { + vim_snprintf(msgbuf, sizeof(msgbuf), (char *)msg, idx); idx++; - if (encode_vim_to_msgpack(lpacker, &li->li_tv, msgbuf) == FAIL) { + if (encode_vim_to_msgpack(lpacker, TV_LIST_ITEM_TV(li), msgbuf) == FAIL) { break; } - } + }); msgpack_packer_free(lpacker); } @@ -12688,10 +12716,10 @@ static void f_msgpackparse(typval_T *argvars, typval_T *rettv, FunPtr fptr) } list_T *ret_list = tv_list_alloc_ret(rettv); const list_T *list = argvars[0].vval.v_list; - if (list == NULL || list->lv_first == NULL) { + if (tv_list_len(list) == 0) { return; } - if (list->lv_first->li_tv.v_type != VAR_STRING) { + if (TV_LIST_ITEM_TV(tv_list_first(list))->v_type != VAR_STRING) { EMSG2(_(e_invarg2), "List item is not a string"); return; } @@ -12732,9 +12760,9 @@ static void f_msgpackparse(typval_T *argvars, typval_T *rettv, FunPtr fptr) } if (result == MSGPACK_UNPACK_SUCCESS) { listitem_T *li = tv_list_item_alloc(); - li->li_tv.v_type = VAR_UNKNOWN; + TV_LIST_ITEM_TV(li)->v_type = VAR_UNKNOWN; tv_list_append(ret_list, li); - if (msgpack_to_vim(unpacked.data, &li->li_tv) == FAIL) { + if (msgpack_to_vim(unpacked.data, TV_LIST_ITEM_TV(li)) == FAIL) { EMSG2(_(e_invarg2), "Failed to convert msgpack string"); goto f_msgpackparse_exit; } @@ -13027,9 +13055,9 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) } li = tv_list_item_alloc(); - li->li_tv.v_type = VAR_STRING; - li->li_tv.v_lock = 0; - li->li_tv.vval.v_string = s; + TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; + TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; + TV_LIST_ITEM_TV(li)->vval.v_string = s; tv_list_append(rettv->vval.v_list, li); start = p + 1; /* step over newline */ @@ -13106,7 +13134,8 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) */ if (maxline < 0) while (cnt > -maxline) { - tv_list_item_remove(rettv->vval.v_list, rettv->vval.v_list->lv_first); + tv_list_item_remove(rettv->vval.v_list, + tv_list_first(rettv->vval.v_list)); cnt--; } @@ -13123,9 +13152,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// @return OK In case of success, FAIL in case of error static int list2proftime(typval_T *arg, proftime_T *tm) FUNC_ATTR_NONNULL_ALL { - if (arg->v_type != VAR_LIST - || arg->vval.v_list == NULL - || arg->vval.v_list->lv_len != 2) { + if (arg->v_type != VAR_LIST || tv_list_len(arg->vval.v_list) != 2) { return FAIL; } @@ -13249,8 +13276,8 @@ static void f_remove(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } else if (argvars[0].v_type != VAR_LIST) { EMSG2(_(e_listdictarg), "remove()"); - } else if ((l = argvars[0].vval.v_list) != NULL - && !tv_check_lock(l->lv_lock, arg_errmsg, TV_TRANSLATE)) { + } else if (!tv_check_lock(tv_list_locked((l = argvars[0].vval.v_list)), + arg_errmsg, TV_TRANSLATE)) { bool error = false; idx = tv_get_number_chk(&argvars[1], &error); @@ -13262,7 +13289,7 @@ static void f_remove(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (argvars[2].v_type == VAR_UNKNOWN) { // Remove one item, return its value. tv_list_remove_items(l, item, item); - *rettv = item->li_tv; + *rettv = *TV_LIST_ITEM_TV(item); xfree(item); } else { // Remove range of items, return list with values. @@ -13274,15 +13301,17 @@ static void f_remove(typval_T *argvars, typval_T *rettv, FunPtr fptr) } else { int cnt = 0; - for (li = item; li != NULL; li = li->li_next) { - ++cnt; - if (li == item2) + for (li = item; li != NULL; li = TV_LIST_ITEM_NEXT(l, li)) { + cnt++; + if (li == item2) { break; + } } if (li == NULL) { // Didn't find "item2" after "item". emsgf(_(e_invrange)); } else { tv_list_remove_items(l, item, item2); + // FIXME: Abstract the below away or move to eval/typval. l = tv_list_alloc_ret(rettv); l->lv_first = item; l->lv_last = item2; @@ -13524,9 +13553,9 @@ static void f_reverse(typval_T *argvars, typval_T *rettv, FunPtr fptr) list_T *l; if (argvars[0].v_type != VAR_LIST) { EMSG2(_(e_listarg), "reverse()"); - } else if ((l = argvars[0].vval.v_list) != NULL - && !tv_check_lock(l->lv_lock, N_("reverse() argument"), - TV_TRANSLATE)) { + } else if (!tv_check_lock(tv_list_locked((l = argvars[0].vval.v_list)), + N_("reverse() argument"), TV_TRANSLATE)) { + // FIXME: Abstract the below away or move to eval/typval. listitem_T *li = l->lv_last; l->lv_first = l->lv_last = NULL; l->lv_len = 0; @@ -13537,7 +13566,7 @@ static void f_reverse(typval_T *argvars, typval_T *rettv, FunPtr fptr) } rettv->vval.v_list = l; rettv->v_type = VAR_LIST; - l->lv_refcount++; + tv_list_ref(l); l->lv_idx = l->lv_len - l->lv_idx - 1; } } @@ -13836,14 +13865,17 @@ static void f_rpcstart(typval_T *argvars, typval_T *rettv, FunPtr fptr) int argsl = 0; if (argvars[1].v_type == VAR_LIST) { args = argvars[1].vval.v_list; - argsl = args->lv_len; + argsl = tv_list_len(args); // Assert that all list items are strings - for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { - if (arg->li_tv.v_type != VAR_STRING) { - EMSG(_(e_invarg)); + int i = 0; + TV_LIST_ITER_CONST(args, arg, { + if (TV_LIST_ITEM_TV(arg)->v_type != VAR_STRING) { + emsgf(_("E5010: List item %d of the second argument is not a string"), + i); return; } - } + i++; + }); } if (argvars[0].vval.v_string == NULL || argvars[0].vval.v_string[0] == NUL) { @@ -13861,9 +13893,9 @@ static void f_rpcstart(typval_T *argvars, typval_T *rettv, FunPtr fptr) int i = 1; // Copy arguments to the vector if (argsl > 0) { - for (listitem_T *arg = args->lv_first; arg != NULL; arg = arg->li_next) { - argv[i++] = xstrdup(tv_get_string(&arg->li_tv)); - } + TV_LIST_ITER_CONST(args, arg, { + argv[i++] = xstrdup(tv_get_string(TV_LIST_ITEM_TV(arg))); + }); } // The last item of argv must be NULL @@ -14292,9 +14324,9 @@ static void f_serverlist(typval_T *argvars, typval_T *rettv, FunPtr fptr) list_T *l = tv_list_alloc_ret(rettv); for (size_t i = 0; i < n; i++) { listitem_T *li = tv_list_item_alloc(); - li->li_tv.v_type = VAR_STRING; - li->li_tv.v_lock = 0; - li->li_tv.vval.v_string = (char_u *)addrs[i]; + TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; + TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; + TV_LIST_ITEM_TV(li)->vval.v_string = (char_u *)addrs[i]; tv_list_append(l, li); } xfree(addrs); @@ -14503,7 +14535,7 @@ static void f_setline(typval_T *argvars, typval_T *rettv, FunPtr fptr) const char *line = NULL; if (argvars[1].v_type == VAR_LIST) { l = argvars[1].vval.v_list; - li = l->lv_first; + li = tv_list_first(l); } else { line = tv_get_string_chk(&argvars[1]); } @@ -14515,8 +14547,8 @@ static void f_setline(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (li == NULL) { break; } - line = tv_get_string_chk(&li->li_tv); - li = li->li_next; + line = tv_get_string_chk(TV_LIST_ITEM_TV(li)); + li = TV_LIST_ITEM_NEXT(l, li); } rettv->vval.v_number = 1; /* FAIL */ @@ -14648,8 +14680,6 @@ static void f_setloclist(typval_T *argvars, typval_T *rettv, FunPtr fptr) */ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - list_T *l; - listitem_T *li; dict_T *d; list_T *s = NULL; @@ -14658,15 +14688,17 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) EMSG(_(e_listreq)); return; } + list_T *l; if ((l = argvars[0].vval.v_list) != NULL) { - /* To some extent make sure that we are dealing with a list from - * "getmatches()". */ - li = l->lv_first; - while (li != NULL) { - if (li->li_tv.v_type != VAR_DICT - || (d = li->li_tv.vval.v_dict) == NULL) { - EMSG(_(e_invarg)); + // To some extent make sure that we are dealing with a list from + // "getmatches()". + int i = 0; + TV_LIST_ITER_CONST(l, li, { + if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT + || (d = TV_LIST_ITEM_TV(li)->vval.v_dict) == NULL) { + emsgf(_("E474: List item %d is either not a dictionary " + "or an empty one"), i); return; } if (!(tv_dict_find(d, S_LEN("group")) != NULL @@ -14674,19 +14706,18 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) || tv_dict_find(d, S_LEN("pos1")) != NULL) && tv_dict_find(d, S_LEN("priority")) != NULL && tv_dict_find(d, S_LEN("id")) != NULL)) { - EMSG(_(e_invarg)); + emsgf(_("E474: List item %d is missing one of the required keys"), i); return; } - li = li->li_next; - } + i++; + }); clear_matches(curwin); - li = l->lv_first; bool match_add_failed = false; - while (li != NULL) { + TV_LIST_ITER_CONST(l, li, { int i = 0; - d = li->li_tv.vval.v_dict; + d = TV_LIST_ITEM_TV(li)->vval.v_dict; dictitem_T *const di = tv_dict_find(d, S_LEN("pattern")); if (di == NULL) { if (s == NULL) { @@ -14704,7 +14735,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) } tv_list_append_tv(s, &pos_di->di_tv); - s->lv_refcount++; + tv_list_ref(s); } else { break; } @@ -14739,8 +14770,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) tv_list_unref(s); s = NULL; } - li = li->li_next; - } + }); if (!match_add_failed) { rettv->vval.v_number = 0; } @@ -14860,7 +14890,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (argvars[1].v_type == VAR_LIST) { list_T *ll = argvars[1].vval.v_list; // If the list is NULL handle like an empty list. - int len = ll == NULL ? 0 : ll->lv_len; + const int len = tv_list_len(ll); // First half: use for pointers to result lines; second half: use for // pointers to allocated copies. @@ -14869,11 +14899,9 @@ static void f_setreg(typval_T *argvars, typval_T *rettv, FunPtr fptr) char **allocval = lstval + len + 2; char **curallocval = allocval; - for (listitem_T *li = ll == NULL ? NULL : ll->lv_first; - li != NULL; - li = li->li_next) { + TV_LIST_ITER_CONST(ll, li, { char buf[NUMBUFLEN]; - *curval = tv_get_string_buf_chk(&li->li_tv, buf); + *curval = tv_get_string_buf_chk(TV_LIST_ITEM_TV(li), buf); if (*curval == NULL) { goto free_lstval; } @@ -14885,7 +14913,7 @@ static void f_setreg(typval_T *argvars, typval_T *rettv, FunPtr fptr) curallocval++; } curval++; - } + }); *curval++ = NULL; write_reg_contents_lst(regname, (char_u **)lstval, append, yank_type, @@ -15135,8 +15163,8 @@ static int item_compare(const void *s1, const void *s2, bool keep_zero) sortItem_T *const si1 = (sortItem_T *)s1; sortItem_T *const si2 = (sortItem_T *)s2; - typval_T *const tv1 = &si1->item->li_tv; - typval_T *const tv2 = &si2->item->li_tv; + typval_T *const tv1 = TV_LIST_ITEM_TV(si1->item); + typval_T *const tv2 = TV_LIST_ITEM_TV(si2->item); int res; @@ -15249,8 +15277,8 @@ static int item_compare2(const void *s1, const void *s2, bool keep_zero) // Copy the values. This is needed to be able to set v_lock to VAR_FIXED // in the copy without changing the original list items. - tv_copy(&si1->item->li_tv, &argv[0]); - tv_copy(&si2->item->li_tv, &argv[1]); + tv_copy(TV_LIST_ITEM_TV(si1->item), &argv[0]); + tv_copy(TV_LIST_ITEM_TV(si2->item), &argv[1]); rettv.v_type = VAR_UNKNOWN; // tv_clear() uses this res = call_func((const char_u *)func_name, @@ -15294,8 +15322,6 @@ static int item_compare2_not_keeping_zero(const void *s1, const void *s2) */ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) { - list_T *l; - listitem_T *li; sortItem_T *ptrs; long len; long i; @@ -15313,13 +15339,13 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) if (argvars[0].v_type != VAR_LIST) { EMSG2(_(e_listarg), sort ? "sort()" : "uniq()"); } else { - l = argvars[0].vval.v_list; - if (l == NULL || tv_check_lock(l->lv_lock, arg_errmsg, TV_TRANSLATE)) { + list_T *const l = argvars[0].vval.v_list; + if (tv_check_lock(tv_list_locked(l), arg_errmsg, TV_TRANSLATE)) { goto theend; } rettv->vval.v_list = l; rettv->v_type = VAR_LIST; - ++l->lv_refcount; + tv_list_ref(l); len = tv_list_len(l); if (len <= 1) { @@ -15391,11 +15417,11 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) i = 0; if (sort) { // sort(): ptrs will be the list to sort. - for (li = l->lv_first; li != NULL; li = li->li_next) { + TV_LIST_ITER(l, li, { ptrs[i].item = li; ptrs[i].idx = i; i++; - } + }); info.item_compare_func_err = false; // Test the compare function. @@ -15414,6 +15440,7 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) if (!info.item_compare_func_err) { // Clear the list and append the items in the sorted order. + // FIXME: Somehow abstract away or move to eval/typval. l->lv_first = NULL; l->lv_last = NULL; l->lv_idx_item = NULL; @@ -15431,25 +15458,30 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) info.item_compare_func_err = false; if (info.item_compare_func != NULL || info.item_compare_partial != NULL) { - item_compare_func_ptr = item_compare2_keeping_zero; + item_compare_func_ptr = item_compare2_keeping_zero; } else { - item_compare_func_ptr = item_compare_keeping_zero; + item_compare_func_ptr = item_compare_keeping_zero; } - for (li = l->lv_first; li != NULL && li->li_next != NULL; li = li->li_next) { - if (item_compare_func_ptr(&li, &li->li_next) == 0) { - ptrs[i++].item = li; - } - if (info.item_compare_func_err) { - EMSG(_("E882: Uniq compare function failed")); - break; + listitem_T *prev_li = NULL; + TV_LIST_ITER(l, li, { + if (prev_li != NULL) { + if (item_compare_func_ptr(prev_li, li) == 0) { + ptrs[i++].item = prev_li; + } + if (info.item_compare_func_err) { + EMSG(_("E882: Uniq compare function failed")); + break; + } } - } + prev_li = li; + }); if (!info.item_compare_func_err) { while (--i >= 0) { + // FIXME: Abstract away. assert(ptrs[i].item->li_next); - li = ptrs[i].item->li_next; + listitem_T *const li = ptrs[i].item->li_next; ptrs[i].item->li_next = li->li_next; if (li->li_next != NULL) { li->li_next->li_prev = ptrs[i].item; @@ -15592,7 +15624,6 @@ static void f_spellsuggest(typval_T *argvars, typval_T *rettv, FunPtr fptr) bool typeerr = false; int maxcount; garray_T ga; - listitem_T *li; bool need_capital = false; tv_list_alloc_ret(rettv); @@ -15618,10 +15649,10 @@ static void f_spellsuggest(typval_T *argvars, typval_T *rettv, FunPtr fptr) for (int i = 0; i < ga.ga_len; i++) { char *p = ((char **)ga.ga_data)[i]; - li = tv_list_item_alloc(); - li->li_tv.v_type = VAR_STRING; - li->li_tv.v_lock = 0; - li->li_tv.vval.v_string = (char_u *)p; + listitem_T *const li = tv_list_item_alloc(); + TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; + TV_LIST_ITEM_TV(li)->v_lock = VAR_LOCKED; + TV_LIST_ITEM_TV(li)->vval.v_string = (char_u *)p; tv_list_append(rettv->vval.v_list, li); } ga_clear(&ga); @@ -15677,7 +15708,7 @@ static void f_split(typval_T *argvars, typval_T *rettv, FunPtr fptr) } else { end = str + strlen(str); } - if (keepempty || end > str || (rettv->vval.v_list->lv_len > 0 + if (keepempty || end > str || (tv_list_len(rettv->vval.v_list) > 0 && *str != NUL && match && end < (const char *)regmatch.endp[0])) { @@ -16405,7 +16436,7 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, keepempty = tv_get_number(&argvars[2]); } rettv->vval.v_list = string_to_list(res, nread, (bool)keepempty); - rettv->vval.v_list->lv_refcount++; + tv_list_ref(rettv->vval.v_list); rettv->v_type = VAR_LIST; xfree(res); @@ -17451,8 +17482,8 @@ static bool write_list(FileDescriptor *const fp, const list_T *const list, const bool binary) { int error = 0; - for (const listitem_T *li = list->lv_first; li != NULL; li = li->li_next) { - const char *const s = tv_get_string_chk(&li->li_tv); + TV_LIST_ITER_CONST(list, li, { + const char *const s = tv_get_string_chk(TV_LIST_ITEM_TV(li)); if (s == NULL) { return false; } @@ -17479,14 +17510,14 @@ static bool write_list(FileDescriptor *const fp, const list_T *const list, } } } - if (!binary || li->li_next != NULL) { + if (!binary || TV_LIST_ITEM_NEXT(list, li) != NULL) { const ptrdiff_t written = file_write(fp, "\n", 1); if (written < 0) { error = (int)written; goto write_list_error; } } - } + }); if ((error = file_flush(fp)) != 0) { goto write_list_error; } @@ -17499,13 +17530,14 @@ write_list_error: /// Initializes a static list with 10 items. void init_static_list(staticList10_T *sl) { + // FIXME: Move to eval/typval. list_T *l = &sl->sl_list; memset(sl, 0, sizeof(staticList10_T)); l->lv_first = &sl->sl_items[0]; l->lv_last = &sl->sl_items[9]; l->lv_refcount = DO_NOT_FREE_CNT; - l->lv_lock = VAR_FIXED; + tv_list_set_lock(l, VAR_FIXED); sl->sl_list.lv_len = 10; for (int i = 0; i < 10; i++) { @@ -17556,9 +17588,9 @@ static char *save_tv_as_string(typval_T *tv, ptrdiff_t *const len, bool endnl) // Pre-calculate the resulting length. *len = 0; list_T *list = tv->vval.v_list; - for (listitem_T *li = list->lv_first; li != NULL; li = li->li_next) { - *len += strlen(tv_get_string(&li->li_tv)) + 1; - } + TV_LIST_ITER_CONST(list, li, { + *len += strlen(tv_get_string(TV_LIST_ITEM_TV(li))) + 1; + }); if (*len == 0) { return NULL; @@ -17566,14 +17598,14 @@ static char *save_tv_as_string(typval_T *tv, ptrdiff_t *const len, bool endnl) char *ret = xmalloc(*len + endnl); char *end = ret; - for (listitem_T *li = list->lv_first; li != NULL; li = li->li_next) { - for (const char *s = tv_get_string(&li->li_tv); *s != NUL; s++) { + TV_LIST_ITER_CONST(list, li, { + for (const char *s = tv_get_string(TV_LIST_ITEM_TV(li)); *s != NUL; s++) { *end++ = (*s == '\n') ? NUL : *s; } - if (endnl || li->li_next != NULL) { + if (endnl || TV_LIST_ITEM_NEXT(list, li) != NULL) { *end++ = '\n'; } - } + }); *end = NUL; *len = end - ret; return ret; @@ -17720,9 +17752,9 @@ pos_T *var2fpos(const typval_T *const tv, const int dollar_lnum, // We accept "$" for the column number: last column. li = tv_list_find(l, 1L); - if (li != NULL && li->li_tv.v_type == VAR_STRING - && li->li_tv.vval.v_string != NULL - && STRCMP(li->li_tv.vval.v_string, "$") == 0) { + if (li != NULL && TV_LIST_ITEM_TV(li)->v_type == VAR_STRING + && TV_LIST_ITEM_TV(li)->vval.v_string != NULL + && STRCMP(TV_LIST_ITEM_TV(li)->vval.v_string, "$") == 0) { pos.col = len + 1; } @@ -17799,17 +17831,18 @@ pos_T *var2fpos(const typval_T *const tv, const int dollar_lnum, */ static int list2fpos(typval_T *arg, pos_T *posp, int *fnump, colnr_T *curswantp) { - list_T *l = arg->vval.v_list; + list_T *l; long i = 0; long n; - /* List must be: [fnum, lnum, col, coladd, curswant], where "fnum" is only - * there when "fnump" isn't NULL; "coladd" and "curswant" are optional. */ + // List must be: [fnum, lnum, col, coladd, curswant], where "fnum" is only + // there when "fnump" isn't NULL; "coladd" and "curswant" are optional. if (arg->v_type != VAR_LIST - || l == NULL - || l->lv_len < (fnump == NULL ? 2 : 3) - || l->lv_len > (fnump == NULL ? 4 : 5)) + || (l = arg->vval.v_list) == NULL + || tv_list_len(l) < (fnump == NULL ? 2 : 3) + || tv_list_len(l) > (fnump == NULL ? 4 : 5)) { return FAIL; + } if (fnump != NULL) { n = tv_list_find_nr(l, i++, NULL); // fnum @@ -18234,7 +18267,7 @@ void set_vim_var_list(const VimVarIndex idx, list_T *const val) vimvars[idx].vv_type = VAR_LIST; vimvars[idx].vv_list = val; if (val != NULL) { - val->lv_refcount++; + tv_list_ref(val); } } @@ -19270,9 +19303,10 @@ int var_item_copy(const vimconv_T *const conv, if (from->vval.v_list == NULL) to->vval.v_list = NULL; else if (copyID != 0 && from->vval.v_list->lv_copyID == copyID) { - /* use the copy made earlier */ + // FIXME: Abstract away. + // Use the copy made earlier. to->vval.v_list = from->vval.v_list->lv_copylist; - ++to->vval.v_list->lv_refcount; + tv_list_ref(to->vval.v_list); } else { to->vval.v_list = tv_list_copy(conv, from->vval.v_list, deep, copyID); } @@ -21153,9 +21187,10 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, v->di_tv.v_type = VAR_LIST; v->di_tv.v_lock = VAR_FIXED; v->di_tv.vval.v_list = &fc->l_varlist; + // FIXME: Abstract away static list. memset(&fc->l_varlist, 0, sizeof(list_T)); fc->l_varlist.lv_refcount = DO_NOT_FREE_CNT; - fc->l_varlist.lv_lock = VAR_FIXED; + tv_list_set_lock(&fc->l_varlist, VAR_FIXED); // Set a:firstline to "firstline" and a:lastline to "lastline". // Set a:name to named arguments. @@ -21204,8 +21239,8 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, if (ai >= 0 && ai < MAX_FUNC_ARGS) { tv_list_append(&fc->l_varlist, &fc->l_listitems[ai]); - fc->l_listitems[ai].li_tv = argvars[i]; - fc->l_listitems[ai].li_tv.v_lock = VAR_FIXED; + *TV_LIST_ITEM_TV(&fc->l_listitems[ai]) = argvars[i]; + TV_LIST_ITEM_TV(&fc->l_listitems[ai])->v_lock = VAR_FIXED; } } @@ -21407,10 +21442,9 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, }); // Make a copy of the a:000 items, since we didn't do that above. - for (listitem_T *li = fc->l_varlist.lv_first; li != NULL; - li = li->li_next) { - tv_copy(&li->li_tv, &li->li_tv); - } + TV_LIST_ITER(&fc->l_varlist, li, { + tv_copy(TV_LIST_ITEM_TV(li), TV_LIST_ITEM_TV(li)); + }); } if (--fp->uf_calls <= 0 && fp->uf_refcount <= 0) { @@ -21437,6 +21471,7 @@ static void funccal_unref(funccall_T *fc, ufunc_T *fp, bool force) return; } + // FIXME: Abstract away static list implementation details. if (--fc->fc_refcount <= 0 && (force || ( fc->l_varlist.lv_refcount == DO_NOT_FREE_CNT && fc->l_vars.dv_refcount == DO_NOT_FREE_CNT @@ -21475,8 +21510,6 @@ free_funccal ( int free_val /* a: vars were allocated */ ) { - listitem_T *li; - for (int i = 0; i < fc->fc_funcs.ga_len; i++) { ufunc_T *fp = ((ufunc_T **)(fc->fc_funcs.ga_data))[i]; @@ -21494,14 +21527,14 @@ free_funccal ( // allocated variables. vars_clear_ext(&fc->l_avars.dv_hashtab, free_val); - /* free all l: variables */ + // Free all l: variables. vars_clear(&fc->l_vars.dv_hashtab); // Free the a:000 variables if they were allocated. if (free_val) { - for (li = fc->l_varlist.lv_first; li != NULL; li = li->li_next) { - tv_clear(&li->li_tv); - } + TV_LIST_ITER(&fc->l_varlist, li, { + tv_clear(TV_LIST_ITEM_TV(li)); + }); } func_ptr_unref(fc->func); @@ -22437,7 +22470,7 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments) {.v_type = VAR_UNKNOWN} }; typval_T rettv = {.v_type = VAR_UNKNOWN, .v_lock = 0}; - arguments->lv_refcount++; + tv_list_ref(arguments); int dummy; (void)call_func((const char_u *)func, diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index 0933b1bf9c..e3098683a4 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -61,7 +61,7 @@ static inline void create_special_dict(typval_T *const rettv, type_di->di_tv.v_type = VAR_LIST; type_di->di_tv.v_lock = VAR_UNLOCKED; type_di->di_tv.vval.v_list = (list_T *) eval_msgpack_type_lists[type]; - type_di->di_tv.vval.v_list->lv_refcount++; + tv_list_ref(type_di->di_tv.vval.v_list); tv_dict_add(dict, type_di); dictitem_T *const val_di = tv_dict_item_alloc_len(S_LEN("_VAL")); val_di->di_tv = val; @@ -234,7 +234,7 @@ list_T *decode_create_map_special_dict(typval_T *const ret_tv) FUNC_ATTR_NONNULL_ALL { list_T *const list = tv_list_alloc(); - list->lv_refcount++; + tv_list_ref(list); create_special_dict(ret_tv, kMPMap, ((typval_T) { .v_type = VAR_LIST, .v_lock = VAR_UNLOCKED, @@ -270,7 +270,7 @@ typval_T decode_string(const char *const s, const size_t len, : (bool)hasnul); if (really_hasnul) { list_T *const list = tv_list_alloc(); - list->lv_refcount++; + tv_list_ref(list); typval_T tv; create_special_dict(&tv, binary ? kMPBinary : kMPString, ((typval_T) { .v_type = VAR_LIST, @@ -849,7 +849,7 @@ json_decode_string_cycle_start: } case '[': { list_T *list = tv_list_alloc(); - list->lv_refcount++; + tv_list_ref(list); typval_T tv = { .v_type = VAR_LIST, .v_lock = VAR_UNLOCKED, @@ -970,7 +970,7 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) }; } else { list_T *const list = tv_list_alloc(); - list->lv_refcount++; + tv_list_ref(list); create_special_dict(rettv, kMPInteger, ((typval_T) { .v_type = VAR_LIST, .v_lock = VAR_UNLOCKED, @@ -993,7 +993,7 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) }; } else { list_T *const list = tv_list_alloc(); - list->lv_refcount++; + tv_list_ref(list); create_special_dict(rettv, kMPInteger, ((typval_T) { .v_type = VAR_LIST, .v_lock = VAR_UNLOCKED, @@ -1039,7 +1039,7 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) } case MSGPACK_OBJECT_ARRAY: { list_T *const list = tv_list_alloc(); - list->lv_refcount++; + tv_list_ref(list); *rettv = (typval_T) { .v_type = VAR_LIST, .v_lock = VAR_UNLOCKED, @@ -1110,7 +1110,7 @@ msgpack_to_vim_generic_map: {} } case MSGPACK_OBJECT_EXT: { list_T *const list = tv_list_alloc(); - list->lv_refcount++; + tv_list_ref(list); tv_list_append_number(list, mobj.via.ext.type); list_T *const ext_val_list = tv_list_alloc(); tv_list_append_list(list, ext_val_list); diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 4bc3a85efb..eaf70b41fd 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -66,7 +66,7 @@ listitem_T *tv_list_item_alloc(void) void tv_list_item_free(listitem_T *const item) FUNC_ATTR_NONNULL_ALL { - tv_clear(&item->li_tv); + tv_clear(TV_LIST_ITEM_TV(item)); xfree(item); } @@ -326,7 +326,7 @@ void tv_list_append_tv(list_T *const l, typval_T *const tv) FUNC_ATTR_NONNULL_ALL { listitem_T *const li = tv_list_item_alloc(); - tv_copy(tv, &li->li_tv); + tv_copy(tv, TV_LIST_ITEM_TV(li)); tv_list_append(l, li); } @@ -339,12 +339,12 @@ void tv_list_append_list(list_T *const list, list_T *const itemlist) { listitem_T *const li = tv_list_item_alloc(); - li->li_tv.v_type = VAR_LIST; - li->li_tv.v_lock = VAR_UNLOCKED; - li->li_tv.vval.v_list = itemlist; + TV_LIST_ITEM_TV(li)->v_type = VAR_LIST; + TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; + TV_LIST_ITEM_TV(li)->vval.v_list = itemlist; tv_list_append(list, li); if (itemlist != NULL) { - itemlist->lv_refcount++; + tv_list_ref(itemlist); } } @@ -357,9 +357,9 @@ void tv_list_append_dict(list_T *const list, dict_T *const dict) { listitem_T *const li = tv_list_item_alloc(); - li->li_tv.v_type = VAR_DICT; - li->li_tv.v_lock = VAR_UNLOCKED; - li->li_tv.vval.v_dict = dict; + TV_LIST_ITEM_TV(li)->v_type = VAR_DICT; + TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; + TV_LIST_ITEM_TV(li)->vval.v_dict = dict; tv_list_append(list, li); if (dict != NULL) { dict->dv_refcount++; @@ -399,9 +399,9 @@ void tv_list_append_allocated_string(list_T *const l, char *const str) listitem_T *const li = tv_list_item_alloc(); tv_list_append(l, li); - li->li_tv.v_type = VAR_STRING; - li->li_tv.v_lock = VAR_UNLOCKED; - li->li_tv.vval.v_string = (char_u *)str; + TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; + TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; + TV_LIST_ITEM_TV(li)->vval.v_string = (char_u *)str; } /// Append number to the list @@ -412,9 +412,9 @@ void tv_list_append_allocated_string(list_T *const l, char *const str) void tv_list_append_number(list_T *const l, const varnumber_T n) { listitem_T *const li = tv_list_item_alloc(); - li->li_tv.v_type = VAR_NUMBER; - li->li_tv.v_lock = VAR_UNLOCKED; - li->li_tv.vval.v_number = n; + TV_LIST_ITEM_TV(li)->v_type = VAR_NUMBER; + TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; + TV_LIST_ITEM_TV(li)->vval.v_number = n; tv_list_append(l, li); } @@ -439,33 +439,32 @@ list_T *tv_list_copy(const vimconv_T *const conv, list_T *const orig, } list_T *copy = tv_list_alloc(); + tv_list_ref(copy); if (copyID != 0) { // Do this before adding the items, because one of the items may // refer back to this list. orig->lv_copyID = copyID; orig->lv_copylist = copy; } - listitem_T *item; - for (item = orig->lv_first; item != NULL && !got_int; - item = item->li_next) { + TV_LIST_ITER(orig, item, { listitem_T *const ni = tv_list_item_alloc(); if (deep) { - if (var_item_copy(conv, &item->li_tv, &ni->li_tv, deep, copyID) == FAIL) { + if (var_item_copy(conv, TV_LIST_ITEM_TV(item), TV_LIST_ITEM_TV(ni), + deep, copyID) == FAIL) { xfree(ni); - break; + goto tv_list_copy_error; } } else { - tv_copy(&item->li_tv, &ni->li_tv); + tv_copy(TV_LIST_ITEM_TV(item), TV_LIST_ITEM_TV(ni)); } tv_list_append(copy, ni); - } - copy->lv_refcount++; - if (item != NULL) { - tv_list_unref(copy); - copy = NULL; - } + }); return copy; + +tv_list_copy_error: + tv_list_unref(copy); + return NULL; } /// Extend first list with the second @@ -475,17 +474,17 @@ list_T *tv_list_copy(const vimconv_T *const conv, list_T *const orig, /// @param[in] bef If not NULL, extends before this item. void tv_list_extend(list_T *const l1, list_T *const l2, listitem_T *const bef) - FUNC_ATTR_NONNULL_ARG(1, 2) + FUNC_ATTR_NONNULL_ARG(1) { - int todo = l2->lv_len; + int todo = tv_list_len(l2); listitem_T *const befbef = (bef == NULL ? NULL : bef->li_prev); listitem_T *const saved_next = (befbef == NULL ? NULL : befbef->li_next); // We also quit the loop when we have inserted the original item count of // the list, avoid a hang when we extend a list with itself. - for (listitem_T *item = l2->lv_first - ; item != NULL && --todo >= 0 + for (listitem_T *item = tv_list_first(l2) + ; item != NULL && todo-- ; item = (item == befbef ? saved_next : item->li_next)) { - tv_list_insert_tv(l1, &item->li_tv, bef); + tv_list_insert_tv(l1, TV_LIST_ITEM_TV(item), bef); } } @@ -540,13 +539,12 @@ static int list_join_inner(garray_T *const gap, list_T *const l, { size_t sumlen = 0; bool first = true; - listitem_T *item; // Stringify each item in the list. - for (item = l->lv_first; item != NULL && !got_int; item = item->li_next) { + TV_LIST_ITER(l, item, { char *s; size_t len; - s = encode_tv2echo(&item->li_tv, &len); + s = encode_tv2echo(TV_LIST_ITEM_TV(item), &len); if (s == NULL) { return FAIL; } @@ -557,7 +555,7 @@ static int list_join_inner(garray_T *const gap, list_T *const l, p->tofree = p->s = (char_u *)s; line_breakcheck(); - } + }); // Allocate result buffer with its total size, avoid re-allocation and // multiple copy operations. Add 2 for a tailing ']' and NUL. @@ -591,16 +589,16 @@ static int list_join_inner(garray_T *const gap, list_T *const l, /// /// @return OK in case of success, FAIL otherwise. int tv_list_join(garray_T *const gap, list_T *const l, const char *const sep) - FUNC_ATTR_NONNULL_ALL + FUNC_ATTR_NONNULL_ARG(1) { - if (l->lv_len < 1) { + if (!tv_list_len(l)) { return OK; } garray_T join_ga; int retval; - ga_init(&join_ga, (int)sizeof(Join), l->lv_len); + ga_init(&join_ga, (int)sizeof(Join), tv_list_len(l)); retval = list_join_inner(gap, l, sep, &join_ga); #define FREE_JOIN_TOFREE(join) xfree((join)->tofree) @@ -632,11 +630,13 @@ bool tv_list_equal(list_T *const l1, list_T *const l2, const bool ic, return false; } - listitem_T *item1 = l1->lv_first; - listitem_T *item2 = l2->lv_first; + listitem_T *item1 = tv_list_first(l1); + listitem_T *item2 = tv_list_first(l2); for (; item1 != NULL && item2 != NULL - ; item1 = item1->li_next, item2 = item2->li_next) { - if (!tv_equal(&item1->li_tv, &item2->li_tv, ic, recursive)) { + ; item1 = TV_LIST_ITEM_NEXT(l1, item1), + item2 = TV_LIST_ITEM_NEXT(n2, item2)) { + if (!tv_equal(TV_LIST_ITEM_TV(item1), TV_LIST_ITEM_TV(item2), ic, + recursive)) { return false; } } @@ -662,13 +662,8 @@ listitem_T *tv_list_find(list_T *const l, int n) return NULL; } - // Negative index is relative to the end. - if (n < 0) { - n = l->lv_len + n; - } - - // Check for index out of range. - if (n < 0 || n >= l->lv_len) { + n = tv_list_uidx(l, n); + if (n == -1) { return NULL; } @@ -740,7 +735,7 @@ varnumber_T tv_list_find_nr(list_T *const l, const int n, bool *const ret_error) } return -1; } - return tv_get_number_chk(&li->li_tv, ret_error); + return tv_get_number_chk(TV_LIST_ITEM_TV(li), ret_error); } /// Get list item l[n] as a string @@ -757,7 +752,7 @@ const char *tv_list_find_str(list_T *const l, const int n) emsgf(_(e_listidx), (int64_t)n); return NULL; } - return tv_get_string(&li->li_tv); + return tv_get_string(TV_LIST_ITEM_TV(li)); } /// Locate item in a list and return its index @@ -772,15 +767,14 @@ long tv_list_idx_of_item(const list_T *const l, const listitem_T *const item) if (l == NULL) { return -1; } - long idx = 0; - const listitem_T *li; - for (li = l->lv_first; li != NULL && li != item; li = li->li_next) { + int idx = 0; + TV_LIST_ITER_CONST(l, li, { + if (li == item) { + return idx; + } idx++; - } - if (li == NULL) { - return -1; - } - return idx; + }); + return -1; } //{{{1 Dictionaries @@ -1339,7 +1333,7 @@ int tv_dict_add_list(dict_T *const d, const char *const key, item->di_tv.v_lock = VAR_UNLOCKED; item->di_tv.v_type = VAR_LIST; item->di_tv.vval.v_list = list; - list->lv_refcount++; + tv_list_ref(list); if (tv_dict_add(d, item) == FAIL) { tv_dict_item_free(item); return FAIL; @@ -1677,7 +1671,7 @@ list_T *tv_list_alloc_ret(typval_T *const ret_tv) ret_tv->vval.v_list = l; ret_tv->v_type = VAR_LIST; ret_tv->v_lock = VAR_UNLOCKED; - l->lv_refcount++; + tv_list_ref(l); return l; } @@ -2027,7 +2021,7 @@ void tv_copy(typval_T *const from, typval_T *const to) } case VAR_LIST: { if (from->vval.v_list != NULL) { - to->vval.v_list->lv_refcount++; + tv_list_ref(to->vval.v_list); } break; } @@ -2084,9 +2078,9 @@ void tv_item_lock(typval_T *const tv, const int deep, const bool lock) CHANGE_LOCK(lock, l->lv_lock); if (deep < 0 || deep > 1) { // Recursive: lock/unlock the items the List contains. - for (listitem_T *li = l->lv_first; li != NULL; li = li->li_next) { - tv_item_lock(&li->li_tv, deep - 1, lock); - } + TV_LIST_ITER(l, li, { + tv_item_lock(TV_LIST_ITEM_TV(li), deep - 1, lock); + }); } } break; @@ -2122,6 +2116,8 @@ void tv_item_lock(typval_T *const tv, const int deep, const bool lock) /// Check whether VimL value is locked itself or refers to a locked container /// +/// @warning Fixed container is not the same as locked. +/// /// @param[in] tv Value to check. /// /// @return True if value is locked, false otherwise. @@ -2130,8 +2126,7 @@ bool tv_islocked(const typval_T *const tv) { return ((tv->v_lock == VAR_LOCKED) || (tv->v_type == VAR_LIST - && tv->vval.v_list != NULL - && (tv->vval.v_list->lv_lock == VAR_LOCKED)) + && (tv_list_locked(tv->vval.v_list) == VAR_LOCKED)) || (tv->v_type == VAR_DICT && tv->vval.v_dict != NULL && (tv->vval.v_dict->dv_lock == VAR_LOCKED))); diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index b00f43f625..2a0c52b4be 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -6,6 +6,7 @@ #include #include #include +#include #include "nvim/types.h" #include "nvim/hashtab.h" @@ -284,9 +285,6 @@ typedef struct list_stack_S { #define TV_DICT_HI2DI(hi) \ ((dictitem_T *)((hi)->hi_key - offsetof(dictitem_T, di_key))) -static inline void tv_list_ref(list_T *const l) - REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; - /// Increase reference count for a given list /// /// Does nothing for NULL lists. @@ -332,13 +330,13 @@ static inline void tv_list_set_lock(list_T *const l, l->lv_lock = lock; } -static inline long tv_list_len(const list_T *const l) +static inline int tv_list_len(const list_T *const l) REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; /// Get the number of items in a list /// /// @param[in] l List to check. -static inline long tv_list_len(const list_T *const l) +static inline int tv_list_len(const list_T *const l) { if (l == NULL) { return 0; @@ -346,6 +344,29 @@ static inline long tv_list_len(const list_T *const l) return l->lv_len; } +static inline int tv_list_uidx(const list_T *const l, int n) + REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; + +/// Normalize index: that is, return either -1 or non-negative index +/// +/// @param[in] l List to intex. Used to get length. +/// @param[in] n List index, possibly negative. +/// +/// @return -1 or list index in range [0, tv_list_len(l)). +static inline int tv_list_uidx(const list_T *const l, int n) +{ + // Negative index is relative to the end. + if (n < 0) { + n += tv_list_len(l); + } + + // Check for index out of range. + if (n < 0 || n >= tv_list_len(l)) { + return -1; + } + return n; +} + static inline listitem_T *tv_list_first(const list_T *const l) REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; @@ -427,7 +448,7 @@ extern bool tv_in_free_unref_items; do { \ modifier list_T *const l_ = (l); \ if (l_ != NULL) { \ - for (modifier listitem_T *const li = l_->lv_first; \ + for (modifier listitem_T *li = l_->lv_first; \ li != NULL; li = li->li_next) { \ code \ } \ diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index cacba3ce87..18134c56e3 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -306,7 +306,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) case kObjectTypeArray: { cur.tv->v_type = VAR_LIST; cur.tv->vval.v_list = tv_list_alloc(); - cur.tv->vval.v_list->lv_refcount++; + tv_list_ref(cur.tv->vval.v_list); if (table_props.maxidx != 0) { cur.container = true; cur.idx = lua_gettop(lstate); diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 432c9a8b47..9f445204d0 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2568,7 +2568,7 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg) for (size_t i = 0; i < reg->y_size; i++) { tv_list_append_string(list, (const char *)reg->y_array[i], -1); } - list->lv_lock = VAR_FIXED; + tv_list_set_lock(list, VAR_FIXED); tv_dict_add_list(dict, S_LEN("regcontents"), list); // the register type -- cgit From 21745d72b8c24c7f19dea5d53384da4875c43e74 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 03:50:52 +0300 Subject: eval: Fix inputlist() --- src/nvim/eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index edf016fc41..da953999cc 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -11254,7 +11254,7 @@ static void f_inputlist(typval_T *argvars, typval_T *rettv, FunPtr fptr) int selected; int mouse_used; - if (argvars[0].v_type != VAR_LIST || argvars[0].vval.v_list == NULL) { + if (argvars[0].v_type != VAR_LIST) { EMSG2(_(e_listarg), "inputlist()"); return; } -- cgit From 5c1ddb5078c90f69c7225a7b2e74ccb914dcdd6a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 03:54:21 +0300 Subject: eval: Fix writefile() --- src/nvim/eval.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index da953999cc..2f908f70a9 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -17480,6 +17480,7 @@ static void f_winsaveview(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// @return true in case of success, false otherwise. static bool write_list(FileDescriptor *const fp, const list_T *const list, const bool binary) + FUNC_ATTR_NONNULL_ARG(1) { int error = 0; TV_LIST_ITER_CONST(list, li, { @@ -17645,9 +17646,6 @@ static void f_writefile(typval_T *argvars, typval_T *rettv, FunPtr fptr) EMSG2(_(e_listarg), "writefile()"); return; } - if (argvars[0].vval.v_list == NULL) { - return; - } bool binary = false; bool append = false; -- cgit From 4a5bc6275d09056ff0ccf5a29a878d48bbe58655 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Fri, 8 Dec 2017 10:42:30 -0500 Subject: ci: run oldtests in Appveyor #7705 --- src/nvim/testdir/Makefile | 20 +++++++++++++++----- src/nvim/testdir/unix.vim | 6 ++++++ 2 files changed, 21 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 111bd172ef..e1faaccb84 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -2,7 +2,11 @@ # Makefile to run all tests for Vim # -NVIM_PRG ?= ../../../build/bin/nvim +ifeq ($(OS),Windows_NT) + NVIM_PRG ?= ../../../build/bin/nvim.exe +else + NVIM_PRG ?= ../../../build/bin/nvim +endif TMPDIR ?= Xtest-tmpdir SCRIPTSOURCE := ../../../runtime @@ -10,12 +14,9 @@ export SHELL := sh export NVIM_PRG := $(NVIM_PRG) export TMPDIR -SCRIPTS ?= \ - test13.out \ +SCRIPTS_DEFAULT = \ test14.out \ - test17.out \ test24.out \ - test32.out \ test37.out \ test40.out \ test42.out \ @@ -27,6 +28,15 @@ SCRIPTS ?= \ test73.out \ test79.out \ +ifneq ($(OS),Windows_NT) + SCRIPTS_DEFAULTS := $(SCRIPTS_DEFAULT) \ + test17.out \ + test32.out \ + +endif + +SCRIPTS ?= $(SCRIPTS_DEFAULT) + # Tests using runtest.vim. # Keep test_alot*.res as the last one, sort the others. NEW_TESTS ?= \ diff --git a/src/nvim/testdir/unix.vim b/src/nvim/testdir/unix.vim index a7daacf8cf..ce2beff7fe 100644 --- a/src/nvim/testdir/unix.vim +++ b/src/nvim/testdir/unix.vim @@ -2,6 +2,12 @@ " Always use "sh", don't use the value of "$SHELL". set shell=sh +if has('win32') + set shellcmdflag=-c shellxquote= shellxescape= shellquote= + let &shellredir = '>%s 2>&1' + set shellslash +endif + " Don't depend on system locale, always use utf-8 set encoding=utf-8 -- cgit From 1f2b35860f755513a58c1d010f082d946c889b47 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Thu, 7 Dec 2017 20:53:02 -0500 Subject: mac: Set $LANG based on the system locale Unix's typical locale-related environment variables aren't always set appropriately on a Mac. Instead of relying on them, query the locale information using Mac specific APIs and then set $LANG appropriately for the rest of nvim. Closes #5873 --- src/nvim/CMakeLists.txt | 3 +++ src/nvim/option.c | 3 +++ src/nvim/os/lang.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/nvim/os/lang.h | 7 +++++++ 4 files changed, 53 insertions(+) create mode 100644 src/nvim/os/lang.c create mode 100644 src/nvim/os/lang.h (limited to 'src') diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index d3e07326bf..7eb1afa135 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -13,6 +13,9 @@ endif() if(WIN32) # tell MinGW compiler to enable wmain set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -municode") +elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreFoundation") + set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -framework CoreFoundation") endif() set(TOUCHES_DIR ${PROJECT_BINARY_DIR}/touches) diff --git a/src/nvim/option.c b/src/nvim/option.c index 37c4233142..f8a05f133d 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -75,6 +75,7 @@ #include "nvim/window.h" #include "nvim/os/os.h" #include "nvim/os/input.h" +#include "nvim/os/lang.h" /* * The options that are local to a window or buffer have "indir" set to one of @@ -784,6 +785,8 @@ void set_init_1(void) didset_options2(); + lang_init(); + // enc_locale() will try to find the encoding of the current locale. // This will be used when 'default' is used as encoding specifier // in 'fileencodings' diff --git a/src/nvim/os/lang.c b/src/nvim/os/lang.c new file mode 100644 index 0000000000..f0bbf4b1cb --- /dev/null +++ b/src/nvim/os/lang.c @@ -0,0 +1,40 @@ +#ifdef __APPLE__ +# define Boolean CFBoolean // Avoid conflict with API's Boolean +# include +# include +# undef Boolean +#endif + +#ifdef HAVE_LOCALE_H +# include +#endif +#include "nvim/os/os.h" + +void lang_init(void) +{ +#ifdef __APPLE__ + if (os_getenv("LANG") == NULL) { + CFLocaleRef cf_locale = CFLocaleCopyCurrent(); + CFTypeRef cf_lang_region = CFLocaleGetValue(cf_locale, + kCFLocaleIdentifier); + CFRetain(cf_lang_region); + CFRelease(cf_locale); + + const char *lang_region = CFStringGetCStringPtr(cf_lang_region, + kCFStringEncodingUTF8); + if (lang_region) { + os_setenv("LANG", lang_region, true); + } else { + char buf[20] = { 0 }; + if (CFStringGetCString(cf_lang_region, buf, 20, + kCFStringEncodingUTF8)) { + os_setenv("LANG", lang_region, true); + } + } + CFRelease(cf_lang_region); +# ifdef HAVE_LOCALE_H + setlocale(LC_ALL, ""); +# endif + } +#endif +} diff --git a/src/nvim/os/lang.h b/src/nvim/os/lang.h new file mode 100644 index 0000000000..f60e064f57 --- /dev/null +++ b/src/nvim/os/lang.h @@ -0,0 +1,7 @@ +#ifndef NVIM_OS_LANG_H +#define NVIM_OS_LANG_H + +#ifdef INCLUDE_GENERATED_DECLARATIONS +# include "os/lang.h.generated.h" +#endif +#endif // NVIM_OS_LANG_H -- cgit From abe38f7d26d68d7032ea391c039c56c8b87675a5 Mon Sep 17 00:00:00 2001 From: glacambre Date: Sun, 26 Nov 2017 13:29:32 +0100 Subject: window.c: do BufEnter in correct window after closing help #7431 closes #7429 Problem: after a help window was closed, a window was selected and its autocommands triggered. After that, restore_snapshot was called and the focused window changed, confusing the user. Solution: Add function get_snapshot_focus() that returns the window that holds the cursor in a snapshot. Use this function in win_close to make sure the right window is selected before any autocommand is triggered. --- src/nvim/window.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src') diff --git a/src/nvim/window.c b/src/nvim/window.c index 4e4eb297aa..e39569321e 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1991,6 +1991,14 @@ int win_close(win_T *win, int free_buf) * the screen space. */ wp = win_free_mem(win, &dir, NULL); + if (help_window) { + // Closing the help window moves the cursor back to the original window. + win_T *tmpwp = get_snapshot_focus(SNAP_HELP_IDX); + if (tmpwp != NULL) { + wp = tmpwp; + } + } + /* Make sure curwin isn't invalid. It can cause severe trouble when * printing an error message. For win_equal() curbuf needs to be valid * too. */ @@ -5421,6 +5429,27 @@ static win_T *restore_snapshot_rec(frame_T *sn, frame_T *fr) return wp; } +/// Gets the focused window (the one holding the cursor) of the snapshot. +static win_T *get_snapshot_focus(int idx) +{ + if (curtab->tp_snapshot[idx] == NULL) { + return NULL; + } + + frame_T *sn = curtab->tp_snapshot[idx]; + // This should be equivalent to the recursive algorithm found in + // restore_snapshot as far as traveling nodes go. + while (sn->fr_child != NULL || sn->fr_next != NULL) { + while (sn->fr_child != NULL) { + sn = sn->fr_child; + } + if (sn->fr_next != NULL) { + sn = sn->fr_next; + } + } + + return sn->fr_win; +} /* * Set "win" to be the curwin and "tp" to be the current tab page. -- cgit From dc232b74fb1a7927d6c13bd8c80bb42fc18a859f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 10 Dec 2017 01:24:54 +0100 Subject: doc: hack to avoid doxygen bug Use `@cond ` to obscure a section from doxygen. doxygen thinks kvec_withinit_t() is a function. That adds noise to the generated API documentation, and also prevents the following function from being noticed. --- src/nvim/api/vim.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 416e7d22d2..f0db391abe 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -789,6 +789,10 @@ ArrayOf(Dictionary) nvim_get_keymap(String mode) return keymap_array(mode, NULL); } +/// Returns a 2-tuple (Array), where item 0 is the current channel id and item +/// 1 is the |api-metadata| map (Dictionary). +/// +/// @returns 2-tuple [{channel-id}, {api-metadata}] Array nvim_get_api_info(uint64_t channel_id) FUNC_API_SINCE(1) FUNC_API_ASYNC FUNC_API_REMOTE_ONLY { @@ -896,7 +900,9 @@ typedef struct { Object *ret_node_p; } ExprASTConvStackItem; +///@cond DOXYGEN_NOT_A_FUNCTION typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack; +///@endcond /// Parse a VimL expression /// -- cgit From ad9c2d3cb97bbc4ba83ce7d23c9df23f9d3d11db Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 14 Nov 2017 10:47:49 +0100 Subject: doc closes #7622 --- src/nvim/api/buffer.c | 4 ++-- src/nvim/tui/tui.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/api/buffer.c b/src/nvim/api/buffer.c index 4b6a88e5fa..fdde28f2bb 100644 --- a/src/nvim/api/buffer.c +++ b/src/nvim/api/buffer.c @@ -763,8 +763,8 @@ ArrayOf(Integer, 2) nvim_buf_get_mark(Buffer buffer, String name, Error *err) /// or -1 for ungrouped highlight /// @param hl_group Name of the highlight group to use /// @param line Line to highlight (zero-indexed) -/// @param col_start Start of range of columns to highlight -/// @param col_end End of range of columns to highlight, +/// @param col_start Start of (byte-indexed) column range to highlight +/// @param col_end End of (byte-indexed) column range to highlight, /// or -1 to highlight to end of line /// @param[out] err Error details, if any /// @return The src_id that was used diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 6e2a5cbe67..9ff1acf64a 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1529,7 +1529,7 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, || iterm || iterm_pretending_xterm || teraterm // per TeraTerm "Supported Control Functions" doco // Some linux-type terminals (such as console-terminal-emulator - // from the nosh toolset) implement implement the xterm extension. + // from the nosh toolset) implement the xterm extension. || (linuxvt && (xterm_version || (vte_version > 0) || colorterm)))) { data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", "\x1b[%p1%d q"); -- cgit From e9504b7fd8cbf781aa9e68c48a4f3d59c633f269 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Fri, 10 Nov 2017 22:51:03 +0800 Subject: vim-patch: NA vim-patch:8.0.0299 NA vim-patch:8.0.0309 NA vim-patch:8.0.0310 NA vim-patch:8.0.0215 NA Problem: When a Cscope line contains CTRL-L a NULL pointer may be used. (Coverity) Solution: Don't check for an emacs tag in a cscope line. https://github.com/vim/vim/commit/e362c3d2c34f2b7ff38b4c3d2a7ff127d2290e09 vim-patch:8.0.0244 NA Problem: When the user sets t_BE empty after startup to disable bracketed paste, this has no direct effect. Solution: When t_BE is made empty write t_BD. When t_BE is made non-empty write the new value. https://github.com/vim/vim/commit/d9c60648e50a82dcb85b8dffb47f6416c3d56972 Some patches were not properly marked in the commit logs. So they are marked here: vim-patch:8.0.1230 vim-patch:8.0.1229 vim-patch:8.0.0618 vim-patch:8.0.0104 vim-patch:8.0.0405 vim-patch:8.0.0400 vim-patch:8.0.0302 vim-patch:8.0.0288 vim-patch:8.0.0285 vim-patch:8.0.0284 vim-patch:8.0.0281 vim-patch:8.0.0279 vim-patch:8.0.0278 vim-patch:8.0.0277 vim-patch:8.0.0276 vim-patch:8.0.0273 vim-patch:8.0.0272 vim-patch:8.0.0271 vim-patch:8.0.0270 vim-patch:8.0.0269 vim-patch:8.0.0268 vim-patch:8.0.0267 vim-patch:8.0.0260 vim-patch:8.0.0257 vim-patch:8.0.0249 vim-patch:8.0.0248 vim-patch:8.0.0246 vim-patch:8.0.0244 vim-patch:8.0.0241 vim-patch:8.0.0240 vim-patch:8.0.0239 vim-patch:8.0.0232 vim-patch:8.0.0221 vim-patch:8.0.0217 vim-patch:8.0.0215 vim-patch:8.0.0213 vim-patch:8.0.0211 vim-patch:8.0.0203 vim-patch:8.0.0199 vim-patch:8.0.0193 vim-patch:8.0.0192 vim-patch:8.0.0191 vim-patch:8.0.0187 vim-patch:8.0.0183 vim-patch:8.0.0180 vim-patch:8.0.0173 vim-patch:8.0.0171 vim-patch:8.0.0170 vim-patch:8.0.0169 vim-patch:8.0.0166 vim-patch:8.0.0163 vim-patch:8.0.0162 vim-patch:8.0.0161 vim-patch:8.0.0152 vim-patch:8.0.0145 vim-patch:8.0.0144 vim-patch:8.0.0141 vim-patch:8.0.0139 vim-patch:8.0.0138 vim-patch:8.0.0130 vim-patch:8.0.0129 vim-patch:8.0.0123 vim-patch:8.0.0122 vim-patch:8.0.0120 vim-patch:8.0.0117 vim-patch:8.0.0115 vim-patch:8.0.0114 vim-patch:8.0.0113 vim-patch:8.0.0109 vim-patch:8.0.0108 vim-patch:8.0.0107 vim-patch:8.0.0105 vim-patch:8.0.0103 vim-patch:8.0.0098 vim-patch:8.0.0097 vim-patch:8.0.0095 vim-patch:8.0.0094 vim-patch:8.0.0093 vim-patch:8.0.0089 vim-patch:8.0.0087 vim-patch:8.0.0082 vim-patch:8.0.0080 vim-patch:8.0.0077 vim-patch:8.0.0076 vim-patch:8.0.0072 vim-patch:8.0.0071 vim-patch:8.0.0070 vim-patch:8.0.0067 vim-patch:8.0.0065 vim-patch:8.0.0063 vim-patch:8.0.0061 vim-patch:8.0.0059 vim-patch:8.0.0055 vim-patch:8.0.0054 vim-patch:8.0.0051 vim-patch:8.0.0050 vim-patch:8.0.0048 vim-patch:8.0.0045 vim-patch:8.0.0039 vim-patch:8.0.0036 vim-patch:8.0.0030 vim-patch:8.0.0029 vim-patch:8.0.0028 vim-patch:8.0.0027 vim-patch:8.0.0024 vim-patch:8.0.0022 vim-patch:8.0.0021 vim-patch:8.0.0018 vim-patch:8.0.0016 vim-patch:8.0.0015 vim-patch:8.0.0014 vim-patch:8.0.0013 vim-patch:8.0.0011 vim-patch:8.0.0010 vim-patch:8.0.0009 vim-patch:8.0.0007 vim-patch:8.0.0005 --- src/nvim/version.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 1a9c9d73e5..e8cf1d0f0b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1012,7 +1012,7 @@ static const int included_patches[] = { 247, // 246 NA 245, - // 244, + // 244 NA 243, 242, // 241 NA @@ -1041,7 +1041,7 @@ static const int included_patches[] = { 218, // 217 NA // 216, - // 215, + // 215 NA // 214, // 213 NA // 212, -- cgit From ac4bbf55f6d6b9b252dd90fe800626850022b690 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 22:04:43 +0300 Subject: *: Hide list implementation in other files as well --- src/nvim/api/private/helpers.c | 2 +- src/nvim/edit.c | 16 ++--- src/nvim/eval/decode.c | 28 +++++---- src/nvim/eval/encode.c | 76 ++++++++++++------------ src/nvim/eval/encode.h | 13 +++-- src/nvim/eval/typval.h | 16 +++++ src/nvim/eval/typval_encode.c.h | 125 ++++++++++++++++++++++++---------------- src/nvim/ex_cmds.c | 14 +++-- src/nvim/ex_getln.c | 43 +++++++------- src/nvim/lua/converter.c | 10 ++-- src/nvim/ops.c | 27 ++++----- src/nvim/quickfix.c | 36 +++++++----- src/nvim/regexp.c | 25 ++++---- src/nvim/shada.c | 21 +++---- src/nvim/spell.c | 11 ++-- src/nvim/window.c | 50 ++++++++-------- 16 files changed, 277 insertions(+), 236 deletions(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index e5a1e150f9..4492f8bb93 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -789,7 +789,7 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err) Object item = obj.data.array.items[i]; listitem_T *li = tv_list_item_alloc(); - if (!object_to_vim(item, &li->li_tv, err)) { + if (!object_to_vim(item, TV_LIST_ITEM_TV(li), err)) { // cleanup tv_list_item_free(li); tv_list_free(list); diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 859f98d2ad..2fa4a52387 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -3536,19 +3536,19 @@ theend: /* * Add completions from a list. */ -static void ins_compl_add_list(list_T *list) +static void ins_compl_add_list(list_T *const list) { - listitem_T *li; int dir = compl_direction; - /* Go through the List with matches and add each of them. */ - for (li = list->lv_first; li != NULL; li = li->li_next) { - if (ins_compl_add_tv(&li->li_tv, dir) == OK) - /* if dir was BACKWARD then honor it just once */ + // Go through the List with matches and add each of them. + TV_LIST_ITER(list, li, { + if (ins_compl_add_tv(TV_LIST_ITEM_TV(li), dir) == OK) { + // If dir was BACKWARD then honor it just once. dir = FORWARD; - else if (did_emsg) + } else if (did_emsg) { break; - } + } + }); } /* diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index e3098683a4..b2d901462a 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -120,7 +120,7 @@ static inline int json_decoder_pop(ValuesStackItem obj, last_container = kv_last(*container_stack); } if (last_container.container.v_type == VAR_LIST) { - if (last_container.container.vval.v_list->lv_len != 0 + if (tv_list_len(last_container.container.vval.v_list) != 0 && !obj.didcomma) { EMSG2(_("E474: Expected comma before list item: %s"), val_location); tv_clear(&obj.val); @@ -128,7 +128,7 @@ static inline int json_decoder_pop(ValuesStackItem obj, } assert(last_container.special_val == NULL); listitem_T *obj_li = tv_list_item_alloc(); - obj_li->li_tv = obj.val; + *TV_LIST_ITEM_TV(obj_li) = obj.val; tv_list_append(last_container.container.vval.v_list, obj_li); } else if (last_container.stack_index == kv_size(*stack) - 2) { if (!obj.didcolon) { @@ -155,10 +155,10 @@ static inline int json_decoder_pop(ValuesStackItem obj, list_T *const kv_pair = tv_list_alloc(); tv_list_append_list(last_container.special_val, kv_pair); listitem_T *const key_li = tv_list_item_alloc(); - key_li->li_tv = key.val; + *TV_LIST_ITEM_TV(key_li) = key.val; tv_list_append(kv_pair, key_li); listitem_T *const val_li = tv_list_item_alloc(); - val_li->li_tv = obj.val; + *TV_LIST_ITEM_TV(val_li) = obj.val; tv_list_append(kv_pair, val_li); } } else { @@ -738,8 +738,9 @@ json_decode_string_cycle_start: } else if (last_container.special_val == NULL ? (last_container.container.v_type == VAR_DICT ? (DICT_LEN(last_container.container.vval.v_dict) == 0) - : (last_container.container.vval.v_list->lv_len == 0)) - : (last_container.special_val->lv_len == 0)) { + : (tv_list_len(last_container.container.vval.v_list) + == 0)) + : (tv_list_len(last_container.special_val) == 0)) { emsgf(_("E474: Leading comma: %.*s"), LENP(p, e)); goto json_decode_string_fail; } @@ -1047,9 +1048,10 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) }; for (size_t i = 0; i < mobj.via.array.size; i++) { listitem_T *const li = tv_list_item_alloc(); - li->li_tv.v_type = VAR_UNKNOWN; + TV_LIST_ITEM_TV(li)->v_type = VAR_UNKNOWN; tv_list_append(list, li); - if (msgpack_to_vim(mobj.via.array.ptr[i], &li->li_tv) == FAIL) { + if (msgpack_to_vim(mobj.via.array.ptr[i], TV_LIST_ITEM_TV(li)) + == FAIL) { return FAIL; } } @@ -1094,15 +1096,17 @@ msgpack_to_vim_generic_map: {} list_T *const kv_pair = tv_list_alloc(); tv_list_append_list(list, kv_pair); listitem_T *const key_li = tv_list_item_alloc(); - key_li->li_tv.v_type = VAR_UNKNOWN; + TV_LIST_ITEM_TV(key_li)->v_type = VAR_UNKNOWN; tv_list_append(kv_pair, key_li); listitem_T *const val_li = tv_list_item_alloc(); - val_li->li_tv.v_type = VAR_UNKNOWN; + TV_LIST_ITEM_TV(val_li)->v_type = VAR_UNKNOWN; tv_list_append(kv_pair, val_li); - if (msgpack_to_vim(mobj.via.map.ptr[i].key, &key_li->li_tv) == FAIL) { + if (msgpack_to_vim(mobj.via.map.ptr[i].key, TV_LIST_ITEM_TV(key_li)) + == FAIL) { return FAIL; } - if (msgpack_to_vim(mobj.via.map.ptr[i].val, &val_li->li_tv) == FAIL) { + if (msgpack_to_vim(mobj.via.map.ptr[i].val, TV_LIST_ITEM_TV(val_li)) + == FAIL) { return FAIL; } } diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index ef647b3ee4..0e5db84ad5 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -53,17 +53,18 @@ int encode_list_write(void *const data, const char *const buf, const size_t len) list_T *const list = (list_T *) data; const char *const end = buf + len; const char *line_end = buf; - listitem_T *li = list->lv_last; + listitem_T *li = tv_list_last(list); // Continue the last list element if (li != NULL) { line_end = xmemscan(buf, NL, len); if (line_end != buf) { const size_t line_length = (size_t)(line_end - buf); - char *str = (char *)li->li_tv.vval.v_string; + char *str = (char *)TV_LIST_ITEM_TV(li)->vval.v_string; const size_t li_len = (str == NULL ? 0 : strlen(str)); - li->li_tv.vval.v_string = xrealloc(str, li_len + line_length + 1); - str = (char *)li->li_tv.vval.v_string + li_len; + TV_LIST_ITEM_TV(li)->vval.v_string = xrealloc( + str, li_len + line_length + 1); + str = (char *)TV_LIST_ITEM_TV(li)->vval.v_string + li_len; memcpy(str, buf, line_length); str[line_length] = 0; memchrsub(str, NUL, NL, line_length); @@ -135,21 +136,18 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack, } case kMPConvPairs: case kMPConvList: { - int idx = 0; - const listitem_T *li; - for (li = v.data.l.list->lv_first; - li != NULL && li->li_next != v.data.l.li; - li = li->li_next) { - idx++; - } + const listitem_T *const li = TV_LIST_ITEM_PREV(v.data.l.list, + v.data.l.li); + int idx = (int)tv_list_idx_of_item(v.data.l.list, li); if (v.type == kMPConvList || li == NULL - || (li->li_tv.v_type != VAR_LIST - && li->li_tv.vval.v_list->lv_len <= 0)) { - vim_snprintf((char *) IObuff, IOSIZE, idx_msg, idx); + || (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST + && tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) <= 0)) { + vim_snprintf((char *)IObuff, IOSIZE, idx_msg, idx); ga_concat(&msg_ga, IObuff); } else { - typval_T key_tv = li->li_tv.vval.v_list->lv_first->li_tv; + typval_T key_tv = *TV_LIST_ITEM_TV( + tv_list_first(TV_LIST_ITEM_TV(li)->vval.v_list)); char *const key = encode_tv2echo(&key_tv, NULL); vim_snprintf((char *) IObuff, IOSIZE, key_pair_msg, key, idx); xfree(key); @@ -202,21 +200,17 @@ bool encode_vim_list_to_buf(const list_T *const list, size_t *const ret_len, FUNC_ATTR_NONNULL_ARG(2, 3) FUNC_ATTR_WARN_UNUSED_RESULT { size_t len = 0; - if (list != NULL) { - for (const listitem_T *li = list->lv_first; - li != NULL; - li = li->li_next) { - if (li->li_tv.v_type != VAR_STRING) { - return false; - } - len++; - if (li->li_tv.vval.v_string != 0) { - len += STRLEN(li->li_tv.vval.v_string); - } + TV_LIST_ITER_CONST(list, li, { + if (TV_LIST_ITEM_TV(li)->v_type != VAR_STRING) { + return false; } - if (len) { - len--; + len++; + if (TV_LIST_ITEM_TV(li)->vval.v_string != 0) { + len += STRLEN(TV_LIST_ITEM_TV(li)->vval.v_string); } + }); + if (len) { + len--; } *ret_len = len; if (len == 0) { @@ -253,31 +247,34 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, char *const buf_end = buf + nbuf; char *p = buf; while (p < buf_end) { - assert(state->li_length == 0 || state->li->li_tv.vval.v_string != NULL); + assert(state->li_length == 0 + || TV_LIST_ITEM_TV(state->li)->vval.v_string != NULL); for (size_t i = state->offset; i < state->li_length && p < buf_end; i++) { - assert(state->li->li_tv.vval.v_string != NULL); - const char ch = (char)state->li->li_tv.vval.v_string[state->offset++]; + assert(TV_LIST_ITEM_TV(state->li)->vval.v_string != NULL); + const char ch = (char)( + TV_LIST_ITEM_TV(state->li)->vval.v_string[state->offset++]); *p++ = (char)((char)ch == (char)NL ? (char)NUL : (char)ch); } if (p < buf_end) { - state->li = state->li->li_next; + state->li = TV_LIST_ITEM_NEXT(state->list, state->li); if (state->li == NULL) { *read_bytes = (size_t) (p - buf); return OK; } *p++ = NL; - if (state->li->li_tv.v_type != VAR_STRING) { + if (TV_LIST_ITEM_TV(state->li)->v_type != VAR_STRING) { *read_bytes = (size_t) (p - buf); return FAIL; } state->offset = 0; - state->li_length = (state->li->li_tv.vval.v_string == NULL + state->li_length = (TV_LIST_ITEM_TV(state->li)->vval.v_string == NULL ? 0 - : STRLEN(state->li->li_tv.vval.v_string)); + : STRLEN(TV_LIST_ITEM_TV(state->li)->vval.v_string)); } } *read_bytes = nbuf; - return (state->offset < state->li_length || state->li->li_next != NULL + return ((state->offset < state->li_length + || TV_LIST_ITEM_NEXT(state->list, state->li) != NULL) ? NOTDONE : OK); } @@ -727,12 +724,11 @@ bool encode_check_json_key(const typval_T *const tv) if (val_di->di_tv.vval.v_list == NULL) { return true; } - for (const listitem_T *li = val_di->di_tv.vval.v_list->lv_first; - li != NULL; li = li->li_next) { - if (li->li_tv.v_type != VAR_STRING) { + TV_LIST_ITER_CONST(val_di->di_tv.vval.v_list, li, { + if (TV_LIST_ITEM_TV(li)->v_type != VAR_STRING) { return false; } - } + }); return true; } diff --git a/src/nvim/eval/encode.h b/src/nvim/eval/encode.h index 9bc665253b..ccea245ab3 100644 --- a/src/nvim/eval/encode.h +++ b/src/nvim/eval/encode.h @@ -33,9 +33,10 @@ int encode_vim_to_echo(garray_T *const packer, /// Structure defining state for read_from_list() typedef struct { + const list_T *const list; ///< List being currently read. const listitem_T *li; ///< Item currently read. - size_t offset; ///< Byte offset inside the read item. - size_t li_length; ///< Length of the string inside the read item. + size_t offset; ///< Byte offset inside the read item. + size_t li_length; ///< Length of the string inside the read item. } ListReaderState; /// Initialize ListReaderState structure @@ -43,11 +44,13 @@ static inline ListReaderState encode_init_lrstate(const list_T *const list) FUNC_ATTR_NONNULL_ALL { return (ListReaderState) { - .li = list->lv_first, + .list = list, + .li = tv_list_first(list), .offset = 0, - .li_length = (list->lv_first->li_tv.vval.v_string == NULL + .li_length = (TV_LIST_ITEM_TV(tv_list_first(list))->vval.v_string == NULL ? 0 - : STRLEN(list->lv_first->li_tv.vval.v_string)), + : STRLEN(TV_LIST_ITEM_TV( + tv_list_first(list))->vval.v_string)), }; } diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 2a0c52b4be..a05abd8a53 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -383,6 +383,22 @@ static inline listitem_T *tv_list_first(const list_T *const l) return l->lv_first; } +static inline listitem_T *tv_list_last(const list_T *const l) + REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; + +/// Get last list item +/// +/// @param[in] l List to get item from. +/// +/// @return List item or NULL in case of an empty list. +static inline listitem_T *tv_list_last(const list_T *const l) +{ + if (l == NULL) { + return NULL; + } + return l->lv_last; +} + static inline long tv_dict_len(const dict_T *const d) REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; diff --git a/src/nvim/eval/typval_encode.c.h b/src/nvim/eval/typval_encode.c.h index a93ad2dbba..800760cf7b 100644 --- a/src/nvim/eval/typval_encode.c.h +++ b/src/nvim/eval/typval_encode.c.h @@ -355,14 +355,14 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( break; } case VAR_LIST: { - if (tv->vval.v_list == NULL || tv->vval.v_list->lv_len == 0) { + if (tv->vval.v_list == NULL || tv_list_len(tv->vval.v_list) == 0) { TYPVAL_ENCODE_CONV_EMPTY_LIST(tv); break; } const int saved_copyID = tv->vval.v_list->lv_copyID; _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_list, lv_copyID, copyID, kMPConvList); - TYPVAL_ENCODE_CONV_LIST_START(tv, tv->vval.v_list->lv_len); + TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(tv->vval.v_list)); assert(saved_copyID != copyID && saved_copyID != copyID - 1); _mp_push(*mpstack, ((MPConvStackVal) { .type = kMPConvList, @@ -371,7 +371,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( .data = { .l = { .list = tv->vval.v_list, - .li = tv->vval.v_list->lv_first, + .li = tv_list_first(tv->vval.v_list), }, }, })); @@ -440,23 +440,43 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( // bits is not checked), other unsigned and have at most 31 // non-zero bits (number of bits is not checked). if (val_di->di_tv.v_type != VAR_LIST - || (val_list = val_di->di_tv.vval.v_list) == NULL - || val_list->lv_len != 4 - || val_list->lv_first->li_tv.v_type != VAR_NUMBER - || (sign = val_list->lv_first->li_tv.vval.v_number) == 0 - || val_list->lv_first->li_next->li_tv.v_type != VAR_NUMBER - || (highest_bits = - val_list->lv_first->li_next->li_tv.vval.v_number) < 0 - || val_list->lv_last->li_prev->li_tv.v_type != VAR_NUMBER - || (high_bits = - val_list->lv_last->li_prev->li_tv.vval.v_number) < 0 - || val_list->lv_last->li_tv.v_type != VAR_NUMBER - || (low_bits = val_list->lv_last->li_tv.vval.v_number) < 0) { + || tv_list_len(val_list = val_di->di_tv.vval.v_list) != 4) { goto _convert_one_value_regular_dict; } - uint64_t number = ((uint64_t)(((uint64_t)highest_bits) << 62) - | (uint64_t)(((uint64_t)high_bits) << 31) - | (uint64_t)low_bits); + + const listitem_T *const sign_li = tv_list_first(val_list); + if (TV_LIST_ITEM_TV(sign_li)->v_type != VAR_NUMBER + || (sign = TV_LIST_ITEM_TV(sign_li)->vval.v_number) == 0) { + goto _convert_one_value_regular_dict; + } + + const listitem_T *const highest_bits_li = ( + TV_LIST_ITEM_NEXT(val_list, sign_li)); + if (TV_LIST_ITEM_TV(highest_bits_li)->v_type != VAR_NUMBER + || ((highest_bits + = TV_LIST_ITEM_TV(highest_bits_li)->vval.v_number) + < 0)) { + goto _convert_one_value_regular_dict; + } + + const listitem_T *const high_bits_li = ( + TV_LIST_ITEM_NEXT(val_list, highest_bits_li)); + if (TV_LIST_ITEM_TV(high_bits_li)->v_type != VAR_NUMBER + || ((high_bits = TV_LIST_ITEM_TV(high_bits_li)->vval.v_number) + < 0)) { + goto _convert_one_value_regular_dict; + } + + const listitem_T *const low_bits_li = tv_list_last(val_list); + if (TV_LIST_ITEM_TV(low_bits_li)->v_type != VAR_NUMBER + || ((low_bits = TV_LIST_ITEM_TV(low_bits_li)->vval.v_number) + < 0)) { + goto _convert_one_value_regular_dict; + } + + const uint64_t number = ((uint64_t)(((uint64_t)highest_bits) << 62) + | (uint64_t)(((uint64_t)high_bits) << 31) + | (uint64_t)low_bits); if (sign > 0) { TYPVAL_ENCODE_CONV_UNSIGNED_NUMBER(tv, number); } else { @@ -499,8 +519,8 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_di->di_tv.vval.v_list, lv_copyID, copyID, kMPConvList); - TYPVAL_ENCODE_CONV_LIST_START(tv, - val_di->di_tv.vval.v_list->lv_len); + TYPVAL_ENCODE_CONV_LIST_START( + tv, tv_list_len(val_di->di_tv.vval.v_list)); assert(saved_copyID != copyID && saved_copyID != copyID - 1); _mp_push(*mpstack, ((MPConvStackVal) { .tv = tv, @@ -509,7 +529,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( .data = { .l = { .list = val_di->di_tv.vval.v_list, - .li = val_di->di_tv.vval.v_list->lv_first, + .li = tv_list_first(val_di->di_tv.vval.v_list), }, }, })); @@ -520,22 +540,21 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( goto _convert_one_value_regular_dict; } list_T *const val_list = val_di->di_tv.vval.v_list; - if (val_list == NULL || val_list->lv_len == 0) { + if (val_list == NULL || tv_list_len(val_list) == 0) { TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, TYPVAL_ENCODE_NODICT_VAR); break; } - for (const listitem_T *li = val_list->lv_first; li != NULL; - li = li->li_next) { - if (li->li_tv.v_type != VAR_LIST - || li->li_tv.vval.v_list->lv_len != 2) { + TV_LIST_ITER_CONST(val_list, li, { + if (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST + || tv_list_len(TV_LIST_ITEM_TV(li)->vval.v_list) != 2) { goto _convert_one_value_regular_dict; } - } + }); const int saved_copyID = val_di->di_tv.vval.v_list->lv_copyID; _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_list, lv_copyID, copyID, kMPConvPairs); TYPVAL_ENCODE_CONV_DICT_START(tv, TYPVAL_ENCODE_NODICT_VAR, - val_list->lv_len); + tv_list_len(val_list)); assert(saved_copyID != copyID && saved_copyID != copyID - 1); _mp_push(*mpstack, ((MPConvStackVal) { .tv = tv, @@ -544,7 +563,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( .data = { .l = { .list = val_list, - .li = val_list->lv_first, + .li = tv_list_first(val_list), }, }, })); @@ -554,18 +573,22 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( const list_T *val_list; varnumber_T type; if (val_di->di_tv.v_type != VAR_LIST - || (val_list = val_di->di_tv.vval.v_list) == NULL - || val_list->lv_len != 2 - || (val_list->lv_first->li_tv.v_type != VAR_NUMBER) - || (type = val_list->lv_first->li_tv.vval.v_number) > INT8_MAX + || tv_list_len((val_list = val_di->di_tv.vval.v_list)) != 2 + || (TV_LIST_ITEM_TV(tv_list_first(val_list))->v_type + != VAR_NUMBER) + || ((type + = TV_LIST_ITEM_TV(tv_list_first(val_list))->vval.v_number) + > INT8_MAX) || type < INT8_MIN - || (val_list->lv_last->li_tv.v_type != VAR_LIST)) { + || (TV_LIST_ITEM_TV(tv_list_last(val_list))->v_type + != VAR_LIST)) { goto _convert_one_value_regular_dict; } size_t len; char *buf; - if (!encode_vim_list_to_buf(val_list->lv_last->li_tv.vval.v_list, - &len, &buf)) { + if (!encode_vim_list_to_buf( + TV_LIST_ITEM_TV(tv_list_last(val_list))->vval.v_list, &len, + &buf)) { goto _convert_one_value_regular_dict; } TYPVAL_ENCODE_CONV_EXT_STRING(tv, buf, len, type); @@ -674,11 +697,13 @@ typval_encode_stop_converting_one_item: cur_mpsv->data.l.list->lv_copyID = cur_mpsv->saved_copyID; TYPVAL_ENCODE_CONV_LIST_END(cur_mpsv->tv); continue; - } else if (cur_mpsv->data.l.li != cur_mpsv->data.l.list->lv_first) { + } else if (cur_mpsv->data.l.li + != tv_list_first(cur_mpsv->data.l.list)) { TYPVAL_ENCODE_CONV_LIST_BETWEEN_ITEMS(cur_mpsv->tv); } - tv = &cur_mpsv->data.l.li->li_tv; - cur_mpsv->data.l.li = cur_mpsv->data.l.li->li_next; + tv = TV_LIST_ITEM_TV(cur_mpsv->data.l.li); + cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list, + cur_mpsv->data.l.li); break; } case kMPConvPairs: { @@ -687,24 +712,26 @@ typval_encode_stop_converting_one_item: cur_mpsv->data.l.list->lv_copyID = cur_mpsv->saved_copyID; TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR); continue; - } else if (cur_mpsv->data.l.li != cur_mpsv->data.l.list->lv_first) { + } else if (cur_mpsv->data.l.li + != tv_list_first(cur_mpsv->data.l.list)) { TYPVAL_ENCODE_CONV_DICT_BETWEEN_ITEMS( cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR); } - const list_T *const kv_pair = cur_mpsv->data.l.li->li_tv.vval.v_list; + const list_T *const kv_pair = ( + TV_LIST_ITEM_TV(cur_mpsv->data.l.li)->vval.v_list); TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK( - encode_vim_to__error_ret, kv_pair->lv_first->li_tv); - if (_TYPVAL_ENCODE_CONVERT_ONE_VALUE(TYPVAL_ENCODE_FIRST_ARG_NAME, - &mpstack, cur_mpsv, - &kv_pair->lv_first->li_tv, - copyID, - objname) == FAIL) { + encode_vim_to__error_ret, *TV_LIST_ITEM_TV(tv_list_first(kv_pair))); + if (_TYPVAL_ENCODE_CONVERT_ONE_VALUE( + TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack, cur_mpsv, + TV_LIST_ITEM_TV(tv_list_first(kv_pair)), copyID, objname) + == FAIL) { goto encode_vim_to__error_ret; } TYPVAL_ENCODE_CONV_DICT_AFTER_KEY(cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR); - tv = &kv_pair->lv_last->li_tv; - cur_mpsv->data.l.li = cur_mpsv->data.l.li->li_next; + tv = TV_LIST_ITEM_TV(tv_list_last(kv_pair)); + cur_mpsv->data.l.li = TV_LIST_ITEM_NEXT(cur_mpsv->data.l.list, + cur_mpsv->data.l.li); break; } case kMPConvPartial: { diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 8616508d88..4f54d4c88b 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -6334,7 +6334,6 @@ char_u *skip_vimgrep_pat(char_u *p, char_u **s, int *flags) void ex_oldfiles(exarg_T *eap) { list_T *l = get_vim_var_list(VV_OLDFILES); - listitem_T *li; long nr = 0; if (l == NULL) { @@ -6342,19 +6341,22 @@ void ex_oldfiles(exarg_T *eap) } else { msg_start(); msg_scroll = true; - for (li = l->lv_first; li != NULL && !got_int; li = li->li_next) { + TV_LIST_ITER(l, li, { + if (got_int) { + break; + } nr++; - const char *fname = tv_get_string(&li->li_tv); + const char *fname = tv_get_string(TV_LIST_ITEM_TV(li)); if (!message_filtered((char_u *)fname)) { msg_outnum(nr); MSG_PUTS(": "); - msg_outtrans((char_u *)tv_get_string(&li->li_tv)); + msg_outtrans((char_u *)tv_get_string(TV_LIST_ITEM_TV(li))); msg_clr_eos(); msg_putchar('\n'); ui_flush(); // output one line at a time os_breakcheck(); } - } + }); // Assume "got_int" was set to truncate the listing. got_int = false; @@ -6364,7 +6366,7 @@ void ex_oldfiles(exarg_T *eap) quit_more = false; nr = prompt_for_number(false); msg_starthere(); - if (nr > 0 && nr <= l->lv_len) { + if (nr > 0 && nr <= tv_list_len(l)) { const char *const p = tv_list_find_str(l, nr - 1); if (p == NULL) { return; diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 1adc8325f8..fcd230d535 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2618,20 +2618,20 @@ static bool color_cmdline(CmdlineInfo *colored_ccline) } varnumber_T prev_end = 0; int i = 0; - for (const listitem_T *li = tv.vval.v_list->lv_first; - li != NULL; li = li->li_next, i++) { - if (li->li_tv.v_type != VAR_LIST) { + TV_LIST_ITER_CONST(tv.vval.v_list, li, { + if (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST) { PRINT_ERRMSG(_("E5401: List item %i is not a List"), i); goto color_cmdline_error; } - const list_T *const l = li->li_tv.vval.v_list; + const list_T *const l = TV_LIST_ITEM_TV(li)->vval.v_list; if (tv_list_len(l) != 3) { PRINT_ERRMSG(_("E5402: List item %i has incorrect length: %li /= 3"), i, tv_list_len(l)); goto color_cmdline_error; } bool error = false; - const varnumber_T start = tv_get_number_chk(&l->lv_first->li_tv, &error); + const varnumber_T start = ( + tv_get_number_chk(TV_LIST_ITEM_TV(tv_list_first(l)), &error)); if (error) { goto color_cmdline_error; } else if (!(prev_end <= start && start < colored_ccline->cmdlen)) { @@ -2651,8 +2651,8 @@ static bool color_cmdline(CmdlineInfo *colored_ccline) .attr = 0, })); } - const varnumber_T end = tv_get_number_chk(&l->lv_first->li_next->li_tv, - &error); + const varnumber_T end = tv_get_number_chk( + TV_LIST_ITEM_TV(TV_LIST_ITEM_NEXT(l, tv_list_first(l))), &error); if (error) { goto color_cmdline_error; } else if (!(start < end && end <= colored_ccline->cmdlen)) { @@ -2668,7 +2668,8 @@ static bool color_cmdline(CmdlineInfo *colored_ccline) goto color_cmdline_error; } prev_end = end; - const char *const group = tv_get_string_chk(&l->lv_last->li_tv); + const char *const group = tv_get_string_chk( + TV_LIST_ITEM_TV(tv_list_last(l))); if (group == NULL) { goto color_cmdline_error; } @@ -2679,7 +2680,7 @@ static bool color_cmdline(CmdlineInfo *colored_ccline) .end = end, .attr = attr, })); - } + }); if (prev_end < colored_ccline->cmdlen) { kv_push(ccline_colors->colors, ((CmdlineColorChunk) { .start = prev_end, @@ -5021,24 +5022,24 @@ static int ExpandUserDefined(expand_T *xp, regmatch_T *regmatch, int *num_file, */ static int ExpandUserList(expand_T *xp, int *num_file, char_u ***file) { - list_T *retlist; - listitem_T *li; - garray_T ga; - - retlist = call_user_expand_func((user_expand_func_T)call_func_retlist, xp, - num_file, file); + list_T *const retlist = call_user_expand_func( + (user_expand_func_T)call_func_retlist, xp, num_file, file); if (retlist == NULL) { return FAIL; } + garray_T ga; ga_init(&ga, (int)sizeof(char *), 3); - /* Loop over the items in the list. */ - for (li = retlist->lv_first; li != NULL; li = li->li_next) { - if (li->li_tv.v_type != VAR_STRING || li->li_tv.vval.v_string == NULL) - continue; /* Skip non-string items and empty strings */ + // Loop over the items in the list. + TV_LIST_ITER_CONST(retlist, li, { + if (TV_LIST_ITEM_TV(li)->v_type != VAR_STRING + || TV_LIST_ITEM_TV(li)->vval.v_string == NULL) { + continue; // Skip non-string items and empty strings. + } - GA_APPEND(char_u *, &ga, vim_strsave(li->li_tv.vval.v_string)); - } + GA_APPEND(char *, &ga, xstrdup( + (const char *)TV_LIST_ITEM_TV(li)->vval.v_string)); + }); tv_list_unref(retlist); *file = ga.ga_data; diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index 18134c56e3..8303ecdd37 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -214,9 +214,9 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) list_T *const kv_pair = tv_list_alloc(); tv_list_append_list(cur.tv->vval.v_list, kv_pair); listitem_T *const key = tv_list_item_alloc(); - key->li_tv = decode_string(s, len, kTrue, false, false); + *TV_LIST_ITEM_TV(key) = decode_string(s, len, kTrue, false, false); tv_list_append(kv_pair, key); - if (key->li_tv.v_type == VAR_UNKNOWN) { + if (TV_LIST_ITEM_TV(key)->v_type == VAR_UNKNOWN) { ret = false; tv_list_unref(kv_pair); continue; @@ -224,7 +224,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) listitem_T *const val = tv_list_item_alloc(); tv_list_append(kv_pair, val); kv_push(stack, cur); - cur = (TVPopStackItem) { &val->li_tv, false, false, 0 }; + cur = (TVPopStackItem) { TV_LIST_ITEM_TV(val), false, false, 0 }; } else { dictitem_T *const di = tv_dict_item_alloc_len(s, len); if (tv_dict_add(cur.tv->vval.v_dict, di) == FAIL) { @@ -239,7 +239,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) } } else { assert(cur.tv->v_type == VAR_LIST); - lua_rawgeti(lstate, -1, cur.tv->vval.v_list->lv_len + 1); + lua_rawgeti(lstate, -1, tv_list_len(cur.tv->vval.v_list) + 1); if (lua_isnil(lstate, -1)) { lua_pop(lstate, 2); continue; @@ -247,7 +247,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) listitem_T *const li = tv_list_item_alloc(); tv_list_append(cur.tv->vval.v_list, li); kv_push(stack, cur); - cur = (TVPopStackItem) { &li->li_tv, false, false, 0 }; + cur = (TVPopStackItem) { TV_LIST_ITEM_TV(li), false, false, 0 }; } } assert(!cur.container); diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 9f445204d0..3cc73b2e40 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -4854,9 +4854,8 @@ static void *get_reg_wrap_one_line(char_u *s, int flags) if (!(flags & kGRegList)) { return s; } - list_T *list = tv_list_alloc(); - tv_list_append_string(list, NULL, 0); - list->lv_first->li_tv.vval.v_string = s; + list_T *const list = tv_list_alloc(); + tv_list_append_allocated_string(list, (char *)s); return list; } @@ -5610,12 +5609,13 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet) list_T *res = result.vval.v_list; list_T *lines = NULL; - if (res->lv_len == 2 && res->lv_first->li_tv.v_type == VAR_LIST) { - lines = res->lv_first->li_tv.vval.v_list; - if (res->lv_last->li_tv.v_type != VAR_STRING) { + if (tv_list_len(res) == 2 + && TV_LIST_ITEM_TV(tv_list_first(res))->v_type == VAR_LIST) { + lines = TV_LIST_ITEM_TV(tv_list_first(res))->vval.v_list; + if (TV_LIST_ITEM_TV(tv_list_last(res))->v_type != VAR_STRING) { goto err; } - char_u *regtype = res->lv_last->li_tv.vval.v_string; + char_u *regtype = TV_LIST_ITEM_TV(tv_list_last(res))->vval.v_string; if (regtype == NULL || strlen((char*)regtype) > 1) { goto err; } @@ -5641,20 +5641,21 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet) reg->y_type = kMTUnknown; } - reg->y_array = xcalloc((size_t)lines->lv_len, sizeof(uint8_t *)); - reg->y_size = (size_t)lines->lv_len; + reg->y_array = xcalloc((size_t)tv_list_len(lines), sizeof(char_u *)); + reg->y_size = (size_t)tv_list_len(lines); reg->additional_data = NULL; reg->timestamp = 0; // Timestamp is not saved for clipboard registers because clipboard registers // are not saved in the ShaDa file. int i = 0; - for (listitem_T *li = lines->lv_first; li != NULL; li = li->li_next) { - if (li->li_tv.v_type != VAR_STRING) { + TV_LIST_ITER_CONST(lines, li, { + if (TV_LIST_ITEM_TV(li)->v_type != VAR_STRING) { goto err; } - reg->y_array[i++] = (char_u *)xstrdupnul((char *)li->li_tv.vval.v_string); - } + reg->y_array[i++] = (char_u *)xstrdupnul( + (const char *)TV_LIST_ITEM_TV(li)->vval.v_string); + }); if (reg->y_size > 0 && strlen((char*)reg->y_array[reg->y_size-1]) == 0) { // a known-to-be charwise yank might have a final linebreak diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 1fc585f0c9..56d11c21ab 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -156,6 +156,7 @@ typedef struct { FILE *fd; typval_T *tv; char_u *p_str; + list_T *p_list; listitem_T *p_li; buf_T *buf; linenr_T buflnum; @@ -516,17 +517,17 @@ static int qf_get_next_list_line(qfstate_T *state) // Get the next line from the supplied list while (p_li != NULL - && (p_li->li_tv.v_type != VAR_STRING - || p_li->li_tv.vval.v_string == NULL)) { - p_li = p_li->li_next; // Skip non-string items + && (TV_LIST_ITEM_TV(p_li)->v_type != VAR_STRING + || TV_LIST_ITEM_TV(p_li)->vval.v_string == NULL)) { + p_li = TV_LIST_ITEM_NEXT(state->p_list, p_li); // Skip non-string items. } - if (p_li == NULL) { // End of the list + if (p_li == NULL) { // End of the list. state->p_li = NULL; return QF_END_OF_INPUT; } - len = STRLEN(p_li->li_tv.vval.v_string); + len = STRLEN(TV_LIST_ITEM_TV(p_li)->vval.v_string); if (len > IOSIZE - 2) { state->linebuf = qf_grow_linebuf(state, len); } else { @@ -534,9 +535,10 @@ static int qf_get_next_list_line(qfstate_T *state) state->linelen = len; } - STRLCPY(state->linebuf, p_li->li_tv.vval.v_string, state->linelen + 1); + STRLCPY(state->linebuf, TV_LIST_ITEM_TV(p_li)->vval.v_string, + state->linelen + 1); - state->p_li = p_li->li_next; // next item + state->p_li = TV_LIST_ITEM_NEXT(state->p_list, p_li); return QF_OK; } @@ -983,7 +985,7 @@ qf_init_ext( ) { qfstate_T state = { NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, - NULL, 0, 0 }; + NULL, NULL, 0, 0 }; qffields_T fields = { NULL, NULL, 0, 0L, 0, false, NULL, 0, 0, 0 }; qfline_T *old_last = NULL; bool adding = false; @@ -1064,7 +1066,8 @@ qf_init_ext( if (tv->v_type == VAR_STRING) { state.p_str = tv->vval.v_string; } else if (tv->v_type == VAR_LIST) { - state.p_li = tv->vval.v_list->lv_first; + state.p_list = tv->vval.v_list; + state.p_li = tv_list_first(tv->vval.v_list); } state.tv = tv; } @@ -4100,7 +4103,6 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title, int action) { - listitem_T *li; dict_T *d; qfline_T *old_last = NULL; int retval = OK; @@ -4117,13 +4119,15 @@ static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title, qf_store_title(qi, title); } - for (li = list->lv_first; li != NULL; li = li->li_next) { - if (li->li_tv.v_type != VAR_DICT) - continue; /* Skip non-dict items */ + TV_LIST_ITER_CONST(list, li, { + if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT) { + continue; // Skip non-dict items. + } - d = li->li_tv.vval.v_dict; - if (d == NULL) + d = TV_LIST_ITEM_TV(li)->vval.v_dict; + if (d == NULL) { continue; + } char *const filename = tv_dict_get_string(d, "filename", true); int bufnum = (int)tv_dict_get_number(d, "bufnr"); @@ -4175,7 +4179,7 @@ static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title, retval = FAIL; break; } - } + }); if (qi->qf_lists[qi->qf_curlist].qf_index == 0) { // no valid entry diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index ae611a0005..ffe393f1b0 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -6477,10 +6477,6 @@ static regsubmatch_T rsm; // can only be used when can_f_submatch is true /// vim_regsub_both(). static int fill_submatch_list(int argc, typval_T *argv, int argcount) { - listitem_T *li; - int i; - char_u *s; - if (argcount == 0) { // called function doesn't take an argument return 0; @@ -6490,28 +6486,26 @@ static int fill_submatch_list(int argc, typval_T *argv, int argcount) init_static_list((staticList10_T *)(argv->vval.v_list)); // There are always 10 list items in staticList10_T. - li = argv->vval.v_list->lv_first; - for (i = 0; i < 10; i++) { - s = rsm.sm_match->startp[i]; + listitem_T *li = tv_list_first(argv->vval.v_list); + for (int i = 0; i < 10; i++) { + char_u *s = rsm.sm_match->startp[i]; if (s == NULL || rsm.sm_match->endp[i] == NULL) { s = NULL; } else { s = vim_strnsave(s, (int)(rsm.sm_match->endp[i] - s)); } - li->li_tv.v_type = VAR_STRING; - li->li_tv.vval.v_string = s; - li = li->li_next; + TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; + TV_LIST_ITEM_TV(li)->vval.v_string = s; + li = TV_LIST_ITEM_NEXT(argv->vval.v_list, li); } return 1; } static void clear_submatch_list(staticList10_T *sl) { - int i; - - for (i = 0; i < 10; i++) { - xfree(sl->sl_items[i].li_tv.vval.v_string); - } + TV_LIST_ITER(&sl->sl_list, li, { + xfree(TV_LIST_ITEM_TV(li)->vval.v_string); + }); } /// vim_regsub() - perform substitutions after a vim_regexec() or @@ -6651,6 +6645,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, rettv.vval.v_string = NULL; argv[0].v_type = VAR_LIST; argv[0].vval.v_list = &matchList.sl_list; + // FIXME: Abstract away matchList.sl_list.lv_len = 0; if (expr->v_type == VAR_FUNC) { s = expr->vval.v_string; diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 736d6bf162..75f91ce6d8 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -1180,8 +1180,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags) list_T *oldfiles_list = get_vim_var_list(VV_OLDFILES); const bool force = flags & kShaDaForceit; const bool get_old_files = (flags & (kShaDaGetOldfiles | kShaDaForceit) - && (force || oldfiles_list == NULL - || oldfiles_list->lv_len == 0)); + && (force || tv_list_len(oldfiles_list) == 0)); const bool want_marks = flags & kShaDaWantMarks; const unsigned srni_flags = (unsigned) ( (flags & kShaDaWantInfo @@ -1599,13 +1598,13 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, #define DUMP_ADDITIONAL_ELEMENTS(src, what) \ do { \ if ((src) != NULL) { \ - for (listitem_T *li = (src)->lv_first; li != NULL; li = li->li_next) { \ - if (encode_vim_to_msgpack(spacker, &li->li_tv, \ + TV_LIST_ITER((src), li, { \ + if (encode_vim_to_msgpack(spacker, TV_LIST_ITEM_TV(li), \ _("additional elements of ShaDa " what)) \ == FAIL) { \ goto shada_pack_entry_error; \ } \ - } \ + }); \ } \ } while (0) #define DUMP_ADDITIONAL_DATA(src, what) \ @@ -1648,9 +1647,7 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, const bool is_hist_search = entry.data.history_item.histtype == HIST_SEARCH; const size_t arr_size = 2 + (size_t) is_hist_search + (size_t) ( - entry.data.history_item.additional_elements == NULL - ? 0 - : entry.data.history_item.additional_elements->lv_len); + tv_list_len(entry.data.history_item.additional_elements)); msgpack_pack_array(spacker, arr_size); msgpack_pack_uint8(spacker, entry.data.history_item.histtype); PACK_BIN(cstr_as_string(entry.data.history_item.string)); @@ -1663,9 +1660,7 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, } case kSDItemVariable: { const size_t arr_size = 2 + (size_t) ( - entry.data.global_var.additional_elements == NULL - ? 0 - : entry.data.global_var.additional_elements->lv_len); + tv_list_len(entry.data.global_var.additional_elements)); msgpack_pack_array(spacker, arr_size); const String varname = cstr_as_string(entry.data.global_var.name); PACK_BIN(varname); @@ -1685,9 +1680,7 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, } case kSDItemSubString: { const size_t arr_size = 1 + (size_t) ( - entry.data.sub_string.additional_elements == NULL - ? 0 - : entry.data.sub_string.additional_elements->lv_len); + tv_list_len(entry.data.sub_string.additional_elements)); msgpack_pack_array(spacker, arr_size); PACK_BIN(cstr_as_string(entry.data.sub_string.sub)); DUMP_ADDITIONAL_ELEMENTS(entry.data.sub_string.additional_elements, diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 42c9bcc0ee..6a1b46fb5b 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -3213,26 +3213,25 @@ spell_find_suggest ( // Find suggestions by evaluating expression "expr". static void spell_suggest_expr(suginfo_T *su, char_u *expr) { - list_T *list; - listitem_T *li; int score; const char *p; // The work is split up in a few parts to avoid having to export // suginfo_T. // First evaluate the expression and get the resulting list. - list = eval_spell_expr(su->su_badword, expr); + list_T *const list = eval_spell_expr(su->su_badword, expr); if (list != NULL) { // Loop over the items in the list. - for (li = list->lv_first; li != NULL; li = li->li_next) - if (li->li_tv.v_type == VAR_LIST) { + TV_LIST_ITER(list, li, { + if (TV_LIST_ITEM_TV(li)->v_type == VAR_LIST) { // Get the word and the score from the items. - score = get_spellword(li->li_tv.vval.v_list, &p); + score = get_spellword(TV_LIST_ITEM_TV(li)->vval.v_list, &p); if (score >= 0 && score <= su->su_maxscore) { add_suggestion(su, &su->su_ga, (const char_u *)p, su->su_badlen, score, 0, true, su->su_sallang, false); } } + }); tv_list_unref(list); } diff --git a/src/nvim/window.c b/src/nvim/window.c index 4e4eb297aa..21d668a2bd 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5579,30 +5579,26 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, // Set up position matches if (pos_list != NULL) { - linenr_T toplnum = 0; - linenr_T botlnum = 0; - listitem_T *li; - int i; - - for (i = 0, li = pos_list->lv_first; li != NULL && i < MAXPOSMATCH; - i++, li = li->li_next) { - linenr_T lnum = 0; - colnr_T col = 0; - int len = 1; - list_T *subl; - listitem_T *subli; + linenr_T toplnum = 0; + linenr_T botlnum = 0; + + int i = 0; + TV_LIST_ITER(pos_list, li, { + linenr_T lnum = 0; + colnr_T col = 0; + int len = 1; bool error = false; - if (li->li_tv.v_type == VAR_LIST) { - subl = li->li_tv.vval.v_list; + if (TV_LIST_ITEM_TV(li)->v_type == VAR_LIST) { + const list_T *const subl = TV_LIST_ITEM_TV(li)->vval.v_list; if (subl == NULL) { goto fail; } - subli = subl->lv_first; + const listitem_T *subli = tv_list_first(subl); if (subli == NULL) { goto fail; } - lnum = tv_get_number_chk(&subli->li_tv, &error); + lnum = tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error); if (error) { goto fail; } @@ -5611,15 +5607,15 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, continue; } m->pos.pos[i].lnum = lnum; - subli = subli->li_next; + subli = TV_LIST_ITEM_NEXT(subl, subli); if (subli != NULL) { - col = tv_get_number_chk(&subli->li_tv, &error); + col = tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error); if (error) { goto fail; } - subli = subli->li_next; + subli = TV_LIST_ITEM_NEXT(subl, subli); if (subli != NULL) { - len = tv_get_number_chk(&subli->li_tv, &error); + len = tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error); if (error) { goto fail; } @@ -5627,12 +5623,12 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, } m->pos.pos[i].col = col; m->pos.pos[i].len = len; - } else if (li->li_tv.v_type == VAR_NUMBER) { - if (li->li_tv.vval.v_number == 0) { - --i; + } else if (TV_LIST_ITEM_TV(li)->v_type == VAR_NUMBER) { + if (TV_LIST_ITEM_TV(li)->vval.v_number == 0) { + i--; continue; } - m->pos.pos[i].lnum = li->li_tv.vval.v_number; + m->pos.pos[i].lnum = TV_LIST_ITEM_TV(li)->vval.v_number; m->pos.pos[i].col = 0; m->pos.pos[i].len = 0; } else { @@ -5645,7 +5641,11 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, if (botlnum == 0 || lnum >= botlnum) { botlnum = lnum + 1; } - } + i++; + if (i >= MAXPOSMATCH) { + break; + } + }); // Calculate top and bottom lines for redrawing area if (toplnum != 0){ -- cgit From f572bd7e4e15a99cc19244a4411c6a596309f489 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 22:24:11 +0300 Subject: eval,functests: Fix tests and complete() and setline() behaviour --- src/nvim/eval.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 2f908f70a9..81dd6434a1 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -7496,7 +7496,7 @@ static void f_complete(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (!undo_allowed()) return; - if (argvars[1].v_type != VAR_LIST || argvars[1].vval.v_list == NULL) { + if (argvars[1].v_type != VAR_LIST) { EMSG(_(e_invarg)); return; } @@ -14540,20 +14540,19 @@ static void f_setline(typval_T *argvars, typval_T *rettv, FunPtr fptr) line = tv_get_string_chk(&argvars[1]); } - /* default result is zero == OK */ + // Default result is zero == OK. for (;; ) { - if (l != NULL) { // List argument, get next string. - if (li == NULL) { - break; - } - line = tv_get_string_chk(TV_LIST_ITEM_TV(li)); - li = TV_LIST_ITEM_NEXT(l, li); + if (li == NULL) { + break; } + line = tv_get_string_chk(TV_LIST_ITEM_TV(li)); + li = TV_LIST_ITEM_NEXT(l, li); - rettv->vval.v_number = 1; /* FAIL */ - if (line == NULL || lnum < 1 || lnum > curbuf->b_ml.ml_line_count + 1) + rettv->vval.v_number = 1; // FAIL + if (line == NULL || lnum < 1 || lnum > curbuf->b_ml.ml_line_count + 1) { break; + } /* When coming here from Insert mode, sync undo, so that this can be * undone separately from what was previously inserted. */ -- cgit From 5008205a3e1eef61396e457e5091eb1341b98278 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 22:28:18 +0300 Subject: eval: Fix setmatches(), setqflist() and setloclist() --- src/nvim/eval.c | 153 +++++++++++++++++++++++++++----------------------------- 1 file changed, 75 insertions(+), 78 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 81dd6434a1..c654fe691e 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -14653,8 +14653,8 @@ skip_args: title = (wp ? "setloclist()" : "setqflist()"); } - list_T *l = list_arg->vval.v_list; - if (l && set_errorlist(wp, l, action, (char_u *)title, d) == OK) { + list_T *const l = list_arg->vval.v_list; + if (set_errorlist(wp, l, action, (char_u *)title, d) == OK) { rettv->vval.v_number = 0; } } @@ -14687,92 +14687,89 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) EMSG(_(e_listreq)); return; } - list_T *l; - if ((l = argvars[0].vval.v_list) != NULL) { + list_T *const l = argvars[0].vval.v_list; + // To some extent make sure that we are dealing with a list from + // "getmatches()". + int i = 0; + TV_LIST_ITER_CONST(l, li, { + if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT + || (d = TV_LIST_ITEM_TV(li)->vval.v_dict) == NULL) { + emsgf(_("E474: List item %d is either not a dictionary " + "or an empty one"), i); + return; + } + if (!(tv_dict_find(d, S_LEN("group")) != NULL + && (tv_dict_find(d, S_LEN("pattern")) != NULL + || tv_dict_find(d, S_LEN("pos1")) != NULL) + && tv_dict_find(d, S_LEN("priority")) != NULL + && tv_dict_find(d, S_LEN("id")) != NULL)) { + emsgf(_("E474: List item %d is missing one of the required keys"), i); + return; + } + i++; + }); - // To some extent make sure that we are dealing with a list from - // "getmatches()". + clear_matches(curwin); + bool match_add_failed = false; + TV_LIST_ITER_CONST(l, li, { int i = 0; - TV_LIST_ITER_CONST(l, li, { - if (TV_LIST_ITEM_TV(li)->v_type != VAR_DICT - || (d = TV_LIST_ITEM_TV(li)->vval.v_dict) == NULL) { - emsgf(_("E474: List item %d is either not a dictionary " - "or an empty one"), i); - return; - } - if (!(tv_dict_find(d, S_LEN("group")) != NULL - && (tv_dict_find(d, S_LEN("pattern")) != NULL - || tv_dict_find(d, S_LEN("pos1")) != NULL) - && tv_dict_find(d, S_LEN("priority")) != NULL - && tv_dict_find(d, S_LEN("id")) != NULL)) { - emsgf(_("E474: List item %d is missing one of the required keys"), i); - return; - } - i++; - }); - clear_matches(curwin); - bool match_add_failed = false; - TV_LIST_ITER_CONST(l, li, { - int i = 0; - - d = TV_LIST_ITEM_TV(li)->vval.v_dict; - dictitem_T *const di = tv_dict_find(d, S_LEN("pattern")); - if (di == NULL) { - if (s == NULL) { - s = tv_list_alloc(); - } - - // match from matchaddpos() - for (i = 1; i < 9; i++) { - char buf[5]; - snprintf(buf, sizeof(buf), "pos%d", i); - dictitem_T *const pos_di = tv_dict_find(d, buf, -1); - if (pos_di != NULL) { - if (pos_di->di_tv.v_type != VAR_LIST) { - return; - } + d = TV_LIST_ITEM_TV(li)->vval.v_dict; + dictitem_T *const di = tv_dict_find(d, S_LEN("pattern")); + if (di == NULL) { + if (s == NULL) { + s = tv_list_alloc(); + } - tv_list_append_tv(s, &pos_di->di_tv); - tv_list_ref(s); - } else { - break; + // match from matchaddpos() + for (i = 1; i < 9; i++) { + char buf[5]; + snprintf(buf, sizeof(buf), "pos%d", i); + dictitem_T *const pos_di = tv_dict_find(d, buf, -1); + if (pos_di != NULL) { + if (pos_di->di_tv.v_type != VAR_LIST) { + return; } + + tv_list_append_tv(s, &pos_di->di_tv); + tv_list_ref(s); + } else { + break; } } + } - // Note: there are three number buffers involved: - // - group_buf below. - // - numbuf in tv_dict_get_string(). - // - mybuf in tv_get_string(). - // - // If you change this code make sure that buffers will not get - // accidentally reused. - char group_buf[NUMBUFLEN]; - const char *const group = tv_dict_get_string_buf(d, "group", group_buf); - const int priority = (int)tv_dict_get_number(d, "priority"); - const int id = (int)tv_dict_get_number(d, "id"); - dictitem_T *const conceal_di = tv_dict_find(d, S_LEN("conceal")); - const char *const conceal = (conceal_di != NULL - ? tv_get_string(&conceal_di->di_tv) - : NULL); - if (i == 0) { - if (match_add(curwin, group, - tv_dict_get_string(d, "pattern", false), - priority, id, NULL, conceal) != id) { - match_add_failed = true; - } - } else { - if (match_add(curwin, group, NULL, priority, id, s, conceal) != id) { - match_add_failed = true; - } - tv_list_unref(s); - s = NULL; + // Note: there are three number buffers involved: + // - group_buf below. + // - numbuf in tv_dict_get_string(). + // - mybuf in tv_get_string(). + // + // If you change this code make sure that buffers will not get + // accidentally reused. + char group_buf[NUMBUFLEN]; + const char *const group = tv_dict_get_string_buf(d, "group", group_buf); + const int priority = (int)tv_dict_get_number(d, "priority"); + const int id = (int)tv_dict_get_number(d, "id"); + dictitem_T *const conceal_di = tv_dict_find(d, S_LEN("conceal")); + const char *const conceal = (conceal_di != NULL + ? tv_get_string(&conceal_di->di_tv) + : NULL); + if (i == 0) { + if (match_add(curwin, group, + tv_dict_get_string(d, "pattern", false), + priority, id, NULL, conceal) != id) { + match_add_failed = true; } - }); - if (!match_add_failed) { - rettv->vval.v_number = 0; + } else { + if (match_add(curwin, group, NULL, priority, id, s, conceal) != id) { + match_add_failed = true; + } + tv_list_unref(s); + s = NULL; } + }); + if (!match_add_failed) { + rettv->vval.v_number = 0; } } -- cgit From 83f77c80c084a0390b5a6efd364b33620c9f3d10 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 22:33:05 +0300 Subject: quickfix: Fix :cexpr and :lexpr --- src/nvim/quickfix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 56d11c21ab..a4dc9c68ce 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4403,7 +4403,7 @@ void ex_cexpr(exarg_T *eap) typval_T tv; if (eval0(eap->arg, &tv, NULL, true) != FAIL) { if ((tv.v_type == VAR_STRING && tv.vval.v_string != NULL) - || (tv.v_type == VAR_LIST && tv.vval.v_list != NULL)) { + || tv.v_type == VAR_LIST) { if (qf_init_ext(qi, NULL, NULL, &tv, p_efm, (eap->cmdidx != CMD_caddexpr && eap->cmdidx != CMD_laddexpr), -- cgit From 7572d5ac5a09c18651843c026ebc92bffafe348f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 22:41:00 +0300 Subject: eval/encode: Fix crash in json_encode test suite --- src/nvim/eval/encode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 0e5db84ad5..50ddb1f38c 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -136,8 +136,10 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack, } case kMPConvPairs: case kMPConvList: { - const listitem_T *const li = TV_LIST_ITEM_PREV(v.data.l.list, - v.data.l.li); + const listitem_T *const li = (v.data.l.li == NULL + ? tv_list_last(v.data.l.list) + : TV_LIST_ITEM_PREV(v.data.l.list, + v.data.l.li)); int idx = (int)tv_list_idx_of_item(v.data.l.list, li); if (v.type == kMPConvList || li == NULL -- cgit From d11884db497114bc8ac5e33964ed81165f8a50fe Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 23:02:19 +0300 Subject: eval: Fix uniq() crash in legacy test 055 --- src/nvim/eval.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index c654fe691e..064f2c072c 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -15232,6 +15232,8 @@ item_compare_end: // When the result would be zero, compare the item indexes. Makes the // sort stable. if (res == 0 && !keep_zero) { + // WARNING: When using uniq si1 and si2 are actually listitem_T **, no + // indexes are there. res = si1->idx > si2->idx ? 1 : -1; } return res; @@ -15297,6 +15299,8 @@ static int item_compare2(const void *s1, const void *s2, bool keep_zero) // When the result would be zero, compare the pointers themselves. Makes // the sort stable. if (res == 0 && !keep_zero) { + // WARNING: When using uniq si1 and si2 are actually listitem_T **, no + // indexes are there. res = si1->idx > si2->idx ? 1 : -1; } @@ -15337,7 +15341,7 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) } else { list_T *const l = argvars[0].vval.v_list; if (tv_check_lock(tv_list_locked(l), arg_errmsg, TV_TRANSLATE)) { - goto theend; + goto theend; } rettv->vval.v_list = l; rettv->v_type = VAR_LIST; @@ -15462,7 +15466,7 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) listitem_T *prev_li = NULL; TV_LIST_ITER(l, li, { if (prev_li != NULL) { - if (item_compare_func_ptr(prev_li, li) == 0) { + if (item_compare_func_ptr(&prev_li, &li) == 0) { ptrs[i++].item = prev_li; } if (info.item_compare_func_err) { -- cgit From fe55f37083b0bef07aa9ac78eb2727c244fdafd3 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 10 Dec 2017 23:18:24 +0300 Subject: eval: Still check for NULL when doing :unlet --- src/nvim/eval.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 064f2c072c..6271603a1d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2875,9 +2875,12 @@ static int do_unlet_var(lval_T *const lp, char_u *const name_end, int forceit) ret = FAIL; } *name_end = cc; - } else if (tv_check_lock(tv_list_locked(lp->ll_list), - (const char *)lp->ll_name, - lp->ll_name_len) + } else if ((lp->ll_list != NULL + // ll_list is not NULL when lvalue is not in a list, NULL lists + // yield E689. + && tv_check_lock(tv_list_locked(lp->ll_list), + (const char *)lp->ll_name, + lp->ll_name_len)) || (lp->ll_dict != NULL && tv_check_lock(lp->ll_dict->dv_lock, (const char *)lp->ll_name, -- cgit From ceb45a08858837319c8ea67b1aaeceaeb24c8510 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 11 Dec 2017 01:43:36 +0300 Subject: *: Fix test failures --- src/nvim/eval.c | 10 ++++++---- src/nvim/eval/encode.c | 4 +++- src/nvim/ex_getln.c | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 6271603a1d..b45cfcb427 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -14545,12 +14545,14 @@ static void f_setline(typval_T *argvars, typval_T *rettv, FunPtr fptr) // Default result is zero == OK. for (;; ) { + if (argvars[1].v_type == VAR_LIST) { // List argument, get next string. - if (li == NULL) { - break; + if (li == NULL) { + break; + } + line = tv_get_string_chk(TV_LIST_ITEM_TV(li)); + li = TV_LIST_ITEM_NEXT(l, li); } - line = tv_get_string_chk(TV_LIST_ITEM_TV(li)); - li = TV_LIST_ITEM_NEXT(l, li); rettv->vval.v_number = 1; // FAIL if (line == NULL || lnum < 1 || lnum > curbuf->b_ml.ml_line_count + 1) { diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 50ddb1f38c..85fd4d1578 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -140,7 +140,9 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack, ? tv_list_last(v.data.l.list) : TV_LIST_ITEM_PREV(v.data.l.list, v.data.l.li)); - int idx = (int)tv_list_idx_of_item(v.data.l.list, li); + int idx = (li == NULL + ? 0 + : (int)tv_list_idx_of_item(v.data.l.list, li)); if (v.type == kMPConvList || li == NULL || (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index fcd230d535..a5a8804e1c 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2680,6 +2680,7 @@ static bool color_cmdline(CmdlineInfo *colored_ccline) .end = end, .attr = attr, })); + i++; }); if (prev_end < colored_ccline->cmdlen) { kv_push(ccline_colors->colors, ((CmdlineColorChunk) { -- cgit From d46e37cb4c71f39312233799d7f28eb86dceef60 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 11 Dec 2017 10:12:59 +0300 Subject: *: Finish hiding list implementation --- src/nvim/eval.c | 104 +++++++--------------------------------- src/nvim/eval/typval.c | 90 +++++++++++++++++++++++++++++++++- src/nvim/eval/typval.h | 75 ++++++++++++++++++++++++++++- src/nvim/eval/typval_encode.c.h | 10 ++-- src/nvim/regexp.c | 8 ++-- 5 files changed, 187 insertions(+), 100 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index b45cfcb427..ad8b575867 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -110,9 +110,6 @@ #define DICT_MAXNEST 100 /* maximum nesting of lists and dicts */ -#define DO_NOT_FREE_CNT 99999 /* refcount for dict or list that should not - be freed. */ - #define AUTOLOAD_CHAR '#' /* Character used as separator in autoload function/variable names. */ @@ -5271,7 +5268,6 @@ static int free_unref_items(int copyID) for (ll = gc_first_list; ll != NULL; ll = ll_next) { ll_next = ll->lv_used_next; if ((ll->lv_copyID & COPYID_MASK) != (copyID & COPYID_MASK) - // FIXME: Abstract away lv_watch. && ll->lv_watch == NULL) { // Free the List and ordinary items it contains, but don't recurse // into Lists and Dictionaries, they will be in the list of dicts @@ -13313,14 +13309,7 @@ static void f_remove(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (li == NULL) { // Didn't find "item2" after "item". emsgf(_(e_invrange)); } else { - tv_list_remove_items(l, item, item2); - // FIXME: Abstract the below away or move to eval/typval. - l = tv_list_alloc_ret(rettv); - l->lv_first = item; - l->lv_last = item2; - item->li_prev = NULL; - item2->li_next = NULL; - l->lv_len = cnt; + tv_list_move_items(l, item, item2, tv_list_alloc_ret(rettv), cnt); } } } @@ -13558,19 +13547,10 @@ static void f_reverse(typval_T *argvars, typval_T *rettv, FunPtr fptr) EMSG2(_(e_listarg), "reverse()"); } else if (!tv_check_lock(tv_list_locked((l = argvars[0].vval.v_list)), N_("reverse() argument"), TV_TRANSLATE)) { - // FIXME: Abstract the below away or move to eval/typval. - listitem_T *li = l->lv_last; - l->lv_first = l->lv_last = NULL; - l->lv_len = 0; - while (li != NULL) { - listitem_T *const ni = li->li_prev; - tv_list_append(l, li); - li = ni; - } + tv_list_reverse(l); rettv->vval.v_list = l; rettv->v_type = VAR_LIST; tv_list_ref(l); - l->lv_idx = l->lv_len - l->lv_idx - 1; } } @@ -15445,12 +15425,7 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) if (!info.item_compare_func_err) { // Clear the list and append the items in the sorted order. - // FIXME: Somehow abstract away or move to eval/typval. - l->lv_first = NULL; - l->lv_last = NULL; - l->lv_idx_item = NULL; - l->lv_len = 0; - + tv_list_clear(l); for (i = 0; i < len; i++) { tv_list_append(l, ptrs[i].item); } @@ -15468,34 +15443,20 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) item_compare_func_ptr = item_compare_keeping_zero; } - listitem_T *prev_li = NULL; - TV_LIST_ITER(l, li, { - if (prev_li != NULL) { - if (item_compare_func_ptr(&prev_li, &li) == 0) { - ptrs[i++].item = prev_li; - } + int idx = 0; + for (listitem_T *li = TV_LIST_ITEM_NEXT(l, tv_list_first(l)) + ; li != NULL + ; li = TV_LIST_ITEM_NEXT(l, li)) { + listitem_T *const prev_li = TV_LIST_ITEM_PREV(l, li); + if (item_compare_func_ptr(&prev_li, &li) == 0) { if (info.item_compare_func_err) { EMSG(_("E882: Uniq compare function failed")); break; } - } - prev_li = li; - }); - - if (!info.item_compare_func_err) { - while (--i >= 0) { - // FIXME: Abstract away. - assert(ptrs[i].item->li_next); - listitem_T *const li = ptrs[i].item->li_next; - ptrs[i].item->li_next = li->li_next; - if (li->li_next != NULL) { - li->li_next->li_prev = ptrs[i].item; - } else { - l->lv_last = ptrs[i].item; - } - tv_list_watch_fix(l, li); - tv_list_item_free(li); - l->lv_len--; + tv_list_item_remove(l, li); + li = tv_list_find(l, idx); + } else { + idx++; } } } @@ -17533,35 +17494,6 @@ write_list_error: return false; } -/// Initializes a static list with 10 items. -void init_static_list(staticList10_T *sl) -{ - // FIXME: Move to eval/typval. - list_T *l = &sl->sl_list; - - memset(sl, 0, sizeof(staticList10_T)); - l->lv_first = &sl->sl_items[0]; - l->lv_last = &sl->sl_items[9]; - l->lv_refcount = DO_NOT_FREE_CNT; - tv_list_set_lock(l, VAR_FIXED); - sl->sl_list.lv_len = 10; - - for (int i = 0; i < 10; i++) { - listitem_T *li = &sl->sl_items[i]; - - if (i == 0) { - li->li_prev = NULL; - } else { - li->li_prev = li - 1; - } - if (i == 9) { - li->li_next = NULL; - } else { - li->li_next = li + 1; - } - } -} - /// Saves a typval_T as a string. /// /// For lists, replaces NLs with NUL and separates items with NLs. @@ -19305,10 +19237,9 @@ int var_item_copy(const vimconv_T *const conv, to->v_lock = 0; if (from->vval.v_list == NULL) to->vval.v_list = NULL; - else if (copyID != 0 && from->vval.v_list->lv_copyID == copyID) { - // FIXME: Abstract away. + else if (copyID != 0 && tv_list_copyid(from->vval.v_list) == copyID) { // Use the copy made earlier. - to->vval.v_list = from->vval.v_list->lv_copylist; + to->vval.v_list = tv_list_latest_copy(from->vval.v_list); tv_list_ref(to->vval.v_list); } else { to->vval.v_list = tv_list_copy(conv, from->vval.v_list, deep, copyID); @@ -21190,9 +21121,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, v->di_tv.v_type = VAR_LIST; v->di_tv.v_lock = VAR_FIXED; v->di_tv.vval.v_list = &fc->l_varlist; - // FIXME: Abstract away static list. - memset(&fc->l_varlist, 0, sizeof(list_T)); - fc->l_varlist.lv_refcount = DO_NOT_FREE_CNT; + tv_list_init_static(&fc->l_varlist); tv_list_set_lock(&fc->l_varlist, VAR_FIXED); // Set a:firstline to "firstline" and a:lastline to "lastline". @@ -21474,7 +21403,6 @@ static void funccal_unref(funccall_T *fc, ufunc_T *fp, bool force) return; } - // FIXME: Abstract away static list implementation details. if (--fc->fc_refcount <= 0 && (force || ( fc->l_varlist.lv_refcount == DO_NOT_FREE_CNT && fc->l_vars.dv_refcount == DO_NOT_FREE_CNT diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index eaf70b41fd..df81c0450d 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -153,6 +153,45 @@ list_T *tv_list_alloc(void) return list; } +/// Initialize a static list with 10 items +/// +/// @param[out] sl Static list to initialize. +void tv_list_init_static10(staticList10_T *const sl) + FUNC_ATTR_NONNULL_ALL +{ +#define SL_SIZE ARRAY_SIZE(sl->sl_items) + list_T *const l = &sl->sl_list; + + memset(sl, 0, sizeof(staticList10_T)); + l->lv_first = &sl->sl_items[0]; + l->lv_last = &sl->sl_items[SL_SIZE - 1]; + l->lv_refcount = DO_NOT_FREE_CNT; + tv_list_set_lock(l, VAR_FIXED); + sl->sl_list.lv_len = 10; + + sl->sl_items[0].li_prev = NULL; + sl->sl_items[0].li_next = &sl->sl_items[1]; + sl->sl_items[SL_SIZE - 1].li_prev = &sl->sl_items[SL_SIZE - 2]; + sl->sl_items[SL_SIZE - 1].li_next = NULL; + + for (size_t i = 1; i < SL_SIZE - 1; i++) { + listitem_T *const li = &sl->sl_items[i]; + li->li_prev = li - 1; + li->li_next = li + 1; + } +#undef SL_SIZE +} + +/// Initialize static list with undefined number of elements +/// +/// @param[out] l List to initialize. +void tv_list_init_static(list_T *const l) + FUNC_ATTR_NONNULL_ALL +{ + memset(l, 0, sizeof(*l)); + l->lv_refcount = DO_NOT_FREE_CNT; +} + /// Free items contained in a list /// /// @param[in,out] l List to clear. @@ -221,7 +260,7 @@ void tv_list_unref(list_T *const l) //{{{2 Add/remove -/// Remove items "item" to "item2" from list "l". +/// Remove items "item" to "item2" from list "l" /// /// @warning Does not free the listitem or the value! /// @@ -251,6 +290,30 @@ void tv_list_remove_items(list_T *const l, listitem_T *const item, l->lv_idx_item = NULL; } +/// Move items "item" to "item2" from list "l" to the end of the list "tgt_l" +/// +/// @param[out] l List to move from. +/// @param[in] item First item to move. +/// @param[in] item2 Last item to move. +/// @param[out] tgt_l List to move to. +/// @param[in] cnt Number of items moved. +void tv_list_move_items(list_T *const l, listitem_T *const item, + listitem_T *const item2, list_T *const tgt_l, + const int cnt) + FUNC_ATTR_NONNULL_ALL +{ + tv_list_remove_items(l, item, item2); + item->li_prev = tgt_l->lv_last; + item2->li_next = NULL; + if (tgt_l->lv_last == NULL) { + tgt_l->lv_first = item; + } else { + tgt_l->lv_last->li_next = item; + } + tgt_l->lv_last = item2; + tgt_l->lv_len += cnt; +} + /// Insert list item /// /// @param[out] l List to insert to. @@ -644,6 +707,31 @@ bool tv_list_equal(list_T *const l1, list_T *const l2, const bool ic, return true; } +/// Reverse list in-place +/// +/// @param[in,out] l List to reverse. +void tv_list_reverse(list_T *const l) +{ + if (tv_list_len(l) <= 1) { + return; + } +#define SWAP(a, b) \ + do { \ + tmp = a; \ + a = b; \ + b = tmp; \ + } while (0) + listitem_T *tmp; + + SWAP(l->lv_first, l->lv_last); + for (listitem_T *li = l->lv_first; li != NULL; li = li->li_next) { + SWAP(li->li_next, li->li_prev); + } +#undef SWAP + + l->lv_idx = l->lv_len - l->lv_idx - 1; +} + //{{{2 Indexing/searching /// Locate item with a given index in a list and return it diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index a05abd8a53..a7255fdba0 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "nvim/types.h" #include "nvim/hashtab.h" @@ -27,6 +28,9 @@ typedef uint64_t uvarnumber_T; /// Type used for VimL VAR_FLOAT values typedef double float_T; +/// Refcount for dict or list that should not be freed +enum { DO_NOT_FREE_CNT = (INT_MAX / 2) }; + /// Maximal possible value of varnumber_T variable #define VARNUMBER_MAX INT64_MAX #define UVARNUMBER_MAX UINT64_MAX @@ -151,12 +155,26 @@ struct listvar_S { list_T *lv_used_prev; ///< Previous list in used lists list. }; -// Static list with 10 items. Use init_static_list() to initialize. +// Static list with 10 items. Use tv_list_init_static10() to initialize. typedef struct { list_T sl_list; // must be first listitem_T sl_items[10]; } staticList10_T; +#define TV_LIST_STATIC10_INIT { \ + .sl_list = { \ + .lv_first = NULL, \ + .lv_last = NULL, \ + .lv_refcount = 0, \ + .lv_len = 0, \ + .lv_watch = NULL, \ + .lv_idx_item = NULL, \ + .lv_lock = VAR_FIXED, \ + .lv_used_next = NULL, \ + .lv_used_prev = NULL, \ + }, \ + } + // Structure to hold an item of a Dictionary. // Also used for a variable. // The key is copied into "di_key" to avoid an extra alloc/free for it. @@ -330,6 +348,19 @@ static inline void tv_list_set_lock(list_T *const l, l->lv_lock = lock; } +/// Set list copyID +/// +/// Does not expect NULL list, be careful. +/// +/// @param[out] l List to modify. +/// @param[in] copyid New copyID. +static inline void tv_list_set_copyid(list_T *const l, + const int copyid) + FUNC_ATTR_NONNULL_ALL +{ + l->lv_copyID = copyid; +} + static inline int tv_list_len(const list_T *const l) REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; @@ -344,6 +375,48 @@ static inline int tv_list_len(const list_T *const l) return l->lv_len; } +static inline int tv_list_copyid(const list_T *const l) + REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_NONNULL_ALL; + +/// Get list copyID +/// +/// Does not expect NULL list, be careful. +/// +/// @param[in] l List to check. +static inline int tv_list_copyid(const list_T *const l) +{ + return l->lv_copyID; +} + +static inline list_T *tv_list_latest_copy(const list_T *const l) + REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_NONNULL_ALL; + +/// Get latest list copy +/// +/// Gets lv_copylist field assigned by tv_list_copy() earlier. +/// +/// Does not expect NULL list, be careful. +/// +/// @param[in] l List to check. +static inline list_T *tv_list_latest_copy(const list_T *const l) +{ + return l->lv_copylist; +} + +/// Clear the list without freeing anything at all +/// +/// For use in sort() which saves items to a separate array and readds them back +/// after sorting via a number of tv_list_append() calls. +/// +/// @param[out] l List to clear. +static inline void tv_list_clear(list_T *const l) +{ + l->lv_first = NULL; + l->lv_last = NULL; + l->lv_idx_item = NULL; + l->lv_len = 0; +} + static inline int tv_list_uidx(const list_T *const l, int n) REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; diff --git a/src/nvim/eval/typval_encode.c.h b/src/nvim/eval/typval_encode.c.h index 800760cf7b..e4ed2bc636 100644 --- a/src/nvim/eval/typval_encode.c.h +++ b/src/nvim/eval/typval_encode.c.h @@ -359,7 +359,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( TYPVAL_ENCODE_CONV_EMPTY_LIST(tv); break; } - const int saved_copyID = tv->vval.v_list->lv_copyID; + const int saved_copyID = tv_list_copyid(tv->vval.v_list); _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(tv->vval.v_list, lv_copyID, copyID, kMPConvList); TYPVAL_ENCODE_CONV_LIST_START(tv, tv_list_len(tv->vval.v_list)); @@ -515,7 +515,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( if (val_di->di_tv.v_type != VAR_LIST) { goto _convert_one_value_regular_dict; } - const int saved_copyID = val_di->di_tv.vval.v_list->lv_copyID; + const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list); _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_di->di_tv.vval.v_list, lv_copyID, copyID, kMPConvList); @@ -550,7 +550,7 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( goto _convert_one_value_regular_dict; } }); - const int saved_copyID = val_di->di_tv.vval.v_list->lv_copyID; + const int saved_copyID = tv_list_copyid(val_di->di_tv.vval.v_list); _TYPVAL_ENCODE_DO_CHECK_SELF_REFERENCE(val_list, lv_copyID, copyID, kMPConvPairs); TYPVAL_ENCODE_CONV_DICT_START(tv, TYPVAL_ENCODE_NODICT_VAR, @@ -694,7 +694,7 @@ typval_encode_stop_converting_one_item: case kMPConvList: { if (cur_mpsv->data.l.li == NULL) { (void)_mp_pop(mpstack); - cur_mpsv->data.l.list->lv_copyID = cur_mpsv->saved_copyID; + tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID); TYPVAL_ENCODE_CONV_LIST_END(cur_mpsv->tv); continue; } else if (cur_mpsv->data.l.li @@ -709,7 +709,7 @@ typval_encode_stop_converting_one_item: case kMPConvPairs: { if (cur_mpsv->data.l.li == NULL) { (void)_mp_pop(mpstack); - cur_mpsv->data.l.list->lv_copyID = cur_mpsv->saved_copyID; + tv_list_set_copyid(cur_mpsv->data.l.list, cur_mpsv->saved_copyID); TYPVAL_ENCODE_CONV_DICT_END(cur_mpsv->tv, TYPVAL_ENCODE_NODICT_VAR); continue; } else if (cur_mpsv->data.l.li diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index ffe393f1b0..463a408885 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -6483,7 +6483,7 @@ static int fill_submatch_list(int argc, typval_T *argv, int argcount) } // Relies on sl_list to be the first item in staticList10_T. - init_static_list((staticList10_T *)(argv->vval.v_list)); + tv_list_init_static10((staticList10_T *)argv->vval.v_list); // There are always 10 list items in staticList10_T. listitem_T *li = tv_list_first(argv->vval.v_list); @@ -6639,14 +6639,12 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, typval_T argv[2]; int dummy; typval_T rettv; - staticList10_T matchList; + staticList10_T matchList = TV_LIST_STATIC10_INIT; rettv.v_type = VAR_STRING; rettv.vval.v_string = NULL; argv[0].v_type = VAR_LIST; argv[0].vval.v_list = &matchList.sl_list; - // FIXME: Abstract away - matchList.sl_list.lv_len = 0; if (expr->v_type == VAR_FUNC) { s = expr->vval.v_string; call_func(s, (int)STRLEN(s), &rettv, 1, argv, @@ -6660,7 +6658,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest, fill_submatch_list, 0L, 0L, &dummy, true, partial, NULL); } - if (matchList.sl_list.lv_len > 0) { + if (tv_list_len(&matchList.sl_list) > 0) { // fill_submatch_list() was called. clear_submatch_list(&matchList); } -- cgit From f4132fb38b1355115d824b7c04eff25733d059d6 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 11 Dec 2017 10:19:20 +0300 Subject: *: Fix linter errors --- src/nvim/eval.c | 23 +++++++++++++---------- src/nvim/eval/decode.c | 2 +- src/nvim/eval/encode.c | 2 +- src/nvim/eval/typval.c | 4 ++-- src/nvim/eval/typval_encode.c.h | 10 ++++++---- src/nvim/ops.c | 2 +- src/nvim/shada.c | 8 ++++---- src/nvim/window.c | 3 +-- 8 files changed, 29 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index ad8b575867..10dbf208ea 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1540,7 +1540,8 @@ ex_let_vars ( listitem_T *item = tv_list_first(l); while (*arg != ']') { arg = skipwhite(arg + 1); - arg = ex_let_one(arg, TV_LIST_ITEM_TV(item), TRUE, (char_u *)",;]", nextchars); + arg = ex_let_one(arg, TV_LIST_ITEM_TV(item), true, (const char_u *)",;]", + nextchars); item = TV_LIST_ITEM_NEXT(l, item); if (arg == NULL) { return FAIL; @@ -2415,13 +2416,14 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, lp->ll_li = TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li); lp->ll_n1++; } - if (ri != NULL) + if (ri != NULL) { EMSG(_("E710: List value has more items than target")); - else if (lp->ll_empty2 - ? (lp->ll_li != NULL - && TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li) != NULL) - : lp->ll_n1 != lp->ll_n2) + } else if (lp->ll_empty2 + ? (lp->ll_li != NULL + && TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li) != NULL) + : lp->ll_n1 != lp->ll_n2) { EMSG(_("E711: List value has not enough items")); + } } else { typval_T oldtv = TV_INITIAL_VALUE; dict_T *dict = lp->ll_dict; @@ -8561,8 +8563,9 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map) nli = TV_LIST_ITEM_NEXT(l, li); vimvars[VV_KEY].vv_nr = idx; if (filter_map_one(TV_LIST_ITEM_TV(li), expr, map, &rem) == FAIL - || did_emsg) + || did_emsg) { break; + } if (!map && rem) { tv_list_item_remove(l, li); } @@ -19235,9 +19238,9 @@ int var_item_copy(const vimconv_T *const conv, case VAR_LIST: to->v_type = VAR_LIST; to->v_lock = 0; - if (from->vval.v_list == NULL) + if (from->vval.v_list == NULL) { to->vval.v_list = NULL; - else if (copyID != 0 && tv_list_copyid(from->vval.v_list) == copyID) { + } else if (copyID != 0 && tv_list_copyid(from->vval.v_list) == copyID) { // Use the copy made earlier. to->vval.v_list = tv_list_latest_copy(from->vval.v_list); tv_list_ref(to->vval.v_list); @@ -22400,7 +22403,7 @@ typval_T eval_call_provider(char *provider, char *method, list_T *arguments) {.v_type = VAR_LIST, .vval.v_list = arguments, .v_lock = 0}, {.v_type = VAR_UNKNOWN} }; - typval_T rettv = {.v_type = VAR_UNKNOWN, .v_lock = 0}; + typval_T rettv = { .v_type = VAR_UNKNOWN, .v_lock = VAR_UNLOCKED }; tv_list_ref(arguments); int dummy; diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index b2d901462a..d5c65ebe81 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -60,7 +60,7 @@ static inline void create_special_dict(typval_T *const rettv, dictitem_T *const type_di = tv_dict_item_alloc_len(S_LEN("_TYPE")); type_di->di_tv.v_type = VAR_LIST; type_di->di_tv.v_lock = VAR_UNLOCKED; - type_di->di_tv.vval.v_list = (list_T *) eval_msgpack_type_lists[type]; + type_di->di_tv.vval.v_list = (list_T *)eval_msgpack_type_lists[type]; tv_list_ref(type_di->di_tv.vval.v_list); tv_dict_add(dict, type_di); dictitem_T *const val_di = tv_dict_item_alloc_len(S_LEN("_VAL")); diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 85fd4d1578..9f16b78976 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -267,7 +267,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, } *p++ = NL; if (TV_LIST_ITEM_TV(state->li)->v_type != VAR_STRING) { - *read_bytes = (size_t) (p - buf); + *read_bytes = (size_t)(p - buf); return FAIL; } state->offset = 0; diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index df81c0450d..0c9c4a0347 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -696,8 +696,8 @@ bool tv_list_equal(list_T *const l1, list_T *const l2, const bool ic, listitem_T *item1 = tv_list_first(l1); listitem_T *item2 = tv_list_first(l2); for (; item1 != NULL && item2 != NULL - ; item1 = TV_LIST_ITEM_NEXT(l1, item1), - item2 = TV_LIST_ITEM_NEXT(n2, item2)) { + ; (item1 = TV_LIST_ITEM_NEXT(l1, item1), + item2 = TV_LIST_ITEM_NEXT(n2, item2))) { if (!tv_equal(TV_LIST_ITEM_TV(item1), TV_LIST_ITEM_TV(item2), ic, recursive)) { return false; diff --git a/src/nvim/eval/typval_encode.c.h b/src/nvim/eval/typval_encode.c.h index e4ed2bc636..e9531178ef 100644 --- a/src/nvim/eval/typval_encode.c.h +++ b/src/nvim/eval/typval_encode.c.h @@ -586,9 +586,10 @@ static int _TYPVAL_ENCODE_CONVERT_ONE_VALUE( } size_t len; char *buf; - if (!encode_vim_list_to_buf( - TV_LIST_ITEM_TV(tv_list_last(val_list))->vval.v_list, &len, - &buf)) { + if (!( + encode_vim_list_to_buf( + TV_LIST_ITEM_TV(tv_list_last(val_list))->vval.v_list, &len, + &buf))) { goto _convert_one_value_regular_dict; } TYPVAL_ENCODE_CONV_EXT_STRING(tv, buf, len, type); @@ -721,7 +722,8 @@ typval_encode_stop_converting_one_item: TV_LIST_ITEM_TV(cur_mpsv->data.l.li)->vval.v_list); TYPVAL_ENCODE_SPECIAL_DICT_KEY_CHECK( encode_vim_to__error_ret, *TV_LIST_ITEM_TV(tv_list_first(kv_pair))); - if (_TYPVAL_ENCODE_CONVERT_ONE_VALUE( + if ( + _TYPVAL_ENCODE_CONVERT_ONE_VALUE( TYPVAL_ENCODE_FIRST_ARG_NAME, &mpstack, cur_mpsv, TV_LIST_ITEM_TV(tv_list_first(kv_pair)), copyID, objname) == FAIL) { diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 3cc73b2e40..a5e131190d 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -5616,7 +5616,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet) goto err; } char_u *regtype = TV_LIST_ITEM_TV(tv_list_last(res))->vval.v_string; - if (regtype == NULL || strlen((char*)regtype) > 1) { + if (regtype == NULL || strlen((char *)regtype) > 1) { goto err; } switch (regtype[0]) { diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 75f91ce6d8..6bf816bb74 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -1646,20 +1646,20 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, case kSDItemHistoryEntry: { const bool is_hist_search = entry.data.history_item.histtype == HIST_SEARCH; - const size_t arr_size = 2 + (size_t) is_hist_search + (size_t) ( + const size_t arr_size = 2 + (size_t)is_hist_search + (size_t)( tv_list_len(entry.data.history_item.additional_elements)); msgpack_pack_array(spacker, arr_size); msgpack_pack_uint8(spacker, entry.data.history_item.histtype); PACK_BIN(cstr_as_string(entry.data.history_item.string)); if (is_hist_search) { - msgpack_pack_uint8(spacker, (uint8_t) entry.data.history_item.sep); + msgpack_pack_uint8(spacker, (uint8_t)entry.data.history_item.sep); } DUMP_ADDITIONAL_ELEMENTS(entry.data.history_item.additional_elements, "history entry item"); break; } case kSDItemVariable: { - const size_t arr_size = 2 + (size_t) ( + const size_t arr_size = 2 + (size_t)( tv_list_len(entry.data.global_var.additional_elements)); msgpack_pack_array(spacker, arr_size); const String varname = cstr_as_string(entry.data.global_var.name); @@ -1679,7 +1679,7 @@ static ShaDaWriteResult shada_pack_entry(msgpack_packer *const packer, break; } case kSDItemSubString: { - const size_t arr_size = 1 + (size_t) ( + const size_t arr_size = 1 + (size_t)( tv_list_len(entry.data.sub_string.additional_elements)); msgpack_pack_array(spacker, arr_size); PACK_BIN(cstr_as_string(entry.data.sub_string.sub)); diff --git a/src/nvim/window.c b/src/nvim/window.c index 21d668a2bd..4c996aea79 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5577,8 +5577,7 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, } // Set up position matches - if (pos_list != NULL) - { + if (pos_list != NULL) { linenr_T toplnum = 0; linenr_T botlnum = 0; -- cgit From 1a961b57505f57130012fe4fcfda0e8009c8da45 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 11 Dec 2017 10:34:58 +0300 Subject: eval: Fix add() --- src/nvim/eval.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 10dbf208ea..357ca52a3d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6544,11 +6544,11 @@ static void f_abs(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_add(typval_T *argvars, typval_T *rettv, FunPtr fptr) { list_T *l; - rettv->vval.v_number = 1; /* Default: Failed */ if (argvars[0].v_type == VAR_LIST) { - if ((l = argvars[0].vval.v_list) != NULL - && !tv_check_lock(tv_list_locked(l), "add() argument", TV_TRANSLATE)) { + if (!tv_check_lock(tv_list_locked((l = argvars[0].vval.v_list)), + N_("add() argument"), + TV_TRANSLATE)) { tv_list_append_tv(l, &argvars[1]); tv_copy(&argvars[0], rettv); } -- cgit From 9f534422e6c3649ee40904ae3606455d26b48188 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 11 Dec 2017 11:09:09 +0300 Subject: eval/typval: Fix typo [ci skip] --- src/nvim/eval/typval.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index a7255fdba0..c0d1790c63 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -422,7 +422,7 @@ static inline int tv_list_uidx(const list_T *const l, int n) /// Normalize index: that is, return either -1 or non-negative index /// -/// @param[in] l List to intex. Used to get length. +/// @param[in] l List to index. Used to get length. /// @param[in] n List index, possibly negative. /// /// @return -1 or list index in range [0, tv_list_len(l)). -- cgit From ceed29687f7772a661ab7caf5e32a7dfadebf743 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 11 Dec 2017 10:50:45 -0500 Subject: Disable translation of default 'titleold' value It's an empty string, so there's no reason to try to translate it. Closes #7717 --- src/nvim/options.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/nvim/options.lua b/src/nvim/options.lua index dd28a765fd..16f472230a 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -2505,11 +2505,10 @@ return { full_name='titleold', type='string', scope={'global'}, secure=true, - gettext=true, no_mkrc=true, vi_def=true, varname='p_titleold', - defaults={if_true={vi=N_("")}} + defaults={if_true={vi=""}} }, { full_name='titlestring', -- cgit From 45998deb5d325c7a44ce38b0c7d954919458f105 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 12 Dec 2017 00:52:14 +0300 Subject: *: Fix linter errors --- src/nvim/api/vim.c | 4 ++-- src/nvim/eval.c | 8 +++----- src/nvim/tui/tui.c | 34 ++++++++++++++++++---------------- 3 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index f0db391abe..c0daac8085 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -900,9 +900,9 @@ typedef struct { Object *ret_node_p; } ExprASTConvStackItem; -///@cond DOXYGEN_NOT_A_FUNCTION +/// @cond DOXYGEN_NOT_A_FUNCTION typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack; -///@endcond +/// @endcond /// Parse a VimL expression /// diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 357ca52a3d..2d8c22cc7a 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6543,12 +6543,10 @@ static void f_abs(typval_T *argvars, typval_T *rettv, FunPtr fptr) */ static void f_add(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - list_T *l; - rettv->vval.v_number = 1; /* Default: Failed */ + rettv->vval.v_number = 1; // Default: failed. if (argvars[0].v_type == VAR_LIST) { - if (!tv_check_lock(tv_list_locked((l = argvars[0].vval.v_list)), - N_("add() argument"), - TV_TRANSLATE)) { + list_T *const l = argvars[0].vval.v_list; + if (!tv_check_lock(tv_list_locked(l), N_("add() argument"), TV_TRANSLATE)) { tv_list_append_tv(l, &argvars[1]); tv_copy(&argvars[0], rettv); } diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 9ff1acf64a..60897c08da 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1515,22 +1515,24 @@ static void patch_terminfo_bugs(TUIData *data, const char *term, // DECSCUSR (cursor shape) sequence is widely supported by several terminal // types. https://github.com/gnachman/iTerm2/pull/92 // xterm extension: vertical bar - if (!konsole && ((xterm && !vte_version) // anything claiming xterm compat - // per MinTTY 0.4.3-1 release notes from 2009 - || putty - // per https://bugzilla.gnome.org/show_bug.cgi?id=720821 - || (vte_version >= 3900) - || tmux // per tmux manual page - // https://lists.gnu.org/archive/html/screen-devel/2013-03/msg00000.html - || screen - || st // #7641 - || rxvt // per command.C - // per analysis of VT100Terminal.m - || iterm || iterm_pretending_xterm - || teraterm // per TeraTerm "Supported Control Functions" doco - // Some linux-type terminals (such as console-terminal-emulator - // from the nosh toolset) implement the xterm extension. - || (linuxvt && (xterm_version || (vte_version > 0) || colorterm)))) { + if (!konsole + && ((xterm && !vte_version) // anything claiming xterm compat + // per MinTTY 0.4.3-1 release notes from 2009 + || putty + // per https://bugzilla.gnome.org/show_bug.cgi?id=720821 + || (vte_version >= 3900) + || tmux // per tmux manual page + // https://lists.gnu.org/archive/html/screen-devel/2013-03/msg00000.html + || screen + || st // #7641 + || rxvt // per command.C + // per analysis of VT100Terminal.m + || iterm || iterm_pretending_xterm + || teraterm // per TeraTerm "Supported Control Functions" doco + // Some linux-type terminals implement the xterm extension. + // Example: console-terminal-emulator from the nosh toolset. + || (linuxvt + && (xterm_version || (vte_version > 0) || colorterm)))) { data->unibi_ext.set_cursor_style = (int)unibi_add_ext_str(ut, "Ss", "\x1b[%p1%d q"); if (-1 == data->unibi_ext.reset_cursor_style) { -- cgit From 932ea7a0d1d19288fad719afd52e9cbeb924c4c2 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 12 Dec 2017 01:13:04 +0300 Subject: clint,eval: Make linter check for direct usage of list attributes --- src/clint.py | 9 +++++++++ src/nvim/eval.c | 33 ++++++++++++++++++++++----------- src/nvim/eval/typval.h | 15 +++++++++++++++ 3 files changed, 46 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/clint.py b/src/clint.py index e63175a69b..8426807c80 100755 --- a/src/clint.py +++ b/src/clint.py @@ -201,6 +201,7 @@ _ERROR_CATEGORIES = [ 'runtime/printf', 'runtime/printf_format', 'runtime/threadsafe_fn', + 'runtime/deprecated', 'syntax/parenthesis', 'whitespace/alignment', 'whitespace/blank_line', @@ -3200,6 +3201,14 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, if match: error(filename, linenum, 'runtime/printf', 4, 'Use xstrlcat or snprintf instead of %s' % match.group(1)) + if not Search(r'eval/typval\.[ch]$', filename): + match = Search(r'(?:\.|->)' + r'(?:lv_(?:first|last|refcount|len|watch|idx(?:_item)?' + r'|copylist|lock)' + r'|li_(?:next|prev|tv))\b', line) + if match: + error(filename, linenum, 'runtime/deprecated', 4, + 'Accessing list_T internals directly is prohibited') # Check for suspicious usage of "if" like # } if (a == b) { diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 2d8c22cc7a..37356d43b4 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5249,8 +5249,8 @@ static int free_unref_items(int copyID) // But don't free a list that has a watcher (used in a for loop), these // are not referenced anywhere. for (list_T *ll = gc_first_list; ll != NULL; ll = ll->lv_used_next) { - if ((ll->lv_copyID & COPYID_MASK) != (copyID & COPYID_MASK) - && ll->lv_watch == NULL) { + if ((tv_list_copyid(ll) & COPYID_MASK) != (copyID & COPYID_MASK) + && !tv_list_has_watchers(ll)) { // Free the List and ordinary items it contains, but don't recurse // into Lists and Dictionaries, they will be in the list of dicts // or list of lists. @@ -5270,7 +5270,7 @@ static int free_unref_items(int copyID) for (ll = gc_first_list; ll != NULL; ll = ll_next) { ll_next = ll->lv_used_next; if ((ll->lv_copyID & COPYID_MASK) != (copyID & COPYID_MASK) - && ll->lv_watch == NULL) { + && !tv_list_has_watchers(ll)) { // Free the List and ordinary items it contains, but don't recurse // into Lists and Dictionaries, they will be in the list of dicts // or list of lists. @@ -21009,6 +21009,22 @@ void func_ptr_ref(ufunc_T *fp) } } +/// Check whether funccall is still referenced outside +/// +/// It is supposed to be referenced if either it is referenced itself or if l:, +/// a: or a:000 are referenced as all these are statically allocated within +/// funccall structure. +static inline bool fc_referenced(const funccall_T *const fc) + FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT + FUNC_ATTR_NONNULL_ALL +{ + return ((fc->l_varlist.lv_refcount // NOLINT(runtime/deprecated) + != DO_NOT_FREE_CNT) + || fc->l_vars.dv_refcount != DO_NOT_FREE_CNT + || fc->l_avars.dv_refcount != DO_NOT_FREE_CNT + || fc->fc_refcount > 0); +} + /// Call a user function /// /// @param fp Function to call. @@ -21357,10 +21373,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, // If the a:000 list and the l: and a: dicts are not referenced and there // is no closure using it, we can free the funccall_T and what's in it. - if (fc->l_varlist.lv_refcount == DO_NOT_FREE_CNT - && fc->l_vars.dv_refcount == DO_NOT_FREE_CNT - && fc->l_avars.dv_refcount == DO_NOT_FREE_CNT - && fc->fc_refcount <= 0) { + if (!fc_referenced(fc)) { free_funccal(fc, false); } else { // "fc" is still in use. This can happen when returning "a:000", @@ -21404,10 +21417,8 @@ static void funccal_unref(funccall_T *fc, ufunc_T *fp, bool force) return; } - if (--fc->fc_refcount <= 0 && (force || ( - fc->l_varlist.lv_refcount == DO_NOT_FREE_CNT - && fc->l_vars.dv_refcount == DO_NOT_FREE_CNT - && fc->l_avars.dv_refcount == DO_NOT_FREE_CNT))) { + fc->fc_refcount--; + if (force ? fc->fc_refcount <= 0 : !fc_referenced(fc)) { for (pfc = &previous_funccal; *pfc != NULL; pfc = &(*pfc)->caller) { if (fc == *pfc) { *pfc = fc->caller; diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index c0d1790c63..2bce7bd6b2 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -440,6 +440,21 @@ static inline int tv_list_uidx(const list_T *const l, int n) return n; } +static inline bool tv_list_has_watchers(const list_T *const l) + REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; + +/// Check whether list has watchers +/// +/// E.g. is referenced by a :for loop. +/// +/// @param[in] l List to check. +/// +/// @return true if there are watchers, false otherwise. +static inline bool tv_list_has_watchers(const list_T *const l) +{ + return l && l->lv_watch; +} + static inline listitem_T *tv_list_first(const list_T *const l) REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; -- cgit From 34057045beca40406673ff421a4ef1e8e8c08853 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Tue, 12 Dec 2017 18:23:19 +0100 Subject: ui: forward relevant option updates to UIs (#7520) also make termguicolors mutable after startup --- src/nvim/api/ui.c | 1 + src/nvim/api/ui_events.in.h | 2 ++ src/nvim/generators/gen_api_ui_events.lua | 15 ++++++++--- src/nvim/generators/gen_options.lua | 1 + src/nvim/option.c | 42 +++++++++++++++++++++++++++++++ src/nvim/option_defs.h | 3 +++ src/nvim/options.lua | 26 +++++++++++-------- src/nvim/tui/tui.c | 9 +++++++ src/nvim/ui.c | 1 + src/nvim/ui_bridge.c | 24 ++++++++++++++++++ 10 files changed, 110 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index a9eaccfac5..35508fde6b 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -93,6 +93,7 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height, ui->suspend = remote_ui_suspend; ui->set_title = remote_ui_set_title; ui->set_icon = remote_ui_set_icon; + ui->option_set = remote_ui_option_set; ui->event = remote_ui_event; memset(ui->ui_ext, 0, sizeof(ui->ui_ext)); diff --git a/src/nvim/api/ui_events.in.h b/src/nvim/api/ui_events.in.h index 847b21072a..3d2253e918 100644 --- a/src/nvim/api/ui_events.in.h +++ b/src/nvim/api/ui_events.in.h @@ -58,6 +58,8 @@ void set_title(String title) FUNC_API_SINCE(3); void set_icon(String icon) FUNC_API_SINCE(3); +void option_set(String name, Object value) + FUNC_API_SINCE(4) FUNC_API_BRIDGE_IMPL; void popupmenu_show(Array items, Integer selected, Integer row, Integer col) FUNC_API_SINCE(3) FUNC_API_REMOTE_ONLY; diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua index d2b90db707..2666ca6e6f 100644 --- a/src/nvim/generators/gen_api_ui_events.lua +++ b/src/nvim/generators/gen_api_ui_events.lua @@ -37,7 +37,7 @@ function write_arglist(output, ev, need_copy) for j = 1, #ev.parameters do local param = ev.parameters[j] local kind = string.upper(param[1]) - local do_copy = need_copy and (kind == "ARRAY" or kind == "DICTIONARY" or kind == "STRING") + local do_copy = need_copy and (kind == "ARRAY" or kind == "DICTIONARY" or kind == "STRING" or kind == "OBJECT") output:write(' ADD(args, ') if do_copy then output:write('copy_object(') @@ -91,7 +91,7 @@ for i = 1, #events do recv_cleanup = recv_cleanup..' api_free_string('..param[2]..');\n' argc = argc+2 elseif param[1] == 'Array' then - send = send..' Array copy_'..param[2]..' = copy_array('..param[2]..');\n' + send = send..' Array '..copy..' = copy_array('..param[2]..');\n' argv = argv..', '..copy..'.items, INT2PTR('..copy..'.size)' recv = (recv..' Array '..param[2].. ' = (Array){.items = argv['..argc..'],'.. @@ -99,6 +99,15 @@ for i = 1, #events do recv_argv = recv_argv..', '..param[2] recv_cleanup = recv_cleanup..' api_free_array('..param[2]..');\n' argc = argc+2 + elseif param[1] == 'Object' then + send = send..' Object *'..copy..' = xmalloc(sizeof(Object));\n' + send = send..' *'..copy..' = copy_object('..param[2]..');\n' + argv = argv..', '..copy + recv = recv..' Object '..param[2]..' = *(Object *)argv['..argc..'];\n' + recv_argv = recv_argv..', '..param[2] + recv_cleanup = (recv_cleanup..' api_free_object('..param[2]..');\n'.. + ' xfree(argv['..argc..']);\n') + argc = argc+1 elseif param[1] == 'Integer' or param[1] == 'Boolean' then argv = argv..', INT2PTR('..param[2]..')' recv_argv = recv_argv..', PTR2INT(argv['..argc..'])' @@ -119,7 +128,7 @@ for i = 1, #events do write_signature(bridge_output, ev, 'UI *ui') bridge_output:write('\n{\n') bridge_output:write(send) - bridge_output:write(' UI_BRIDGE_CALL(ui, '..ev.name..', '..argc..', ui'..argv..');\n}\n') + bridge_output:write(' UI_BRIDGE_CALL(ui, '..ev.name..', '..argc..', ui'..argv..');\n}\n\n') end end diff --git a/src/nvim/generators/gen_options.lua b/src/nvim/generators/gen_options.lua index 36562c0be9..fdc00d5dc0 100644 --- a/src/nvim/generators/gen_options.lua +++ b/src/nvim/generators/gen_options.lua @@ -36,6 +36,7 @@ local redraw_flags={ all_windows='P_RALL', everything='P_RCLR', curswant='P_CURSWANT', + ui_option='P_UI_OPTION', } local list_flags={ diff --git a/src/nvim/option.c b/src/nvim/option.c index f8a05f133d..499cf79836 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -74,6 +74,7 @@ #include "nvim/undo.h" #include "nvim/window.h" #include "nvim/os/os.h" +#include "nvim/api/private/helpers.h" #include "nvim/os/input.h" #include "nvim/os/lang.h" @@ -248,6 +249,7 @@ typedef struct vimoption { #define P_RWINONLY 0x10000000U ///< only redraw current window #define P_NDNAME 0x20000000U ///< only normal dir name chars allowed +#define P_UI_OPTION 0x40000000U ///< send option to remote ui #define HIGHLIGHT_INIT \ "8:SpecialKey,~:EndOfBuffer,z:TermCursor,Z:TermCursorNC,@:NonText," \ @@ -1188,6 +1190,7 @@ do_set ( set_options_default(OPT_FREE | opt_flags); didset_options(); didset_options2(); + ui_refresh_options(); redraw_all_later(CLEAR); } else { showoptions(1, opt_flags); @@ -1815,6 +1818,10 @@ do_set ( NULL, false, NULL); reset_v_option_vars(); xfree(saved_origval); + if (options[opt_idx].flags & P_UI_OPTION) { + ui_call_option_set(cstr_as_string(options[opt_idx].fullname), + STRING_OBJ(cstr_as_string(*(char **)varp))); + } } } else { // key code option(FIXME(tarruda): Show a warning or something @@ -2417,6 +2424,10 @@ static char *set_string_option(const int opt_idx, const char *const value, NULL, false, NULL); reset_v_option_vars(); xfree(saved_oldval); + if (options[opt_idx].flags & P_UI_OPTION) { + ui_call_option_set(cstr_as_string(options[opt_idx].fullname), + STRING_OBJ(cstr_as_string((char *)(*varp)))); + } } return r; @@ -4024,6 +4035,10 @@ static char *set_bool_option(const int opt_idx, char_u *const varp, (char_u *) options[opt_idx].fullname, NULL, false, NULL); reset_v_option_vars(); + if (options[opt_idx].flags & P_UI_OPTION) { + ui_call_option_set(cstr_as_string(options[opt_idx].fullname), + BOOLEAN_OBJ(value)); + } } comp_col(); /* in case 'ruler' or 'showcmd' changed */ @@ -4429,6 +4444,10 @@ static char *set_num_option(int opt_idx, char_u *varp, long value, (char_u *) options[opt_idx].fullname, NULL, false, NULL); reset_v_option_vars(); + if (options[opt_idx].flags & P_UI_OPTION) { + ui_call_option_set(cstr_as_string(options[opt_idx].fullname), + INTEGER_OBJ(value)); + } } comp_col(); /* in case 'columns' or 'ls' changed */ @@ -4999,6 +5018,29 @@ static int optval_default(vimoption_T *p, char_u *varp) return STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0; } +/// Send update to UIs with values of UI relevant options +void ui_refresh_options(void) +{ + for (int opt_idx = 0; options[opt_idx].fullname; opt_idx++) { + uint32_t flags = options[opt_idx].flags; + if (!(flags & P_UI_OPTION)) { + continue; + } + String name = cstr_as_string(options[opt_idx].fullname); + void *varp = options[opt_idx].var; + Object value = OBJECT_INIT; + if (flags & P_BOOL) { + value = BOOLEAN_OBJ(*(int *)varp); + } else if (flags & P_NUM) { + value = INTEGER_OBJ(*(long *)varp); + } else if (flags & P_STRING) { + // cstr_as_string handles NULL string + value = STRING_OBJ(cstr_as_string(*(char **)varp)); + } + ui_call_option_set(name, value); + } +} + /* * showoneopt: show the value of one option * must not be called with a hidden option! diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index b16f222705..1b978137ae 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -447,6 +447,9 @@ EXTERN char_u *p_popt; // 'printoptions' EXTERN char_u *p_header; // 'printheader' EXTERN int p_prompt; // 'prompt' EXTERN char_u *p_guicursor; // 'guicursor' +EXTERN char_u *p_guifont; // 'guifont' +EXTERN char_u *p_guifontset; // 'guifontset' +EXTERN char_u *p_guifontwide; // 'guifontwide' EXTERN char_u *p_hf; // 'helpfile' EXTERN long p_hh; // 'helpheight' EXTERN char_u *p_hlg; // 'helplang' diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 16f472230a..45efd49391 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -68,7 +68,8 @@ return { type='bool', scope={'global'}, vi_def=true, vim=true, - redraw={'everything'}, + redraw={'everything', 'ui_option'}, + varname='p_arshape', defaults={if_true={vi=true}} }, @@ -91,7 +92,7 @@ return { full_name='ambiwidth', abbreviation='ambw', type='string', scope={'global'}, vi_def=true, - redraw={'everything'}, + redraw={'everything', 'ui_option'}, varname='p_ambw', defaults={if_true={vi="single"}} }, @@ -661,7 +662,7 @@ return { full_name='emoji', abbreviation='emo', type='bool', scope={'global'}, vi_def=true, - redraw={'everything'}, + redraw={'everything', 'ui_option'}, varname='p_emoji', defaults={if_true={vi=true}} }, @@ -1021,23 +1022,26 @@ return { type='string', list='onecomma', scope={'global'}, deny_duplicates=true, vi_def=true, - redraw={'everything'}, - enable_if=false, + varname='p_guifont', + redraw={'everything', 'ui_option'}, + defaults={if_true={vi=""}} }, { full_name='guifontset', abbreviation='gfs', type='string', list='onecomma', scope={'global'}, vi_def=true, - redraw={'everything'}, - enable_if=false, + varname='p_guifontset', + redraw={'everything', 'ui_option'}, + defaults={if_true={vi=""}} }, { full_name='guifontwide', abbreviation='gfw', type='string', list='onecomma', scope={'global'}, deny_duplicates=true, vi_def=true, - redraw={'everything'}, - enable_if=false, + redraw={'everything', 'ui_option'}, + varname='p_guifontwide', + defaults={if_true={vi=""}} }, { full_name='guioptions', abbreviation='go', @@ -2164,7 +2168,7 @@ return { full_name='showtabline', abbreviation='stal', type='number', scope={'global'}, vi_def=true, - redraw={'all_windows'}, + redraw={'all_windows', 'ui_option'}, varname='p_stal', defaults={if_true={vi=1}} }, @@ -2435,7 +2439,7 @@ return { full_name='termguicolors', abbreviation='tgc', type='bool', scope={'global'}, vi_def=false, - redraw={'everything'}, + redraw={'everything', 'ui_option'}, varname='p_tgc', defaults={if_true={vi=false}} }, diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 9ff1acf64a..49aa41b9b0 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -151,6 +151,7 @@ UI *tui_start(void) ui->suspend = tui_suspend; ui->set_title = tui_set_title; ui->set_icon = tui_set_icon; + ui->option_set= tui_option_set; ui->event = tui_event; memset(ui->ui_ext, 0, sizeof(ui->ui_ext)); @@ -1136,6 +1137,14 @@ static void tui_set_icon(UI *ui, String icon) { } +static void tui_option_set(UI *ui, String name, Object value) +{ + if (strequal(name.data, "termguicolors")) { + // NB: value for bridge is set in ui_bridge.c + ui->rgb = value.data.boolean; + } +} + // NB: if we start to use this, the ui_bridge must be updated // to make a copy for the tui thread static void tui_event(UI *ui, char *name, Array args, bool *args_consumed) diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 3b8b3ac9a7..81da88c54a 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -339,6 +339,7 @@ void ui_attach_impl(UI *ui) } uis[ui_count++] = ui; + ui_refresh_options(); ui_refresh(); } diff --git a/src/nvim/ui_bridge.c b/src/nvim/ui_bridge.c index 7573fa1653..0a69cf0ecb 100644 --- a/src/nvim/ui_bridge.c +++ b/src/nvim/ui_bridge.c @@ -66,6 +66,7 @@ UI *ui_bridge_attach(UI *ui, ui_main_fn ui_main, event_scheduler scheduler) rv->bridge.suspend = ui_bridge_suspend; rv->bridge.set_title = ui_bridge_set_title; rv->bridge.set_icon = ui_bridge_set_icon; + rv->bridge.option_set = ui_bridge_option_set; rv->scheduler = scheduler; for (UIWidget i = 0; (int)i < UI_WIDGETS; i++) { @@ -144,6 +145,29 @@ static void ui_bridge_highlight_set_event(void **argv) xfree(argv[1]); } +static void ui_bridge_option_set(UI *ui, String name, Object value) +{ + // Assumes bridge is only used by TUI + if (strequal(name.data, "termguicolors")) { + ui->rgb = value.data.boolean; + } + String copy_name = copy_string(name); + Object *copy_value = xmalloc(sizeof(Object)); + *copy_value = copy_object(value); + UI_BRIDGE_CALL(ui, option_set, 4, ui, + copy_name.data, INT2PTR(copy_name.size), copy_value); +} +static void ui_bridge_option_set_event(void **argv) +{ + UI *ui = UI(argv[0]); + String name = (String){ .data = argv[1], .size = (size_t)argv[2] }; + Object value = *(Object *)argv[3]; + ui->option_set(ui, name, value); + api_free_string(name); + api_free_object(value); + xfree(argv[3]); +} + static void ui_bridge_suspend(UI *b) { UIBridgeData *data = (UIBridgeData *)b; -- cgit From 6203c23449cfdf8fb09c33d3ab267703d57123fa Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 12 Dec 2017 01:31:15 +0100 Subject: pty_process_unix: _exit() on execvp() failure Mostly cargo-culting based on a reading of the manpages, interwebs, and the Vim source. --- src/nvim/os/pty_process_unix.c | 8 ++++---- src/nvim/os/signal.c | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/os/pty_process_unix.c b/src/nvim/os/pty_process_unix.c index 53301e4b53..855ca2ae47 100644 --- a/src/nvim/os/pty_process_unix.c +++ b/src/nvim/os/pty_process_unix.c @@ -72,8 +72,7 @@ int pty_process_spawn(PtyProcess *ptyproc) ELOG("forkpty failed: %s", strerror(errno)); return status; } else if (pid == 0) { - init_child(ptyproc); - abort(); + init_child(ptyproc); // never returns } // make sure the master file descriptor is non blocking @@ -163,14 +162,15 @@ static void init_child(PtyProcess *ptyproc) FUNC_ATTR_NONNULL_ALL Process *proc = (Process *)ptyproc; if (proc->cwd && os_chdir(proc->cwd) != 0) { - fprintf(stderr, "chdir failed: %s\n", strerror(errno)); + ELOG("chdir failed: %s", strerror(errno)); return; } char *prog = ptyproc->process.argv[0]; setenv("TERM", ptyproc->term_name ? ptyproc->term_name : "ansi", 1); execvp(prog, ptyproc->process.argv); - fprintf(stderr, "execvp failed: %s: %s\n", strerror(errno), prog); + ELOG("execvp failed: %s: %s", strerror(errno), prog); + _exit(122); // 122 is EXEC_FAILED in the Vim source. } static void init_termios(struct termios *termios) FUNC_ATTR_NONNULL_ALL diff --git a/src/nvim/os/signal.c b/src/nvim/os/signal.c index fd6d3b32e4..732be072e1 100644 --- a/src/nvim/os/signal.c +++ b/src/nvim/os/signal.c @@ -10,6 +10,7 @@ #endif #include "nvim/ascii.h" +#include "nvim/log.h" #include "nvim/vim.h" #include "nvim/globals.h" #include "nvim/memline.h" @@ -162,7 +163,7 @@ static void on_signal(SignalWatcher *handle, int signum, void *data) } break; default: - fprintf(stderr, "Invalid signal %d", signum); + ELOG("invalid signal: %d", signum); break; } } -- cgit From 6b51c72e0cc99c6c03c521f77793028cf63afd45 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 11 Dec 2017 23:05:36 +0100 Subject: tui: rework deferred-termcodes implementation Try another approach to defer the termcodes. Seems less janky, but still not perfect. ref #7664 ref #7649 ref #7664 ref 27f9b1c7b029d8 --- src/nvim/main.c | 3 +++ src/nvim/tui/tui.c | 15 +++++++-------- src/nvim/ui.c | 8 ++++++++ src/nvim/ui.h | 3 +-- src/nvim/ui_bridge.c | 11 +++++++++++ 5 files changed, 30 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index 0346414697..5d826d9524 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -563,6 +563,9 @@ int main(int argc, char **argv) (void)eval_has_provider("clipboard"); } + if (!headless_mode) { + ui_builtin_after_startup(); + } TIME_MSG("before starting main loop"); ILOG("starting main loop"); diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 49aa41b9b0..0d3a241793 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -126,6 +126,7 @@ UI *tui_start(void) { UI *ui = xcalloc(1, sizeof(UI)); ui->stop = tui_stop; + ui->after_startup = tui_after_startup; ui->rgb = p_tgc; ui->resize = tui_resize; ui->clear = tui_clear; @@ -174,13 +175,7 @@ static size_t unibi_pre_fmt_str(TUIData *data, unsigned int unibi_index, static void terminfo_after_startup_event(void **argv) { UI *ui = argv[0]; - bool defer = argv[1] != NULL; // clever(?) boolean without malloc() dance. TUIData *data = ui->data; - if (defer) { // We're on the main-loop. Now forward to the TUI loop. - loop_schedule(data->loop, - event_create(terminfo_after_startup_event, 2, ui, NULL)); - return; - } // Enable bracketed paste unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste); // Enable focus reporting @@ -278,9 +273,13 @@ static void terminfo_start(UI *ui) uv_pipe_init(&data->write_loop, &data->output_handle.pipe, 0); uv_pipe_open(&data->output_handle.pipe, data->out_fd); } +} - loop_schedule(&main_loop, - event_create(terminfo_after_startup_event, 2, ui, ui)); +static void tui_after_startup(UI *ui) +{ + TUIData *data = ui->data; + loop_schedule(data->loop, + event_create(terminfo_after_startup_event, 1, ui)); } static void terminfo_stop(UI *ui) diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 81da88c54a..5c8e9380db 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -138,6 +138,14 @@ void ui_builtin_start(void) #endif } +/// Immediately after VimEnter event. +void ui_builtin_after_startup(void) +{ +#ifdef FEAT_TUI + UI_CALL(after_startup); +#endif +} + void ui_builtin_stop(void) { UI_CALL(stop); diff --git a/src/nvim/ui.h b/src/nvim/ui.h index f1ea0716e6..84d17e9ec2 100644 --- a/src/nvim/ui.h +++ b/src/nvim/ui.h @@ -31,13 +31,12 @@ struct ui_t { bool ui_ext[UI_WIDGETS]; ///< Externalized widgets int width, height; void *data; - #ifdef INCLUDE_GENERATED_DECLARATIONS # include "ui_events.generated.h" #endif - void (*event)(UI *ui, char *name, Array args, bool *args_consumed); void (*stop)(UI *ui); + void (*after_startup)(UI *ui); }; #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/ui_bridge.c b/src/nvim/ui_bridge.c index 0a69cf0ecb..324d821df5 100644 --- a/src/nvim/ui_bridge.c +++ b/src/nvim/ui_bridge.c @@ -42,6 +42,7 @@ UI *ui_bridge_attach(UI *ui, ui_main_fn ui_main, event_scheduler scheduler) rv->ui = ui; rv->bridge.rgb = ui->rgb; rv->bridge.stop = ui_bridge_stop; + rv->bridge.after_startup = ui_bridge_after_startup; rv->bridge.resize = ui_bridge_resize; rv->bridge.clear = ui_bridge_clear; rv->bridge.eol_clear = ui_bridge_eol_clear; @@ -106,6 +107,16 @@ static void ui_thread_run(void *data) bridge->ui_main(bridge, bridge->ui); } +static void ui_bridge_after_startup(UI *b) +{ + UI_BRIDGE_CALL(b, after_startup, 1, b); +} +static void ui_bridge_after_startup_event(void **argv) +{ + UI *ui = UI(argv[0]); + ui->after_startup(ui); +} + static void ui_bridge_stop(UI *b) { UIBridgeData *bridge = (UIBridgeData *)b; -- cgit From ed92ece815e1f32259b3f0397476ff6ac92726e3 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 12 Dec 2017 20:41:25 +0100 Subject: tui: defer termcodes using a timer With this implementation there is no "jank" during startup. Using the main_loop in any fashion is janky. Using only the TUI loop emits the termcodes too soon, or requires bad hacks like counting tui_flush invocations (9 seems to work). ref #7664 ref #7649 ref #7664 ref 27f9b1c7b029d8 --- src/nvim/main.c | 3 --- src/nvim/tui/tui.c | 41 +++++++++++++++++++++-------------------- src/nvim/ui.c | 8 -------- src/nvim/ui.h | 1 - src/nvim/ui_bridge.c | 11 ----------- 5 files changed, 21 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/nvim/main.c b/src/nvim/main.c index 5d826d9524..0346414697 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -563,9 +563,6 @@ int main(int argc, char **argv) (void)eval_has_provider("clipboard"); } - if (!headless_mode) { - ui_builtin_after_startup(); - } TIME_MSG("before starting main loop"); ILOG("starting main loop"); diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 0d3a241793..b8f43e9d13 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -70,6 +70,7 @@ typedef struct { UIBridgeData *bridge; Loop *loop; bool stop; + uv_timer_t after_startup_timer; unibi_var_t params[9]; char buf[OUTBUF_SIZE]; size_t bufpos; @@ -126,7 +127,6 @@ UI *tui_start(void) { UI *ui = xcalloc(1, sizeof(UI)); ui->stop = tui_stop; - ui->after_startup = tui_after_startup; ui->rgb = p_tgc; ui->resize = tui_resize; ui->clear = tui_clear; @@ -170,18 +170,6 @@ static size_t unibi_pre_fmt_str(TUIData *data, unsigned int unibi_index, return unibi_run(str, data->params, buf, len); } -/// Emits some termcodes after Nvim startup, which were observed to slowdown -/// rendering during startup in tmux 2.3 (+focus-events). #7649 -static void terminfo_after_startup_event(void **argv) -{ - UI *ui = argv[0]; - TUIData *data = ui->data; - // Enable bracketed paste - unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste); - // Enable focus reporting - unibi_out_ext(ui, data->unibi_ext.enable_focus_reporting); -} - static void termname_set_event(void **argv) { char *termname = argv[0]; @@ -261,6 +249,9 @@ static void terminfo_start(UI *ui) unibi_out(ui, unibi_enter_ca_mode); unibi_out(ui, unibi_keypad_xmit); unibi_out(ui, unibi_clear_screen); + // Enable bracketed paste + unibi_out_ext(ui, data->unibi_ext.enable_bracketed_paste); + uv_loop_init(&data->write_loop); if (data->out_isatty) { uv_tty_init(&data->write_loop, &data->output_handle.tty, data->out_fd, 0); @@ -275,13 +266,6 @@ static void terminfo_start(UI *ui) } } -static void tui_after_startup(UI *ui) -{ - TUIData *data = ui->data; - loop_schedule(data->loop, - event_create(terminfo_after_startup_event, 1, ui)); -} - static void terminfo_stop(UI *ui) { TUIData *data = ui->data; @@ -307,6 +291,18 @@ static void terminfo_stop(UI *ui) unibi_destroy(data->ut); } +static void after_startup_timer_cb(uv_timer_t *handle) + FUNC_ATTR_NONNULL_ALL +{ + UI *ui = handle->data; + TUIData *data = ui->data; + uv_timer_stop(&data->after_startup_timer); + + // Emit this after Nvim startup, not during. This works around a tmux + // 2.3 bug(?) which caused slow drawing during startup. #7649 + unibi_out_ext(ui, data->unibi_ext.enable_focus_reporting); +} + static void tui_terminal_start(UI *ui) { TUIData *data = ui->data; @@ -316,6 +312,8 @@ static void tui_terminal_start(UI *ui) update_size(ui); signal_watcher_start(&data->winch_handle, sigwinch_cb, SIGWINCH); term_input_start(&data->input); + + uv_timer_start(&data->after_startup_timer, after_startup_timer_cb, 500, 0); } static void tui_terminal_stop(UI *ui) @@ -349,6 +347,8 @@ static void tui_main(UIBridgeData *bridge, UI *ui) #ifdef UNIX signal_watcher_start(&data->cont_handle, sigcont_cb, SIGCONT); #endif + uv_timer_init(&data->loop->uv, &data->after_startup_timer); + data->after_startup_timer.data = ui; #if TERMKEY_VERSION_MAJOR > 0 || TERMKEY_VERSION_MINOR > 18 data->input.tk_ti_hook_fn = tui_tk_ti_getstr; @@ -367,6 +367,7 @@ static void tui_main(UIBridgeData *bridge, UI *ui) loop_poll_events(&tui_loop, -1); // tui_loop.events is never processed } + uv_close((uv_handle_t *)&data->after_startup_timer, NULL); ui_bridge_stopped(bridge); term_input_destroy(&data->input); signal_watcher_stop(&data->cont_handle); diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 5c8e9380db..81da88c54a 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -138,14 +138,6 @@ void ui_builtin_start(void) #endif } -/// Immediately after VimEnter event. -void ui_builtin_after_startup(void) -{ -#ifdef FEAT_TUI - UI_CALL(after_startup); -#endif -} - void ui_builtin_stop(void) { UI_CALL(stop); diff --git a/src/nvim/ui.h b/src/nvim/ui.h index 84d17e9ec2..0e40a1a215 100644 --- a/src/nvim/ui.h +++ b/src/nvim/ui.h @@ -36,7 +36,6 @@ struct ui_t { #endif void (*event)(UI *ui, char *name, Array args, bool *args_consumed); void (*stop)(UI *ui); - void (*after_startup)(UI *ui); }; #ifdef INCLUDE_GENERATED_DECLARATIONS diff --git a/src/nvim/ui_bridge.c b/src/nvim/ui_bridge.c index 324d821df5..0a69cf0ecb 100644 --- a/src/nvim/ui_bridge.c +++ b/src/nvim/ui_bridge.c @@ -42,7 +42,6 @@ UI *ui_bridge_attach(UI *ui, ui_main_fn ui_main, event_scheduler scheduler) rv->ui = ui; rv->bridge.rgb = ui->rgb; rv->bridge.stop = ui_bridge_stop; - rv->bridge.after_startup = ui_bridge_after_startup; rv->bridge.resize = ui_bridge_resize; rv->bridge.clear = ui_bridge_clear; rv->bridge.eol_clear = ui_bridge_eol_clear; @@ -107,16 +106,6 @@ static void ui_thread_run(void *data) bridge->ui_main(bridge, bridge->ui); } -static void ui_bridge_after_startup(UI *b) -{ - UI_BRIDGE_CALL(b, after_startup, 1, b); -} -static void ui_bridge_after_startup_event(void **argv) -{ - UI *ui = UI(argv[0]); - ui->after_startup(ui); -} - static void ui_bridge_stop(UI *b) { UIBridgeData *bridge = (UIBridgeData *)b; -- cgit From 7164f618504bb1b3374da1bcc26c6cf2ac8b3f86 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 13 Dec 2017 22:22:02 +0100 Subject: typval_encode.c.h: avoid -Wnonnull-compare warning (#7712) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * typval_encode.c.h: avoid -Wnonnull-compare warning closes #6847 The NULL check is needed because TYPVAL_ENCODE_CONV_EMPTY_DICT may be invoked with literal `NULL`. Warning occurs even for `Debug` build-type: neovim/src/nvim/eval/typval.c: In function ‘_typval_encode_nothing_convert_one_value’: neovim/src/nvim/eval/typval.c:1802:10: warning: nonnull argument ‘tv’ compared to NULL [-Wnonnull-compare] if (tv != NULL) { \ ^ ../src/nvim/eval/typval_encode.c.h:398:9: note: in expansion of macro ‘TYPVAL_ENCODE_CONV_EMPTY_DICT’ TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, tv->vval.v_dict); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gcc version: gcc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406 * fixup! typval_encode.c.h: avoid -Wnonnull-compare warning --- src/nvim/eval/typval.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 4bc3a85efb..b5382d1ccb 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -1794,14 +1794,20 @@ static inline void _nothing_conv_func_end(typval_T *const tv, const int copyID) tv->v_lock = VAR_UNLOCKED; \ } while (0) +static inline void _nothing_conv_empty_dict(typval_T *const tv, + dict_T **const dictp) + FUNC_ATTR_ALWAYS_INLINE FUNC_ATTR_NONNULL_ARG(2) +{ + tv_dict_unref(*dictp); + *dictp = NULL; + if (tv != NULL) { + tv->v_lock = VAR_UNLOCKED; + } +} #define TYPVAL_ENCODE_CONV_EMPTY_DICT(tv, dict) \ do { \ assert((void *)&dict != (void *)&TYPVAL_ENCODE_NODICT_VAR); \ - tv_dict_unref((dict_T *)dict); \ - *((dict_T **)&dict) = NULL; \ - if (tv != NULL) { \ - ((typval_T *)tv)->v_lock = VAR_UNLOCKED; \ - } \ + _nothing_conv_empty_dict(tv, ((dict_T **)&dict)); \ } while (0) static inline int _nothing_conv_real_list_after_start( -- cgit From c8a5d6181b19009e170a3497a30ce35cf288bddf Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 15 Dec 2017 02:39:46 +0300 Subject: *: Fix some problems found during review Still missing: problems in window.c, it should be possible to construct a test for them. --- src/nvim/eval/encode.c | 2 +- src/nvim/eval/typval.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 9f16b78976..39897aa9ab 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -209,7 +209,7 @@ bool encode_vim_list_to_buf(const list_T *const list, size_t *const ret_len, return false; } len++; - if (TV_LIST_ITEM_TV(li)->vval.v_string != 0) { + if (TV_LIST_ITEM_TV(li)->vval.v_string != NULL) { len += STRLEN(TV_LIST_ITEM_TV(li)->vval.v_string); } }); diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 0c9c4a0347..5040695b09 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -406,9 +406,7 @@ void tv_list_append_list(list_T *const list, list_T *const itemlist) TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; TV_LIST_ITEM_TV(li)->vval.v_list = itemlist; tv_list_append(list, li); - if (itemlist != NULL) { - tv_list_ref(itemlist); - } + tv_list_ref(itemlist); } /// Append a dictionary to a list @@ -510,6 +508,9 @@ list_T *tv_list_copy(const vimconv_T *const conv, list_T *const orig, orig->lv_copylist = copy; } TV_LIST_ITER(orig, item, { + if (got_int) { + break; + } listitem_T *const ni = tv_list_item_alloc(); if (deep) { if (var_item_copy(conv, TV_LIST_ITEM_TV(item), TV_LIST_ITEM_TV(ni), @@ -605,6 +606,9 @@ static int list_join_inner(garray_T *const gap, list_T *const l, // Stringify each item in the list. TV_LIST_ITER(l, item, { + if (got_int) { + break; + } char *s; size_t len; s = encode_tv2echo(TV_LIST_ITEM_TV(item), &len); @@ -697,7 +701,7 @@ bool tv_list_equal(list_T *const l1, list_T *const l2, const bool ic, listitem_T *item2 = tv_list_first(l2); for (; item1 != NULL && item2 != NULL ; (item1 = TV_LIST_ITEM_NEXT(l1, item1), - item2 = TV_LIST_ITEM_NEXT(n2, item2))) { + item2 = TV_LIST_ITEM_NEXT(l2, item2))) { if (!tv_equal(TV_LIST_ITEM_TV(item1), TV_LIST_ITEM_TV(item2), ic, recursive)) { return false; @@ -2108,9 +2112,7 @@ void tv_copy(typval_T *const from, typval_T *const to) break; } case VAR_LIST: { - if (from->vval.v_list != NULL) { - tv_list_ref(to->vval.v_list); - } + tv_list_ref(to->vval.v_list); break; } case VAR_DICT: { -- cgit From fb07391ce46b8bff90ef7ef073b75919a307e64c Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 15 Dec 2017 11:38:34 +0300 Subject: window: Fix matchaddpos() and enhance error reporting --- src/nvim/eval.c | 82 +++++++++++++++++++++++++++---------------------------- src/nvim/window.c | 20 ++++++++------ 2 files changed, 53 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 37356d43b4..640967b91c 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12440,56 +12440,56 @@ static void f_matchadd(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void f_matchaddpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - rettv->vval.v_number = -1; + rettv->vval.v_number = -1; - char buf[NUMBUFLEN]; - const char *const group = tv_get_string_buf_chk(&argvars[0], buf); - if (group == NULL) { - return; - } + char buf[NUMBUFLEN]; + const char *const group = tv_get_string_buf_chk(&argvars[0], buf); + if (group == NULL) { + return; + } - if (argvars[1].v_type != VAR_LIST) { - EMSG2(_(e_listarg), "matchaddpos()"); - return; - } + if (argvars[1].v_type != VAR_LIST) { + EMSG2(_(e_listarg), "matchaddpos()"); + return; + } - list_T *l; - l = argvars[1].vval.v_list; - if (l == NULL) { - return; - } + list_T *l; + l = argvars[1].vval.v_list; + if (l == NULL) { + return; + } - bool error = false; - int prio = 10; - int id = -1; - const char *conceal_char = NULL; + bool error = false; + int prio = 10; + int id = -1; + const char *conceal_char = NULL; - if (argvars[2].v_type != VAR_UNKNOWN) { - prio = tv_get_number_chk(&argvars[2], &error); - if (argvars[3].v_type != VAR_UNKNOWN) { - id = tv_get_number_chk(&argvars[3], &error); - if (argvars[4].v_type != VAR_UNKNOWN) { - if (argvars[4].v_type != VAR_DICT) { - EMSG(_(e_dictreq)); - return; - } - dictitem_T *di; - if ((di = tv_dict_find(argvars[4].vval.v_dict, S_LEN("conceal"))) - != NULL) { - conceal_char = tv_get_string(&di->di_tv); - } + if (argvars[2].v_type != VAR_UNKNOWN) { + prio = tv_get_number_chk(&argvars[2], &error); + if (argvars[3].v_type != VAR_UNKNOWN) { + id = tv_get_number_chk(&argvars[3], &error); + if (argvars[4].v_type != VAR_UNKNOWN) { + if (argvars[4].v_type != VAR_DICT) { + EMSG(_(e_dictreq)); + return; + } + dictitem_T *di; + if ((di = tv_dict_find(argvars[4].vval.v_dict, S_LEN("conceal"))) + != NULL) { + conceal_char = tv_get_string(&di->di_tv); } } } - if (error == true) { - return; - } + } + if (error == true) { + return; + } - // id == 3 is ok because matchaddpos() is supposed to substitute :3match - if (id == 1 || id == 2) { - EMSGN(_("E798: ID is reserved for \"match\": %" PRId64), id); - return; - } + // id == 3 is ok because matchaddpos() is supposed to substitute :3match + if (id == 1 || id == 2) { + EMSGN(_("E798: ID is reserved for \"match\": %" PRId64), id); + return; + } rettv->vval.v_number = match_add(curwin, group, NULL, prio, id, l, conceal_char); diff --git a/src/nvim/window.c b/src/nvim/window.c index 28cb9449d1..583314d437 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5619,19 +5619,17 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, if (TV_LIST_ITEM_TV(li)->v_type == VAR_LIST) { const list_T *const subl = TV_LIST_ITEM_TV(li)->vval.v_list; - if (subl == NULL) { - goto fail; - } const listitem_T *subli = tv_list_first(subl); if (subli == NULL) { + emsgf(_("E5030: Empty list at position %d"), + (int)tv_list_idx_of_item(pos_list, li)); goto fail; } lnum = tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error); if (error) { goto fail; } - if (lnum == 0) { - --i; + if (lnum <= 0) { continue; } m->pos.pos[i].lnum = lnum; @@ -5641,9 +5639,15 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, if (error) { goto fail; } + if (col < 0) { + continue; + } subli = TV_LIST_ITEM_NEXT(subl, subli); if (subli != NULL) { len = tv_get_number_chk(TV_LIST_ITEM_TV(subli), &error); + if (len < 0) { + continue; + } if (error) { goto fail; } @@ -5652,15 +5656,15 @@ int match_add(win_T *wp, const char *const grp, const char *const pat, m->pos.pos[i].col = col; m->pos.pos[i].len = len; } else if (TV_LIST_ITEM_TV(li)->v_type == VAR_NUMBER) { - if (TV_LIST_ITEM_TV(li)->vval.v_number == 0) { - i--; + if (TV_LIST_ITEM_TV(li)->vval.v_number <= 0) { continue; } m->pos.pos[i].lnum = TV_LIST_ITEM_TV(li)->vval.v_number; m->pos.pos[i].col = 0; m->pos.pos[i].len = 0; } else { - EMSG(_("List or number required")); + emsgf(_("E5031: List or number required at position %d"), + (int)tv_list_idx_of_item(pos_list, li)); goto fail; } if (toplnum == 0 || lnum < toplnum) { -- cgit From d5bce42b524708a54243658e87b1e3bd9c7acdf3 Mon Sep 17 00:00:00 2001 From: Michael Schupikov Date: Sat, 23 Sep 2017 09:56:44 +0200 Subject: vim-patch:8.0.0074 Problem: Cannot make Vim fail on an internal error. Solution: Add IEMSG() and IEMSG2(). (Domenique Pelle) Avoid reporting an internal error without mentioning where. https://github.com/vim/vim/commit/95f096030ed1a8afea028f2ea295d6f6a70f466f Signed-off-by: Michael Schupikov --- src/nvim/edit.c | 4 ++-- src/nvim/eval.c | 25 +++++++++++----------- src/nvim/eval/encode.c | 2 +- src/nvim/eval/typval_encode.c.h | 2 +- src/nvim/ex_eval.c | 14 ++++++------ src/nvim/getchar.c | 29 +++++++++++++------------ src/nvim/globals.h | 2 +- src/nvim/hashtab.c | 2 +- src/nvim/memfile.c | 5 +++-- src/nvim/memline.c | 39 +++++++++++++++++----------------- src/nvim/message.c | 47 ++++++++++++++++++++++++++++++++++++++--- src/nvim/message.h | 9 ++++++++ src/nvim/option.c | 8 +++---- src/nvim/os/env.c | 2 +- src/nvim/quickfix.c | 2 +- src/nvim/regexp.c | 11 +++++----- src/nvim/spell.c | 2 +- src/nvim/undo.c | 20 +++++++++--------- src/nvim/version.c | 2 +- src/nvim/window.c | 2 +- 20 files changed, 144 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 859f98d2ad..4f0a3eaf34 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -1927,7 +1927,7 @@ bool vim_is_ctrl_x_key(int c) case CTRL_X_EVAL: return (c == Ctrl_P || c == Ctrl_N); } - EMSG(_(e_internal)); + internal_error("vim_is_ctrl_x_key()"); return false; } @@ -4681,7 +4681,7 @@ static int ins_complete(int c, bool enable_pum) line = ml_get(curwin->w_cursor.lnum); compl_pattern = vim_strnsave(line + compl_col, compl_length); } else { - EMSG2(_(e_intern2), "ins_complete()"); + internal_error("ins_complete()"); return FAIL; } diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 56aedb1b4e..7fa9f7563e 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1102,10 +1102,11 @@ static void restore_vimvar(int idx, typval_T *save_tv) vimvars[idx].vv_tv = *save_tv; if (vimvars[idx].vv_type == VAR_UNKNOWN) { hi = hash_find(&vimvarht, vimvars[idx].vv_di.di_key); - if (HASHITEM_EMPTY(hi)) - EMSG2(_(e_intern2), "restore_vimvar()"); - else + if (HASHITEM_EMPTY(hi)) { + internal_error("restore_vimvar()"); + } else { hash_remove(&vimvarht, hi); + } } } @@ -1567,7 +1568,7 @@ ex_let_vars ( } break; } else if (*arg != ',' && *arg != ']') { - EMSG2(_(e_intern2), "ex_let_vars()"); + internal_error("ex_let_vars()"); return FAIL; } } @@ -2960,7 +2961,7 @@ int do_unlet(const char *const name, const size_t name_len, const int forceit) d = di->di_tv.vval.v_dict; } if (d == NULL) { - EMSG2(_(e_intern2), "do_unlet()"); + internal_error("do_unlet()"); return FAIL; } hashitem_T *hi = hash_find(ht, (const char_u *)varname); @@ -7959,7 +7960,7 @@ static void f_empty(typval_T *argvars, typval_T *rettv, FunPtr fptr) n = argvars[0].vval.v_special != kSpecialVarTrue; break; case VAR_UNKNOWN: - EMSG2(_(e_intern2), "f_empty(UNKNOWN)"); + internal_error("f_empty(UNKNOWN)"); break; } @@ -17151,7 +17152,7 @@ static void f_type(typval_T *argvars, typval_T *rettv, FunPtr fptr) break; } case VAR_UNKNOWN: { - EMSG2(_(e_intern2), "f_type(UNKNOWN)"); + internal_error("f_type(UNKNOWN)"); break; } } @@ -19030,7 +19031,7 @@ static void set_var(const char *name, const size_t name_len, typval_T *const tv, } return; } else if (v->di_tv.v_type != tv->v_type) { - EMSG2(_(e_intern2), "set_var()"); + internal_error("set_var()"); } } @@ -19297,7 +19298,7 @@ int var_item_copy(const vimconv_T *const conv, } break; case VAR_UNKNOWN: - EMSG2(_(e_intern2), "var_item_copy(UNKNOWN)"); + internal_error("var_item_copy(UNKNOWN)"); ret = FAIL; } --recurse; @@ -20985,11 +20986,11 @@ void func_unref(char_u *name) if (fp == NULL && isdigit(*name)) { #ifdef EXITFREE if (!entered_free_all_mem) { - EMSG2(_(e_intern2), "func_unref()"); + internal_error("func_unref()"); abort(); } #else - EMSG2(_(e_intern2), "func_unref()"); + internal_error("func_unref()"); abort(); #endif } @@ -21028,7 +21029,7 @@ void func_ref(char_u *name) } else if (isdigit(*name)) { // Only give an error for a numbered function. // Fail silently, when named or lambda function isn't found. - EMSG2(_(e_intern2), "func_ref()"); + internal_error("func_ref()"); } } diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index ef647b3ee4..1607d2139a 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -340,7 +340,7 @@ int encode_read_from_list(ListReaderState *const state, char *const buf, do { \ const char *const fun_ = (const char *)(fun); \ if (fun_ == NULL) { \ - EMSG2(_(e_intern2), "string(): NULL function name"); \ + internal_error("string(): NULL function name"); \ ga_concat(gap, "function(NULL"); \ } else { \ ga_concat(gap, "function("); \ diff --git a/src/nvim/eval/typval_encode.c.h b/src/nvim/eval/typval_encode.c.h index a93ad2dbba..df820f664c 100644 --- a/src/nvim/eval/typval_encode.c.h +++ b/src/nvim/eval/typval_encode.c.h @@ -600,7 +600,7 @@ _convert_one_value_regular_dict: {} break; } case VAR_UNKNOWN: { - EMSG2(_(e_intern2), STR(_TYPVAL_ENCODE_CONVERT_ONE_VALUE) "()"); + internal_error(STR(_TYPVAL_ENCODE_CONVERT_ONE_VALUE) "()"); return FAIL; } } diff --git a/src/nvim/ex_eval.c b/src/nvim/ex_eval.c index 9037b3c151..4010a088c8 100644 --- a/src/nvim/ex_eval.c +++ b/src/nvim/ex_eval.c @@ -517,7 +517,7 @@ static void discard_exception(except_T *excp, int was_finished) char_u *saved_IObuff; if (excp == NULL) { - EMSG(_(e_internal)); + internal_error("discard_exception()"); return; } @@ -619,8 +619,9 @@ static void catch_exception(except_T *excp) */ static void finish_exception(except_T *excp) { - if (excp != caught_stack) - EMSG(_(e_internal)); + if (excp != caught_stack) { + internal_error("finish_exception()"); + } caught_stack = caught_stack->caught; if (caught_stack != NULL) { set_vim_var_string(VV_EXCEPTION, (char *) caught_stack->value, -1); @@ -1422,8 +1423,9 @@ void ex_catch(exarg_T *eap) * ":endtry" or when the catch clause is left by a ":continue", * ":break", ":return", ":finish", error, interrupt, or another * exception. */ - if (cstack->cs_exception[cstack->cs_idx] != current_exception) - EMSG(_(e_internal)); + if (cstack->cs_exception[cstack->cs_idx] != current_exception) { + internal_error("ex_catch()"); + } } else { /* * If there is a preceding catch clause and it caught the exception, @@ -1547,7 +1549,7 @@ void ex_finally(exarg_T *eap) * exception will be discarded. */ if (did_throw && cstack->cs_exception[cstack->cs_idx] != current_exception) - EMSG(_(e_internal)); + internal_error("ex_finally()"); } /* diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 4f8a8528a0..1b5d3472ab 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -254,16 +254,17 @@ static void add_buff(buffheader_T *const buf, const char *const s, return; } - if (buf->bh_first.b_next == NULL) { /* first add to list */ + if (buf->bh_first.b_next == NULL) { // first add to list buf->bh_space = 0; buf->bh_curr = &(buf->bh_first); - } else if (buf->bh_curr == NULL) { /* buffer has already been read */ - EMSG(_("E222: Add to read buffer")); + } else if (buf->bh_curr == NULL) { // buffer has already been read + IEMSG(_("E222: Add to read buffer")); return; - } else if (buf->bh_index != 0) + } else if (buf->bh_index != 0) { memmove(buf->bh_first.b_next->b_str, - buf->bh_first.b_next->b_str + buf->bh_index, - STRLEN(buf->bh_first.b_next->b_str + buf->bh_index) + 1); + buf->bh_first.b_next->b_str + buf->bh_index, + STRLEN(buf->bh_first.b_next->b_str + buf->bh_index) + 1); + } buf->bh_index = 0; size_t len; @@ -1152,14 +1153,16 @@ void alloc_typebuf(void) */ void free_typebuf(void) { - if (typebuf.tb_buf == typebuf_init) - EMSG2(_(e_intern2), "Free typebuf 1"); - else + if (typebuf.tb_buf == typebuf_init) { + internal_error("Free typebuf 1"); + } else { xfree(typebuf.tb_buf); - if (typebuf.tb_noremap == noremapbuf_init) - EMSG2(_(e_intern2), "Free typebuf 2"); - else + } + if (typebuf.tb_noremap == noremapbuf_init) { + internal_error("Free typebuf 2"); + } else { xfree(typebuf.tb_noremap); + } } /* @@ -3905,7 +3908,7 @@ makemap ( c1 = 't'; break; default: - EMSG(_("E228: makemap: Illegal mode")); + IEMSG(_("E228: makemap: Illegal mode")); return FAIL; } do { /* do this twice if c2 is set, 3 times with c3 */ diff --git a/src/nvim/globals.h b/src/nvim/globals.h index ef56954aa0..dd216f177f 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1043,6 +1043,7 @@ EXTERN char_u e_for[] INIT(= N_("E588: :endfor without :for")); EXTERN char_u e_exists[] INIT(= N_("E13: File exists (add ! to override)")); EXTERN char_u e_failed[] INIT(= N_("E472: Command failed")); EXTERN char_u e_internal[] INIT(= N_("E473: Internal error")); +EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s")); EXTERN char_u e_interr[] INIT(= N_("Interrupted")); EXTERN char_u e_invaddr[] INIT(= N_("E14: Invalid address")); EXTERN char_u e_invarg[] INIT(= N_("E474: Invalid argument")); @@ -1134,7 +1135,6 @@ EXTERN char_u e_write[] INIT(= N_("E80: Error while writing")); EXTERN char_u e_zerocount[] INIT(= N_("E939: Positive count required")); EXTERN char_u e_usingsid[] INIT(= N_( "E81: Using not in a script context")); -EXTERN char_u e_intern2[] INIT(= N_("E685: Internal error: %s")); EXTERN char_u e_maxmempat[] INIT(= N_( "E363: pattern uses more memory than 'maxmempattern'")); EXTERN char_u e_emptybuf[] INIT(= N_("E749: empty buffer")); diff --git a/src/nvim/hashtab.c b/src/nvim/hashtab.c index 3397788b00..526bc284a4 100644 --- a/src/nvim/hashtab.c +++ b/src/nvim/hashtab.c @@ -208,7 +208,7 @@ int hash_add(hashtab_T *ht, char_u *key) hash_T hash = hash_hash(key); hashitem_T *hi = hash_lookup(ht, (const char *)key, STRLEN(key), hash); if (!HASHITEM_EMPTY(hi)) { - EMSG2(_(e_intern2), "hash_add()"); + internal_error("hash_add()"); return FAIL; } hash_add_item(ht, hi, key, hash); diff --git a/src/nvim/memfile.c b/src/nvim/memfile.c index 4428dd42aa..4eeba12b87 100644 --- a/src/nvim/memfile.c +++ b/src/nvim/memfile.c @@ -376,8 +376,9 @@ void mf_put(memfile_T *mfp, bhdr_T *hp, bool dirty, bool infile) { unsigned flags = hp->bh_flags; - if ((flags & BH_LOCKED) == 0) - EMSG(_("E293: block was not locked")); + if ((flags & BH_LOCKED) == 0) { + IEMSG(_("E293: block was not locked")); + } flags &= ~BH_LOCKED; if (dirty) { flags |= BH_DIRTY; diff --git a/src/nvim/memline.c b/src/nvim/memline.c index f28a9e60f4..fde21f7992 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -293,7 +293,7 @@ int ml_open(buf_T *buf) */ hp = mf_new(mfp, false, 1); if (hp->bh_bnum != 0) { - EMSG(_("E298: Didn't get block nr 0?")); + IEMSG(_("E298: Didn't get block nr 0?")); goto error; } b0p = hp->bh_data; @@ -335,7 +335,7 @@ int ml_open(buf_T *buf) if ((hp = ml_new_ptr(mfp)) == NULL) goto error; if (hp->bh_bnum != 1) { - EMSG(_("E298: Didn't get block nr 1?")); + IEMSG(_("E298: Didn't get block nr 1?")); goto error; } pp = hp->bh_data; @@ -351,7 +351,7 @@ int ml_open(buf_T *buf) */ hp = ml_new_data(mfp, FALSE, 1); if (hp->bh_bnum != 2) { - EMSG(_("E298: Didn't get block nr 2?")); + IEMSG(_("E298: Didn't get block nr 2?")); goto error; } @@ -635,13 +635,14 @@ static void ml_upd_block0(buf_T *buf, upd_block0_T what) if (mfp == NULL || (hp = mf_get(mfp, 0, 1)) == NULL) return; b0p = hp->bh_data; - if (ml_check_b0_id(b0p) == FAIL) - EMSG(_("E304: ml_upd_block0(): Didn't get block 0??")); - else { - if (what == UB_FNAME) + if (ml_check_b0_id(b0p) == FAIL) { + IEMSG(_("E304: ml_upd_block0(): Didn't get block 0??")); + } else { + if (what == UB_FNAME) { set_b0_fname(b0p, buf); - else /* what == UB_SAME_DIR */ + } else { // what == UB_SAME_DIR set_b0_dir_flag(b0p, buf); + } } mf_put(mfp, hp, true, false); } @@ -1745,7 +1746,7 @@ ml_get_buf ( /* Avoid giving this message for a recursive call, may happen when * the GUI redraws part of the text. */ ++recursive; - EMSGN(_("E315: ml_get: invalid lnum: %" PRId64), lnum); + IEMSGN(_("E315: ml_get: invalid lnum: %" PRId64), lnum); --recursive; } errorret: @@ -1777,7 +1778,7 @@ errorret: /* Avoid giving this message for a recursive call, may happen * when the GUI redraws part of the text. */ ++recursive; - EMSGN(_("E316: ml_get: cannot find line %" PRId64), lnum); + IEMSGN(_("E316: ml_get: cannot find line %" PRId64), lnum); --recursive; } goto errorret; @@ -2162,7 +2163,7 @@ ml_append_int ( return FAIL; pp = hp->bh_data; /* must be pointer block */ if (pp->pb_id != PTR_ID) { - EMSG(_("E317: pointer block id wrong 3")); + IEMSG(_("E317: pointer block id wrong 3")); mf_put(mfp, hp, false, false); return FAIL; } @@ -2295,8 +2296,8 @@ ml_append_int ( * Safety check: fallen out of for loop? */ if (stack_idx < 0) { - EMSG(_("E318: Updated too many blocks?")); - buf->b_ml.ml_stack_top = 0; /* invalidate stack */ + IEMSG(_("E318: Updated too many blocks?")); + buf->b_ml.ml_stack_top = 0; // invalidate stack } } @@ -2435,7 +2436,7 @@ static int ml_delete_int(buf_T *buf, linenr_T lnum, int message) return FAIL; pp = hp->bh_data; /* must be pointer block */ if (pp->pb_id != PTR_ID) { - EMSG(_("E317: pointer block id wrong 4")); + IEMSG(_("E317: pointer block id wrong 4")); mf_put(mfp, hp, false, false); return FAIL; } @@ -2631,7 +2632,7 @@ static void ml_flush_line(buf_T *buf) hp = ml_find_line(buf, lnum, ML_FIND); if (hp == NULL) - EMSGN(_("E320: Cannot find line %" PRId64), lnum); + IEMSGN(_("E320: Cannot find line %" PRId64), lnum); else { dp = hp->bh_data; idx = lnum - buf->b_ml.ml_locked_low; @@ -2841,7 +2842,7 @@ static bhdr_T *ml_find_line(buf_T *buf, linenr_T lnum, int action) pp = (PTR_BL *)(dp); /* must be pointer block */ if (pp->pb_id != PTR_ID) { - EMSG(_("E317: pointer block id wrong")); + IEMSG(_("E317: pointer block id wrong")); goto error_block; } @@ -2880,11 +2881,11 @@ static bhdr_T *ml_find_line(buf_T *buf, linenr_T lnum, int action) } if (idx >= (int)pp->pb_count) { /* past the end: something wrong! */ if (lnum > buf->b_ml.ml_line_count) - EMSGN(_("E322: line number out of range: %" PRId64 " past the end"), + IEMSGN(_("E322: line number out of range: %" PRId64 " past the end"), lnum - buf->b_ml.ml_line_count); else - EMSGN(_("E323: line count wrong in block %" PRId64), bnum); + IEMSGN(_("E323: line count wrong in block %" PRId64), bnum); goto error_block; } if (action == ML_DELETE) { @@ -2960,7 +2961,7 @@ static void ml_lineadd(buf_T *buf, int count) pp = hp->bh_data; /* must be pointer block */ if (pp->pb_id != PTR_ID) { mf_put(mfp, hp, false, false); - EMSG(_("E317: pointer block id wrong 2")); + IEMSG(_("E317: pointer block id wrong 2")); break; } pp->pb_pointer[ip->ip_index].pe_line_count += count; diff --git a/src/nvim/message.c b/src/nvim/message.c index 5c8f0655bf..1d9a4de9c0 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -582,20 +582,61 @@ void emsg_invreg(int name) /// Print an error message with unknown number of arguments bool emsgf(const char *const fmt, ...) +{ + bool ret; + + va_list ap; + va_start(ap, fmt); + ret = emsgfv(fmt, ap); + va_end(ap); + + return ret; +} + +/// Print an error message with unknown number of arguments +static bool emsgfv(const char *fmt, va_list ap) { static char errbuf[IOSIZE]; if (emsg_not_now()) { return true; } - va_list ap; - va_start(ap, fmt); vim_vsnprintf(errbuf, sizeof(errbuf), fmt, ap, NULL); - va_end(ap); return emsg((const char_u *)errbuf); } +/// Same as emsg(...), but abort on error when ABORT_ON_INTERNAL_ERROR is +/// defined. It is used for internal errors only, so that they can be +/// detected when fuzzing vim. +void iemsg(const char *s) +{ + msg((char_u *)s); +#ifdef ABORT_ON_INTERNAL_ERROR + abort(); +#endif +} + +/// Same as emsgf(...) but abort on error when ABORT_ON_INTERNAL_ERROR is +/// defined. It is used for internal errors only, so that they can be +/// detected when fuzzing vim. +void iemsgf(const char *s, ...) +{ + va_list ap; + va_start(ap, s); + (void)emsgfv(s, ap); + va_end(ap); +#ifdef ABORT_ON_INTERNAL_ERROR + abort(); +#endif +} + +/// Give an "Internal error" message. +void internal_error(char *where) +{ + IEMSG2(_(e_intern2), where); +} + static void msg_emsgf_event(void **argv) { char *s = argv[0]; diff --git a/src/nvim/message.h b/src/nvim/message.h index 904a9d3ca1..82935a36a9 100644 --- a/src/nvim/message.h +++ b/src/nvim/message.h @@ -49,6 +49,15 @@ /// Like #EMSG, but for messages with one "%" PRIu64 inside #define EMSGU(s, n) emsgf((const char *) (s), (uint64_t)(n)) +/// Like #EMSG, but for internal messages +#define IEMSG(s) iemsg((const char *)(s)) + +/// Like #EMSG2, but for internal messages +#define IEMSG2(s, p) iemsgf((const char *)(s), (p)) + +/// Like #EMSGN, but for internal messages +#define IEMSGN(s, n) iemsgf((const char *)(s), (int64_t)(n)) + /// Display message at the recorded position #define MSG_PUTS(s) msg_puts((const char *)(s)) diff --git a/src/nvim/option.c b/src/nvim/option.c index 499cf79836..a345906200 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2258,7 +2258,7 @@ int was_set_insecurely(char_u *opt, int opt_flags) uint32_t *flagp = insecure_flag(idx, opt_flags); return (*flagp & P_INSECURE) != 0; } - EMSG2(_(e_intern2), "was_set_insecurely()"); + internal_error("was_set_insecurely()"); return -1; } @@ -2317,8 +2317,8 @@ set_string_option_direct ( if (idx == -1) { // Use name. idx = findoption((const char *)name); if (idx < 0) { // Not found (should not happen). - EMSG2(_(e_intern2), "set_string_option_direct()"); - EMSG2(_("For option %s"), name); + internal_error("set_string_option_direct()"); + IEMSG2(_("For option %s"), name); return; } } @@ -5584,7 +5584,7 @@ static char_u *get_varp(vimoption_T *p) case PV_KMAP: return (char_u *)&(curbuf->b_p_keymap); case PV_SCL: return (char_u *)&(curwin->w_p_scl); case PV_WINHL: return (char_u *)&(curwin->w_p_winhl); - default: EMSG(_("E356: get_varp ERROR")); + default: IEMSG(_("E356: get_varp ERROR")); } /* always return a valid pointer to avoid a crash! */ return (char_u *)&(curbuf->b_p_wm); diff --git a/src/nvim/os/env.c b/src/nvim/os/env.c index de0cd10d9c..999fcd434a 100644 --- a/src/nvim/os/env.c +++ b/src/nvim/os/env.c @@ -887,7 +887,7 @@ bool os_setenv_append_path(const char *fname) # define MAX_ENVPATHLEN INT_MAX #endif if (!path_is_absolute_path((char_u *)fname)) { - EMSG2(_(e_intern2), "os_setenv_append_path()"); + internal_error("os_setenv_append_path()"); return false; } const char *tail = (char *)path_tail_with_sep((char_u *)fname); diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 1fc585f0c9..3df025a51d 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -2853,7 +2853,7 @@ static void qf_fill_buffer(qf_info_T *qi, buf_T *buf, qfline_T *old_last) if (old_last == NULL) { if (buf != curbuf) { - EMSG2(_(e_intern2), "qf_fill_buffer()"); + internal_error("qf_fill_buffer()"); return; } diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index ae611a0005..e921706b3a 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -459,14 +459,15 @@ static int toggle_Magic(int x) /* Used for an error (down from) vim_regcomp(): give the error message, set * rc_did_emsg and return NULL */ #define EMSG_RET_NULL(m) return (EMSG(m), rc_did_emsg = TRUE, (void *)NULL) +#define IEMSG_RET_NULL(m) return (IEMSG(m), rc_did_emsg = true, (void *)NULL) #define EMSG_RET_FAIL(m) return (EMSG(m), rc_did_emsg = TRUE, FAIL) #define EMSG2_RET_NULL(m, \ c) return (EMSG2((m), \ - (c) ? "" : "\\"), rc_did_emsg = TRUE, \ + (c) ? "" : "\\"), rc_did_emsg = true, \ (void *)NULL) #define EMSG2_RET_FAIL(m, \ c) return (EMSG2((m), \ - (c) ? "" : "\\"), rc_did_emsg = TRUE, \ + (c) ? "" : "\\"), rc_did_emsg = true, \ FAIL) #define EMSG_ONE_RET_NULL EMSG2_RET_NULL(_( \ "E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL) @@ -1891,8 +1892,8 @@ static char_u *regatom(int *flagp) case Magic(')'): if (one_exactly) EMSG_ONE_RET_NULL; - EMSG_RET_NULL(_(e_internal)); /* Supposed to be caught earlier. */ - /* NOTREACHED */ + IEMSG_RET_NULL(_(e_internal)); // Supposed to be caught earlier. + // NOTREACHED case Magic('='): case Magic('?'): @@ -4534,7 +4535,7 @@ regmatch ( brace_max[no] = OPERAND_MAX(scan); brace_count[no] = 0; } else { - EMSG(_(e_internal)); /* Shouldn't happen */ + internal_error("BRACE_LIMITS"); status = RA_FAIL; } } diff --git a/src/nvim/spell.c b/src/nvim/spell.c index 42c9bcc0ee..c837038659 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -5355,7 +5355,7 @@ add_sound_suggest ( // Find the word nr in the soundfold tree. sfwordnr = soundfold_find(slang, goodword); if (sfwordnr < 0) { - EMSG2(_(e_intern2), "add_sound_suggest()"); + internal_error("add_sound_suggest()"); return; } diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 3d7ebc8837..f611a3bb29 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -2096,8 +2096,8 @@ void undo_time(long step, int sec, int file, int absolute) uhp = uhp->uh_prev.ptr; if (uhp == NULL || uhp->uh_walk != mark) { - /* Need to redo more but can't find it... */ - EMSG2(_(e_intern2), "undo_time()"); + // Need to redo more but can't find it... + internal_error("undo_time()"); break; } } @@ -2163,8 +2163,8 @@ static void u_undoredo(int undo) if (top > curbuf->b_ml.ml_line_count || top >= bot || bot > curbuf->b_ml.ml_line_count + 1) { unblock_autocmds(); - EMSG(_("E438: u_undo: line numbers wrong")); - changed(); /* don't want UNCHANGED now */ + IEMSG(_("E438: u_undo: line numbers wrong")); + changed(); // don't want UNCHANGED now return; } @@ -2655,7 +2655,7 @@ static void u_unch_branch(u_header_T *uhp) static u_entry_T *u_get_headentry(void) { if (curbuf->b_u_newhead == NULL || curbuf->b_u_newhead->uh_entry == NULL) { - EMSG(_("E439: undo list corrupt")); + IEMSG(_("E439: undo list corrupt")); return NULL; } return curbuf->b_u_newhead->uh_entry; @@ -2684,11 +2684,11 @@ static void u_getbot(void) extra = curbuf->b_ml.ml_line_count - uep->ue_lcount; uep->ue_bot = uep->ue_top + uep->ue_size + 1 + extra; if (uep->ue_bot < 1 || uep->ue_bot > curbuf->b_ml.ml_line_count) { - EMSG(_("E440: undo line missing")); - uep->ue_bot = uep->ue_top + 1; /* assume all lines deleted, will - * get all the old lines back - * without deleting the current - * ones */ + IEMSG(_("E440: undo line missing")); + uep->ue_bot = uep->ue_top + 1; // assume all lines deleted, will + // get all the old lines back + // without deleting the current + // ones } curbuf->b_u_newhead->uh_getbot_entry = NULL; diff --git a/src/nvim/version.c b/src/nvim/version.c index e8cf1d0f0b..8ab9fc1a4b 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -1182,7 +1182,7 @@ static const int included_patches[] = { // 77 NA // 76 NA 75, - // 74, + 74, 73, // 72 NA // 71 NA diff --git a/src/nvim/window.c b/src/nvim/window.c index e39569321e..63c9361663 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2115,7 +2115,7 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) ptp = ptp->tp_next) ; if (ptp == NULL) { - EMSG2(_(e_intern2), "win_close_othertab()"); + internal_error("win_close_othertab()"); return; } ptp->tp_next = tp->tp_next; -- cgit From dcb2780b834d4df006f55a0475e03bd2a38ac344 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 15 Dec 2017 15:57:38 -0500 Subject: lint --- src/nvim/memline.c | 29 +++++++++++++++-------------- src/nvim/regexp.c | 16 ++++++---------- 2 files changed, 21 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/nvim/memline.c b/src/nvim/memline.c index fde21f7992..80775c607d 100644 --- a/src/nvim/memline.c +++ b/src/nvim/memline.c @@ -1743,11 +1743,11 @@ ml_get_buf ( if (lnum > buf->b_ml.ml_line_count) { /* invalid line number */ if (recursive == 0) { - /* Avoid giving this message for a recursive call, may happen when - * the GUI redraws part of the text. */ - ++recursive; + // Avoid giving this message for a recursive call, may happen when + // the GUI redraws part of the text. + recursive++; IEMSGN(_("E315: ml_get: invalid lnum: %" PRId64), lnum); - --recursive; + recursive--; } errorret: STRCPY(IObuff, "???"); @@ -1775,11 +1775,11 @@ errorret: */ if ((hp = ml_find_line(buf, lnum, ML_FIND)) == NULL) { if (recursive == 0) { - /* Avoid giving this message for a recursive call, may happen - * when the GUI redraws part of the text. */ - ++recursive; + // Avoid giving this message for a recursive call, may happen + // when the GUI redraws part of the text. + recursive++; IEMSGN(_("E316: ml_get: cannot find line %" PRId64), lnum); - --recursive; + recursive--; } goto errorret; } @@ -2631,9 +2631,9 @@ static void ml_flush_line(buf_T *buf) new_line = buf->b_ml.ml_line_ptr; hp = ml_find_line(buf, lnum, ML_FIND); - if (hp == NULL) + if (hp == NULL) { IEMSGN(_("E320: Cannot find line %" PRId64), lnum); - else { + } else { dp = hp->bh_data; idx = lnum - buf->b_ml.ml_locked_low; start = ((dp->db_index[idx]) & DB_INDEX_MASK); @@ -2879,13 +2879,14 @@ static bhdr_T *ml_find_line(buf_T *buf, linenr_T lnum, int action) break; } } - if (idx >= (int)pp->pb_count) { /* past the end: something wrong! */ - if (lnum > buf->b_ml.ml_line_count) + if (idx >= (int)pp->pb_count) { // past the end: something wrong! + if (lnum > buf->b_ml.ml_line_count) { IEMSGN(_("E322: line number out of range: %" PRId64 " past the end"), - lnum - buf->b_ml.ml_line_count); + lnum - buf->b_ml.ml_line_count); - else + } else { IEMSGN(_("E323: line count wrong in block %" PRId64), bnum); + } goto error_block; } if (action == ML_DELETE) { diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index e921706b3a..ec9916f4a2 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -458,17 +458,13 @@ static int toggle_Magic(int x) /* Used for an error (down from) vim_regcomp(): give the error message, set * rc_did_emsg and return NULL */ -#define EMSG_RET_NULL(m) return (EMSG(m), rc_did_emsg = TRUE, (void *)NULL) +#define EMSG_RET_NULL(m) return (EMSG(m), rc_did_emsg = true, (void *)NULL) #define IEMSG_RET_NULL(m) return (IEMSG(m), rc_did_emsg = true, (void *)NULL) -#define EMSG_RET_FAIL(m) return (EMSG(m), rc_did_emsg = TRUE, FAIL) -#define EMSG2_RET_NULL(m, \ - c) return (EMSG2((m), \ - (c) ? "" : "\\"), rc_did_emsg = true, \ - (void *)NULL) -#define EMSG2_RET_FAIL(m, \ - c) return (EMSG2((m), \ - (c) ? "" : "\\"), rc_did_emsg = true, \ - FAIL) +#define EMSG_RET_FAIL(m) return (EMSG(m), rc_did_emsg = true, FAIL) +#define EMSG2_RET_NULL(m, c) \ + return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = true, (void *)NULL) +#define EMSG2_RET_FAIL(m, c) \ + return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = true, FAIL) #define EMSG_ONE_RET_NULL EMSG2_RET_NULL(_( \ "E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL) -- cgit From 91d3efa35a26f6c5e58850413ccbb350cb8e7b37 Mon Sep 17 00:00:00 2001 From: ZyX Date: Fri, 15 Dec 2017 11:40:27 +0300 Subject: eval/encode: Avoid unnecessary tv_list_idx_of_item() calls --- src/nvim/eval/encode.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/eval/encode.c b/src/nvim/eval/encode.c index 39897aa9ab..b7af102681 100644 --- a/src/nvim/eval/encode.c +++ b/src/nvim/eval/encode.c @@ -136,13 +136,18 @@ static int conv_error(const char *const msg, const MPConvStack *const mpstack, } case kMPConvPairs: case kMPConvList: { + const int idx = (v.data.l.li == tv_list_first(v.data.l.list) + ? 0 + : (v.data.l.li == NULL + ? tv_list_len(v.data.l.list) - 1 + : (int)tv_list_idx_of_item( + v.data.l.list, + TV_LIST_ITEM_PREV(v.data.l.list, + v.data.l.li)))); const listitem_T *const li = (v.data.l.li == NULL ? tv_list_last(v.data.l.list) : TV_LIST_ITEM_PREV(v.data.l.list, v.data.l.li)); - int idx = (li == NULL - ? 0 - : (int)tv_list_idx_of_item(v.data.l.list, li)); if (v.type == kMPConvList || li == NULL || (TV_LIST_ITEM_TV(li)->v_type != VAR_LIST -- cgit From bfb21f3e012d9473d6038dd254fc3a0ecdf8c0e9 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 16 Dec 2017 00:38:58 +0100 Subject: tui: rework deferred-termcodes ... again - Revert timer-based approach. - Instead, call loop_poll_events() with a timeout in an "active" loop, to infer that "TUI startup activity has mostly finished", but also to enforce a mininum time (100 ms) before emitting "enable focus reporting" termcode. (If TUI startup takes longer than that minimum time, it's probably a slow environment anyways.) - Tickle `main_loop` by sending a dummy event. Without this, the initial "focus-gained" response from the terminal may not get processed until the user hits a key. ref #7720 ref #7664 ref #7649 ref #7664 ref 27f9b1c7b029d8 --- src/nvim/event/loop.c | 19 +++++++++++++++---- src/nvim/tui/tui.c | 42 +++++++++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/nvim/event/loop.c b/src/nvim/event/loop.c index 5adf16c0f3..55ef0261d9 100644 --- a/src/nvim/event/loop.c +++ b/src/nvim/event/loop.c @@ -30,19 +30,22 @@ void loop_init(Loop *loop, void *data) uv_signal_init(&loop->uv, &loop->children_watcher); uv_timer_init(&loop->uv, &loop->children_kill_timer); uv_timer_init(&loop->uv, &loop->poll_timer); + loop->poll_timer.data = xmalloc(sizeof(bool)); // "timeout expired" flag } -void loop_poll_events(Loop *loop, int ms) +/// @returns true if `ms` timeout was reached +bool loop_poll_events(Loop *loop, int ms) { if (loop->recursive++) { abort(); // Should not re-enter uv_run } uv_run_mode mode = UV_RUN_ONCE; + bool timeout_expired = false; if (ms > 0) { - // Use a repeating timeout of ms milliseconds to make sure - // we do not block indefinitely for I/O. + *((bool *)loop->poll_timer.data) = false; // reset "timeout expired" flag + // Dummy timer to ensure UV_RUN_ONCE does not block indefinitely for I/O. uv_timer_start(&loop->poll_timer, timer_cb, (uint64_t)ms, (uint64_t)ms); } else if (ms == 0) { // For ms == 0, do a non-blocking event poll. @@ -52,11 +55,13 @@ void loop_poll_events(Loop *loop, int ms) uv_run(&loop->uv, mode); if (ms > 0) { + timeout_expired = *((bool *)loop->poll_timer.data); uv_timer_stop(&loop->poll_timer); } loop->recursive--; // Can re-enter uv_run now multiqueue_process_events(loop->fast_events); + return timeout_expired; } /// Schedules an event from another thread. @@ -111,7 +116,7 @@ bool loop_close(Loop *loop, bool wait) uv_mutex_destroy(&loop->mutex); uv_close((uv_handle_t *)&loop->children_watcher, NULL); uv_close((uv_handle_t *)&loop->children_kill_timer, NULL); - uv_close((uv_handle_t *)&loop->poll_timer, NULL); + uv_close((uv_handle_t *)&loop->poll_timer, timer_close_cb); uv_close((uv_handle_t *)&loop->async, NULL); uint64_t start = wait ? os_hrtime() : 0; while (true) { @@ -163,5 +168,11 @@ static void async_cb(uv_async_t *handle) static void timer_cb(uv_timer_t *handle) { + bool *timeout_expired = handle->data; + *timeout_expired = true; } +static void timer_close_cb(uv_handle_t *handle) +{ + xfree(handle->data); +} diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index b8f43e9d13..3c181aca65 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -70,7 +70,6 @@ typedef struct { UIBridgeData *bridge; Loop *loop; bool stop; - uv_timer_t after_startup_timer; unibi_var_t params[9]; char buf[OUTBUF_SIZE]; size_t bufpos; @@ -291,18 +290,6 @@ static void terminfo_stop(UI *ui) unibi_destroy(data->ut); } -static void after_startup_timer_cb(uv_timer_t *handle) - FUNC_ATTR_NONNULL_ALL -{ - UI *ui = handle->data; - TUIData *data = ui->data; - uv_timer_stop(&data->after_startup_timer); - - // Emit this after Nvim startup, not during. This works around a tmux - // 2.3 bug(?) which caused slow drawing during startup. #7649 - unibi_out_ext(ui, data->unibi_ext.enable_focus_reporting); -} - static void tui_terminal_start(UI *ui) { TUIData *data = ui->data; @@ -312,8 +299,16 @@ static void tui_terminal_start(UI *ui) update_size(ui); signal_watcher_start(&data->winch_handle, sigwinch_cb, SIGWINCH); term_input_start(&data->input); +} + +static void tui_terminal_after_startup(UI *ui) + FUNC_ATTR_NONNULL_ALL +{ + TUIData *data = ui->data; - uv_timer_start(&data->after_startup_timer, after_startup_timer_cb, 500, 0); + // Emit this after Nvim startup, not during. This works around a tmux + // 2.3 bug(?) which caused slow drawing during startup. #7649 + unibi_out_ext(ui, data->unibi_ext.enable_focus_reporting); } static void tui_terminal_stop(UI *ui) @@ -347,8 +342,6 @@ static void tui_main(UIBridgeData *bridge, UI *ui) #ifdef UNIX signal_watcher_start(&data->cont_handle, sigcont_cb, SIGCONT); #endif - uv_timer_init(&data->loop->uv, &data->after_startup_timer); - data->after_startup_timer.data = ui; #if TERMKEY_VERSION_MAJOR > 0 || TERMKEY_VERSION_MINOR > 18 data->input.tk_ti_hook_fn = tui_tk_ti_getstr; @@ -363,11 +356,21 @@ static void tui_main(UIBridgeData *bridge, UI *ui) loop_schedule_deferred(&main_loop, event_create(show_termcap_event, 1, data->ut)); + // "Active" loop: first ~100 ms of startup. + for (size_t ms = 0; ms < 100 && !data->stop;) { + ms += (loop_poll_events(&tui_loop, 20) ? 20 : 1); + } + if (!data->stop) { + tui_terminal_after_startup(ui); + // Tickle `main_loop` with a dummy event, else the initial "focus-gained" + // terminal response may not get processed until user hits a key. + loop_schedule_deferred(&main_loop, event_create(tui_dummy_event, 0)); + } + // "Passive" (I/O-driven) loop: TUI thread "main loop". while (!data->stop) { loop_poll_events(&tui_loop, -1); // tui_loop.events is never processed } - uv_close((uv_handle_t *)&data->after_startup_timer, NULL); ui_bridge_stopped(bridge); term_input_destroy(&data->input); signal_watcher_stop(&data->cont_handle); @@ -379,6 +382,10 @@ static void tui_main(UIBridgeData *bridge, UI *ui) xfree(ui); } +static void tui_dummy_event(void **argv) +{ +} + static void tui_scheduler(Event event, void *d) { UI *ui = d; @@ -1100,6 +1107,7 @@ static void suspend_event(void **argv) loop_poll_events(data->loop, -1); } tui_terminal_start(ui); + tui_terminal_after_startup(ui); if (enable_mouse) { tui_mouse_on(ui); } -- cgit From 76ffe0c5aa51fe4fe14811e86867af2c711190a1 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 16 Dec 2017 14:21:56 +0300 Subject: eval: Fix linter error --- src/nvim/eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 640967b91c..3aaa5f349d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12485,7 +12485,7 @@ static void f_matchaddpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } - // id == 3 is ok because matchaddpos() is supposed to substitute :3match + // id == 3 is ok because matchaddpos() is supposed to substitute :3match if (id == 1 || id == 2) { EMSGN(_("E798: ID is reserved for \"match\": %" PRId64), id); return; -- cgit From edccf18df56d982dea350770ea42ffa25759b43f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 17 Dec 2017 15:23:27 +0300 Subject: eval: Fix some issues found in review --- src/nvim/eval.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 74b0cdc746..6b04dd4eea 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5336,18 +5336,16 @@ bool set_ref_in_list(list_T *l, int copyID, ht_stack_T **ht_stack) list_T *cur_l = l; for (;;) { - if (!abort) { - // Mark each item in the list. If the item contains a hashtab - // it is added to ht_stack, if it contains a list it is added to - // list_stack. - TV_LIST_ITER(cur_l, li, { - abort = set_ref_in_item(TV_LIST_ITEM_TV(li), copyID, ht_stack, - &list_stack); - if (abort) { - break; - } - }); - } + // Mark each item in the list. If the item contains a hashtab + // it is added to ht_stack, if it contains a list it is added to + // list_stack. + TV_LIST_ITER(cur_l, li, { + if (abort) { + break; + } + abort = set_ref_in_item(TV_LIST_ITEM_TV(li), copyID, ht_stack, + &list_stack); + }); if (list_stack == NULL) { break; @@ -8968,7 +8966,7 @@ static void common_function(typval_T *argvars, typval_T *rettv, goto theend; } list = argvars[arg_idx].vval.v_list; - if (list == NULL || tv_list_len(list) == 0) { + if (tv_list_len(list) == 0) { arg_idx = 0; } } @@ -11069,8 +11067,7 @@ static void f_index(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (argvars[2].v_type != VAR_UNKNOWN) { bool error = false; - // Start at specified item. Use the cached index that tv_list_find() - // sets, so that a negative number also works. + // Start at specified item. idx = tv_list_uidx(l, tv_get_number_chk(&argvars[2], &error)); if (error || idx == -1) { item = NULL; @@ -11080,6 +11077,9 @@ static void f_index(typval_T *argvars, typval_T *rettv, FunPtr fptr) } if (argvars[3].v_type != VAR_UNKNOWN) { ic = !!tv_get_number_chk(&argvars[3], &error); + if (error) { + item = NULL; + } } } @@ -12248,10 +12248,10 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) } if (l != NULL) { idx = tv_list_uidx(l, start); - li = tv_list_find(l, idx); - if (li == NULL) { + if (idx == -1) { goto theend; } + li = tv_list_find(l, idx); } else { if (start < 0) start = 0; -- cgit From c162bc629440afaf8910f1a29f1dfdb03f898101 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 16 Dec 2017 21:50:20 -0500 Subject: vim-patch:8.0.0420: text garbled when the system encoding differs from 'encoding' Problem: When running :make the output may be in the system encoding, different from 'encoding'. Solution: Add the 'makeencoding' option. (Ken Takata) https://github.com/vim/vim/commit/2c7292dc5bbf155fe2192d417363b8c085759cad --- src/nvim/buffer.c | 1 + src/nvim/buffer_defs.h | 1 + src/nvim/if_cscope.c | 4 +- src/nvim/main.c | 2 +- src/nvim/option.c | 12 +++- src/nvim/option_defs.h | 2 + src/nvim/options.lua | 7 +++ src/nvim/quickfix.c | 56 +++++++++++++---- src/nvim/testdir/Makefile | 1 + src/nvim/testdir/test_makeencoding.py | 67 +++++++++++++++++++++ src/nvim/testdir/test_makeencoding.vim | 106 +++++++++++++++++++++++++++++++++ 11 files changed, 241 insertions(+), 18 deletions(-) create mode 100644 src/nvim/testdir/test_makeencoding.py create mode 100644 src/nvim/testdir/test_makeencoding.vim (limited to 'src') diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 766003a021..21830539f5 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1808,6 +1808,7 @@ void free_buf_options(buf_T *buf, int free_p_ff) buf->b_p_ul = NO_LOCAL_UNDOLEVEL; clear_string_option(&buf->b_p_lw); clear_string_option(&buf->b_p_bkc); + clear_string_option(&buf->b_p_menc); } diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index f1cbcb2627..5702ceaaef 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -637,6 +637,7 @@ struct file_buffer { uint32_t b_p_fex_flags; ///< flags for 'formatexpr' char_u *b_p_kp; ///< 'keywordprg' int b_p_lisp; ///< 'lisp' + char_u *b_p_menc; ///< 'makeencoding' char_u *b_p_mps; ///< 'matchpairs' int b_p_ml; ///< 'modeline' int b_p_ml_nobin; ///< b_p_ml saved for binary mode diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 3c02f5acbd..654b4630c5 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -1012,9 +1012,9 @@ static int cs_find_common(char *opt, char *pat, int forceit, int verbose, fclose(f); if (use_ll) /* Use location list */ wp = curwin; - /* '-' starts a new error list */ + // '-' starts a new error list if (qf_init(wp, tmp, (char_u *)"%f%*\\t%l%*\\t%m", - *qfpos == '-', cmdline) > 0) { + *qfpos == '-', cmdline, NULL) > 0) { if (postponed_split != 0) { (void)win_split(postponed_split > 0 ? postponed_split : 0, postponed_split_flags); diff --git a/src/nvim/main.c b/src/nvim/main.c index 0346414697..0b24023ad0 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1369,7 +1369,7 @@ static void handle_quickfix(mparm_T *paramp) set_string_option_direct((char_u *)"ef", -1, paramp->use_ef, OPT_FREE, SID_CARG); vim_snprintf((char *)IObuff, IOSIZE, "cfile %s", p_ef); - if (qf_init(NULL, p_ef, p_efm, true, IObuff) < 0) { + if (qf_init(NULL, p_ef, p_efm, true, IObuff, p_menc) < 0) { ui_linefeed(); mch_exit(3); } diff --git a/src/nvim/option.c b/src/nvim/option.c index a345906200..192d2b0f78 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -2217,6 +2217,7 @@ void check_buf_options(buf_T *buf) check_string_option(&buf->b_p_tsr); check_string_option(&buf->b_p_lw); check_string_option(&buf->b_p_bkc); + check_string_option(&buf->b_p_menc); } /* @@ -2635,8 +2636,8 @@ did_set_string_option ( else if (varp == &p_ei) { if (check_ei() == FAIL) errmsg = e_invarg; - /* 'encoding' and 'fileencoding' */ - } else if (varp == &p_enc || gvarp == &p_fenc) { + // 'encoding', 'fileencoding' and 'makeencoding' + } else if (varp == &p_enc || gvarp == &p_fenc || gvarp == &p_menc) { if (gvarp == &p_fenc) { if (!MODIFIABLE(curbuf) && opt_flags != OPT_GLOBAL) { errmsg = e_modifiable; @@ -5400,6 +5401,9 @@ void unset_global_local_option(char *name, void *from) case PV_LW: clear_string_option(&buf->b_p_lw); break; + case PV_MENC: + clear_string_option(&buf->b_p_menc); + break; } } @@ -5433,6 +5437,7 @@ static char_u *get_varp_scope(vimoption_T *p, int opt_flags) case PV_UL: return (char_u *)&(curbuf->b_p_ul); case PV_LW: return (char_u *)&(curbuf->b_p_lw); case PV_BKC: return (char_u *)&(curbuf->b_p_bkc); + case PV_MENC: return (char_u *)&(curbuf->b_p_menc); } return NULL; /* "cannot happen" */ } @@ -5488,6 +5493,8 @@ static char_u *get_varp(vimoption_T *p) ? (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_MENC: return *curbuf->b_p_menc != NUL + ? (char_u *)&(curbuf->b_p_menc) : p->var; case PV_ARAB: return (char_u *)&(curwin->w_p_arab); case PV_LIST: return (char_u *)&(curwin->w_p_list); @@ -5885,6 +5892,7 @@ void buf_copy_options(buf_T *buf, int flags) buf->b_p_qe = vim_strsave(p_qe); buf->b_p_udf = p_udf; buf->b_p_lw = empty_option; + buf->b_p_menc = 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 1b978137ae..864723a10c 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -489,6 +489,7 @@ EXTERN char_u *p_lcs; // 'listchars' EXTERN int p_lz; // 'lazyredraw' EXTERN int p_lpl; // 'loadplugins' EXTERN int p_magic; // 'magic' +EXTERN char_u *p_menc; // 'makeencoding' EXTERN char_u *p_mef; // 'makeef' EXTERN char_u *p_mp; // 'makeprg' EXTERN char_u *p_cc; // 'colorcolumn' @@ -736,6 +737,7 @@ enum { , BV_KP , BV_LISP , BV_LW + , BV_MENC , BV_MA , BV_ML , BV_MOD diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 45efd49391..35baaf948f 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -1456,6 +1456,13 @@ return { varname='p_mef', defaults={if_true={vi=""}} }, + { + full_name='makeencoding', abbreviation='menc', + type='string', scope={'global', 'buffer'}, + vi_def=true, + varname='p_menc', + defaults={if_true={vi=""}} + }, { full_name='makeprg', abbreviation='mp', type='string', scope={'global', 'buffer'}, diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 3df025a51d..844ff071c9 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -160,6 +160,7 @@ typedef struct { buf_T *buf; linenr_T buflnum; linenr_T lnumlast; + vimconv_T vc; } qfstate_T; typedef struct { @@ -204,7 +205,8 @@ qf_init ( char_u *efile, char_u *errorformat, int newlist, /* TRUE: start a new error list */ - char_u *qf_title + char_u *qf_title, + char_u *enc ) { qf_info_T *qi = &ql_info; @@ -214,8 +216,8 @@ qf_init ( } return qf_init_ext(qi, efile, curbuf, NULL, errorformat, newlist, - (linenr_T)0, (linenr_T)0, - qf_title); + (linenr_T)0, (linenr_T)0, + qf_title, enc); } // Maximum number of bytes allowed per line while reading an errorfile. @@ -638,6 +640,22 @@ retry: } else { state->linebuf = IObuff; } + + // Convert a line if it contains a non-ASCII character + if (state->vc.vc_type != CONV_NONE && has_non_ascii(state->linebuf)) { + char_u *line = string_convert(&state->vc, state->linebuf, &state->linelen); + if (line != NULL) { + if (state->linelen < IOSIZE) { + STRLCPY(state->linebuf, line, state->linelen + 1); + xfree(line); + } else { + xfree(state->growbuf); + state->linebuf = state->growbuf = line; + state->growbufsiz = state->linelen < LINE_MAXLEN + ? state->linelen : LINE_MAXLEN; + } + } + } return QF_OK; } @@ -979,12 +997,12 @@ qf_init_ext( int newlist, /* TRUE: start a new error list */ linenr_T lnumfirst, /* first line number to use */ linenr_T lnumlast, /* last line number to use */ - char_u *qf_title + char_u *qf_title, + char_u *enc ) { - qfstate_T state = { NULL, 0, NULL, 0, NULL, NULL, NULL, NULL, - NULL, 0, 0 }; - qffields_T fields = { NULL, NULL, 0, 0L, 0, false, NULL, 0, 0, 0 }; + qfstate_T state; + qffields_T fields; qfline_T *old_last = NULL; bool adding = false; static efm_T *fmt_first = NULL; @@ -997,6 +1015,13 @@ qf_init_ext( xfree(qf_last_bufname); qf_last_bufname = NULL; + memset(&state, 0, sizeof(state)); + memset(&fields, 0, sizeof(fields)); + state.vc.vc_type = CONV_NONE; + if (enc != NULL && *enc != NUL) { + convert_setup(&state.vc, enc, p_enc); + } + fields.namebuf = xmalloc(CMDBUFFSIZE + 1); fields.errmsglen = CMDBUFFSIZE + 1; fields.errmsg = xmalloc(fields.errmsglen); @@ -1147,6 +1172,10 @@ qf_init_end: qf_update_buffer(qi, old_last); + if (state.vc.vc_type != CONV_NONE) { + convert_setup(&state.vc, NULL, NULL); + } + return retval; } @@ -3024,6 +3053,7 @@ void ex_make(exarg_T *eap) qf_info_T *qi = &ql_info; int res; char_u *au_name = NULL; + char_u *enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; /* Redirect ":grep" to ":vimgrep" if 'grepprg' is "internal". */ if (grep_internal(eap->cmdidx)) { @@ -3083,9 +3113,8 @@ void ex_make(exarg_T *eap) res = qf_init(wp, fname, (eap->cmdidx != CMD_make && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm, - (eap->cmdidx != CMD_grepadd - && eap->cmdidx != CMD_lgrepadd), - *eap->cmdlinep); + (eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd), + *eap->cmdlinep, enc); if (wp != NULL) qi = GET_LOC_LIST(wp); if (au_name != NULL) { @@ -3429,6 +3458,7 @@ void ex_cfile(exarg_T *eap) if (*eap->arg != NUL) set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0); + char_u *enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; /* * This function is used by the :cfile, :cgetfile and :caddfile * commands. @@ -3441,7 +3471,7 @@ void ex_cfile(exarg_T *eap) */ if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile && eap->cmdidx != CMD_laddfile), - *eap->cmdlinep) > 0 + *eap->cmdlinep, enc) > 0 && (eap->cmdidx == CMD_cfile || eap->cmdidx == CMD_lfile)) { if (au_name != NULL) @@ -4338,7 +4368,7 @@ void ex_cbuffer(exarg_T *eap) if (qf_init_ext(qi, NULL, buf, NULL, p_efm, (eap->cmdidx != CMD_caddbuffer && eap->cmdidx != CMD_laddbuffer), - eap->line1, eap->line2, qf_title) > 0) { + eap->line1, eap->line2, qf_title, NULL) > 0) { if (au_name != NULL) { apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, curbuf->b_fname, true, curbuf); @@ -4403,7 +4433,7 @@ void ex_cexpr(exarg_T *eap) if (qf_init_ext(qi, NULL, NULL, &tv, p_efm, (eap->cmdidx != CMD_caddexpr && eap->cmdidx != CMD_laddexpr), - (linenr_T)0, (linenr_T)0, *eap->cmdlinep) > 0) { + (linenr_T)0, (linenr_T)0, *eap->cmdlinep, NULL) > 0) { if (au_name != NULL) { apply_autocmds(EVENT_QUICKFIXCMDPOST, (char_u *)au_name, curbuf->b_fname, true, curbuf); diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index e1faaccb84..1f8cf8a0e7 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -65,6 +65,7 @@ NEW_TESTS ?= \ test_increment_dbcs.res \ test_lambda.res \ test_langmap.res \ + test_makeencoding.res \ test_marks.res \ test_match.res \ test_matchadd_conceal.res \ diff --git a/src/nvim/testdir/test_makeencoding.py b/src/nvim/testdir/test_makeencoding.py new file mode 100644 index 0000000000..041edadc0a --- /dev/null +++ b/src/nvim/testdir/test_makeencoding.py @@ -0,0 +1,67 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Test program for :make, :grep and :cgetfile. + +from __future__ import print_function, unicode_literals +import locale +import io +import sys + +def set_output_encoding(enc=None): + """Set the encoding of stdout and stderr + + arguments: + enc -- Encoding name. + If omitted, locale.getpreferredencoding() is used. + """ + if enc is None: + enc = locale.getpreferredencoding() + + def get_text_writer(fo, **kwargs): + kw = dict(kwargs) + kw.setdefault('errors', 'backslashreplace') # use \uXXXX style + kw.setdefault('closefd', False) + + if sys.version_info[0] < 3: + # Work around for Python 2.x + # New line conversion isn't needed here. Done in somewhere else. + writer = io.open(fo.fileno(), mode='w', newline='', **kw) + write = writer.write # save the original write() function + enc = locale.getpreferredencoding() + def convwrite(s): + if isinstance(s, bytes): + write(s.decode(enc)) # convert to unistr + else: + write(s) + try: + writer.flush() # needed on Windows + except IOError: + pass + writer.write = convwrite + else: + writer = io.open(fo.fileno(), mode='w', **kw) + return writer + + sys.stdout = get_text_writer(sys.stdout, encoding=enc) + sys.stderr = get_text_writer(sys.stderr, encoding=enc) + + +def main(): + enc = 'utf-8' + if len(sys.argv) > 1: + enc = sys.argv[1] + set_output_encoding(enc) + + message_tbl = { + 'utf-8': 'ÀÈÌÒÙ ã“ã‚“ã«ã¡ã¯ 你好', + 'latin1': 'ÀÈÌÒÙ', + 'cp932': 'ã“ã‚“ã«ã¡ã¯', + 'cp936': '你好', + } + + print('Xfoobar.c(10) : %s (%s)' % (message_tbl[enc], enc)) + + +if __name__ == "__main__": + main() diff --git a/src/nvim/testdir/test_makeencoding.vim b/src/nvim/testdir/test_makeencoding.vim new file mode 100644 index 0000000000..a3d5538a47 --- /dev/null +++ b/src/nvim/testdir/test_makeencoding.vim @@ -0,0 +1,106 @@ +" Tests for 'makeencoding'. +if !has('multi_byte') + finish +endif + +source shared.vim + +let s:python = PythonProg() +if s:python == '' + " Can't run this test. + finish +endif + +let s:script = 'test_makeencoding.py' + +let s:message_tbl = { + \ 'utf-8': 'ÀÈÌÒÙ ã“ã‚“ã«ã¡ã¯ 你好', + \ 'latin1': 'ÀÈÌÒÙ', + \ 'cp932': 'ã“ã‚“ã«ã¡ã¯', + \ 'cp936': '你好', + \} + + +" Tests for :cgetfile and :lgetfile. +func Test_getfile() + set errorfile=Xerror.txt + set errorformat=%f(%l)\ :\ %m + + " :cgetfile + for enc in keys(s:message_tbl) + let &makeencoding = enc + exec "silent !" . s:python . " " . s:script . " " . enc . " > " . &errorfile + cgetfile + copen + call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")", + \ getline('.')) + cclose + endfor + + " :lgetfile + for enc in keys(s:message_tbl) + let &makeencoding = enc + exec "silent !" . s:python . " " . s:script . " " . enc . " > " . &errorfile + lgetfile + lopen + call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")", + \ getline('.')) + lclose + endfor + + call delete(&errorfile) +endfunc + + +" Tests for :grep and :lgrep. +func Test_grep() + let &grepprg = s:python + set grepformat=%f(%l)\ :\ %m + + " :grep + for enc in keys(s:message_tbl) + let &makeencoding = enc + exec "silent grep! " . s:script . " " . enc + copen + call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")", + \ getline('.')) + cclose + endfor + + " :lgrep + for enc in keys(s:message_tbl) + let &makeencoding = enc + exec "silent lgrep! " . s:script . " " . enc + lopen + call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")", + \ getline('.')) + lclose + endfor +endfunc + + +" Tests for :make and :lmake. +func Test_make() + let &makeprg = s:python + set errorformat=%f(%l)\ :\ %m + + " :make + for enc in keys(s:message_tbl) + let &makeencoding = enc + exec "silent make! " . s:script . " " . enc + copen + call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")", + \ getline('.')) + cclose + endfor + + " :lmake + for enc in keys(s:message_tbl) + let &makeencoding = enc + exec "silent lmake! " . s:script . " " . enc + lopen + call assert_equal("Xfoobar.c|10| " . s:message_tbl[enc] . " (" . enc . ")", + \ getline('.')) + lclose + endfor +endfunc -- cgit From db0685a663a7d86d960f22e18f4e8e5041f80833 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 17 Dec 2017 11:17:30 -0500 Subject: lint --- src/nvim/quickfix.c | 54 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 844ff071c9..696f123871 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -194,20 +194,19 @@ typedef struct { static char_u *qf_last_bufname = NULL; static bufref_T qf_last_bufref = { NULL, 0, 0 }; -/* - * Read the errorfile "efile" into memory, line by line, building the error - * list. Set the error list's title to qf_title. - * Return -1 for error, number of errors for success. - */ -int -qf_init ( - win_T *wp, - char_u *efile, - char_u *errorformat, - int newlist, /* TRUE: start a new error list */ - char_u *qf_title, - char_u *enc -) +/// Read the errorfile "efile" into memory, line by line, building the error +/// list. Set the error list's title to qf_title. +/// +/// @params wp If non-NULL, make a location list +/// @params efile If non-NULL, errorfile to parse +/// @params errorformat 'errorformat' string used to parse the error lines +/// @params newlist If true, create a new error list +/// @params qf_title If non-NULL, title of the error list +/// @params enc If non-NULL, encoding used to parse errors +/// +/// @returns -1 for error, number of errors for success. +int qf_init(win_T *wp, char_u *efile, char_u *errorformat, int newlist, + char_u *qf_title, char_u *enc) { qf_info_T *qi = &ql_info; @@ -994,9 +993,9 @@ qf_init_ext( buf_T *buf, typval_T *tv, char_u *errorformat, - int newlist, /* TRUE: start a new error list */ - linenr_T lnumfirst, /* first line number to use */ - linenr_T lnumlast, /* last line number to use */ + int newlist, // TRUE: start a new error list + linenr_T lnumfirst, // first line number to use + linenr_T lnumlast, // last line number to use char_u *qf_title, char_u *enc ) @@ -3115,8 +3114,9 @@ void ex_make(exarg_T *eap) && eap->cmdidx != CMD_lmake) ? p_gefm : p_efm, (eap->cmdidx != CMD_grepadd && eap->cmdidx != CMD_lgrepadd), *eap->cmdlinep, enc); - if (wp != NULL) + if (wp != NULL) { qi = GET_LOC_LIST(wp); + } if (au_name != NULL) { apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, curbuf->b_fname, TRUE, curbuf); @@ -3459,16 +3459,14 @@ void ex_cfile(exarg_T *eap) set_string_option_direct((char_u *)"ef", -1, eap->arg, OPT_FREE, 0); char_u *enc = (*curbuf->b_p_menc != NUL) ? curbuf->b_p_menc : p_menc; - /* - * This function is used by the :cfile, :cgetfile and :caddfile - * commands. - * :cfile always creates a new quickfix list and jumps to the - * first error. - * :cgetfile creates a new quickfix list but doesn't jump to the - * first error. - * :caddfile adds to an existing quickfix list. If there is no - * quickfix list then a new list is created. - */ + // This function is used by the :cfile, :cgetfile and :caddfile + // commands. + // :cfile always creates a new quickfix list and jumps to the + // first error. + // :cgetfile creates a new quickfix list but doesn't jump to the + // first error. + // :caddfile adds to an existing quickfix list. If there is no + // quickfix list then a new list is created. if (qf_init(wp, p_ef, p_efm, (eap->cmdidx != CMD_caddfile && eap->cmdidx != CMD_laddfile), *eap->cmdlinep, enc) > 0 -- cgit From 6e0c038a3cf3565b10ce3b49e4394ba464418b92 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 17 Dec 2017 22:47:27 +0100 Subject: ASAN/LeakSanitizer: ignore loop_schedule_deferred() clang ASAN/LeakSanitizer error (observed in #7706): ==21832==ERROR: LeakSanitizer: detected memory leaks Direct leak of 56 byte(s) in 1 object(s) allocated from: 0 0x511b26 in malloc (/home/travis/build/neovim/neovim/build/bin/nvim+0x511b26) 1 0x1009a84 in try_malloc /home/travis/build/neovim/neovim/src/nvim/memory.c:87:15 2 0x1009c44 in xmalloc /home/travis/build/neovim/neovim/src/nvim/memory.c:121:15 3 0xaa8c36 in loop_schedule_deferred /home/travis/build/neovim/neovim/src/nvim/event/loop.c:89:19 4 0x190856a in tui_main /home/travis/build/neovim/neovim/src/nvim/tui/tui.c:367:5 5 0x1963d61 in ui_thread_run /home/travis/build/neovim/neovim/src/nvim/ui_bridge.c:106:3 6 0x2b5d4190d183 in start_thread /build/eglibc-SvCtMH/eglibc-2.19/nptl/pthread_create.c:312 Possible explanation: During exit, `Loop.thread_events` may not get flushed, so `loop_deferred_event()` is never called. We could instead try to unwind `Loop.thread_events` during teardown, but it seems lower-risk to just tell ASAN to ignore it. Valgrind does not complain: $ while :; do { 2>valglog.txt valgrind ./build/bin/nvim -u NONE +q ; } ; if ! [ $? = 0 ] ; then break ; fi ; done --- src/.asan-blacklist | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/.asan-blacklist b/src/.asan-blacklist index 928d81bd5a..9d7f721a88 100644 --- a/src/.asan-blacklist +++ b/src/.asan-blacklist @@ -1,3 +1,7 @@ # multiqueue.h pointer arithmetic is not accepted by asan fun:multiqueue_node_data fun:tv_dict_watcher_node_data + +# Allocation in loop_schedule_deferred() is freed by loop_deferred_event(), but +# this sometimes does not happen during teardown. +func:loop_schedule_deferred -- cgit From ccbf14322a8d56567a0fe9708cead27818d14271 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 17 Dec 2017 20:51:51 -0500 Subject: vim-patch:8.0.0404: not enough testing for quickfix Problem: Not enough testing for quickfix. Solution: Add some more tests. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/391b1dd040af204b150d43c5a1c97477ee450a28 --- src/nvim/testdir/test_quickfix.vim | 83 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index aff5fc2eed..773502ede4 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -128,6 +128,14 @@ func XlistTests(cchar) let l = split(result, "\n") call assert_equal([' 2 Xtestfile1:1 col 3: Line1', \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) + + " Test for '+' + redir => result + Xlist! +2 + redir END + let l = split(result, "\n") + call assert_equal([' 2 Xtestfile1:1 col 3: Line1', + \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) endfunc func Test_clist() @@ -907,6 +915,11 @@ func Test_efm2() \ "(67,3) warning: 's' already defined" \] set efm=%+P[%f],(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%-Q + " To exercise the push/pop file functionality in quickfix, the test files + " need to be created. + call writefile(['Line1'], 'Xtestfile1') + call writefile(['Line2'], 'Xtestfile2') + call writefile(['Line3'], 'Xtestfile3') cexpr "" for l in lines caddexpr l @@ -917,6 +930,9 @@ func Test_efm2() call assert_equal(2, l[2].col) call assert_equal('w', l[2].type) call assert_equal('e', l[3].type) + call delete('Xtestfile1') + call delete('Xtestfile2') + call delete('Xtestfile3') " Tests for %E, %C and %Z format specifiers let lines = ["Error 275", @@ -1351,11 +1367,25 @@ func Test_switchbuf() call assert_equal(2, winnr('$')) call assert_equal(1, bufwinnr('Xqftestfile3')) + " If only quickfix window is open in the current tabpage, jumping to an + " entry with 'switchubf' set to 'usetab' should search in other tabpages. enew | only + set switchbuf=usetab + tabedit Xqftestfile1 + tabedit Xqftestfile2 + tabedit Xqftestfile3 + tabfirst + copen | only + clast + call assert_equal(4, tabpagenr()) + tabfirst | tabonly | enew | only call delete('Xqftestfile1') call delete('Xqftestfile2') call delete('Xqftestfile3') + set switchbuf&vim + + enew | only endfunc func Xadjust_qflnum(cchar) @@ -1673,3 +1703,56 @@ func Test_dirstack_cleanup() caddbuffer let &efm = save_efm endfunc + +" Tests for jumping to entries from the location list window and quickfix +" window +func Test_cwindow_jump() + set efm=%f%%%l%%%m + lgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"] + lopen | only + lfirst + call assert_true(winnr('$') == 2) + call assert_true(winnr() == 1) + " Location list for the new window should be set + call assert_true(getloclist(0)[2].text == 'Line 30') + + " Open a scratch buffer + " Open a new window and create a location list + " Open the location list window and close the other window + " Jump to an entry. + " Should create a new window and jump to the entry. The scrtach buffer + " should not be used. + enew | only + set buftype=nofile + below new + lgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"] + lopen + 2wincmd c + lnext + call assert_true(winnr('$') == 3) + call assert_true(winnr() == 2) + + " Open two windows with two different location lists + " Open the location list window and close the previous window + " Jump to an entry in the location list window + " Should open the file in the first window and not set the location list. + enew | only + lgetexpr ["F1%5%Line 5"] + below new + lgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"] + lopen + 2wincmd c + lnext + call assert_true(winnr() == 1) + call assert_true(getloclist(0)[0].text == 'Line 5') + + enew | only + cgetexpr ["F1%10%Line 10", "F2%20%Line 20", "F3%30%Line 30"] + copen + cnext + call assert_true(winnr('$') == 2) + call assert_true(winnr() == 1) + + enew | only + set efm&vim +endfunc -- cgit From 853634881335eb9fe4c593710fbb8c71324e1690 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 17 Dec 2017 20:56:01 -0500 Subject: vim-patch:8.0.0484: :lhelpgrep does not fail after a successful one Problem: Using :lhelpgrep with an argument that should fail does not produce an error if the previous :helpgrep worked. Solution: Use another way to detect that autocommands made the quickfix info invalid. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/ee85df37634dfb0c40ae5de0b4f246aef460b392 --- src/nvim/quickfix.c | 10 +- src/nvim/testdir/test_quickfix.vim | 184 +++++++++++++++++++++++++++++-------- 2 files changed, 151 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 696f123871..6d59d15515 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4502,6 +4502,9 @@ void ex_helpgrep(exarg_T *eap) } } + // Autocommands may change the list. Save it for later comparison + qf_info_T *save_qi = qi; + regmatch.regprog = vim_regcomp(eap->arg, RE_MAGIC + RE_STRING); regmatch.rm_ic = FALSE; if (regmatch.regprog != NULL) { @@ -4614,10 +4617,11 @@ void ex_helpgrep(exarg_T *eap) if (au_name != NULL) { apply_autocmds(EVENT_QUICKFIXCMDPOST, au_name, - curbuf->b_fname, TRUE, curbuf); - if (!new_qi && qi != &ql_info && qf_find_buf(qi) == NULL) - /* autocommands made "qi" invalid */ + curbuf->b_fname, true, curbuf); + if (!new_qi && qi != save_qi && qf_find_buf(qi) == NULL) { + // autocommands made "qi" invalid return; + } } /* Jump to first match. */ diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 773502ede4..3d8d18cf88 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -31,7 +31,8 @@ func s:setup_commands(cchar) command! -nargs=* -bang Xnfile cnfile command! -nargs=* -bang Xpfile cpfile command! -nargs=* Xexpr cexpr - command! -nargs=* Xvimgrep vimgrep + command! -range -nargs=* Xvimgrep vimgrep + command! -nargs=* Xvimgrepadd vimgrepadd command! -nargs=* Xgrep grep command! -nargs=* Xgrepadd grepadd command! -nargs=* Xhelpgrep helpgrep @@ -61,7 +62,8 @@ func s:setup_commands(cchar) command! -nargs=* -bang Xnfile lnfile command! -nargs=* -bang Xpfile lpfile command! -nargs=* Xexpr lexpr - command! -nargs=* Xvimgrep lvimgrep + command! -range -nargs=* Xvimgrep lvimgrep + command! -nargs=* Xvimgrepadd lvimgrepadd command! -nargs=* Xgrep lgrep command! -nargs=* Xgrepadd lgrepadd command! -nargs=* Xhelpgrep lhelpgrep @@ -85,57 +87,52 @@ func XlistTests(cchar) \ 'non-error 3', 'Xtestfile3:3:1:Line3'] " List only valid entries - redir => result - Xlist - redir END - let l = split(result, "\n") + let l = split(execute('Xlist', ''), "\n") call assert_equal([' 2 Xtestfile1:1 col 3: Line1', \ ' 4 Xtestfile2:2 col 2: Line2', \ ' 6 Xtestfile3:3 col 1: Line3'], l) " List all the entries - redir => result - Xlist! - redir END - let l = split(result, "\n") + let l = split(execute('Xlist!', ''), "\n") call assert_equal([' 1: non-error 1', ' 2 Xtestfile1:1 col 3: Line1', \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2', \ ' 5: non-error 3', ' 6 Xtestfile3:3 col 1: Line3'], l) " List a range of errors - redir => result - Xlist 3,6 - redir END - let l = split(result, "\n") + let l = split(execute('Xlist 3,6', ''), "\n") call assert_equal([' 4 Xtestfile2:2 col 2: Line2', \ ' 6 Xtestfile3:3 col 1: Line3'], l) - redir => result - Xlist! 3,4 - redir END - let l = split(result, "\n") + let l = split(execute('Xlist! 3,4', ''), "\n") call assert_equal([' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) - redir => result - Xlist -6,-4 - redir END - let l = split(result, "\n") + let l = split(execute('Xlist -6,-4', ''), "\n") call assert_equal([' 2 Xtestfile1:1 col 3: Line1'], l) - redir => result - Xlist! -5,-3 - redir END - let l = split(result, "\n") + let l = split(execute('Xlist! -5,-3', ''), "\n") call assert_equal([' 2 Xtestfile1:1 col 3: Line1', \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) " Test for '+' - redir => result - Xlist! +2 - redir END - let l = split(result, "\n") + let l = split(execute('Xlist! +2', ''), "\n") call assert_equal([' 2 Xtestfile1:1 col 3: Line1', \ ' 3: non-error 2', ' 4 Xtestfile2:2 col 2: Line2'], l) + + " Different types of errors + call g:Xsetlist([{'lnum':10,'col':5,'type':'W', 'text':'Warning','nr':11}, + \ {'lnum':20,'col':10,'type':'e','text':'Error','nr':22}, + \ {'lnum':30,'col':15,'type':'i','text':'Info','nr':33}, + \ {'lnum':40,'col':20,'type':'x', 'text':'Other','nr':44}, + \ {'lnum':50,'col':25,'type':"\",'text':'one','nr':55}]) + let l = split(execute('Xlist', ""), "\n") + call assert_equal([' 1:10 col 5 warning 11: Warning', + \ ' 2:20 col 10 error 22: Error', + \ ' 3:30 col 15 info 33: Info', + \ ' 4:40 col 20 x 44: Other', + \ ' 5:50 col 25 55: one'], l) + + " Error cases + call assert_fails('Xlist abc', 'E488:') endfunc func Test_clist() @@ -324,6 +321,23 @@ func XbufferTests(cchar) \ l[3].lnum == 750 && l[3].col == 25 && l[3].text ==# 'Line 750') enew! + " Check for invalid buffer + call assert_fails('Xbuffer 199', 'E474:') + + " Check for unloaded buffer + edit Xtestfile1 + let bnr = bufnr('%') + enew! + call assert_fails('Xbuffer ' . bnr, 'E681:') + + " Check for invalid range + " Using Xbuffer will not run the range check in the cbuffer/lbuffer + " commands. So directly call the commands. + if (a:cchar == 'c') + call assert_fails('900,999cbuffer', 'E16:') + else + call assert_fails('900,999lbuffer', 'E16:') + endif endfunc func Test_cbuffer() @@ -372,6 +386,9 @@ func Xtest_browse(cchar) call assert_equal('Xqftestfile1', bufname('%')) call assert_equal(5, line('.')) + Xexpr "" + call assert_fails('Xnext', 'E42:') + call delete('Xqftestfile1') call delete('Xqftestfile2') endfunc @@ -393,6 +410,9 @@ func s:test_xhelpgrep(cchar) call assert_true(w:quickfix_title =~ title_text, w:quickfix_title) " This wipes out the buffer, make sure that doesn't cause trouble. Xclose + + " Search for non existing help string + call assert_fails('Xhelpgrep a1b2c3', 'E480:') endfunc func Test_helpgrep() @@ -586,7 +606,7 @@ func Test_locationlist() wincmd n | only augroup! testgroup - endfunc +endfunc func Test_locationlist_curwin_was_closed() augroup testgroup @@ -605,7 +625,7 @@ func Test_locationlist_curwin_was_closed() call assert_fails('lrewind', 'E924:') augroup! testgroup - endfunc +endfunc func Test_locationlist_cross_tab_jump() call writefile(['loclistfoo'], 'loclistfoo') @@ -742,7 +762,7 @@ func Test_efm1() call delete('Xerrorfile1') call delete('Xerrorfile2') call delete('Xtestfile') - endfunc +endfunc " Test for quickfix directory stack support func s:dir_stack_tests(cchar) @@ -901,20 +921,26 @@ func Test_efm2() call assert_equal(l[0].pattern, '^\VLine search text\$') call assert_equal(l[0].lnum, 0) + let l = split(execute('clist', ''), "\n") + call assert_equal([' 1 Xtestfile:^\VLine search text\$: '], l) + " Test for %P, %Q and %t format specifiers let lines=["[Xtestfile1]", \ "(1,17) error: ';' missing", \ "(21,2) warning: variable 'z' not defined", \ "(67,3) error: end of file found before string ended", + \ "--", \ "", \ "[Xtestfile2]", + \ "--", \ "", \ "[Xtestfile3]", \ "NEW compiler v1.1", \ "(2,2) warning: variable 'x' not defined", - \ "(67,3) warning: 's' already defined" + \ "(67,3) warning: 's' already defined", + \ "--" \] - set efm=%+P[%f],(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%-Q + set efm=%+P[%f]%r,(%l\\,%c)%*[\ ]%t%*[^:]:\ %m,%+Q--%r " To exercise the push/pop file functionality in quickfix, the test files " need to be created. call writefile(['Line1'], 'Xtestfile1') @@ -925,7 +951,7 @@ func Test_efm2() caddexpr l endfor let l = getqflist() - call assert_equal(9, len(l)) + call assert_equal(12, len(l)) call assert_equal(21, l[2].lnum) call assert_equal(2, l[2].col) call assert_equal('w', l[2].type) @@ -1080,6 +1106,13 @@ func SetXlistTests(cchar, bnum) call g:Xsetlist([]) let l = g:Xgetlist() call assert_equal(0, len(l)) + + " Error cases: + " Refer to a non-existing buffer and pass a non-dictionary type + call assert_fails("call g:Xsetlist([{'bufnr':998, 'lnum':4}," . + \ " {'bufnr':999, 'lnum':5}])", 'E92:') + call g:Xsetlist([[1, 2,3]]) + call assert_equal(0, len(g:Xgetlist())) endfunc func Test_setqflist() @@ -1098,7 +1131,8 @@ func Xlist_empty_middle(cchar) call s:setup_commands(a:cchar) " create three quickfix lists - Xvimgrep Test_ test_quickfix.vim + let @/ = 'Test_' + Xvimgrep // test_quickfix.vim let testlen = len(g:Xgetlist()) call assert_true(testlen > 0) Xvimgrep empty test_quickfix.vim @@ -1591,6 +1625,22 @@ func Xproperty_tests(cchar) call g:Xsetlist([], ' ', {'title' : 'N3'}) call assert_equal('N2', g:Xgetlist({'nr':2, 'title':1}).title) + " Changing the title of an earlier quickfix list + call g:Xsetlist([], ' ', {'title' : 'NewTitle', 'nr' : 2}) + call assert_equal('NewTitle', g:Xgetlist({'nr':2, 'title':1}).title) + + " Changing the title of an invalid quickfix list + call assert_equal(-1, g:Xsetlist([], ' ', + \ {'title' : 'SomeTitle', 'nr' : 99})) + call assert_equal(-1, g:Xsetlist([], ' ', + \ {'title' : 'SomeTitle', 'nr' : 'abc'})) + + if a:cchar == 'c' + copen + call assert_equal({'winid':win_getid()}, getqflist({'winid':1})) + cclose + endif + " Invalid arguments call assert_fails('call g:Xgetlist([])', 'E715') call assert_fails('call g:Xsetlist([], "a", [])', 'E715') @@ -1598,16 +1648,18 @@ func Xproperty_tests(cchar) call assert_equal(-1, s) call assert_equal({}, g:Xgetlist({'abc':1})) + call assert_equal({}, g:Xgetlist({'nr':99, 'title':1})) + call assert_equal({}, g:Xgetlist({'nr':[], 'title':1})) if a:cchar == 'l' - call assert_equal({}, getloclist(99, {'title': 1})) + call assert_equal({}, getloclist(99, {'title': 1})) endif - endfunc +endfunc func Test_qf_property() call Xproperty_tests('c') call Xproperty_tests('l') - endfunc +endfunc " Tests for the QuickFixCmdPre/QuickFixCmdPost autocommands func QfAutoCmdHandler(loc, cmd) @@ -1756,3 +1808,55 @@ func Test_cwindow_jump() enew | only set efm&vim endfunc + +func XvimgrepTests(cchar) + call s:setup_commands(a:cchar) + + call writefile(['Editor:VIM vim', + \ 'Editor:Emacs EmAcS', + \ 'Editor:Notepad NOTEPAD'], 'Xtestfile1') + call writefile(['Linux', 'MacOS', 'MS-Windows'], 'Xtestfile2') + + " Error cases + call assert_fails('Xvimgrep /abc *', 'E682:') + + let @/='' + call assert_fails('Xvimgrep // *', 'E35:') + + call assert_fails('Xvimgrep abc', 'E683:') + call assert_fails('Xvimgrep a1b2c3 Xtestfile1', 'E480:') + call assert_fails('Xvimgrep pat Xa1b2c3', 'E480:') + + Xexpr "" + Xvimgrepadd Notepad Xtestfile1 + Xvimgrepadd MacOS Xtestfile2 + let l = g:Xgetlist() + call assert_equal(2, len(l)) + call assert_equal('Editor:Notepad NOTEPAD', l[0].text) + + Xvimgrep #\cvim#g Xtestfile? + let l = g:Xgetlist() + call assert_equal(2, len(l)) + call assert_equal(8, l[0].col) + call assert_equal(12, l[1].col) + + 1Xvimgrep ?Editor? Xtestfile* + let l = g:Xgetlist() + call assert_equal(1, len(l)) + call assert_equal('Editor:VIM vim', l[0].text) + + edit +3 Xtestfile2 + Xvimgrep +\cemacs+j Xtestfile1 + let l = g:Xgetlist() + call assert_equal('Xtestfile2', bufname('')) + call assert_equal('Editor:Emacs EmAcS', l[0].text) + + call delete('Xtestfile1') + call delete('Xtestfile2') +endfunc + +" Tests for the :vimgrep command +func Test_vimgrep() + call XvimgrepTests('c') + call XvimgrepTests('l') +endfunc -- cgit From fb8592b7ba673f230f144dc8c29e5dffc33fc50a Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 18 Dec 2017 14:26:49 -0500 Subject: vim-patch:8.0.0517: there is no way to remove quickfix lists Problem: There is no way to remove quickfix lists (for testing). Solution: Add the 'f' action to setqflist(). Add tests. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/b6fa30ccc39cdb7f1d07b99fe2f4c6b61671dac2 --- src/nvim/eval.c | 3 ++- src/nvim/quickfix.c | 15 ++++++++++++- src/nvim/testdir/test_quickfix.vim | 46 +++++++++++++++++++++++++++++++++----- 3 files changed, 56 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 7fa9f7563e..1461ddb8f9 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -14594,7 +14594,8 @@ static void set_qf_ll_list(win_T *wp, typval_T *args, typval_T *rettv) return; } const char *const act = tv_get_string_chk(action_arg); - if ((*act == 'a' || *act == 'r' || *act == ' ') && act[1] == NUL) { + if ((*act == 'a' || *act == 'r' || *act == ' ' || *act == 'f') + && act[1] == NUL) { action = *act; } else { EMSG2(_(e_invact), act); diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 6d59d15515..c7326c46fe 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4267,6 +4267,16 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action) return retval; } +static void qf_free_stack(win_T *wp, qf_info_T *qi) +{ + qf_free_all(wp); + if (wp == NULL) { + // quickfix list + qi->qf_curlist = 0; + qi->qf_listcount = 0; + } +} + // Populate the quickfix list with the items supplied in the list // of dictionaries. "title" will be copied to w:quickfix_title // "action" is 'a' for add, 'r' for replace. Otherwise create a new list. @@ -4280,7 +4290,10 @@ int set_errorlist(win_T *wp, list_T *list, int action, char_u *title, qi = ll_get_or_alloc_list(wp); } - if (what != NULL) { + if (action == 'f') { + // Free the entire quickfix or location list stack + qf_free_stack(wp, qi); + } else if (what != NULL) { retval = qf_set_properties(qi, what, action); } else { retval = qf_add_entries(qi, list, title, action); diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 3d8d18cf88..b953df3fc8 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -38,6 +38,7 @@ func s:setup_commands(cchar) command! -nargs=* Xhelpgrep helpgrep let g:Xgetlist = function('getqflist') let g:Xsetlist = function('setqflist') + call setqflist([], 'f') else command! -nargs=* -bang Xlist llist command! -nargs=* Xgetexpr lgetexpr @@ -69,6 +70,7 @@ func s:setup_commands(cchar) command! -nargs=* Xhelpgrep lhelpgrep let g:Xgetlist = function('getloclist', [0]) let g:Xsetlist = function('setloclist', [0]) + call setloclist(0, [], 'f') endif endfunc @@ -76,6 +78,9 @@ endfunc func XlistTests(cchar) call s:setup_commands(a:cchar) + if a:cchar == 'l' + call assert_fails('llist', 'E776:') + endif " With an empty list, command should return error Xgetexpr [] silent! Xlist @@ -146,6 +151,9 @@ endfunc func XageTests(cchar) call s:setup_commands(a:cchar) + let list = [{'bufnr': 1, 'lnum': 1}] + call g:Xsetlist(list) + " Jumping to a non existent list should return error silent! Xolder 99 call assert_true(v:errmsg ==# 'E380: At bottom of quickfix stack') @@ -179,11 +187,7 @@ func XageTests(cchar) endfunc func Test_cage() - let list = [{'bufnr': 1, 'lnum': 1}] - call setqflist(list) call XageTests('c') - - call setloclist(0, list) call XageTests('l') endfunc @@ -192,6 +196,11 @@ endfunc func XwindowTests(cchar) call s:setup_commands(a:cchar) + " Opening the location list window without any errors should fail + if a:cchar == 'l' + call assert_fails('lopen', 'E776:') + endif + " Create a list with no valid entries Xgetexpr ['non-error 1', 'non-error 2', 'non-error 3'] @@ -232,6 +241,19 @@ func XwindowTests(cchar) " Calling cwindow should close the quickfix window with no valid errors Xwindow call assert_true(winnr('$') == 1) + + if a:cchar == 'c' + " Opening the quickfix window in multiple tab pages should reuse the + " quickfix buffer + Xgetexpr ['Xtestfile1:1:3:Line1', 'Xtestfile2:2:2:Line2', + \ 'Xtestfile3:3:1:Line3'] + Xopen + let qfbufnum = bufnr('%') + tabnew + Xopen + call assert_equal(qfbufnum, bufnr('%')) + new | only | tabonly + endif endfunc func Test_cwindow() @@ -360,6 +382,13 @@ endfunc func Xtest_browse(cchar) call s:setup_commands(a:cchar) + " Jumping to first or next location list entry without any error should + " result in failure + if a:cchar == 'l' + call assert_fails('lfirst', 'E776:') + call assert_fails('lnext', 'E776:') + endif + call s:create_test_file('Xqftestfile1') call s:create_test_file('Xqftestfile2') @@ -1532,6 +1561,11 @@ endfunc func XbottomTests(cchar) call s:setup_commands(a:cchar) + " Calling lbottom without any errors should fail + if a:cchar == 'l' + call assert_fails('lbottom', 'E776:') + endif + call g:Xsetlist([{'filename': 'foo', 'lnum': 42}]) Xopen let wid = win_getid() @@ -1553,10 +1587,9 @@ endfunc func HistoryTest(cchar) call s:setup_commands(a:cchar) - call assert_fails(a:cchar . 'older 99', 'E380:') " clear all lists after the first one, then replace the first one. call g:Xsetlist([]) - Xolder + call assert_fails('Xolder 99', 'E380:') let entry = {'filename': 'foo', 'lnum': 42} call g:Xsetlist([entry], 'r') call g:Xsetlist([entry, entry]) @@ -1599,6 +1632,7 @@ func Xproperty_tests(cchar) call assert_fails('call g:Xsetlist([], "a", [])', 'E715:') " Set and get the title + call g:Xsetlist([]) Xopen wincmd p call g:Xsetlist([{'filename':'foo', 'lnum':27}]) -- cgit From f0bd2bc39aeb7797e3dd5c14797606dac45c8a75 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 18 Dec 2017 14:36:13 -0500 Subject: vim-patch:8.0.0536: quickfix window not updated when freeing quickfix stack Problem: Quickfix window not updated when freeing quickfix stack. Solution: Update the quickfix window. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/69f40be64555d50f603c6f22722cf762aaa6bbc1 --- src/nvim/quickfix.c | 44 ++++++++++++++++++++++++++ src/nvim/testdir/test_quickfix.vim | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index c7326c46fe..9a4341f3a4 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4267,13 +4267,57 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action) return retval; } +// Find the non-location list window with the specified location list. +static win_T * find_win_with_ll(qf_info_T *qi) +{ + FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { + if ((wp->w_llist == qi) && !bt_quickfix(wp->w_buffer)) { + return wp; + } + } + + return NULL; +} + +// Free the entire quickfix/location list stack. +// If the quickfix/location list window is open, then clear it. static void qf_free_stack(win_T *wp, qf_info_T *qi) { + win_T *qfwin = qf_find_win(qi); + + if (qfwin != NULL) { + // If the quickfix/location list window is open, then clear it + if (qi->qf_curlist < qi->qf_listcount) { + qf_free(qi, qi->qf_curlist); + } + qf_update_buffer(qi, NULL); + } + + win_T *llwin = NULL; + win_T *orig_wp = wp; + if (wp != NULL && IS_LL_WINDOW(wp)) { + // If in the location list window, then use the non-location list + // window with this location list (if present) + llwin = find_win_with_ll(qi); + if (llwin != NULL) { + wp = llwin; + } + } + qf_free_all(wp); if (wp == NULL) { // quickfix list qi->qf_curlist = 0; qi->qf_listcount = 0; + } else if (IS_LL_WINDOW(orig_wp)) { + // If the location list window is open, then create a new empty location + // list + qf_info_T *new_ll = ll_new_list(); + orig_wp->w_llist_ref = new_ll; + if (llwin != NULL) { + llwin->w_llist = new_ll; + new_ll->qf_refcount++; + } } } diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index b953df3fc8..40ad387dee 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -1894,3 +1894,66 @@ func Test_vimgrep() call XvimgrepTests('c') call XvimgrepTests('l') endfunc + +func XfreeTests(cchar) + call s:setup_commands(a:cchar) + + enew | only + + " Deleting the quickfix stack should work even When the current list is + " somewhere in the middle of the stack + Xexpr ['Xfile1:10:10:Line 10', 'Xfile1:15:15:Line 15'] + Xexpr ['Xfile2:20:20:Line 20', 'Xfile2:25:25:Line 25'] + Xexpr ['Xfile3:30:30:Line 30', 'Xfile3:35:35:Line 35'] + Xolder + call g:Xsetlist([], 'f') + call assert_equal(0, len(g:Xgetlist())) + + " After deleting the stack, adding a new list should create a stack with a + " single list. + Xexpr ['Xfile1:10:10:Line 10', 'Xfile1:15:15:Line 15'] + call assert_equal(1, g:Xgetlist({'all':1}).nr) + + " Deleting the stack from a quickfix window should update/clear the + " quickfix/location list window. + Xexpr ['Xfile1:10:10:Line 10', 'Xfile1:15:15:Line 15'] + Xexpr ['Xfile2:20:20:Line 20', 'Xfile2:25:25:Line 25'] + Xexpr ['Xfile3:30:30:Line 30', 'Xfile3:35:35:Line 35'] + Xolder + Xwindow + call g:Xsetlist([], 'f') + call assert_equal(2, winnr('$')) + call assert_equal(1, line('$')) + Xclose + + " Deleting the stack from a non-quickfix window should update/clear the + " quickfix/location list window. + Xexpr ['Xfile1:10:10:Line 10', 'Xfile1:15:15:Line 15'] + Xexpr ['Xfile2:20:20:Line 20', 'Xfile2:25:25:Line 25'] + Xexpr ['Xfile3:30:30:Line 30', 'Xfile3:35:35:Line 35'] + Xolder + Xwindow + wincmd p + call g:Xsetlist([], 'f') + call assert_equal(0, len(g:Xgetlist())) + wincmd p + call assert_equal(2, winnr('$')) + call assert_equal(1, line('$')) + + " After deleting the location list stack, if the location list window is + " opened, then a new location list should be created. So opening the + " location list window again should not create a new window. + if a:cchar == 'l' + lexpr ['Xfile1:10:10:Line 10', 'Xfile1:15:15:Line 15'] + wincmd p + lopen + call assert_equal(2, winnr('$')) + endif + Xclose +endfunc + +" Tests for the quickifx free functionality +func Test_qf_free() + call XfreeTests('c') + call XfreeTests('l') +endfunc -- cgit From 765ff94b5be90bc33eb8eba3fdfe3e910124450d Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 18 Dec 2017 14:56:49 -0500 Subject: vim-patch:8.0.0584: memory leak when executing quickfix tests Problem: Memory leak when executing quickfix tests. Solution: Free the list reference. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/d788f6fe89c77262c474de323f5dab6d1c814e27 --- src/nvim/quickfix.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 9a4341f3a4..73ad14ab22 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4313,6 +4313,10 @@ static void qf_free_stack(win_T *wp, qf_info_T *qi) // If the location list window is open, then create a new empty location // list qf_info_T *new_ll = ll_new_list(); + + // first free the list reference in the location list window + ll_free_all(&orig_wp->w_llist_ref); + orig_wp->w_llist_ref = new_ll; if (llwin != NULL) { llwin->w_llist = new_ll; -- cgit From 1b2d386a852fcdf1f7509dc29f2a26ab8e5b59ca Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 18 Dec 2017 21:35:40 -0500 Subject: vim-patch:8.0.0565: using freed memory in :caddbuf Problem: Using freed memory in :caddbuf after clearing quickfix list. (Dominique Pelle) Solution: Set qf_last to NULL. https://github.com/vim/vim/commit/31bdd13c335533c749993b57dcd980a87373139e --- src/nvim/quickfix.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 73ad14ab22..be998077c0 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -2411,6 +2411,7 @@ static void qf_free(qf_info_T *qi, int idx) qi->qf_lists[idx].qf_ptr = NULL; qi->qf_lists[idx].qf_title = NULL; qi->qf_lists[idx].qf_index = 0; + qi->qf_lists[idx].qf_last = NULL; qf_clean_dir_stack(&qi->qf_dir_stack); qi->qf_directory = NULL; -- cgit From dd2739286195c8953a31346908f02a85563a3fa2 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 18 Dec 2017 21:37:11 -0500 Subject: vim-patch:8.0.0574: get only one quickfix list after :caddbuf Problem: Get only one quickfix list after :caddbuf. Solution: Reset qf_multiline. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/99895eac1cf71be43ece7e14b50e206e041fbe9f --- src/nvim/quickfix.c | 6 +++ src/nvim/testdir/test_quickfix.vim | 89 +++++++++++++++++++++++++++++++------- 2 files changed, 80 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index be998077c0..ee3bb1dfba 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -2411,12 +2411,18 @@ static void qf_free(qf_info_T *qi, int idx) qi->qf_lists[idx].qf_ptr = NULL; qi->qf_lists[idx].qf_title = NULL; qi->qf_lists[idx].qf_index = 0; + qi->qf_lists[idx].qf_start = NULL; qi->qf_lists[idx].qf_last = NULL; + qi->qf_lists[idx].qf_ptr = NULL; + qi->qf_lists[idx].qf_nonevalid = true; qf_clean_dir_stack(&qi->qf_dir_stack); qi->qf_directory = NULL; qf_clean_dir_stack(&qi->qf_file_stack); qi->qf_currfile = NULL; + qi->qf_multiline = false; + qi->qf_multiignore = false; + qi->qf_multiscan = false; } /* diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 40ad387dee..e729290c1e 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -24,8 +24,8 @@ func s:setup_commands(cchar) command! -nargs=* Xgetbuffer cgetbuffer command! -nargs=* Xaddbuffer caddbuffer command! -nargs=* Xrewind crewind - command! -nargs=* -bang Xnext cnext - command! -nargs=* -bang Xprev cprev + command! -count -nargs=* -bang Xnext cnext + command! -count -nargs=* -bang Xprev cprev command! -nargs=* -bang Xfirst cfirst command! -nargs=* -bang Xlast clast command! -nargs=* -bang Xnfile cnfile @@ -56,8 +56,8 @@ func s:setup_commands(cchar) command! -nargs=* Xgetbuffer lgetbuffer command! -nargs=* Xaddbuffer laddbuffer command! -nargs=* Xrewind lrewind - command! -nargs=* -bang Xnext lnext - command! -nargs=* -bang Xprev lprev + command! -count -nargs=* -bang Xnext lnext + command! -count -nargs=* -bang Xprev lprev command! -nargs=* -bang Xfirst lfirst command! -nargs=* -bang Xlast llast command! -nargs=* -bang Xnfile lnfile @@ -395,7 +395,9 @@ func Xtest_browse(cchar) Xgetexpr ['Xqftestfile1:5:Line5', \ 'Xqftestfile1:6:Line6', \ 'Xqftestfile2:10:Line10', - \ 'Xqftestfile2:11:Line11'] + \ 'Xqftestfile2:11:Line11', + \ 'RegularLine1', + \ 'RegularLine2'] Xfirst call assert_fails('Xprev', 'E553') @@ -407,6 +409,7 @@ func Xtest_browse(cchar) call assert_equal('Xqftestfile1', bufname('%')) call assert_equal(6, line('.')) Xlast + Xprev call assert_equal('Xqftestfile2', bufname('%')) call assert_equal(11, line('.')) call assert_fails('Xnext', 'E553') @@ -415,6 +418,13 @@ func Xtest_browse(cchar) call assert_equal('Xqftestfile1', bufname('%')) call assert_equal(5, line('.')) + 10Xnext + call assert_equal('Xqftestfile2', bufname('%')) + call assert_equal(11, line('.')) + 10Xprev + call assert_equal('Xqftestfile1', bufname('%')) + call assert_equal(5, line('.')) + Xexpr "" call assert_fails('Xnext', 'E42:') @@ -437,9 +447,30 @@ func s:test_xhelpgrep(cchar) let title_text = ':lhelpgrep quickfix' endif call assert_true(w:quickfix_title =~ title_text, w:quickfix_title) + + " Jumping to a help topic should open the help window + only + Xnext + call assert_true(&buftype == 'help') + call assert_true(winnr('$') == 2) + " Jumping to the next match should reuse the help window + Xnext + call assert_true(&buftype == 'help') + call assert_true(winnr() == 1) + call assert_true(winnr('$') == 2) + " Jumping to the next match from the quickfix window should reuse the help + " window + Xopen + Xnext + call assert_true(&buftype == 'help') + call assert_true(winnr() == 1) + call assert_true(winnr('$') == 2) + " This wipes out the buffer, make sure that doesn't cause trouble. Xclose + new | only + " Search for non existing help string call assert_fails('Xhelpgrep a1b2c3', 'E480:') endfunc @@ -578,10 +609,7 @@ func Test_locationlist() lrewind enew lopen - lnext - lnext - lnext - lnext + 4lnext vert split wincmd L lopen @@ -1039,6 +1067,25 @@ func Test_efm2() call assert_equal(1, l[4].valid) call assert_equal('unittests/dbfacadeTest.py', bufname(l[4].bufnr)) + " The following sequence of commands used to crash Vim + set efm=%W%m + cgetexpr ['msg1'] + let l = getqflist() + call assert_equal(1, len(l), string(l)) + call assert_equal('msg1', l[0].text) + set efm=%C%m + lexpr 'msg2' + let l = getloclist(0) + call assert_equal(1, len(l), string(l)) + call assert_equal('msg2', l[0].text) + lopen + call setqflist([], 'r') + caddbuf + let l = getqflist() + call assert_equal(1, len(l), string(l)) + call assert_equal('|| msg2', l[0].text) + + new | only let &efm = save_efm endfunc @@ -1369,18 +1416,18 @@ func Test_switchbuf() let winid = win_getid() cfirst | cnext call assert_equal(winid, win_getid()) - cnext | cnext + 2cnext call assert_equal(winid, win_getid()) - cnext | cnext + 2cnext call assert_equal(winid, win_getid()) enew set switchbuf=useopen cfirst | cnext call assert_equal(file1_winid, win_getid()) - cnext | cnext + 2cnext call assert_equal(file2_winid, win_getid()) - cnext | cnext + 2cnext call assert_equal(file2_winid, win_getid()) enew | only @@ -1390,9 +1437,9 @@ func Test_switchbuf() tabfirst cfirst | cnext call assert_equal(2, tabpagenr()) - cnext | cnext + 2cnext call assert_equal(3, tabpagenr()) - cnext | cnext + 2cnext call assert_equal(3, tabpagenr()) tabfirst | tabonly | enew @@ -1957,3 +2004,15 @@ func Test_qf_free() call XfreeTests('c') call XfreeTests('l') endfunc + +func Test_no_reuse_mem() + set efm=E,%W%m, + cgetexpr ['C'] + set efm=%C%m + lexpr '0' + lopen + call setqflist([], 'r') + caddbuf + + set efm& +endfunc -- cgit From 9fb7926a0dbc08daf19fca5eb93f95ae83a6303c Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 18 Dec 2017 21:40:08 -0500 Subject: vim-patch:8.0.0579: duplicate test case for quickfix Problem: Duplicate test case for quickfix. Solution: Remove the function. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/9b77016545d5ef1a1f4a90c9bb4b7a6693af8918 --- src/nvim/testdir/test_quickfix.vim | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index e729290c1e..7e4100cca0 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -2004,15 +2004,3 @@ func Test_qf_free() call XfreeTests('c') call XfreeTests('l') endfunc - -func Test_no_reuse_mem() - set efm=E,%W%m, - cgetexpr ['C'] - set efm=%C%m - lexpr '0' - lopen - call setqflist([], 'r') - caddbuf - - set efm& -endfunc -- cgit From 4d2d844c12e1a94a5d3cbe93794bb04ef6fb8377 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 18 Dec 2017 21:40:34 -0500 Subject: vim-patch:8.0.0580: cannot set the valid flag with setqflist() Problem: Cannot set the valid flag with setqflist(). Solution: Add the "valid" argument. (Yegappan Lakshmanan, closes vim/vim#1642) https://github.com/vim/vim/commit/f1d21c8cc83f40c815b6bf13cd2043152db533ee --- src/nvim/quickfix.c | 5 +++++ src/nvim/testdir/test_quickfix.vim | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index ee3bb1dfba..d77cec4fd8 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4189,6 +4189,11 @@ static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title, bufnum = 0; } + // If the 'valid' field is present it overrules the detected value. + if (tv_dict_find(d, "valid", -1) != NULL) { + valid = (int)tv_dict_get_number(d, "valid"); + } + int status = qf_add_entry(qi, NULL, // dir (char_u *)filename, diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 7e4100cca0..dd64e37ce3 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -1183,6 +1183,25 @@ func SetXlistTests(cchar, bnum) let l = g:Xgetlist() call assert_equal(0, len(l)) + " Tests for setting the 'valid' flag + call g:Xsetlist([{'bufnr':a:bnum, 'lnum':4, 'valid':0}]) + Xwindow + call assert_equal(1, winnr('$')) + let l = g:Xgetlist() + call g:Xsetlist(l) + call assert_equal(0, g:Xgetlist()[0].valid) + call g:Xsetlist([{'text':'Text1', 'valid':1}]) + Xwindow + call assert_equal(2, winnr('$')) + Xclose + let save_efm = &efm + set efm=%m + Xgetexpr 'TestMessage' + let l = g:Xgetlist() + call g:Xsetlist(l) + call assert_equal(1, g:Xgetlist()[0].valid) + let &efm = save_efm + " Error cases: " Refer to a non-existing buffer and pass a non-dictionary type call assert_fails("call g:Xsetlist([{'bufnr':998, 'lnum':4}," . -- cgit From 20708a07bfc1de2c56657123c41bb52919a728d8 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 19 Dec 2017 08:39:09 -0500 Subject: vim-patch:8.0.0590: cannot add a context to locations Problem: Cannot add a context to locations. Solution: Add the "context" entry in location entries. (Yegappan Lakshmanan, closes vim/vim#1012) https://github.com/vim/vim/commit/8f77c5a4ec756f3f866bd6b18feb6fca6f2a2e91 --- src/nvim/eval.c | 2 ++ src/nvim/quickfix.c | 71 ++++++++++++++++++++++++++++++++++++++ src/nvim/testdir/test_quickfix.vim | 32 +++++++++++++++++ 3 files changed, 105 insertions(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 1461ddb8f9..2355c8c813 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5173,6 +5173,8 @@ bool garbage_collect(bool testing) ABORTING(set_ref_list)(sub.additional_elements, copyID); } + ABORTING(set_ref_in_quickfix)(copyID); + bool did_free = false; if (!abort) { // 2. Free lists and dictionaries that are not referenced. diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index d77cec4fd8..e7d11df833 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -85,6 +85,7 @@ typedef struct qf_list_S { int qf_nonevalid; // TRUE if not a single valid entry found char_u *qf_title; // title derived from the command that created // the error list + typval_T *qf_ctx; // context set by setqflist/setloclist } qf_list_T; struct qf_info_S { @@ -1409,6 +1410,13 @@ void copy_loclist(win_T *from, win_T *to) else to_qfl->qf_title = NULL; + if (from_qfl->qf_ctx != NULL) { + to_qfl->qf_ctx = xcalloc(1, sizeof(typval_T)); + tv_copy(from_qfl->qf_ctx, to_qfl->qf_ctx); + } else { + to_qfl->qf_ctx = NULL; + } + if (from_qfl->qf_count) { qfline_T *from_qfp; qfline_T *prevp; @@ -2410,6 +2418,8 @@ static void qf_free(qf_info_T *qi, int idx) qi->qf_lists[idx].qf_start = NULL; qi->qf_lists[idx].qf_ptr = NULL; qi->qf_lists[idx].qf_title = NULL; + tv_free(qi->qf_lists[idx].qf_ctx); + qi->qf_lists[idx].qf_ctx = NULL; qi->qf_lists[idx].qf_index = 0; qi->qf_lists[idx].qf_start = NULL; qi->qf_lists[idx].qf_last = NULL; @@ -4060,6 +4070,7 @@ enum { QF_GETLIST_ITEMS = 0x2, QF_GETLIST_NR = 0x4, QF_GETLIST_WINID = 0x8, + QF_GETLIST_CONTEXT = 0x10, QF_GETLIST_ALL = 0xFF }; @@ -4110,6 +4121,10 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) flags |= QF_GETLIST_WINID; } + if (tv_dict_find(what, S_LEN("context")) != NULL) { + flags |= QF_GETLIST_CONTEXT; + } + if (flags & QF_GETLIST_TITLE) { char_u *t = qi->qf_lists[qf_idx].qf_title; if (t == NULL) { @@ -4127,6 +4142,18 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) } } + if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) { + if (qi->qf_lists[qf_idx].qf_ctx != NULL) { + di = tv_dict_item_alloc_len(S_LEN("context")); + if (di != NULL) { + tv_copy(qi->qf_lists[qf_idx].qf_ctx, &di->di_tv); + tv_dict_add(retdict, di); + } + } else { + status = tv_dict_add_str(retdict, S_LEN("context"), ""); + } + } + return status; } @@ -4276,6 +4303,14 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action) } } + if ((di = tv_dict_find(what, S_LEN("context"))) != NULL) { + tv_free(qi->qf_lists[qi->qf_curlist].qf_ctx); + + typval_T *ctx = xcalloc(1, sizeof(typval_T)); + tv_copy(&di->di_tv, ctx); + qi->qf_lists[qi->qf_curlist].qf_ctx = ctx; + } + return retval; } @@ -4362,6 +4397,42 @@ int set_errorlist(win_T *wp, list_T *list, int action, char_u *title, return retval; } +static bool mark_quickfix_ctx(qf_info_T *qi, int copyID) +{ + bool abort = false; + + for (int i = 0; i < LISTCOUNT && !abort; i++) { + typval_T *ctx = qi->qf_lists[i].qf_ctx; + if (ctx != NULL && ctx->v_type != VAR_NUMBER + && ctx->v_type != VAR_STRING && ctx->v_type != VAR_FLOAT) { + abort = set_ref_in_item(ctx, copyID, NULL, NULL); + } + } + + return abort; +} + +/// Mark the context of the quickfix list and the location lists (if present) as +/// "in use". So that garabage collection doesn't free the context. +bool set_ref_in_quickfix(int copyID) +{ + bool abort = mark_quickfix_ctx(&ql_info, copyID); + if (abort) { + return abort; + } + + FOR_ALL_TAB_WINDOWS(tp, win) { + if (win->w_llist != NULL) { + abort = mark_quickfix_ctx(win->w_llist, copyID); + if (abort) { + return abort; + } + } + } + + return abort; +} + /* * ":[range]cbuffer [bufnr]" command. * ":[range]caddbuffer [bufnr]" command. diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index dd64e37ce3..1d17da31ed 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -1754,6 +1754,38 @@ func Xproperty_tests(cchar) if a:cchar == 'l' call assert_equal({}, getloclist(99, {'title': 1})) endif + + " Context related tests + call g:Xsetlist([], 'a', {'context':[1,2,3]}) + call test_garbagecollect_now() + let d = g:Xgetlist({'context':1}) + call assert_equal([1,2,3], d.context) + call g:Xsetlist([], 'a', {'context':{'color':'green'}}) + let d = g:Xgetlist({'context':1}) + call assert_equal({'color':'green'}, d.context) + call g:Xsetlist([], 'a', {'context':"Context info"}) + let d = g:Xgetlist({'context':1}) + call assert_equal("Context info", d.context) + call g:Xsetlist([], 'a', {'context':246}) + let d = g:Xgetlist({'context':1}) + call assert_equal(246, d.context) + if a:cchar == 'l' + " Test for copying context across two different location lists + new | only + let w1_id = win_getid() + let l = [1] + call setloclist(0, [], 'a', {'context':l}) + new + let w2_id = win_getid() + call add(l, 2) + call assert_equal([1, 2], getloclist(w1_id, {'context':1}).context) + call assert_equal([1, 2], getloclist(w2_id, {'context':1}).context) + unlet! l + call assert_equal([1, 2], getloclist(w2_id, {'context':1}).context) + only + call setloclist(0, [], 'f') + call assert_equal({}, getloclist(0, {'context':1})) + endif endfunc func Test_qf_property() -- cgit From 6fcadab3ce16ff29be53176f8658e61819691df1 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 19 Dec 2017 10:41:50 -0500 Subject: vim-patch:8.0.0595: Coverity warning for not checking return value Problem: Coverity warning for not checking return value of dict_add(). Solution: Check the return value for FAIL. https://github.com/vim/vim/commit/beb9cb19c660484488a71a25eda46ab0fa579278 --- src/nvim/quickfix.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index e7d11df833..df735e32a9 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4147,7 +4147,9 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) di = tv_dict_item_alloc_len(S_LEN("context")); if (di != NULL) { tv_copy(qi->qf_lists[qf_idx].qf_ctx, &di->di_tv); - tv_dict_add(retdict, di); + if (tv_dict_add(retdict, di) == FAIL) { + tv_dict_item_free(di); + } } } else { status = tv_dict_add_str(retdict, S_LEN("context"), ""); -- cgit From cdd86f42cf93135d1c4dddcc2ba13b9798034350 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 19 Dec 2017 10:48:31 -0500 Subject: vim-patch:8.0.0597: off-by-one error in size computation Problem: Off-by-one error in buffer size computation. Solution: Use ">=" instead of ">". (Lemonboy, closes vim/vim#1694) https://github.com/vim/vim/commit/253f9128779f315ea670f9b4a17446b7b4c74927 --- src/nvim/quickfix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index df735e32a9..3608a41a6e 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -801,7 +801,7 @@ restofline: fields->type = *regmatch.startp[i]; } if (fmt_ptr->flags == '+' && !qi->qf_multiscan) { // %+ - if (linelen > fields->errmsglen) { + if (linelen >= fields->errmsglen) { // linelen + null terminator fields->errmsg = xrealloc(fields->errmsg, linelen + 1); fields->errmsglen = linelen + 1; @@ -812,7 +812,7 @@ restofline: continue; } len = (size_t)(regmatch.endp[i] - regmatch.startp[i]); - if (len > fields->errmsglen) { + if (len >= fields->errmsglen) { // len + null terminator fields->errmsg = xrealloc(fields->errmsg, len + 1); fields->errmsglen = len + 1; @@ -889,7 +889,7 @@ restofline: fields->namebuf[0] = NUL; // no match found, remove file name fields->lnum = 0; // don't jump to this line fields->valid = false; - if (linelen > fields->errmsglen) { + if (linelen >= fields->errmsglen) { // linelen + null terminator fields->errmsg = xrealloc(fields->errmsg, linelen + 1); fields->errmsglen = linelen + 1; -- cgit From 190814bdae496c0ce4dfb524f9bb5ee7a09b4f60 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Tue, 19 Dec 2017 10:53:59 -0500 Subject: vim-patch:8.0.0606: cannot set the context for a specified quickfix list Problem: Cannot set the context for a specified quickfix list. Solution: Use the list index instead of the current list. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/6e62da3e14d32f76f60d5cc8b267059923842f17 --- src/nvim/quickfix.c | 9 +++++--- src/nvim/testdir/test_quickfix.vim | 47 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 3608a41a6e..c5d03e73f1 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4278,7 +4278,10 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action) if ((di = tv_dict_find(what, S_LEN("nr"))) != NULL) { // Use the specified quickfix/location list if (di->di_tv.v_type == VAR_NUMBER) { - qf_idx = (int)di->di_tv.vval.v_number - 1; + // for zero use the current list + if (di->di_tv.vval.v_number != 0) { + qf_idx = (int)di->di_tv.vval.v_number - 1; + } if (qf_idx < 0 || qf_idx >= qi->qf_listcount) { return FAIL; } @@ -4306,11 +4309,11 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action) } if ((di = tv_dict_find(what, S_LEN("context"))) != NULL) { - tv_free(qi->qf_lists[qi->qf_curlist].qf_ctx); + tv_free(qi->qf_lists[qf_idx].qf_ctx); typval_T *ctx = xcalloc(1, sizeof(typval_T)); tv_copy(&di->di_tv, ctx); - qi->qf_lists[qi->qf_curlist].qf_ctx = ctx; + qi->qf_lists[qf_idx].qf_ctx = ctx; } return retval; diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 1d17da31ed..30023dddc9 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -1786,6 +1786,37 @@ func Xproperty_tests(cchar) call setloclist(0, [], 'f') call assert_equal({}, getloclist(0, {'context':1})) endif + + " Test for changing the context of previous quickfix lists + call g:Xsetlist([], 'f') + Xexpr "One" + Xexpr "Two" + Xexpr "Three" + call g:Xsetlist([], ' ', {'context' : [1], 'nr' : 1}) + call g:Xsetlist([], ' ', {'context' : [2], 'nr' : 2}) + " Also, check for setting the context using quickfix list number zero. + call g:Xsetlist([], ' ', {'context' : [3], 'nr' : 0}) + call test_garbagecollect_now() + let l = g:Xgetlist({'nr' : 1, 'context' : 1}) + call assert_equal([1], l.context) + let l = g:Xgetlist({'nr' : 2, 'context' : 1}) + call assert_equal([2], l.context) + let l = g:Xgetlist({'nr' : 3, 'context' : 1}) + call assert_equal([3], l.context) + + " Test for changing the context through reference and for garbage + " collection of quickfix context + let l = ["red"] + call g:Xsetlist([], ' ', {'context' : l}) + call add(l, "blue") + let x = g:Xgetlist({'context' : 1}) + call add(x.context, "green") + call assert_equal(["red", "blue", "green"], l) + call assert_equal(["red", "blue", "green"], x.context) + unlet l + call test_garbagecollect_now() + let m = g:Xgetlist({'context' : 1}) + call assert_equal(["red", "blue", "green"], m.context) endfunc func Test_qf_property() @@ -2055,3 +2086,19 @@ func Test_qf_free() call XfreeTests('c') call XfreeTests('l') endfunc + +" Test for buffer overflow when parsing lines and adding new entries to +" the quickfix list. +func Test_bufoverflow() + set efm=%f:%l:%m + cgetexpr ['File1:100:' . repeat('x', 1025)] + + set efm=%+GCompiler:\ %.%#,%f:%l:%m + cgetexpr ['Compiler: ' . repeat('a', 1015), 'File1:10:Hello World'] + + set efm=%DEntering\ directory\ %f,%f:%l:%m + cgetexpr ['Entering directory ' . repeat('a', 1006), + \ 'File1:10:Hello World'] + set efm&vim +endfunc + -- cgit From 6c731d33f6729a272c5168d040ee4b86942c599b Mon Sep 17 00:00:00 2001 From: ckelsel Date: Thu, 21 Dec 2017 18:31:26 +0800 Subject: vim-patch:8.0.0314: getcmd*() functions are not tested Problem: getcmdtype(), getcmdpos() and getcmdline() are not tested. Solution: Add tests. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/65189a1294307abf007faab7385dc0145ba72b06 --- src/nvim/testdir/test_cmdline.vim | 32 ++++++++++++++++++++++++++++++++ src/nvim/version.c | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index ac44e09a5a..dc9790a39c 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -330,4 +330,36 @@ func Test_cmdline_search_range() bwipe! endfunc +" Tests for getcmdline(), getcmdpos() and getcmdtype() +func Check_cmdline(cmdtype) + call assert_equal('MyCmd a', getcmdline()) + call assert_equal(8, getcmdpos()) + call assert_equal(a:cmdtype, getcmdtype()) + return '' +endfunc + +func Test_getcmdtype() + call feedkeys(":MyCmd a\=Check_cmdline(':')\\", "xt") + + let cmdtype = '' + debuggreedy + call feedkeys(":debug echo 'test'\", "t") + call feedkeys("let cmdtype = \=string(getcmdtype())\\", "t") + call feedkeys("cont\", "xt") + 0debuggreedy + call assert_equal('>', cmdtype) + + call feedkeys("/MyCmd a\=Check_cmdline('/')\\", "xt") + call feedkeys("?MyCmd a\=Check_cmdline('?')\\", "xt") + + call feedkeys(":call input('Answer?')\", "t") + call feedkeys("MyCmd a\=Check_cmdline('@')\\", "xt") + + call feedkeys(":insert\MyCmd a\=Check_cmdline('-')\\", "xt") + + cnoremap Check_cmdline('=') + call feedkeys("a\=MyCmd a\\\", "xt") + cunmap +endfunc + set cpo& diff --git a/src/nvim/version.c b/src/nvim/version.c index 8ab9fc1a4b..26e15e3b15 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -942,7 +942,7 @@ static const int included_patches[] = { // 317, // 316, // 315, - // 314, + 314, // 313, // 312, 311, -- cgit From eb95b88156aa7ee022db4cf5d48656c1b5fd5a06 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Thu, 21 Dec 2017 18:40:40 +0800 Subject: vim-patch:8.0.0315: :help :[range] does not work Problem: ":help :[range]" does not work. (Tony Mechelynck) Solution: Translate to insert a backslash. https://github.com/vim/vim/commit/a76f59d817e2da31d83b4f0e978b52abe81e0ae9 --- src/nvim/ex_cmds.c | 6 ++++-- src/nvim/version.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 8616508d88..7188be5407 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -4619,7 +4619,8 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la "/\\(\\)", "/\\%(\\)", "?", ":?", "?", "g?", "g?g?", "g??", "z?", "/\\?", "/\\z(\\)", "\\=", ":s\\=", - "[count]", "[quotex]", "[range]", + "[count]", "[quotex]", + "[range]", ":[range]", "[pattern]", "\\|", "\\%$", "s/\\~", "s/\\U", "s/\\L", "s/\\1", "s/\\2", "s/\\3", "s/\\9"}; @@ -4628,7 +4629,8 @@ int find_help_tags(char_u *arg, int *num_matches, char_u ***matches, int keep_la "/\\\\(\\\\)", "/\\\\%(\\\\)", "?", ":?", "?", "g?", "g?g?", "g??", "z?", "/\\\\?", "/\\\\z(\\\\)", "\\\\=", ":s\\\\=", - "\\[count]", "\\[quotex]", "\\[range]", + "\\[count]", "\\[quotex]", + "\\[range]", ":\\[range]", "\\[pattern]", "\\\\bar", "/\\\\%\\$", "s/\\\\\\~", "s/\\\\U", "s/\\\\L", "s/\\\\1", "s/\\\\2", "s/\\\\3", "s/\\\\9"}; diff --git a/src/nvim/version.c b/src/nvim/version.c index 26e15e3b15..d511ccb0d6 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -941,7 +941,7 @@ static const int included_patches[] = { // 318, // 317, // 316, - // 315, + 315, 314, // 313, // 312, -- cgit From d2c01d529fb618889ffc25083ba14461ef22f57a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 23 Dec 2017 15:47:04 +0300 Subject: regexp: Fix linter errors --- src/nvim/regexp.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index a1332a43dd..ddc3681867 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -232,17 +232,17 @@ #define LAST_NL NUPPER + ADD_NL #define WITH_NL(op) ((op) >= FIRST_NL && (op) <= LAST_NL) -#define MOPEN 80 /* -89 Mark this point in input as start of - * \( subexpr. MOPEN + 0 marks start of - * match. */ -#define MCLOSE 90 /* -99 Analogous to MOPEN. MCLOSE + 0 marks - * end of match. */ -#define BACKREF 100 /* -109 node Match same string again \1-\9 */ - -# define ZOPEN 110 /* -119 Mark this point in input as start of - * \z( subexpr. */ -# define ZCLOSE 120 /* -129 Analogous to ZOPEN. */ -# define ZREF 130 /* -139 node Match external submatch \z1-\z9 */ +#define MOPEN 80 // -89 Mark this point in input as start of + // \( … \) subexpr. MOPEN + 0 marks start of + // match. +#define MCLOSE 90 // -99 Analogous to MOPEN. MCLOSE + 0 marks + // end of match. +#define BACKREF 100 // -109 node Match same string again \1-\9. + +# define ZOPEN 110 // -119 Mark this point in input as start of + // \z( … \) subexpr. +# define ZCLOSE 120 // -129 Analogous to ZOPEN. +# define ZREF 130 // -139 node Match external submatch \z1-\z9 #define BRACE_COMPLEX 140 /* -149 node Match nodes between m & n times */ @@ -462,11 +462,11 @@ static int toggle_Magic(int x) #define IEMSG_RET_NULL(m) return (IEMSG(m), rc_did_emsg = true, (void *)NULL) #define EMSG_RET_FAIL(m) return (EMSG(m), rc_did_emsg = true, FAIL) #define EMSG2_RET_NULL(m, c) \ - return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = true, (void *)NULL) + return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = true, (void *)NULL) #define EMSG2_RET_FAIL(m, c) \ - return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = true, FAIL) + return (EMSG2((m), (c) ? "" : "\\"), rc_did_emsg = true, FAIL) #define EMSG_ONE_RET_NULL EMSG2_RET_NULL(_( \ - "E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL) + "E369: invalid item in %s%%[]"), reg_magic == MAGIC_ALL) #define MAX_LIMIT (32767L << 16L) -- cgit From 5cb7a709e7f60b0e7bcde70a1aa9fea5f060fe0f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 23 Dec 2017 15:47:23 +0300 Subject: clint: Make linter report line where it found opening brace --- src/clint.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/clint.py b/src/clint.py index 8426807c80..79ab91ebe1 100755 --- a/src/clint.py +++ b/src/clint.py @@ -2124,8 +2124,10 @@ def CheckExpressionAlignment(filename, clean_lines, linenum, error, startpos=0): + (level_starts[depth][2] == '{')): if depth not in ignore_error_levels: error(filename, linenum, 'whitespace/alignment', 2, - 'Inner expression should be aligned ' - 'as opening brace + 1 (+ 2 in case of {)') + ('Inner expression should be aligned ' + 'as opening brace + 1 (+ 2 in case of {{). ' + 'Relevant opening is on line {0!r}').format( + level_starts[depth][3])) prev_line_start = pos elif brace == 'e': pass @@ -2142,7 +2144,8 @@ def CheckExpressionAlignment(filename, clean_lines, linenum, error, startpos=0): ignore_error_levels.add(depth) line_ended_with_opening = ( pos == len(line) - 2 * (line.endswith(' \\')) - 1) - level_starts[depth] = (pos, line_ended_with_opening, brace) + level_starts[depth] = (pos, line_ended_with_opening, brace, + linenum) if line_ended_with_opening: depth_line_starts[depth] = (prev_line_start, brace) else: -- cgit From 308dd53783314103710a37c9809eddb78279eab4 Mon Sep 17 00:00:00 2001 From: Björn Linse Date: Mon, 27 Nov 2017 13:01:49 +0100 Subject: channel: check for existance before trying to set key This avoids an error message in async context, where it is not safe. --- src/nvim/channel.c | 23 +++++++++++++++++++---- src/nvim/globals.h | 3 +++ 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 40af470bde..3807f2b3cd 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -599,6 +599,7 @@ static void on_stdio_input(Stream *stream, RBuffer *buf, size_t count, on_channel_output(stream, chan, buf, count, eof, &chan->on_stdout, "stdin"); } +/// @param type must have static lifetime static void on_channel_output(Stream *stream, Channel *chan, RBuffer *buf, size_t count, bool eof, CallbackReader *reader, const char *type) @@ -613,14 +614,20 @@ static void on_channel_output(Stream *stream, Channel *chan, RBuffer *buf, if (reader->cb.type != kCallbackNone) { process_channel_event(chan, &reader->cb, type, reader->buffer.ga_data, (size_t)reader->buffer.ga_len, 0); - ga_clear(&reader->buffer); } else if (reader->self) { - list_T *data = buffer_to_tv_list(reader->buffer.ga_data, - (size_t)reader->buffer.ga_len); - tv_dict_add_list(reader->self, type, strlen(type), data); + if (tv_dict_find(reader->self, type, -1) == NULL) { + list_T *data = buffer_to_tv_list(reader->buffer.ga_data, + (size_t)reader->buffer.ga_len); + tv_dict_add_list(reader->self, type, strlen(type), data); + } else { + // can't display error message now, defer it. + channel_incref(chan); + multiqueue_put(chan->events, on_buffered_error, 2, chan, type); + } } else { abort(); } + ga_clear(&reader->buffer); } else if (reader->cb.type != kCallbackNone) { process_channel_event(chan, &reader->cb, type, ptr, 0, 0); } @@ -641,6 +648,14 @@ static void on_channel_output(Stream *stream, Channel *chan, RBuffer *buf, } } +static void on_buffered_error(void **args) +{ + Channel *chan = (Channel *)args[0]; + const char *stream = (const char *)args[1]; + EMSG3(_(e_streamkey), stream, chan->id); + channel_decref(chan); +} + static void channel_process_exit_cb(Process *proc, int status, void *data) { Channel *chan = data; diff --git a/src/nvim/globals.h b/src/nvim/globals.h index dd216f177f..3df201b6bf 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -1063,6 +1063,9 @@ EXTERN char_u e_stdiochan2[] INIT(= N_( EXTERN char_u e_invstream[] INIT(= N_("E906: invalid stream for channel")); EXTERN char_u e_invstreamrpc[] INIT(= N_( "E906: invalid stream for rpc channel, use 'rpc'")); +EXTERN char_u e_streamkey[] INIT(= N_( + "E5210: dict key '%s' already set for buffered stream in channel %" + PRIu64)); EXTERN char_u e_libcall[] INIT(= N_("E364: Library call failed for \"%s()\"")); EXTERN char_u e_mkdir[] INIT(= N_("E739: Cannot create directory %s: %s")); EXTERN char_u e_markinval[] INIT(= N_("E19: Mark has invalid line number")); -- cgit From 6b45dbca0429c52cb70908497bc7a0fed9db2d8d Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Dec 2017 00:29:38 +0300 Subject: mark: Make sure that jumplist item will not have zero lnum Fixes #7169 --- src/nvim/mark.c | 4 ++++ src/nvim/shada.c | 6 ++++++ 2 files changed, 10 insertions(+) (limited to 'src') diff --git a/src/nvim/mark.c b/src/nvim/mark.c index 1ba400972c..3cd26a5bf7 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -171,6 +171,10 @@ void setpcmark(void) curwin->w_prev_pcmark = curwin->w_pcmark; curwin->w_pcmark = curwin->w_cursor; + if (curwin->w_pcmark.lnum == 0) { + curwin->w_pcmark.lnum = 1; + } + /* If jumplist is full: remove oldest entry */ if (++curwin->w_jumplistlen > JUMPLISTSIZE) { curwin->w_jumplistlen = JUMPLISTSIZE; diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 6bf816bb74..ce9303f14d 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -2557,6 +2557,12 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer, xfmark_T fm; jump_iter = mark_jumplist_iter(jump_iter, curwin, &fm); + if (fm.fmark.mark.lnum == 0) { + iemsgf("ShaDa: mark lnum zero (ji:%p, js:%p, len:%i)", + (void *)jump_iter, (void *)&curwin->w_jumplist[0], + curwin->w_jumplistlen); + continue; + } const buf_T *const buf = (fm.fmark.fnum == 0 ? NULL : buflist_findnr(fm.fmark.fnum)); -- cgit From 0c533a488fbe453ae39017a586eff7813da8ed8a Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Dec 2017 01:43:42 +0300 Subject: *: Remove most calls to tv_list_item_alloc Still left calls in eval/typval.c and test/unit/eval/helpers.lua. Latter is the only reason why function did not receive `static` modifier. --- src/nvim/api/private/helpers.c | 8 ++--- src/nvim/eval.c | 75 +++++++++++++++++------------------------ src/nvim/eval/decode.c | 40 ++++++++++------------ src/nvim/eval/typval.c | 76 ++++++++++++++++++++++++------------------ src/nvim/lua/converter.c | 36 ++++++++++++++------ 5 files changed, 119 insertions(+), 116 deletions(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 4492f8bb93..26ad7ac1a6 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -787,16 +787,14 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err) for (uint32_t i = 0; i < obj.data.array.size; i++) { Object item = obj.data.array.items[i]; - listitem_T *li = tv_list_item_alloc(); + typval_T li_tv; - if (!object_to_vim(item, TV_LIST_ITEM_TV(li), err)) { - // cleanup - tv_list_item_free(li); + if (!object_to_vim(item, &li_tv, err)) { tv_list_free(list); return false; } - tv_list_append(list, li); + tv_list_append_owned_tv(list, li_tv); } tv_list_ref(list); diff --git a/src/nvim/eval.c b/src/nvim/eval.c index e6cb8cdec0..fac15770a6 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -4874,8 +4874,6 @@ void partial_unref(partial_T *pt) static int get_list_tv(char_u **arg, typval_T *rettv, int evaluate) { list_T *l = NULL; - typval_T tv; - listitem_T *item; if (evaluate) { l = tv_list_alloc(); @@ -4883,13 +4881,13 @@ static int get_list_tv(char_u **arg, typval_T *rettv, int evaluate) *arg = skipwhite(*arg + 1); while (**arg != ']' && **arg != NUL) { - if (eval1(arg, &tv, evaluate) == FAIL) /* recursive! */ + typval_T tv; + if (eval1(arg, &tv, evaluate) == FAIL) { // Recursive! goto failret; + } if (evaluate) { - item = tv_list_item_alloc(); - *TV_LIST_ITEM_TV(item) = tv; - TV_LIST_ITEM_TV(item)->v_lock = VAR_UNLOCKED; - tv_list_append(l, item); + tv.v_lock = VAR_UNLOCKED; + tv_list_append_owned_tv(l, tv); } if (**arg == ']') { @@ -11441,40 +11439,38 @@ static void dict_list(typval_T *const tv, typval_T *const rettv, tv_list_alloc_ret(rettv); TV_DICT_ITER(tv->vval.v_dict, di, { - listitem_T *const li = tv_list_item_alloc(); - tv_list_append(rettv->vval.v_list, li); + typval_T tv = { .v_lock = VAR_UNLOCKED }; switch (what) { case kDictListKeys: { - TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; - TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; - TV_LIST_ITEM_TV(li)->vval.v_string = vim_strsave(di->di_key); + tv.v_type = VAR_STRING; + tv.vval.v_string = vim_strsave(di->di_key); break; } case kDictListValues: { - tv_copy(&di->di_tv, TV_LIST_ITEM_TV(li)); + tv_copy(&di->di_tv, &tv); break; } case kDictListItems: { // items() list_T *const sub_l = tv_list_alloc(); - TV_LIST_ITEM_TV(li)->v_type = VAR_LIST; - TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; - TV_LIST_ITEM_TV(li)->vval.v_list = sub_l; + tv.v_type = VAR_LIST; + tv.vval.v_list = sub_l; tv_list_ref(sub_l); - listitem_T *sub_li = tv_list_item_alloc(); - tv_list_append(sub_l, sub_li); - TV_LIST_ITEM_TV(sub_li)->v_type = VAR_STRING; - TV_LIST_ITEM_TV(sub_li)->v_lock = VAR_UNLOCKED; - TV_LIST_ITEM_TV(sub_li)->vval.v_string = vim_strsave(di->di_key); + tv_list_append_owned_tv(sub_l, (typval_T) { + .v_type = VAR_STRING, + .v_lock = VAR_UNLOCKED, + .vval.v_string = (char_u *)xstrdup((const char *)di->di_key), + }); + + tv_list_append_tv(sub_l, &di->di_tv); - sub_li = tv_list_item_alloc(); - tv_list_append(sub_l, sub_li); - tv_copy(&di->di_tv, TV_LIST_ITEM_TV(sub_li)); break; } } + + tv_list_append_owned_tv(rettv->vval.v_list, tv); }); } @@ -12762,13 +12758,12 @@ static void f_msgpackparse(typval_T *argvars, typval_T *rettv, FunPtr fptr) goto f_msgpackparse_exit; } if (result == MSGPACK_UNPACK_SUCCESS) { - listitem_T *li = tv_list_item_alloc(); - TV_LIST_ITEM_TV(li)->v_type = VAR_UNKNOWN; - tv_list_append(ret_list, li); - if (msgpack_to_vim(unpacked.data, TV_LIST_ITEM_TV(li)) == FAIL) { + typval_T tv = { .v_type = VAR_UNKNOWN }; + if (msgpack_to_vim(unpacked.data, &tv) == FAIL) { EMSG2(_(e_invarg2), "Failed to convert msgpack string"); goto f_msgpackparse_exit; } + tv_list_append_owned_tv(ret_list, tv); } if (result == MSGPACK_UNPACK_CONTINUE) { if (rlret == OK) { @@ -13030,7 +13025,6 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) p < buf + readlen || (readlen <= 0 && (prevlen > 0 || binary)); ++p) { if (*p == '\n' || readlen <= 0) { - listitem_T *li; char_u *s = NULL; size_t len = p - start; @@ -13057,11 +13051,11 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) prevlen = prevsize = 0; } - li = tv_list_item_alloc(); - TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; - TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; - TV_LIST_ITEM_TV(li)->vval.v_string = s; - tv_list_append(rettv->vval.v_list, li); + tv_list_append_owned_tv(rettv->vval.v_list, (typval_T) { + .v_type = VAR_STRING, + .v_lock = VAR_UNLOCKED, + .vval.v_string = s, + }); start = p + 1; /* step over newline */ if ((++cnt >= maxline && maxline >= 0) || readlen <= 0) @@ -14310,11 +14304,7 @@ static void f_serverlist(typval_T *argvars, typval_T *rettv, FunPtr fptr) // Copy addrs into a linked list. list_T *l = tv_list_alloc_ret(rettv); for (size_t i = 0; i < n; i++) { - listitem_T *li = tv_list_item_alloc(); - TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; - TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; - TV_LIST_ITEM_TV(li)->vval.v_string = (char_u *)addrs[i]; - tv_list_append(l, li); + tv_list_append_allocated_string(l, addrs[i]); } xfree(addrs); } @@ -15619,12 +15609,7 @@ static void f_spellsuggest(typval_T *argvars, typval_T *rettv, FunPtr fptr) for (int i = 0; i < ga.ga_len; i++) { char *p = ((char **)ga.ga_data)[i]; - - listitem_T *const li = tv_list_item_alloc(); - TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; - TV_LIST_ITEM_TV(li)->v_lock = VAR_LOCKED; - TV_LIST_ITEM_TV(li)->vval.v_string = (char_u *)p; - tv_list_append(rettv->vval.v_list, li); + tv_list_append_allocated_string(rettv->vval.v_list, p); } ga_clear(&ga); } diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index d5c65ebe81..af4e055d23 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -127,9 +127,7 @@ static inline int json_decoder_pop(ValuesStackItem obj, return FAIL; } assert(last_container.special_val == NULL); - listitem_T *obj_li = tv_list_item_alloc(); - *TV_LIST_ITEM_TV(obj_li) = obj.val; - tv_list_append(last_container.container.vval.v_list, obj_li); + tv_list_append_owned_tv(last_container.container.vval.v_list, obj.val); } else if (last_container.stack_index == kv_size(*stack) - 2) { if (!obj.didcolon) { EMSG2(_("E474: Expected colon before dictionary value: %s"), @@ -154,12 +152,8 @@ static inline int json_decoder_pop(ValuesStackItem obj, } else { list_T *const kv_pair = tv_list_alloc(); tv_list_append_list(last_container.special_val, kv_pair); - listitem_T *const key_li = tv_list_item_alloc(); - *TV_LIST_ITEM_TV(key_li) = key.val; - tv_list_append(kv_pair, key_li); - listitem_T *const val_li = tv_list_item_alloc(); - *TV_LIST_ITEM_TV(val_li) = obj.val; - tv_list_append(kv_pair, val_li); + tv_list_append_owned_tv(kv_pair, key.val); + tv_list_append_owned_tv(kv_pair, obj.val); } } else { // Object with key only @@ -1047,10 +1041,10 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) .vval = { .v_list = list }, }; for (size_t i = 0; i < mobj.via.array.size; i++) { - listitem_T *const li = tv_list_item_alloc(); - TV_LIST_ITEM_TV(li)->v_type = VAR_UNKNOWN; - tv_list_append(list, li); - if (msgpack_to_vim(mobj.via.array.ptr[i], TV_LIST_ITEM_TV(li)) + // Not populated yet, need to create list item to push. + tv_list_append_owned_tv(list, (typval_T) { .v_type = VAR_UNKNOWN }); + if (msgpack_to_vim(mobj.via.array.ptr[i], + TV_LIST_ITEM_TV(tv_list_last(list))) == FAIL) { return FAIL; } @@ -1095,20 +1089,20 @@ msgpack_to_vim_generic_map: {} for (size_t i = 0; i < mobj.via.map.size; i++) { list_T *const kv_pair = tv_list_alloc(); tv_list_append_list(list, kv_pair); - listitem_T *const key_li = tv_list_item_alloc(); - TV_LIST_ITEM_TV(key_li)->v_type = VAR_UNKNOWN; - tv_list_append(kv_pair, key_li); - listitem_T *const val_li = tv_list_item_alloc(); - TV_LIST_ITEM_TV(val_li)->v_type = VAR_UNKNOWN; - tv_list_append(kv_pair, val_li); - if (msgpack_to_vim(mobj.via.map.ptr[i].key, TV_LIST_ITEM_TV(key_li)) - == FAIL) { + + typval_T key_tv = { .v_type = VAR_UNKNOWN }; + if (msgpack_to_vim(mobj.via.map.ptr[i].key, &key_tv) == FAIL) { + tv_clear(&key_tv); return FAIL; } - if (msgpack_to_vim(mobj.via.map.ptr[i].val, TV_LIST_ITEM_TV(val_li)) - == FAIL) { + tv_list_append_owned_tv(kv_pair, key_tv); + + typval_T val_tv = { .v_type = VAR_UNKNOWN }; + if (msgpack_to_vim(mobj.via.map.ptr[i].val, &val_tv) == FAIL) { + tv_clear(&val_tv); return FAIL; } + tv_list_append_owned_tv(kv_pair, val_tv); } break; } diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 53c56d0ffd..0755507f91 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -393,19 +393,30 @@ void tv_list_append_tv(list_T *const l, typval_T *const tv) tv_list_append(l, li); } +/// Like tv_list_append_tv(), but tv is moved to a list +/// +/// This means that it is no longer valid to use contents of the typval_T after +/// function exits. +void tv_list_append_owned_tv(list_T *const l, typval_T tv) + FUNC_ATTR_NONNULL_ALL +{ + listitem_T *const li = tv_list_item_alloc(); + *TV_LIST_ITEM_TV(li) = tv; + tv_list_append(l, li); +} + /// Append a list to a list as one item /// /// @param[out] l List to append to. /// @param[in,out] itemlist List to append. Reference count is increased. -void tv_list_append_list(list_T *const list, list_T *const itemlist) +void tv_list_append_list(list_T *const l, list_T *const itemlist) FUNC_ATTR_NONNULL_ARG(1) { - listitem_T *const li = tv_list_item_alloc(); - - TV_LIST_ITEM_TV(li)->v_type = VAR_LIST; - TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; - TV_LIST_ITEM_TV(li)->vval.v_list = itemlist; - tv_list_append(list, li); + tv_list_append_owned_tv(l, (typval_T) { + .v_type = VAR_LIST, + .v_lock = VAR_UNLOCKED, + .vval.v_list = itemlist, + }); tv_list_ref(itemlist); } @@ -413,15 +424,14 @@ void tv_list_append_list(list_T *const list, list_T *const itemlist) /// /// @param[out] l List to append to. /// @param[in,out] dict Dictionary to append. Reference count is increased. -void tv_list_append_dict(list_T *const list, dict_T *const dict) +void tv_list_append_dict(list_T *const l, dict_T *const dict) FUNC_ATTR_NONNULL_ARG(1) { - listitem_T *const li = tv_list_item_alloc(); - - TV_LIST_ITEM_TV(li)->v_type = VAR_DICT; - TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; - TV_LIST_ITEM_TV(li)->vval.v_dict = dict; - tv_list_append(list, li); + tv_list_append_owned_tv(l, (typval_T) { + .v_type = VAR_DICT, + .v_lock = VAR_UNLOCKED, + .vval.v_dict = dict, + }); if (dict != NULL) { dict->dv_refcount++; } @@ -438,14 +448,15 @@ void tv_list_append_string(list_T *const l, const char *const str, const ssize_t len) FUNC_ATTR_NONNULL_ARG(1) { - if (str == NULL) { - assert(len == 0 || len == -1); - tv_list_append_allocated_string(l, NULL); - } else { - tv_list_append_allocated_string(l, (len >= 0 - ? xmemdupz(str, (size_t)len) - : xstrdup(str))); - } + tv_list_append_owned_tv(l, (typval_T) { + .v_type = VAR_STRING, + .v_lock = VAR_UNLOCKED, + .vval.v_string = (str == NULL + ? NULL + : (len >= 0 + ? xmemdupz(str, (size_t)len) + : xstrdup(str))), + }); } /// Append given string to the list @@ -457,12 +468,11 @@ void tv_list_append_string(list_T *const l, const char *const str, void tv_list_append_allocated_string(list_T *const l, char *const str) FUNC_ATTR_NONNULL_ARG(1) { - listitem_T *const li = tv_list_item_alloc(); - - tv_list_append(l, li); - TV_LIST_ITEM_TV(li)->v_type = VAR_STRING; - TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; - TV_LIST_ITEM_TV(li)->vval.v_string = (char_u *)str; + tv_list_append_owned_tv(l, (typval_T) { + .v_type = VAR_STRING, + .v_lock = VAR_UNLOCKED, + .vval.v_string = (char_u *)str, + }); } /// Append number to the list @@ -472,11 +482,11 @@ void tv_list_append_allocated_string(list_T *const l, char *const str) /// listitem_T. void tv_list_append_number(list_T *const l, const varnumber_T n) { - listitem_T *const li = tv_list_item_alloc(); - TV_LIST_ITEM_TV(li)->v_type = VAR_NUMBER; - TV_LIST_ITEM_TV(li)->v_lock = VAR_UNLOCKED; - TV_LIST_ITEM_TV(li)->vval.v_number = n; - tv_list_append(l, li); + tv_list_append_owned_tv(l, (typval_T) { + .v_type = VAR_NUMBER, + .v_lock = VAR_UNLOCKED, + .vval.v_number = n, + }); } //{{{2 Operations on the whole list diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index 8303ecdd37..89fedae73a 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -212,19 +212,27 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) const char *s = lua_tolstring(lstate, -2, &len); if (cur.special) { list_T *const kv_pair = tv_list_alloc(); + tv_list_append_list(cur.tv->vval.v_list, kv_pair); - listitem_T *const key = tv_list_item_alloc(); - *TV_LIST_ITEM_TV(key) = decode_string(s, len, kTrue, false, false); - tv_list_append(kv_pair, key); - if (TV_LIST_ITEM_TV(key)->v_type == VAR_UNKNOWN) { + typval_T s_tv = decode_string(s, len, kTrue, false, false); + if (s_tv.v_type == VAR_UNKNOWN) { ret = false; tv_list_unref(kv_pair); continue; } - listitem_T *const val = tv_list_item_alloc(); - tv_list_append(kv_pair, val); + tv_list_append_owned_tv(kv_pair, s_tv); + + // Value: not populated yet, need to create list item to push. + tv_list_append_owned_tv(kv_pair, (typval_T) { + .v_type = VAR_UNKNOWN, + }); kv_push(stack, cur); - cur = (TVPopStackItem) { TV_LIST_ITEM_TV(val), false, false, 0 }; + cur = (TVPopStackItem) { + .tv = TV_LIST_ITEM_TV(tv_list_last(kv_pair)), + .container = false, + .special = false, + .idx = 0, + }; } else { dictitem_T *const di = tv_dict_item_alloc_len(s, len); if (tv_dict_add(cur.tv->vval.v_dict, di) == FAIL) { @@ -244,10 +252,18 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) lua_pop(lstate, 2); continue; } - listitem_T *const li = tv_list_item_alloc(); - tv_list_append(cur.tv->vval.v_list, li); + // Not populated yet, need to create list item to push. + tv_list_append_owned_tv(cur.tv->vval.v_list, (typval_T) { + .v_type = VAR_UNKNOWN, + }); kv_push(stack, cur); - cur = (TVPopStackItem) { TV_LIST_ITEM_TV(li), false, false, 0 }; + // TODO(ZyX-I): Use indexes, here list item *will* be reallocated. + cur = (TVPopStackItem) { + .tv = TV_LIST_ITEM_TV(tv_list_last(cur.tv->vval.v_list)), + .container = false, + .special = false, + .idx = 0, + }; } } assert(!cur.container); -- cgit From 6bf3dc77c484f757d37c22694e1278abc014278f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Dec 2017 01:52:11 +0300 Subject: eval/typval: Make tv_list_item_alloc static Better write this bit in lua then make reviewers or clint filter out tv_list_item_alloc(). --- src/nvim/eval/typval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 0755507f91..751f1e7aec 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -52,7 +52,7 @@ const char *const tv_empty_string = ""; /// and specifically set lv_lock. /// /// @return [allocated] new list item. -listitem_T *tv_list_item_alloc(void) +static listitem_T *tv_list_item_alloc(void) FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC { return xmalloc(sizeof(listitem_T)); -- cgit From 608c3d7baf2745b188bc42f9f45ad1bb188a4828 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Dec 2017 02:11:46 +0300 Subject: eval/typval: Remove tv_list_item_free() as it is unused --- src/nvim/eval/typval.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 751f1e7aec..a49c34e957 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -58,18 +58,6 @@ static listitem_T *tv_list_item_alloc(void) return xmalloc(sizeof(listitem_T)); } -/// Free a list item -/// -/// Also clears the value. Does not touch watchers. -/// -/// @param[out] item Item to free. -void tv_list_item_free(listitem_T *const item) - FUNC_ATTR_NONNULL_ALL -{ - tv_clear(TV_LIST_ITEM_TV(item)); - xfree(item); -} - /// Remove a list item from a List and free it /// /// Also clears the value. @@ -80,7 +68,8 @@ void tv_list_item_remove(list_T *const l, listitem_T *const item) FUNC_ATTR_NONNULL_ALL { tv_list_remove_items(l, item, item); - tv_list_item_free(item); + tv_clear(TV_LIST_ITEM_TV(item)); + xfree(item); } //{{{2 List watchers -- cgit From ac55558c97d02f18b9a99cf2dd279451481c4a2f Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Dec 2017 02:41:34 +0300 Subject: eval/typval: Make tv_list_item_remove return pointer to the next item --- src/nvim/eval.c | 19 ++++++++----------- src/nvim/eval/typval.c | 7 ++++++- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index fac15770a6..0080eded98 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2904,9 +2904,7 @@ static int do_unlet_var(lval_T *const lp, char_u *const name_end, int forceit) // Delete a range of List items. while (lp->ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= lp->ll_n1)) { - li = TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li); - tv_list_item_remove(lp->ll_list, lp->ll_li); - lp->ll_li = li; + lp->ll_li = tv_list_item_remove(lp->ll_list, lp->ll_li); lp->ll_n1++; } } else { @@ -8467,7 +8465,6 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) static void filter_map(typval_T *argvars, typval_T *rettv, int map) { typval_T *expr; - listitem_T *li, *nli; list_T *l = NULL; dictitem_T *di; hashtab_T *ht; @@ -8551,20 +8548,21 @@ static void filter_map(typval_T *argvars, typval_T *rettv, int map) } else { vimvars[VV_KEY].vv_type = VAR_NUMBER; - for (li = tv_list_first(l); li != NULL; li = nli) { + for (listitem_T *li = tv_list_first(l); li != NULL;) { if (map && tv_check_lock(TV_LIST_ITEM_TV(li)->v_lock, arg_errmsg, TV_TRANSLATE)) { break; } - nli = TV_LIST_ITEM_NEXT(l, li); vimvars[VV_KEY].vv_nr = idx; if (filter_map_one(TV_LIST_ITEM_TV(li), expr, map, &rem) == FAIL || did_emsg) { break; } if (!map && rem) { - tv_list_item_remove(l, li); + li = tv_list_item_remove(l, li); + } else { + li = TV_LIST_ITEM_NEXT(l, li); } idx++; } @@ -15440,18 +15438,17 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) int idx = 0; for (listitem_T *li = TV_LIST_ITEM_NEXT(l, tv_list_first(l)) - ; li != NULL - ; li = TV_LIST_ITEM_NEXT(l, li)) { + ; li != NULL;) { listitem_T *const prev_li = TV_LIST_ITEM_PREV(l, li); if (item_compare_func_ptr(&prev_li, &li) == 0) { if (info.item_compare_func_err) { EMSG(_("E882: Uniq compare function failed")); break; } - tv_list_item_remove(l, li); - li = tv_list_find(l, idx); + li = tv_list_item_remove(l, li); } else { idx++; + li = TV_LIST_ITEM_NEXT(l, li); } } } diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index a49c34e957..4ebe12104f 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -64,12 +64,17 @@ static listitem_T *tv_list_item_alloc(void) /// /// @param[out] l List to remove item from. /// @param[in,out] item Item to remove. -void tv_list_item_remove(list_T *const l, listitem_T *const item) +/// +/// @return Pointer to the list item just after removed one, NULL if removed +/// item was the last one. +listitem_T *tv_list_item_remove(list_T *const l, listitem_T *const item) FUNC_ATTR_NONNULL_ALL { + listitem_T *const next_item = TV_LIST_ITEM_NEXT(l, item); tv_list_remove_items(l, item, item); tv_clear(TV_LIST_ITEM_TV(item)); xfree(item); + return next_item; } //{{{2 List watchers -- cgit From 67fa9e5237526b092c1ac672504e259db7f14126 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Dec 2017 16:38:30 +0300 Subject: eval: Rename tv_list_remove_items() to tv_list_drop_items() tv_list_remove_items() may cause confusion with tv_list_item_remove() --- src/nvim/eval.c | 10 +++++----- src/nvim/eval/typval.c | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 0080eded98..c5f4b78198 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1534,8 +1534,8 @@ ex_let_vars ( EMSG(_("E688: More targets than List items")); return FAIL; } - // l may actually be NULL, but it should fail with E688 or even earlier if you - // try to do ":let [] = v:_null_list". + // lt may actually be NULL, but it should fail with E688 or even earlier if + // you try to do ":let [] = v:_null_list". assert(l != NULL); listitem_T *item = tv_list_first(l); @@ -1543,11 +1543,11 @@ ex_let_vars ( arg = skipwhite(arg + 1); arg = ex_let_one(arg, TV_LIST_ITEM_TV(item), true, (const char_u *)",;]", nextchars); - item = TV_LIST_ITEM_NEXT(l, item); if (arg == NULL) { return FAIL; } + item = TV_LIST_ITEM_NEXT(l, item); arg = skipwhite(arg); if (*arg == ';') { /* Put the rest of the list (may be empty) in the var after ';'. @@ -1559,7 +1559,7 @@ ex_let_vars ( } ltv.v_type = VAR_LIST; - ltv.v_lock = 0; + ltv.v_lock = VAR_UNLOCKED; ltv.vval.v_list = rest_list; tv_list_ref(rest_list); @@ -13283,7 +13283,7 @@ static void f_remove(typval_T *argvars, typval_T *rettv, FunPtr fptr) } else { if (argvars[2].v_type == VAR_UNKNOWN) { // Remove one item, return its value. - tv_list_remove_items(l, item, item); + tv_list_drop_items(l, item, item); *rettv = *TV_LIST_ITEM_TV(item); xfree(item); } else { diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 4ebe12104f..4f717250cd 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -71,7 +71,7 @@ listitem_T *tv_list_item_remove(list_T *const l, listitem_T *const item) FUNC_ATTR_NONNULL_ALL { listitem_T *const next_item = TV_LIST_ITEM_NEXT(l, item); - tv_list_remove_items(l, item, item); + tv_list_drop_items(l, item, item); tv_clear(TV_LIST_ITEM_TV(item)); xfree(item); return next_item; @@ -261,8 +261,8 @@ void tv_list_unref(list_T *const l) /// @param[out] l List to remove from. /// @param[in] item First item to remove. /// @param[in] item2 Last item to remove. -void tv_list_remove_items(list_T *const l, listitem_T *const item, - listitem_T *const item2) +void tv_list_drop_items(list_T *const l, listitem_T *const item, + listitem_T *const item2) FUNC_ATTR_NONNULL_ALL { // Notify watchers. @@ -296,7 +296,7 @@ void tv_list_move_items(list_T *const l, listitem_T *const item, const int cnt) FUNC_ATTR_NONNULL_ALL { - tv_list_remove_items(l, item, item2); + tv_list_drop_items(l, item, item2); item->li_prev = tgt_l->lv_last; item2->li_next = NULL; if (tgt_l->lv_last == NULL) { -- cgit From 7997147245da8c9e9fca4e1862d71bd6b28e1c06 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Dec 2017 17:52:04 +0300 Subject: eval: Replace some tv_list_item_remove() calls There is nothing wrong with them, just it is generally better to remove a range then to remove items individually. --- src/nvim/eval.c | 44 ++++++++++++++++++++------------------------ src/nvim/eval/typval.c | 17 +++++++++++++++++ 2 files changed, 37 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index c5f4b78198..c878f0481d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2887,26 +2887,25 @@ static int do_unlet_var(lval_T *const lp, char_u *const name_end, int forceit) lp->ll_name_len))) { return FAIL; } else if (lp->ll_range) { - listitem_T *li; - listitem_T *ll_li = lp->ll_li; - int ll_n1 = lp->ll_n1; - - while (ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= ll_n1)) { - li = TV_LIST_ITEM_NEXT(lp->ll_list, ll_li); - if (tv_check_lock(TV_LIST_ITEM_TV(ll_li)->v_lock, + // Delete a range of List items. + listitem_T *const first_li = lp->ll_li; + listitem_T *last_li = first_li; + for (;;) { + listitem_T *const li = TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li); + if (tv_check_lock(TV_LIST_ITEM_TV(lp->ll_li)->v_lock, (const char *)lp->ll_name, lp->ll_name_len)) { return false; } - ll_li = li; - ll_n1++; - } - - // Delete a range of List items. - while (lp->ll_li != NULL && (lp->ll_empty2 || lp->ll_n2 >= lp->ll_n1)) { - lp->ll_li = tv_list_item_remove(lp->ll_list, lp->ll_li); + lp->ll_li = li; lp->ll_n1++; + if (lp->ll_li == NULL || (!lp->ll_empty2 && lp->ll_n2 < lp->ll_n1)) { + break; + } else { + last_li = lp->ll_li; + } } + tv_list_remove_items(lp->ll_list, first_li, last_li); } else { if (lp->ll_list != NULL) { // unlet a List item. @@ -13123,16 +13122,13 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } /* while */ - /* - * For a negative line count use only the lines at the end of the file, - * free the rest. - */ - if (maxline < 0) - while (cnt > -maxline) { - tv_list_item_remove(rettv->vval.v_list, - tv_list_first(rettv->vval.v_list)); - cnt--; - } + // For a negative line count use only the lines at the end of the file, + // free the rest. + if (maxline < -tv_list_len(rettv->vval.v_list)) { + listitem_T *const first_li = tv_list_find(rettv->vval.v_list, maxline); + listitem_T *const last_li = tv_list_last(rettv->vval.v_list); + tv_list_remove_items(rettv->vval.v_list, first_li, last_li); + } xfree(prev); fclose(fd); diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 4f717250cd..5c9005595d 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -284,6 +284,23 @@ void tv_list_drop_items(list_T *const l, listitem_T *const item, l->lv_idx_item = NULL; } +/// Like tv_list_drop_items, but also frees all removed items +void tv_list_remove_items(list_T *const l, listitem_T *const item, + listitem_T *const item2) + FUNC_ATTR_NONNULL_ALL +{ + tv_list_drop_items(l, item, item2); + for(listitem_T *li = item;;) { + tv_clear(TV_LIST_ITEM_TV(li)); + listitem_T *const nli = li->li_next; + xfree(li); + if (li == item2) { + break; + } + li = nli; + } +} + /// Move items "item" to "item2" from list "l" to the end of the list "tgt_l" /// /// @param[out] l List to move from. -- cgit From bc52ec61105160eb2b648af239e44cc594529fbf Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 24 Dec 2017 23:09:26 +0300 Subject: *: Fix linter errors --- src/nvim/eval/typval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 5c9005595d..fba9e9c843 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -290,7 +290,7 @@ void tv_list_remove_items(list_T *const l, listitem_T *const item, FUNC_ATTR_NONNULL_ALL { tv_list_drop_items(l, item, item2); - for(listitem_T *li = item;;) { + for (listitem_T *li = item;;) { tv_clear(TV_LIST_ITEM_TV(li)); listitem_T *const nli = li->li_next; xfree(li); -- cgit From 6ab5eb347bb437c4aed82e329e65244c63566530 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 25 Dec 2017 01:08:58 +0300 Subject: eval: Remove magic numbers from find_some_match() type argument --- src/nvim/eval.c | 155 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 93 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index c878f0481d..d0f8ced18b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -215,6 +215,15 @@ static garray_T ga_scripts = {0, 0, sizeof(scriptvar_T *), 4, NULL}; static int echo_attr = 0; /* attributes used for ":echo" */ +/// Describe data to return from find_some_match() +typedef enum { + kSomeMatch, ///< Data for match(). + kSomeMatchEnd, ///< Data for matchend(). + kSomeMatchList, ///< Data for matchlist(). + kSomeMatchStr, ///< Data for matchstr(). + kSomeMatchStrPos, ///< Data for matchstrpos(). +} SomeMatchType; + /// trans_function_name() flags typedef enum { TFN_INT = 1, ///< May use internal function name @@ -12183,7 +12192,8 @@ static void f_mapcheck(typval_T *argvars, typval_T *rettv, FunPtr fptr) } -static void find_some_match(typval_T *argvars, typval_T *rettv, int type) +static void find_some_match(typval_T *const argvars, typval_T *const rettv, + const SomeMatchType type) { char_u *str = NULL; long len = 0; @@ -12204,24 +12214,36 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) p_cpo = (char_u *)""; rettv->vval.v_number = -1; - if (type == 3 || type == 4) { - // type 3: return empty list when there are no matches. - // type 4: return ["", -1, -1, -1] - tv_list_alloc_ret(rettv); - if (type == 4) { + switch (type) { + // matchlist(): return empty list when there are no matches. + case kSomeMatchList: { + tv_list_alloc_ret(rettv); + FALLTHROUGH; + } + // matchstrpos(): return ["", -1, -1, -1] + case kSomeMatchStrPos: { tv_list_append_string(rettv->vval.v_list, "", 0); tv_list_append_number(rettv->vval.v_list, -1); tv_list_append_number(rettv->vval.v_list, -1); tv_list_append_number(rettv->vval.v_list, -1); + break; + } + case kSomeMatchStr: { + rettv->v_type = VAR_STRING; + rettv->vval.v_string = NULL; + break; + } + case kSomeMatch: + case kSomeMatchEnd: { + // Do nothing: zero is default. + break; } - } else if (type == 2) { - rettv->v_type = VAR_STRING; - rettv->vval.v_string = NULL; } if (argvars[0].v_type == VAR_LIST) { - if ((l = argvars[0].vval.v_list) == NULL) + if ((l = argvars[0].vval.v_list) == NULL) { goto theend; + } li = tv_list_first(l); } else { expr = str = (char_u *)tv_get_string(&argvars[0]); @@ -12311,63 +12333,72 @@ static void find_some_match(typval_T *argvars, typval_T *rettv, int type) } if (match) { - if (type == 4) { - list_T *const ret_l = rettv->vval.v_list; - listitem_T *li1 = tv_list_first(ret_l); - listitem_T *li2 = TV_LIST_ITEM_NEXT(ret_l, li1); - listitem_T *li3 = TV_LIST_ITEM_NEXT(ret_l, li2); - listitem_T *li4 = TV_LIST_ITEM_NEXT(ret_l, li3); - xfree(TV_LIST_ITEM_TV(li1)->vval.v_string); - - const size_t rd = (size_t)(regmatch.endp[0] - regmatch.startp[0]); - TV_LIST_ITEM_TV(li1)->vval.v_string = xmemdupz( - (const char *)regmatch.startp[0], rd); - TV_LIST_ITEM_TV(li3)->vval.v_number = (varnumber_T)( - regmatch.startp[0] - expr); - TV_LIST_ITEM_TV(li4)->vval.v_number = (varnumber_T)( - regmatch.endp[0] - expr); - if (l != NULL) { - TV_LIST_ITEM_TV(li2)->vval.v_number = (varnumber_T)idx; + switch (type) { + case kSomeMatchStrPos: { + list_T *const ret_l = rettv->vval.v_list; + listitem_T *li1 = tv_list_first(ret_l); + listitem_T *li2 = TV_LIST_ITEM_NEXT(ret_l, li1); + listitem_T *li3 = TV_LIST_ITEM_NEXT(ret_l, li2); + listitem_T *li4 = TV_LIST_ITEM_NEXT(ret_l, li3); + xfree(TV_LIST_ITEM_TV(li1)->vval.v_string); + + const size_t rd = (size_t)(regmatch.endp[0] - regmatch.startp[0]); + TV_LIST_ITEM_TV(li1)->vval.v_string = xmemdupz( + (const char *)regmatch.startp[0], rd); + TV_LIST_ITEM_TV(li3)->vval.v_number = (varnumber_T)( + regmatch.startp[0] - expr); + TV_LIST_ITEM_TV(li4)->vval.v_number = (varnumber_T)( + regmatch.endp[0] - expr); + if (l != NULL) { + TV_LIST_ITEM_TV(li2)->vval.v_number = (varnumber_T)idx; + } + break; } - } else if (type == 3) { - int i; - - /* return list with matched string and submatches */ - for (i = 0; i < NSUBEXP; ++i) { - if (regmatch.endp[i] == NULL) { - tv_list_append_string(rettv->vval.v_list, NULL, 0); - } else { - tv_list_append_string(rettv->vval.v_list, - (const char *)regmatch.startp[i], - (regmatch.endp[i] - regmatch.startp[i])); + case kSomeMatchList: { + // Return list with matched string and submatches. + for (int i = 0; i < NSUBEXP; ++i) { + if (regmatch.endp[i] == NULL) { + tv_list_append_string(rettv->vval.v_list, NULL, 0); + } else { + tv_list_append_string(rettv->vval.v_list, + (const char *)regmatch.startp[i], + (regmatch.endp[i] - regmatch.startp[i])); + } } + break; } - } else if (type == 2) { - // Return matched string. - if (l != NULL) { - tv_copy(TV_LIST_ITEM_TV(li), rettv); - } else { - rettv->vval.v_string = (char_u *)xmemdupz( - (const char *)regmatch.startp[0], - (size_t)(regmatch.endp[0] - regmatch.startp[0])); + case kSomeMatchStr: { + // Return matched string. + if (l != NULL) { + tv_copy(TV_LIST_ITEM_TV(li), rettv); + } else { + rettv->vval.v_string = (char_u *)xmemdupz( + (const char *)regmatch.startp[0], + (size_t)(regmatch.endp[0] - regmatch.startp[0])); + } + break; } - } else if (l != NULL) { - rettv->vval.v_number = idx; - } else { - if (type != 0) { - rettv->vval.v_number = - (varnumber_T)(regmatch.startp[0] - str); - } else { - rettv->vval.v_number = - (varnumber_T)(regmatch.endp[0] - str); + case kSomeMatch: + case kSomeMatchEnd: { + if (l != NULL) { + rettv->vval.v_number = idx; + } else { + if (type == kSomeMatchEnd) { + rettv->vval.v_number = + (varnumber_T)(regmatch.startp[0] - str); + } else { + rettv->vval.v_number = + (varnumber_T)(regmatch.endp[0] - str); + } + rettv->vval.v_number += (varnumber_T)(str - expr); + } } - rettv->vval.v_number += (varnumber_T)(str - expr); } } vim_regfree(regmatch.regprog); } - if (type == 4 && l == NULL) { + if (type == kSomeMatchStrPos && l == NULL) { // matchstrpos() without a list: drop the second item list_T *const ret_l = rettv->vval.v_list; tv_list_item_remove(ret_l, TV_LIST_ITEM_NEXT(ret_l, tv_list_first(ret_l))); @@ -12383,7 +12414,7 @@ theend: */ static void f_match(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - find_some_match(argvars, rettv, 1); + find_some_match(argvars, rettv, kSomeMatch); } /* @@ -12528,7 +12559,7 @@ static void f_matchdelete(typval_T *argvars, typval_T *rettv, FunPtr fptr) */ static void f_matchend(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - find_some_match(argvars, rettv, 0); + find_some_match(argvars, rettv, kSomeMatchEnd); } /* @@ -12536,7 +12567,7 @@ static void f_matchend(typval_T *argvars, typval_T *rettv, FunPtr fptr) */ static void f_matchlist(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - find_some_match(argvars, rettv, 3); + find_some_match(argvars, rettv, kSomeMatchList); } /* @@ -12544,13 +12575,13 @@ static void f_matchlist(typval_T *argvars, typval_T *rettv, FunPtr fptr) */ static void f_matchstr(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - find_some_match(argvars, rettv, 2); + find_some_match(argvars, rettv, kSomeMatchStr); } /// "matchstrpos()" function static void f_matchstrpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - find_some_match(argvars, rettv, 4); + find_some_match(argvars, rettv, kSomeMatchStrPos); } /// Get maximal/minimal number value in a list or dictionary -- cgit From b6ee90a2433276175462b81106378009b4893e04 Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 25 Dec 2017 01:44:44 +0300 Subject: eval: Refactor some potentially dangerous list appends --- src/nvim/eval.c | 71 ++++++++++++++++---------------------------------- src/nvim/eval/typval.c | 42 +++++++++++++++++++++++++++++ src/nvim/eval/typval.h | 22 ++++++---------- 3 files changed, 73 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d0f8ced18b..370d4f0c0b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2421,9 +2421,11 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, if (TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li) == NULL) { // Need to add an empty item. tv_list_append_number(lp->ll_list, 0); - assert(TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li)); + // ll_li may have become invalid after append, don’t use it. + lp->ll_li = tv_list_last(lp->ll_list); // Valid again. + } else { + lp->ll_li = TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li); } - lp->ll_li = TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li); lp->ll_n1++; } if (ri != NULL) { @@ -4528,7 +4530,7 @@ eval_index ( item = tv_list_find(rettv->vval.v_list, n1); while (n1++ <= n2) { tv_list_append_tv(l, TV_LIST_ITEM_TV(item)); - item = TV_LIST_ITEM_NEXT(l, item); + item = TV_LIST_ITEM_NEXT(rettv->vval.v_list, item); } tv_clear(rettv); rettv->v_type = VAR_LIST; @@ -12529,12 +12531,12 @@ static void f_matcharg(typval_T *argvars, typval_T *rettv, FunPtr fptr) { tv_list_alloc_ret(rettv); - int id = tv_get_number(&argvars[0]); + const int id = tv_get_number(&argvars[0]); if (id >= 1 && id <= 3) { - matchitem_T *m; + matchitem_T *const m = (matchitem_T *)get_match(curwin, id); - if ((m = (matchitem_T *)get_match(curwin, id)) != NULL) { + if (m != NULL) { tv_list_append_string(rettv->vval.v_list, (const char *)syn_id2name(m->hlg_id), -1); tv_list_append_string(rettv->vval.v_list, (const char *)m->pattern, -1); @@ -15135,12 +15137,6 @@ static void f_sockconnect(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->v_type = VAR_NUMBER; } -/// struct used in the array that's given to qsort() -typedef struct { - listitem_T *item; - int idx; -} sortItem_T; - /// struct storing information about current sort typedef struct { int item_compare_ic; @@ -15161,8 +15157,8 @@ static sortinfo_T *sortinfo = NULL; */ static int item_compare(const void *s1, const void *s2, bool keep_zero) { - sortItem_T *const si1 = (sortItem_T *)s1; - sortItem_T *const si2 = (sortItem_T *)s2; + ListSortItem *const si1 = (ListSortItem *)s1; + ListSortItem *const si2 = (ListSortItem *)s2; typval_T *const tv1 = TV_LIST_ITEM_TV(si1->item); typval_T *const tv2 = TV_LIST_ITEM_TV(si2->item); @@ -15256,7 +15252,7 @@ static int item_compare_not_keeping_zero(const void *s1, const void *s2) static int item_compare2(const void *s1, const void *s2, bool keep_zero) { - sortItem_T *si1, *si2; + ListSortItem *si1, *si2; int res; typval_T rettv; typval_T argv[3]; @@ -15269,8 +15265,8 @@ static int item_compare2(const void *s1, const void *s2, bool keep_zero) return 0; } - si1 = (sortItem_T *)s1; - si2 = (sortItem_T *)s2; + si1 = (ListSortItem *)s1; + si2 = (ListSortItem *)s2; if (partial == NULL) { func_name = sortinfo->item_compare_func; @@ -15327,7 +15323,7 @@ static int item_compare2_not_keeping_zero(const void *s1, const void *s2) */ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) { - sortItem_T *ptrs; + ListSortItem *ptrs; long len; long i; @@ -15417,42 +15413,21 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) } /* Make an array with each entry pointing to an item in the List. */ - ptrs = xmalloc((size_t)(len * sizeof (sortItem_T))); + ptrs = xmalloc((size_t)(len * sizeof(ListSortItem))); - i = 0; if (sort) { - // sort(): ptrs will be the list to sort. - TV_LIST_ITER(l, li, { - ptrs[i].item = li; - ptrs[i].idx = i; - i++; - }); - info.item_compare_func_err = false; - // Test the compare function. - if ((info.item_compare_func != NULL - || info.item_compare_partial != NULL) - && item_compare2_not_keeping_zero(&ptrs[0], &ptrs[1]) - == ITEM_COMPARE_FAIL) { + tv_list_item_sort(l, ptrs, + ((info.item_compare_func == NULL + && info.item_compare_partial == NULL) + ? item_compare_not_keeping_zero + : item_compare2_not_keeping_zero), + &info.item_compare_func_err); + if (info.item_compare_func_err) { EMSG(_("E702: Sort compare function failed")); - } else { - // Sort the array with item pointers. - qsort(ptrs, (size_t)len, sizeof (sortItem_T), - (info.item_compare_func == NULL - && info.item_compare_partial == NULL ? - item_compare_not_keeping_zero : - item_compare2_not_keeping_zero)); - - if (!info.item_compare_func_err) { - // Clear the list and append the items in the sorted order. - tv_list_clear(l); - for (i = 0; i < len; i++) { - tv_list_append(l, ptrs[i].item); - } - } } } else { - int (*item_compare_func_ptr)(const void *, const void *); + ListSorter item_compare_func_ptr; // f_uniq(): ptrs will be a stack of items to remove. info.item_compare_func_err = false; diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index fba9e9c843..21bb84a945 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -757,6 +758,47 @@ void tv_list_reverse(list_T *const l) l->lv_idx = l->lv_len - l->lv_idx - 1; } +// FIXME Add unit tests for tv_list_item_sort(). + +/// Sort list using libc qsort +/// +/// @param[in,out] l List to sort, will be sorted in-place. +/// @param ptrs Preallocated array of items to sort, must have at least +/// tv_list_len(l) entries. Should not be initialized. +/// @param[in] item_compare_func Function used to compare list items. +/// @param errp Location where information about whether error occurred is +/// saved by item_compare_func. If boolean there appears to be +/// true list will not be modified. Must be initialized to false +/// by the caller. +void tv_list_item_sort(list_T *const l, ListSortItem *const ptrs, + const ListSorter item_compare_func, + bool *errp) + FUNC_ATTR_NONNULL_ARG(3, 4) +{ + const int len = tv_list_len(l); + if (len <= 1) { + return; + } + int i = 0; + TV_LIST_ITER(l, li, { + ptrs[i].item = li; + ptrs[i].idx = i; + i++; + }); + // Sort the array with item pointers. + qsort(ptrs, (size_t)len, sizeof(ListSortItem), item_compare_func); + if (!(*errp)) { + // Clear the list and append the items in the sorted order. + l->lv_first = NULL; + l->lv_last = NULL; + l->lv_idx_item = NULL; + l->lv_len = 0; + for (i = 0; i < len; i++) { + tv_list_append(l, ptrs[i].item); + } + } +} + //{{{2 Indexing/searching /// Locate item with a given index in a list and return it diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 2bce7bd6b2..c9a9a3e7e8 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -296,6 +296,14 @@ typedef struct list_stack_S { struct list_stack_S *prev; } list_stack_T; +/// Structure representing one list item, used for sort array. +typedef struct { + listitem_T *item; ///< Sorted list item. + int idx; ///< Sorted list item index. +} ListSortItem; + +typedef int (*ListSorter)(const void *, const void *); + // In a hashtab item "hi_key" points to "di_key" in a dictitem. // This avoids adding a pointer to the hashtab item. @@ -403,20 +411,6 @@ static inline list_T *tv_list_latest_copy(const list_T *const l) return l->lv_copylist; } -/// Clear the list without freeing anything at all -/// -/// For use in sort() which saves items to a separate array and readds them back -/// after sorting via a number of tv_list_append() calls. -/// -/// @param[out] l List to clear. -static inline void tv_list_clear(list_T *const l) -{ - l->lv_first = NULL; - l->lv_last = NULL; - l->lv_idx_item = NULL; - l->lv_len = 0; -} - static inline int tv_list_uidx(const list_T *const l, int n) REAL_FATTR_PURE REAL_FATTR_WARN_UNUSED_RESULT; -- cgit From fe60fa9faafd90cfe756c80119abae6f8906fc4b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 16 Dec 2017 21:33:59 +0100 Subject: doc vim-patch:8.0.1206: no autocmd for entering or leaving the command line (commit a4f6cec7a31ff8dbfa089b9e22227afbeb951e9b) NA patches: vim-patch:8.0.0320: warning for unused variable with small build --- src/nvim/api/vim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index c0daac8085..172f2ce18e 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -929,7 +929,7 @@ typedef kvec_withinit_t(ExprASTConvStackItem, 16) ExprASTConvStack; /// starting column and ending column (latter exclusive: /// one should highlight region [start_col, end_col)). /// -/// @return AST: top-level dictionary holds keys +/// @return AST: top-level dictionary with these keys: /// /// "error": Dictionary with error, present only if parser saw some /// error. Contains the following keys: -- cgit From ac2f90f2e1d63e1aa16f377580c815059618fe94 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 26 Dec 2017 03:49:00 +0100 Subject: version.c: update --- src/nvim/version.c | 455 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 317 insertions(+), 138 deletions(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index 8ab9fc1a4b..e35b803b4e 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -146,7 +146,7 @@ static const int included_patches[] = { // 1292, // 1291, // 1290, - // 1289, + 1289, // 1288, // 1287, // 1286, @@ -228,8 +228,187 @@ static const int included_patches[] = { // 1210, // 1209, // 1208, - // 1207, + 1207, 1206, + // 1205, + // 1204, + // 1203, + // 1202, + // 1201, + // 1200, + // 1199, + // 1198, + // 1197, + // 1196, + // 1195, + // 1194, + // 1193, + // 1192, + // 1191, + // 1190, + 1189, + // 1188, + // 1187, + // 1186, + // 1185, + // 1184, + // 1183, + // 1182, + // 1181, + // 1180, + // 1179, + // 1178, + // 1177, + // 1176, + // 1175, + // 1174, + // 1173, + // 1172, + // 1171, + // 1170, + // 1169, + // 1168, + // 1167, + // 1166, + // 1165, + // 1164, + // 1163, + // 1162, + // 1161, + // 1160, + // 1159, + // 1158, + // 1157, + // 1156, + // 1155, + // 1154, + // 1153, + // 1152, + // 1151, + // 1150, + // 1149, + // 1148, + // 1147, + // 1146, + // 1145, + // 1144, + // 1143, + // 1142, + // 1141, + // 1140, + // 1139, + // 1138, + // 1137, + // 1136, + // 1135, + // 1134, + // 1133, + // 1132, + // 1131, + // 1130, + // 1129, + // 1128, + // 1127, + // 1126, + // 1125, + // 1124, + // 1123, + // 1122, + // 1121, + // 1120, + // 1119, + // 1118, + // 1117, + // 1116, + // 1115, + // 1114, + // 1113, + // 1112, + // 1111, + // 1110, + // 1109, + 1108, + // 1107, + // 1106, + // 1105, + // 1104, + // 1103, + // 1102, + // 1101, + // 1100, + // 1099, + // 1098, + // 1097, + // 1096, + // 1095, + // 1094, + // 1093, + // 1092, + // 1091, + // 1090, + // 1089, + // 1088, + // 1087, + // 1086, + // 1085, + // 1084, + // 1083, + // 1082, + // 1081, + // 1080, + // 1079, + // 1078, + // 1077, + // 1076, + // 1075, + // 1074, + // 1073, + // 1072, + // 1071, + // 1070, + // 1069, + // 1068, + // 1067, + // 1066, + // 1065, + // 1064, + // 1063, + // 1062, + // 1061, + // 1060, + // 1059, + // 1058, + // 1057, + // 1056, + // 1055, + // 1054, + // 1053, + // 1052, + // 1051, + // 1050, + // 1049, + // 1048, + // 1047, + // 1046, + // 1045, + // 1044, + // 1043, + // 1042, + // 1041, + // 1040, + // 1039, + // 1038, + // 1037, + // 1036, + // 1035, + // 1034, + // 1033, + // 1032, + // 1031, + // 1030, + // 1029, + // 1028, + // 1027, // 1026, 1025, 1024, @@ -237,7 +416,7 @@ static const int included_patches[] = { // 1022, // 1021, // 1020, - // 1019, + 1019, // 1018, // 1017, // 1016, @@ -294,7 +473,7 @@ static const int included_patches[] = { // 965, // 964, // 963, - // 962, + 962, // 961, // 960, // 959, @@ -650,7 +829,7 @@ static const int included_patches[] = { // 609, // 608, 607, - // 606, + 606, 605, // 604, // 603, @@ -659,30 +838,30 @@ static const int included_patches[] = { // 600, // 599, // 598, - // 597, + 597, // 596, - // 595, + 595, // 594, // 593, // 592, // 591, - // 590, + 590, // 589, // 588, // 587, // 586, // 585, - // 584, + 584, // 583, // 582, // 581, - // 580, - // 579, + 580, + 579, // 578, // 577, // 576, // 575, - // 574, + 574, // 573, // 572, 571, @@ -691,7 +870,7 @@ static const int included_patches[] = { // 568, // 567, // 566, - // 565, + 565, // 564, // 563, // 562, @@ -720,7 +899,7 @@ static const int included_patches[] = { // 539, // 538, // 537, - // 536, + 536, // 535, // 534, // 533, @@ -739,7 +918,7 @@ static const int included_patches[] = { // 520, // 519, 518, - // 517, + 517, // 516, // 515, // 514, @@ -772,7 +951,7 @@ static const int included_patches[] = { 487, 486, 485, - // 484, + 484, 483, 482, // 481, @@ -836,7 +1015,7 @@ static const int included_patches[] = { // 423, // 422, // 421, - // 420, + 420, // 419, // 418, // 417, @@ -851,12 +1030,12 @@ static const int included_patches[] = { 408, 407, // 406, - // 405 NA - // 404, + 405, + 404, // 403, // 402, // 401, - // 400 NA + 400, // 399, // 398, // 397, @@ -877,7 +1056,7 @@ static const int included_patches[] = { // 382, // 381, // 380, - // 379, + 379, 378, 377, 376, @@ -936,7 +1115,7 @@ static const int included_patches[] = { // 323, 322, // 321, - // 320, + 320, 319, // 318, // 317, @@ -946,18 +1125,18 @@ static const int included_patches[] = { // 313, // 312, 311, - // 310, - // 309, + 310, + 309, 308, 307, 306, 305, // 304, // 303, - // 302 NA + 302, // 301, 300, - // 299, + 299, 298, 297, // 296, @@ -968,38 +1147,38 @@ static const int included_patches[] = { 291, 290, 289, - // 288 NA + 288, 287, // 286, - // 285 NA - // 284 NA + 285, + 284, 283, 282, - // 281 NA + 281, 280, - // 279 NA - // 278 NA - // 277 NA - // 276 NA + 279, + 278, + 277, + 276, 275, 274, - // 273 NA - // 272 NA - // 271 NA - // 270 NA - // 269 NA - // 268 NA - // 267 NA + 273, + 272, + 271, + 270, + 269, + 268, + 267, 266, // 265, // 264, // 263, // 262, // 261, - // 260 NA + 260, 259, 258, - // 257 NA + 257, // 256, // 255, // 254, @@ -1007,45 +1186,45 @@ static const int included_patches[] = { // 252, // 251, 250, - // 249 NA - // 248 NA + 249, + 248, 247, - // 246 NA + 246, 245, - // 244 NA + 244, 243, 242, - // 241 NA - // 240 NA - // 239 NA + 241, + 240, + 239, // 238, 237, // 236, 235, // 234, // 233, - // 232 NA + 232, // 231, // 230, 229, // 228, - // 227, + 227, 226, // 225, 224, 223, // 222, - // 221 NA + 221, // 220, 219, 218, - // 217 NA + 217, // 216, - // 215 NA + 215, // 214, - // 213 NA + 213, // 212, - // 211 NA + 211, // 210, 209, 208, @@ -1053,49 +1232,49 @@ static const int included_patches[] = { 206, 205, // 204, - // 203 NA + 203, // 202, // 201, // 200, - // 199 NA + 199, // 198, // 197, 196, 195, 194, - // 193 NA - // 192 NA - // 191 NA + 193, + 192, + 191, 190, 189, 188, - // 187 NA + 187, 186, // 185, // 184, - // 183 NA + 183, 182, 181, - // 180 NA + 180, 179, 178, 177, 176, // 175, 174, - // 173 NA + 173, 172, - // 171 NA - // 170 NA - // 169 NA + 171, + 170, + 169, 168, 167, - // 166 NA + 166, 165, 164, - // 163 NA - // 162 NA - // 161 NA + 163, + 162, + 161, // 160, 159, 158, @@ -1104,21 +1283,21 @@ static const int included_patches[] = { 155, // 154, // 153, - // 152 NA + 152, // 151, 150, 149, 148, 147, 146, - // 145 NA - // 144 NA + 145, + 144, 143, 142, - // 141 NA + 141, 140, - // 139 NA - // 138 NA + 139, + 138, 137, 136, 135, @@ -1126,137 +1305,137 @@ static const int included_patches[] = { 133, 132, 131, - // 130 NA - // 129 NA + 130, + 129, 128, 127, 126, 125, 124, - // 123 NA - // 122 NA + 123, + 122, 121, - // 120 NA + 120, 119, 118, - // 117 NA + 117, 116, - // 115 NA - // 114 NA - // 113 NA + 115, + 114, + 113, 112, 111, 110, - // 109 NA - // 108 NA - // 107 NA + 109, + 108, + 107, 106, - // 105 NA + 105, 104, - // 103 NA + 103, 102, 101, 100, 99, - // 98 NA - // 97 NA + 98, + 97, 96, - // 95 NA - // 94 NA - // 93 NA + 95, + 94, + 93, 92, 91, 90, - // 89 NA + 89, 88, - // 87 NA + 87, 86, 85, 84, 83, - // 82 NA + 82, 81, - // 80 NA + 80, 79, 78, - // 77 NA - // 76 NA + 77, + 76, 75, 74, 73, - // 72 NA - // 71 NA - // 70 NA + 72, + 71, + 70, 69, 68, - // 67 NA + 67, 66, - // 65 NA + 65, 64, - // 63 NA + 63, 62, - // 61 NA + 61, 60, - // 59 NA + 59, 58, 57, 56, - // 55 NA - // 54 NA + 55, + 54, 53, 52, - // 51 NA - // 50 NA + 51, + 50, 49, - // 48 NA + 48, 47, 46, - // 45 NA + 45, 44, 43, 42, 41, 40, - // 39 NA + 39, 38, 37, - // 36 NA + 36, 35, 34, 33, 32, 31, - // 30 NA - // 29 NA - // 28 NA - // 27 NA + 30, + 29, + 28, + 27, 26, 25, - // 24 NA + 24, 23, - // 22 NA - // 21 NA + 22, + 21, 20, 19, - // 18 NA + 18, 17, - // 16 NA - // 15 NA - // 14 NA - // 13 NA + 16, + 15, + 14, + 13, 12, - // 11 NA - // 10 NA - // 9 NA + 11, + 10, + 9, 8, - // 7 NA + 7, 6, - // 5 NA + 5, 4, 3, 2, 1, - 0 + 0, }; // clang-format on -- cgit From 2c436b33621a3064aae94e88db90095ae69aabc8 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 29 Dec 2017 16:56:14 +0100 Subject: Fix TabClose autocommand via close_windows Fixes https://github.com/neovim/neovim/issues/7781 --- src/nvim/window.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/window.c b/src/nvim/window.c index 5e85a9bede..bbdf40b874 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1741,6 +1741,11 @@ void close_windows(buf_T *buf, int keep_curwin) } else wp = wp->w_next; } + if (count != tabpage_index(NULL)) { + char_u prev_idx[NUMBUFLEN]; + sprintf((char *)prev_idx, "%i", tabpage_index(curtab)); + apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, curbuf); + } /* Also check windows in other tab pages. */ for (tp = first_tabpage; tp != NULL; tp = nexttp) { @@ -1757,15 +1762,16 @@ void close_windows(buf_T *buf, int keep_curwin) break; } } + if (count != tabpage_index(NULL)) { + char_u prev_idx[NUMBUFLEN]; + sprintf((char *)prev_idx, "%i", tabpage_index(tp)); + apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, curbuf); + } } } --RedrawingDisabled; - if (count != tabpage_index(NULL)) { - apply_autocmds(EVENT_TABCLOSED, NULL, NULL, false, curbuf); - } - redraw_tabline = true; if (h != tabline_height()) { shell_new_rows(); -- cgit From e84e1b68c13443efc3e0c39a16c6a6945fbde20b Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 29 Dec 2017 20:35:52 +0100 Subject: Move applying of TabClosed to win_close_othertab --- src/nvim/ex_docmd.c | 1 - src/nvim/window.c | 18 ++++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index f6a5f59676..a0ede4f3c5 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6230,7 +6230,6 @@ void tabpage_close_other(tabpage_T *tp, int forceit) if (!valid_tabpage(tp) || tp->tp_firstwin == wp) break; } - apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, FALSE, curbuf); redraw_tabline = TRUE; if (h != tabline_height()) diff --git a/src/nvim/window.c b/src/nvim/window.c index bbdf40b874..81e986c5f2 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -1724,7 +1724,6 @@ void close_windows(buf_T *buf, int keep_curwin) { tabpage_T *tp, *nexttp; int h = tabline_height(); - int count = tabpage_index(NULL); ++RedrawingDisabled; @@ -1741,11 +1740,6 @@ void close_windows(buf_T *buf, int keep_curwin) } else wp = wp->w_next; } - if (count != tabpage_index(NULL)) { - char_u prev_idx[NUMBUFLEN]; - sprintf((char *)prev_idx, "%i", tabpage_index(curtab)); - apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, curbuf); - } /* Also check windows in other tab pages. */ for (tp = first_tabpage; tp != NULL; tp = nexttp) { @@ -1762,11 +1756,6 @@ void close_windows(buf_T *buf, int keep_curwin) break; } } - if (count != tabpage_index(NULL)) { - char_u prev_idx[NUMBUFLEN]; - sprintf((char *)prev_idx, "%i", tabpage_index(tp)); - apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, curbuf); - } } } @@ -1854,7 +1843,6 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, // Since goto_tabpage_tp above did not trigger *Enter autocommands, do // that now. - apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, curbuf); apply_autocmds(EVENT_WINENTER, NULL, NULL, false, curbuf); apply_autocmds(EVENT_TABENTER, NULL, NULL, false, curbuf); if (old_curbuf != curbuf) { @@ -2114,6 +2102,10 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) /* When closing the last window in a tab page remove the tab page. */ if (tp->tp_firstwin == tp->tp_lastwin) { + // save index for tabclosed event + char_u prev_idx[NUMBUFLEN]; + sprintf((char *)prev_idx, "%i", tabpage_index(tp)); + if (tp == first_tabpage) first_tabpage = tp->tp_next; else { @@ -2127,6 +2119,8 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) ptp->tp_next = tp->tp_next; } free_tp = TRUE; + + apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, win->w_buffer); } /* Free the memory used for the window. */ -- cgit From 5dd2ca767f3163cb9d051a9a2676ac88f600ebad Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 29 Dec 2017 20:52:56 +0100 Subject: use snprintf and has_event --- src/nvim/window.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/window.c b/src/nvim/window.c index 81e986c5f2..2e1507c0ee 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2102,9 +2102,10 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) /* When closing the last window in a tab page remove the tab page. */ if (tp->tp_firstwin == tp->tp_lastwin) { - // save index for tabclosed event char_u prev_idx[NUMBUFLEN]; - sprintf((char *)prev_idx, "%i", tabpage_index(tp)); + if (has_event(EVENT_TABCLOSED)) { + vim_snprintf((char *)prev_idx, NUMBUFLEN, "%i", tabpage_index(tp)); + } if (tp == first_tabpage) first_tabpage = tp->tp_next; @@ -2120,7 +2121,9 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) } free_tp = TRUE; - apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, win->w_buffer); + if (has_event(EVENT_TABCLOSED)) { + apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, win->w_buffer); + } } /* Free the memory used for the window. */ -- cgit From 697fb05c580ab01cfd97f84632e608e951b80cbf Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 30 Dec 2017 01:17:31 -0500 Subject: vim-patch:8.0.0608: cannot manipulate other than the current quickfix list Problem: Cannot manipulate other than the current quickfix list. Solution: Pass the list index to quickfix functions. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/a3921f48c6b31a035c80fda49925dd3b42df0dec --- src/nvim/quickfix.c | 67 +++++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index f85009dca8..bf2993b320 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1121,6 +1121,7 @@ qf_init_ext( } if (qf_add_entry(qi, + qi->qf_curlist, qi->qf_directory, (*fields.namebuf || qi->qf_directory) ? fields.namebuf : ((qi->qf_currfile && fields.valid) @@ -1182,12 +1183,12 @@ qf_init_end: return retval; } -static void qf_store_title(qf_info_T *qi, char_u *title) +static void qf_store_title(qf_info_T *qi, int qf_idx, char_u *title) { if (title != NULL) { char_u *p = xmalloc(STRLEN(title) + 2); - qi->qf_lists[qi->qf_curlist].qf_title = p; + qi->qf_lists[qf_idx].qf_title = p; sprintf((char *)p, ":%s", (char *)title); } } @@ -1217,7 +1218,7 @@ static void qf_new_list(qf_info_T *qi, char_u *qf_title) } else qi->qf_curlist = qi->qf_listcount++; memset(&qi->qf_lists[qi->qf_curlist], 0, (size_t)(sizeof(qf_list_T))); - qf_store_title(qi, qf_title); + qf_store_title(qi, qi->qf_curlist, qf_title); } /* @@ -1260,6 +1261,7 @@ void qf_free_all(win_T *wp) /// Add an entry to the end of the list of errors. /// /// @param qi quickfix list +/// @param qf_idx list index /// @param dir optional directory name /// @param fname file name or NULL /// @param bufnum buffer number or zero @@ -1273,9 +1275,10 @@ void qf_free_all(win_T *wp) /// @param valid valid entry /// /// @returns OK or FAIL. -static int qf_add_entry(qf_info_T *qi, char_u *dir, char_u *fname, int bufnum, - char_u *mesg, long lnum, int col, char_u vis_col, - char_u *pattern, int nr, char_u type, char_u valid) +static int qf_add_entry(qf_info_T *qi, int qf_idx, char_u *dir, char_u *fname, + int bufnum, char_u *mesg, long lnum, int col, + char_u vis_col, char_u *pattern, int nr, char_u type, + char_u valid) { qfline_T *qfp = xmalloc(sizeof(qfline_T)); qfline_T **lastp; // pointer to qf_last or NULL @@ -1306,12 +1309,12 @@ static int qf_add_entry(qf_info_T *qi, char_u *dir, char_u *fname, int bufnum, qfp->qf_type = (char_u)type; qfp->qf_valid = valid; - lastp = &qi->qf_lists[qi->qf_curlist].qf_last; - if (qi->qf_lists[qi->qf_curlist].qf_count == 0) { + lastp = &qi->qf_lists[qf_idx].qf_last; + if (qi->qf_lists[qf_idx].qf_count == 0) { /* first element in the list */ - qi->qf_lists[qi->qf_curlist].qf_start = qfp; - qi->qf_lists[qi->qf_curlist].qf_ptr = qfp; - qi->qf_lists[qi->qf_curlist].qf_index = 0; + qi->qf_lists[qf_idx].qf_start = qfp; + qi->qf_lists[qf_idx].qf_ptr = qfp; + qi->qf_lists[qf_idx].qf_index = 0; qfp->qf_prev = NULL; } else { assert(*lastp); @@ -1321,12 +1324,11 @@ static int qf_add_entry(qf_info_T *qi, char_u *dir, char_u *fname, int bufnum, qfp->qf_next = NULL; qfp->qf_cleared = false; *lastp = qfp; - qi->qf_lists[qi->qf_curlist].qf_count++; - if (qi->qf_lists[qi->qf_curlist].qf_index == 0 && qfp->qf_valid) { + qi->qf_lists[qf_idx].qf_count++; + if (qi->qf_lists[qf_idx].qf_index == 0 && qfp->qf_valid) { /* first valid entry */ - qi->qf_lists[qi->qf_curlist].qf_index = - qi->qf_lists[qi->qf_curlist].qf_count; - qi->qf_lists[qi->qf_curlist].qf_ptr = qfp; + qi->qf_lists[qf_idx].qf_index = qi->qf_lists[qf_idx].qf_count; + qi->qf_lists[qf_idx].qf_ptr = qfp; } return OK; @@ -1429,6 +1431,7 @@ void copy_loclist(win_T *from, win_T *to) i < from_qfl->qf_count && from_qfp != NULL; i++, from_qfp = from_qfp->qf_next) { if (qf_add_entry(to->w_llist, + to->w_llist->qf_curlist, NULL, NULL, 0, @@ -3704,6 +3707,7 @@ void ex_vimgrep(exarg_T *eap) // dummy buffer, unless duplicate_name is set, then the // buffer will be wiped out below. if (qf_add_entry(qi, + qi->qf_curlist, NULL, // dir fname, duplicate_name ? 0 : buf->b_fnum, @@ -4164,23 +4168,24 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) /// Add list of entries to quickfix/location list. Each list entry is /// a dictionary with item information. -static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title, - int action) +static int qf_add_entries(qf_info_T *qi, int qf_idx, list_T *list, + char_u *title, int action) { dict_T *d; qfline_T *old_last = NULL; int retval = OK; bool did_bufnr_emsg = false; - if (action == ' ' || qi->qf_curlist == qi->qf_listcount) { + if (action == ' ' || qf_idx == qi->qf_listcount) { // make place for a new list qf_new_list(qi, title); - } else if (action == 'a' && qi->qf_lists[qi->qf_curlist].qf_count > 0) { + qf_idx = qi->qf_curlist; + } else if (action == 'a' && qi->qf_lists[qf_idx].qf_count > 0) { // Adding to existing list, use last entry. - old_last = qi->qf_lists[qi->qf_curlist].qf_last; + old_last = qi->qf_lists[qf_idx].qf_last; } else if (action == 'r') { - qf_free(qi, qi->qf_curlist); - qf_store_title(qi, title); + qf_free(qi, qf_idx); + qf_store_title(qi, qf_idx, title); } TV_LIST_ITER_CONST(list, li, { @@ -4228,6 +4233,7 @@ static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title, } int status = qf_add_entry(qi, + qf_idx, NULL, // dir (char_u *)filename, bufnum, @@ -4250,16 +4256,16 @@ static int qf_add_entries(qf_info_T *qi, list_T *list, char_u *title, } }); - if (qi->qf_lists[qi->qf_curlist].qf_index == 0) { + if (qi->qf_lists[qf_idx].qf_index == 0) { // no valid entry - qi->qf_lists[qi->qf_curlist].qf_nonevalid = true; + qi->qf_lists[qf_idx].qf_nonevalid = true; } else { - qi->qf_lists[qi->qf_curlist].qf_nonevalid = false; + qi->qf_lists[qf_idx].qf_nonevalid = false; } if (action != 'a') { - qi->qf_lists[qi->qf_curlist].qf_ptr = qi->qf_lists[qi->qf_curlist].qf_start; - if (qi->qf_lists[qi->qf_curlist].qf_count > 0) { - qi->qf_lists[qi->qf_curlist].qf_index = 1; + qi->qf_lists[qf_idx].qf_ptr = qi->qf_lists[qf_idx].qf_start; + if (qi->qf_lists[qf_idx].qf_count > 0) { + qi->qf_lists[qf_idx].qf_index = 1; } } @@ -4400,7 +4406,7 @@ int set_errorlist(win_T *wp, list_T *list, int action, char_u *title, } else if (what != NULL) { retval = qf_set_properties(qi, what, action); } else { - retval = qf_add_entries(qi, list, title, action); + retval = qf_add_entries(qi, qi->qf_curlist, list, title, action); } return retval; @@ -4718,6 +4724,7 @@ void ex_helpgrep(exarg_T *eap) line[--l] = NUL; if (qf_add_entry(qi, + qi->qf_curlist, NULL, // dir fnames[fi], 0, -- cgit From caf94c72c51b3595676907c66e6259785a87420b Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 30 Dec 2017 07:56:12 -0500 Subject: lint --- src/nvim/quickfix.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index bf2993b320..120a449690 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1186,10 +1186,11 @@ qf_init_end: static void qf_store_title(qf_info_T *qi, int qf_idx, char_u *title) { if (title != NULL) { - char_u *p = xmalloc(STRLEN(title) + 2); + size_t len = STRLEN(title) + 1; + char_u *p = xmallocz(len); qi->qf_lists[qf_idx].qf_title = p; - sprintf((char *)p, ":%s", (char *)title); + snprintf((char *)p, len + 1, ":%s", (char *)title); } } @@ -1311,7 +1312,7 @@ static int qf_add_entry(qf_info_T *qi, int qf_idx, char_u *dir, char_u *fname, lastp = &qi->qf_lists[qf_idx].qf_last; if (qi->qf_lists[qf_idx].qf_count == 0) { - /* first element in the list */ + // first element in the list qi->qf_lists[qf_idx].qf_start = qfp; qi->qf_lists[qf_idx].qf_ptr = qfp; qi->qf_lists[qf_idx].qf_index = 0; @@ -1326,7 +1327,7 @@ static int qf_add_entry(qf_info_T *qi, int qf_idx, char_u *dir, char_u *fname, *lastp = qfp; qi->qf_lists[qf_idx].qf_count++; if (qi->qf_lists[qf_idx].qf_index == 0 && qfp->qf_valid) { - /* first valid entry */ + // first valid entry qi->qf_lists[qf_idx].qf_index = qi->qf_lists[qf_idx].qf_count; qi->qf_lists[qf_idx].qf_ptr = qfp; } -- cgit From 46f432074e739a0eca9bb204e9c7769935669dbd Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 29 Dec 2017 21:13:21 +0100 Subject: tests: termclose_spec: fix flaky SIGTERM test #7787 Followup to https://github.com/neovim/neovim/pull/7217. Build failure: https://travis-ci.org/neovim/neovim/jobs/322930672#L2958. --- src/nvim/window.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/window.c b/src/nvim/window.c index 2e1507c0ee..b687781dfb 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -2104,25 +2104,26 @@ void win_close_othertab(win_T *win, int free_buf, tabpage_T *tp) if (tp->tp_firstwin == tp->tp_lastwin) { char_u prev_idx[NUMBUFLEN]; if (has_event(EVENT_TABCLOSED)) { - vim_snprintf((char *)prev_idx, NUMBUFLEN, "%i", tabpage_index(tp)); + vim_snprintf((char *)prev_idx, NUMBUFLEN, "%i", tabpage_index(tp)); } - if (tp == first_tabpage) + if (tp == first_tabpage) { first_tabpage = tp->tp_next; - else { + } else { for (ptp = first_tabpage; ptp != NULL && ptp->tp_next != tp; - ptp = ptp->tp_next) - ; + ptp = ptp->tp_next) { + // loop + } if (ptp == NULL) { internal_error("win_close_othertab()"); return; } ptp->tp_next = tp->tp_next; } - free_tp = TRUE; + free_tp = true; if (has_event(EVENT_TABCLOSED)) { - apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, win->w_buffer); + apply_autocmds(EVENT_TABCLOSED, prev_idx, prev_idx, false, win->w_buffer); } } -- cgit From c55cf5f4c181856d7ebb6697e8558d71279e7adb Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 31 Dec 2017 00:50:31 +0300 Subject: eval,lua/converter: Fix problems spotted in review --- src/nvim/eval.c | 60 ++++++++++++++++++++++++++---------------------- src/nvim/lua/converter.c | 2 +- 2 files changed, 33 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 370d4f0c0b..d2432e864f 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1515,7 +1515,6 @@ ex_let_vars ( ) { char_u *arg = arg_start; - int i; typval_T ltv; if (*arg != '[') { @@ -1534,17 +1533,17 @@ ex_let_vars ( } list_T *const l = tv->vval.v_list; - i = tv_list_len(l); - if (semicolon == 0 && var_count < i) { + const int len = tv_list_len(l); + if (semicolon == 0 && var_count < len) { EMSG(_("E687: Less targets than List items")); return FAIL; } - if (var_count - semicolon > i) { + if (var_count - semicolon > len) { EMSG(_("E688: More targets than List items")); return FAIL; } - // lt may actually be NULL, but it should fail with E688 or even earlier if - // you try to do ":let [] = v:_null_list". + // List l may actually be NULL, but it should fail with E688 or even earlier + // if you try to do ":let [] = v:_null_list". assert(l != NULL); listitem_T *item = tv_list_first(l); @@ -12220,10 +12219,11 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, // matchlist(): return empty list when there are no matches. case kSomeMatchList: { tv_list_alloc_ret(rettv); - FALLTHROUGH; + break; } // matchstrpos(): return ["", -1, -1, -1] case kSomeMatchStrPos: { + tv_list_alloc_ret(rettv); tv_list_append_string(rettv->vval.v_list, "", 0); tv_list_append_number(rettv->vval.v_list, -1); tv_list_append_number(rettv->vval.v_list, -1); @@ -12385,7 +12385,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, if (l != NULL) { rettv->vval.v_number = idx; } else { - if (type == kSomeMatchEnd) { + if (type == kSomeMatch) { rettv->vval.v_number = (varnumber_T)(regmatch.startp[0] - str); } else { @@ -12394,6 +12394,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, } rettv->vval.v_number += (varnumber_T)(str - expr); } + break; } } } @@ -13020,7 +13021,6 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) long prevlen = 0; /* length of data in prev */ long prevsize = 0; /* size of prev buffer */ long maxline = MAXLNUM; - long cnt = 0; char_u *p; /* position in buf */ char_u *start; /* start of current line */ @@ -13034,6 +13034,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) } tv_list_alloc_ret(rettv); + list_T *const l = rettv->vval.v_list; // Always open the file in binary mode, library functions have a mind of // their own about CR-LF conversion. @@ -13043,7 +13044,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) return; } - while (cnt < maxline || maxline < 0) { + while (maxline < 0 || tv_list_len(l) < maxline) { readlen = (int)fread(buf, 1, io_size, fd); /* This for loop processes what was read, but is also entered at end @@ -13081,22 +13082,32 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) prevlen = prevsize = 0; } - tv_list_append_owned_tv(rettv->vval.v_list, (typval_T) { + tv_list_append_owned_tv(l, (typval_T) { .v_type = VAR_STRING, .v_lock = VAR_UNLOCKED, .vval.v_string = s, }); - start = p + 1; /* step over newline */ - if ((++cnt >= maxline && maxline >= 0) || readlen <= 0) + start = p + 1; // Step over newline. + if (maxline < 0) { + if (tv_list_len(l) > -maxline) { + assert(tv_list_len(l) == 1 + (-maxline)); + tv_list_item_remove(l, tv_list_first(l)); + } + } else if (tv_list_len(l) >= maxline) { + assert(tv_list_len(l) == maxline); break; - } else if (*p == NUL) + } + if (readlen <= 0) { + break; + } + } else if (*p == NUL) { *p = '\n'; - /* Check for utf8 "bom"; U+FEFF is encoded as EF BB BF. Do this - * when finding the BF and check the previous two bytes. */ - else if (*p == 0xbf && enc_utf8 && !binary) { - /* Find the two bytes before the 0xbf. If p is at buf, or buf - * + 1, these may be in the "prev" string. */ + // Check for utf8 "bom"; U+FEFF is encoded as EF BB BF. Do this + // when finding the BF and check the previous two bytes. + } else if (*p == 0xbf && !binary) { + // Find the two bytes before the 0xbf. If p is at buf, or buf + 1, + // these may be in the "prev" string. char_u back1 = p >= buf + 1 ? p[-1] : prevlen >= 1 ? prev[prevlen - 1] : NUL; char_u back2 = p >= buf + 2 ? p[-2] @@ -13130,8 +13141,9 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } /* for */ - if ((cnt >= maxline && maxline >= 0) || readlen <= 0) + if ((maxline >= 0 && tv_list_len(l) >= maxline) || readlen <= 0) { break; + } if (start < p) { /* There's part of a line in buf, store it in "prev". */ if (p - start + prevlen >= prevsize) { @@ -13155,14 +13167,6 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } /* while */ - // For a negative line count use only the lines at the end of the file, - // free the rest. - if (maxline < -tv_list_len(rettv->vval.v_list)) { - listitem_T *const first_li = tv_list_find(rettv->vval.v_list, maxline); - listitem_T *const last_li = tv_list_last(rettv->vval.v_list); - tv_list_remove_items(rettv->vval.v_list, first_li, last_li); - } - xfree(prev); fclose(fd); } diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index 89fedae73a..61cb428923 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -213,7 +213,6 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) if (cur.special) { list_T *const kv_pair = tv_list_alloc(); - tv_list_append_list(cur.tv->vval.v_list, kv_pair); typval_T s_tv = decode_string(s, len, kTrue, false, false); if (s_tv.v_type == VAR_UNKNOWN) { ret = false; @@ -227,6 +226,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) .v_type = VAR_UNKNOWN, }); kv_push(stack, cur); + tv_list_append_list(cur.tv->vval.v_list, kv_pair); cur = (TVPopStackItem) { .tv = TV_LIST_ITEM_TV(tv_list_last(kv_pair)), .container = false, -- cgit From 8ac7c23b7dd7c435fb80315921e3704c8e0a7448 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 31 Dec 2017 00:57:17 +0300 Subject: eval: Fix linter errors --- src/nvim/eval.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index d2432e864f..33f8ffb738 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -12358,7 +12358,7 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, } case kSomeMatchList: { // Return list with matched string and submatches. - for (int i = 0; i < NSUBEXP; ++i) { + for (int i = 0; i < NSUBEXP; i++) { if (regmatch.endp[i] == NULL) { tv_list_append_string(rettv->vval.v_list, NULL, 0); } else { @@ -13021,8 +13021,6 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) long prevlen = 0; /* length of data in prev */ long prevsize = 0; /* size of prev buffer */ long maxline = MAXLNUM; - char_u *p; /* position in buf */ - char_u *start; /* start of current line */ if (argvars[1].v_type != VAR_UNKNOWN) { if (strcmp(tv_get_string(&argvars[1]), "b") == 0) { @@ -13047,14 +13045,16 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) while (maxline < 0 || tv_list_len(l) < maxline) { readlen = (int)fread(buf, 1, io_size, fd); - /* This for loop processes what was read, but is also entered at end - * of file so that either: - * - an incomplete line gets written - * - a "binary" file gets an empty line at the end if it ends in a - * newline. */ + // This for loop processes what was read, but is also entered at end + // of file so that either: + // - an incomplete line gets written + // - a "binary" file gets an empty line at the end if it ends in a + // newline. + char_u *p; // Position in buf. + char_u *start; // Start of current line. for (p = buf, start = buf; p < buf + readlen || (readlen <= 0 && (prevlen > 0 || binary)); - ++p) { + p++) { if (*p == '\n' || readlen <= 0) { char_u *s = NULL; size_t len = p - start; @@ -15416,7 +15416,7 @@ static void do_sort_uniq(typval_T *argvars, typval_T *rettv, bool sort) } } - /* Make an array with each entry pointing to an item in the List. */ + // Make an array with each entry pointing to an item in the List. ptrs = xmalloc((size_t)(len * sizeof(ListSortItem))); if (sort) { -- cgit From 6742fd8aead06e45f19b59222f96ccdcb1748e4c Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 30 Dec 2017 23:39:51 -0500 Subject: vim-patch:8.0.0634: cannot easily get to the last quickfix list Problem: Cannot easily get to the last quickfix list. Solution: Add "$" as a value for the "nr" argument of getqflist() and setqflist(). (Yegappan Lakshmanan) https://github.com/vim/vim/commit/875feea6ce223462d55543735143d747dcaf4287 --- src/nvim/quickfix.c | 47 ++++++++++++++++++++++++++++---------- src/nvim/testdir/test_quickfix.vim | 44 +++++++++++++++++++++++++++++++++-- 2 files changed, 77 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 120a449690..1d368bf87a 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4088,16 +4088,22 @@ enum { int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) { qf_info_T *qi = &ql_info; + dictitem_T *di; if (wp != NULL) { qi = GET_LOC_LIST(wp); if (qi == NULL) { + // If querying for the size of the location list, return 0 + if (((di = tv_dict_find(what, S_LEN("nr"))) != NULL) + && (di->di_tv.v_type == VAR_STRING) + && strequal((const char *)di->di_tv.vval.v_string, "$")) { + return tv_dict_add_nr(retdict, S_LEN("nr"), 0); + } return FAIL; } } int status = OK; - dictitem_T *di; int flags = QF_GETLIST_NONE; int qf_idx = qi->qf_curlist; // default is the current list @@ -4110,6 +4116,17 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) if (qf_idx < 0 || qf_idx >= qi->qf_listcount) { return FAIL; } + } else if (qi->qf_listcount == 0) { // stack is empty + return FAIL; + } + flags |= QF_GETLIST_NR; + } else if (di->di_tv.v_type == VAR_STRING + && strequal((const char *)di->di_tv.vval.v_string, "$")) { + // Get the last quickfix list number + if (qi->qf_listcount > 0) { + qf_idx = qi->qf_listcount - 1; + } else { + qf_idx = -1; // Quickfix stack is empty } flags |= QF_GETLIST_NR; } else { @@ -4117,20 +4134,22 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) } } - if (tv_dict_find(what, S_LEN("all")) != NULL) { - flags |= QF_GETLIST_ALL; - } + if (qf_idx != -1) { + if (tv_dict_find(what, S_LEN("all")) != NULL) { + flags |= QF_GETLIST_ALL; + } - if (tv_dict_find(what, S_LEN("title")) != NULL) { - flags |= QF_GETLIST_TITLE; - } + if (tv_dict_find(what, S_LEN("title")) != NULL) { + flags |= QF_GETLIST_TITLE; + } - if (tv_dict_find(what, S_LEN("winid")) != NULL) { - flags |= QF_GETLIST_WINID; - } + if (tv_dict_find(what, S_LEN("winid")) != NULL) { + flags |= QF_GETLIST_WINID; + } - if (tv_dict_find(what, S_LEN("context")) != NULL) { - flags |= QF_GETLIST_CONTEXT; + if (tv_dict_find(what, S_LEN("context")) != NULL) { + flags |= QF_GETLIST_CONTEXT; + } } if (flags & QF_GETLIST_TITLE) { @@ -4296,6 +4315,10 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action) if (qf_idx < 0 || qf_idx >= qi->qf_listcount) { return FAIL; } + } else if (di->di_tv.v_type == VAR_STRING + && strequal((const char *)di->di_tv.vval.v_string, "$") + && qi->qf_listcount > 0) { + qf_idx = qi->qf_listcount - 1; } else { return FAIL; } diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 30023dddc9..828176e6be 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -1632,12 +1632,12 @@ func XbottomTests(cchar) call assert_fails('lbottom', 'E776:') endif - call g:Xsetlist([{'filename': 'foo', 'lnum': 42}]) + call g:Xsetlist([{'filename': 'foo', 'lnum': 42}]) Xopen let wid = win_getid() call assert_equal(1, line('.')) wincmd w - call g:Xsetlist([{'filename': 'var', 'lnum': 24}], 'a') + call g:Xsetlist([{'filename': 'var', 'lnum': 24}], 'a') Xbottom call win_gotoid(wid) call assert_equal(2, line('.')) @@ -2102,3 +2102,43 @@ func Test_bufoverflow() set efm&vim endfunc +func Test_cclose_from_copen() + augroup QF_Test + au! + au FileType qf :cclose + augroup END + copen + augroup QF_Test + au! + augroup END + augroup! QF_Test +endfunc + +" Tests for getting the quickfix stack size +func XsizeTests(cchar) + call s:setup_commands(a:cchar) + + call g:Xsetlist([], 'f') + call assert_equal(0, g:Xgetlist({'nr':'$'}).nr) + call assert_equal(1, len(g:Xgetlist({'nr':'$', 'all':1}))) + call assert_equal(0, len(g:Xgetlist({'nr':0}))) + + Xexpr "File1:10:Line1" + Xexpr "File2:20:Line2" + Xexpr "File3:30:Line3" + Xolder | Xolder + call assert_equal(3, g:Xgetlist({'nr':'$'}).nr) + call g:Xsetlist([], 'f') + + Xexpr "File1:10:Line1" + Xexpr "File2:20:Line2" + Xexpr "File3:30:Line3" + Xolder | Xolder + call g:Xsetlist([], 'a', {'nr':'$', 'title':'Compiler'}) + call assert_equal('Compiler', g:Xgetlist({'nr':3, 'all':1}).title) +endfunc + +func Test_Qf_Size() + call XsizeTests('c') + call XsizeTests('l') +endfunc -- cgit From d0c4bd23f78ee00943725ea77a63f2a223dba66b Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 31 Dec 2017 00:36:35 -0500 Subject: vim-patch:8.0.0657: cannot get and set quickfix list items Problem: Cannot get and set quickfix list items. Solution: Add the "items" argument to getqflist() and setqflist(). (Yegappan Lakshmanan) https://github.com/vim/vim/commit/6a8958db259d4444da6e6956e54a6513c1af8860 --- src/nvim/quickfix.c | 81 +++++++++++++++++++++++++++++--------- src/nvim/testdir/test_quickfix.vim | 67 +++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 1d368bf87a..224e43008d 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -76,18 +76,25 @@ struct qfline_S { */ #define LISTCOUNT 10 +/// Quickfix/Location list definition +/// +/// Usually the list contains one or more entries. But an empty list can be +/// created using setqflist()/setloclist() with a title and/or user context +/// information and entries can be added later using setqflist()/setloclist(). typedef struct qf_list_S { - qfline_T *qf_start; // pointer to the first error - qfline_T *qf_last; // pointer to the last error - qfline_T *qf_ptr; // pointer to the current error - int qf_count; // number of errors (0 means no error list) - int qf_index; // current index in the error list - int qf_nonevalid; // TRUE if not a single valid entry found - char_u *qf_title; // title derived from the command that created - // the error list - typval_T *qf_ctx; // context set by setqflist/setloclist + qfline_T *qf_start; ///< pointer to the first error + qfline_T *qf_last; ///< pointer to the last error + qfline_T *qf_ptr; ///< pointer to the current error + int qf_count; ///< number of errors (0 means empty list) + int qf_index; ///< current index in the error list + int qf_nonevalid; ///< TRUE if not a single valid entry found + char_u *qf_title; ///< title derived from the command that created + ///< the error list or set by setqflist + typval_T *qf_ctx; ///< context set by setqflist/setloclist } qf_list_T; +/// Quickfix/Location list stack definition +/// Contains a list of quickfix/location lists (qf_list_T) struct qf_info_S { /* * Count of references to this list. Used only for location lists. @@ -1185,6 +1192,9 @@ qf_init_end: static void qf_store_title(qf_info_T *qi, int qf_idx, char_u *title) { + xfree(qi->qf_lists[qf_idx].qf_title); + qi->qf_lists[qf_idx].qf_title = NULL; + if (title != NULL) { size_t len = STRLEN(title) + 1; char_u *p = xmallocz(len); @@ -2396,8 +2406,9 @@ void qf_history(exarg_T *eap) } } -/// Free all the entries in the error list "idx". -static void qf_free(qf_info_T *qi, int idx) +/// Free all the entries in the error list "idx". Note that other information +/// associated with the list like context and title are not freed. +static void qf_free_items(qf_info_T *qi, int idx) { qfline_T *qfp; qfline_T *qfpnext; @@ -2421,12 +2432,9 @@ static void qf_free(qf_info_T *qi, int idx) qi->qf_lists[idx].qf_start = qfpnext; qi->qf_lists[idx].qf_count--; } - xfree(qi->qf_lists[idx].qf_title); + qi->qf_lists[idx].qf_start = NULL; qi->qf_lists[idx].qf_ptr = NULL; - qi->qf_lists[idx].qf_title = NULL; - tv_free(qi->qf_lists[idx].qf_ctx); - qi->qf_lists[idx].qf_ctx = NULL; qi->qf_lists[idx].qf_index = 0; qi->qf_lists[idx].qf_start = NULL; qi->qf_lists[idx].qf_last = NULL; @@ -2442,6 +2450,18 @@ static void qf_free(qf_info_T *qi, int idx) qi->qf_multiscan = false; } +/// Free error list "idx". Frees all the entries in the quickfix list, +/// associated context information and the title. +static void qf_free(qf_info_T *qi, int idx) +{ + qf_free_items(qi, idx); + + xfree(qi->qf_lists[idx].qf_title); + qi->qf_lists[idx].qf_title = NULL; + tv_free(qi->qf_lists[idx].qf_ctx); + qi->qf_lists[idx].qf_ctx = NULL; +} + /* * qf_mark_adjust: adjust marks */ @@ -4150,6 +4170,10 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) if (tv_dict_find(what, S_LEN("context")) != NULL) { flags |= QF_GETLIST_CONTEXT; } + + if (tv_dict_find(what, S_LEN("items")) != NULL) { + flags |= QF_GETLIST_ITEMS; + } } if (flags & QF_GETLIST_TITLE) { @@ -4168,6 +4192,11 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) status = tv_dict_add_nr(retdict, S_LEN("winid"), win->handle); } } + if ((status == OK) && (flags & QF_GETLIST_ITEMS)) { + list_T *l = tv_list_alloc(); + (void)get_errorlist(wp, qf_idx, l); + tv_dict_add_list(retdict, S_LEN("items"), l); + } if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) { if (qi->qf_lists[qf_idx].qf_ctx != NULL) { @@ -4204,7 +4233,7 @@ static int qf_add_entries(qf_info_T *qi, int qf_idx, list_T *list, // Adding to existing list, use last entry. old_last = qi->qf_lists[qf_idx].qf_last; } else if (action == 'r') { - qf_free(qi, qf_idx); + qf_free_items(qi, qf_idx); qf_store_title(qi, qf_idx, title); } @@ -4312,17 +4341,24 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action) if (di->di_tv.vval.v_number != 0) { qf_idx = (int)di->di_tv.vval.v_number - 1; } - if (qf_idx < 0 || qf_idx >= qi->qf_listcount) { + + if ((action == ' ' || action == 'a') && qf_idx == qi->qf_listcount) { + // When creating a new list, accept qf_idx pointing to the next + // non-available list + newlist = true; + } else if (qf_idx < 0 || qf_idx >= qi->qf_listcount) { return FAIL; + } else { + newlist = false; // use the specified list } } else if (di->di_tv.v_type == VAR_STRING && strequal((const char *)di->di_tv.vval.v_string, "$") && qi->qf_listcount > 0) { qf_idx = qi->qf_listcount - 1; + newlist = false; } else { return FAIL; } - newlist = false; // use the specified list } if (newlist) { @@ -4341,6 +4377,15 @@ static int qf_set_properties(qf_info_T *qi, dict_T *what, int action) retval = OK; } } + if ((di = tv_dict_find(what, S_LEN("items"))) != NULL) { + if (di->di_tv.v_type == VAR_LIST) { + char_u *title_save = vim_strsave(qi->qf_lists[qf_idx].qf_title); + + retval = qf_add_entries(qi, qf_idx, di->di_tv.vval.v_list, + title_save, action == ' ' ? 'a' : action); + xfree(title_save); + } + } if ((di = tv_dict_find(what, S_LEN("context"))) != NULL) { tv_free(qi->qf_lists[qf_idx].qf_ctx); diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 828176e6be..95a7d29089 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -1817,6 +1817,73 @@ func Xproperty_tests(cchar) call test_garbagecollect_now() let m = g:Xgetlist({'context' : 1}) call assert_equal(["red", "blue", "green"], m.context) + + " Test for setting/getting items + Xexpr "" + let qfprev = g:Xgetlist({'nr':0}) + call g:Xsetlist([], ' ', {'title':'Green', + \ 'items' : [{'filename':'F1', 'lnum':10}]}) + let qfcur = g:Xgetlist({'nr':0}) + call assert_true(qfcur.nr == qfprev.nr + 1) + let l = g:Xgetlist({'items':1}) + call assert_equal('F1', bufname(l.items[0].bufnr)) + call assert_equal(10, l.items[0].lnum) + call g:Xsetlist([], 'a', {'items' : [{'filename':'F2', 'lnum':20}, + \ {'filename':'F2', 'lnum':30}]}) + let l = g:Xgetlist({'items':1}) + call assert_equal('F2', bufname(l.items[2].bufnr)) + call assert_equal(30, l.items[2].lnum) + call g:Xsetlist([], 'r', {'items' : [{'filename':'F3', 'lnum':40}]}) + let l = g:Xgetlist({'items':1}) + call assert_equal('F3', bufname(l.items[0].bufnr)) + call assert_equal(40, l.items[0].lnum) + call g:Xsetlist([], 'r', {'items' : []}) + let l = g:Xgetlist({'items':1}) + call assert_equal(0, len(l.items)) + + " Save and restore the quickfix stack + call g:Xsetlist([], 'f') + call assert_equal(0, g:Xgetlist({'nr':'$'}).nr) + Xexpr "File1:10:Line1" + Xexpr "File2:20:Line2" + Xexpr "File3:30:Line3" + let last_qf = g:Xgetlist({'nr':'$'}).nr + call assert_equal(3, last_qf) + let qstack = [] + for i in range(1, last_qf) + let qstack = add(qstack, g:Xgetlist({'nr':i, 'all':1})) + endfor + call g:Xsetlist([], 'f') + for i in range(len(qstack)) + call g:Xsetlist([], ' ', qstack[i]) + endfor + call assert_equal(3, g:Xgetlist({'nr':'$'}).nr) + call assert_equal(10, g:Xgetlist({'nr':1, 'items':1}).items[0].lnum) + call assert_equal(20, g:Xgetlist({'nr':2, 'items':1}).items[0].lnum) + call assert_equal(30, g:Xgetlist({'nr':3, 'items':1}).items[0].lnum) + call g:Xsetlist([], 'f') + + " Swap two quickfix lists + Xexpr "File1:10:Line10" + Xexpr "File2:20:Line20" + Xexpr "File3:30:Line30" + call g:Xsetlist([], 'r', {'nr':1,'title':'Colors','context':['Colors']}) + call g:Xsetlist([], 'r', {'nr':2,'title':'Fruits','context':['Fruits']}) + let l1=g:Xgetlist({'nr':1,'all':1}) + let l2=g:Xgetlist({'nr':2,'all':1}) + let l1.nr=2 + let l2.nr=1 + call g:Xsetlist([], 'r', l1) + call g:Xsetlist([], 'r', l2) + let newl1=g:Xgetlist({'nr':1,'all':1}) + let newl2=g:Xgetlist({'nr':2,'all':1}) + call assert_equal(':Fruits', newl1.title) + call assert_equal(['Fruits'], newl1.context) + call assert_equal('Line20', newl1.items[0].text) + call assert_equal(':Colors', newl2.title) + call assert_equal(['Colors'], newl2.context) + call assert_equal('Line10', newl2.items[0].text) + call g:Xsetlist([], 'f') endfunc func Test_qf_property() -- cgit From 1d8c612f788b1a5c8d74814db4654462e0224831 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Mon, 1 Jan 2018 23:08:26 +0800 Subject: vim-patch:8.0.0339: illegal memory access with vi' (#7794) Problem: Illegal memory access with vi' Solution: For quoted text objects bail out if the Visual area spans more than one line. https://github.com/vim/vim/commit/46522af72424c7fadfa7a4cbba3dd21b82d19131 --- src/nvim/search.c | 5 +++++ src/nvim/testdir/test_visual.vim | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/nvim/search.c b/src/nvim/search.c index 387614fd09..1eb1a25a19 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -3669,6 +3669,11 @@ current_quote ( /* Correct cursor when 'selection' is exclusive */ if (VIsual_active) { + // this only works within one line + if (VIsual.lnum != curwin->w_cursor.lnum) { + return false; + } + vis_bef_curs = lt(VIsual, curwin->w_cursor); if (*p_sel == 'e' && vis_bef_curs) dec_cursor(); diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 1694adbd32..69607e642c 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -43,3 +43,10 @@ func Test_dotregister_paste() call assert_equal('hello world world', getline(1)) q! endfunc + +func Test_Visual_inner_quote() + new + normal oxX + normal vki' + bwipe! +endfunc -- cgit From 321a46b724ccb2e574875cf18c8d280f8516527c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 1 Jan 2018 16:21:55 +0100 Subject: vim-patch: b:changedtick-related patches vim-patch:8.0.0334 vim-patch:8.0.0335 vim-patch:8.0.0343 vim-patch:8.0.0345 Problem: Can't access b:changedtick from a dict reference. Solution: Make changedtick a member of the b: dict. (inspired by neovim vim/vim#6112) https://github.com/vim/vim/commit/79518e2ace5fce7b9c49060e462a6e935dba0a84 vim-patch:8.0.0343: b:changedtick can be unlocked Problem: b:changedtick can be unlocked, even though it has no effect. (Nikolai Pavlov) Solution: Add a check and error E940. (closes #1496) vim-patch:8.0.0345: islocked('d.changedtick') does not work Problem: islocked('d.changedtick') does not work. Solution: Make it work. vim-patch:8.0.0335: functions test fails Problem: Functions test fails. Solution: Use the right buffer number. https://github.com/vim/vim/commit/507647da3151f7ffccac1b217936240daa79849c --- src/nvim/testdir/Makefile | 1 + src/nvim/testdir/test_alot.vim | 3 +- src/nvim/testdir/test_changedtick.vim | 57 +++++++++++++++++++++++++++++++++++ src/nvim/testdir/test_functions.vim | 42 ++++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 src/nvim/testdir/test_changedtick.vim (limited to 'src') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 1f8cf8a0e7..5af8dd20cd 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -42,6 +42,7 @@ SCRIPTS ?= $(SCRIPTS_DEFAULT) NEW_TESTS ?= \ test_autocmd.res \ test_bufwintabinfo.res \ + test_changedtick.res \ test_charsearch.res \ test_cmdline.res \ test_command_count.res \ diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index c1f6405579..5ce6799b99 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -2,9 +2,10 @@ " This makes testing go faster, since Vim doesn't need to restart. source test_assign.vim +source test_changedtick.vim source test_cursor_func.vim -source test_execute_func.vim source test_ex_undo.vim +source test_execute_func.vim source test_expr.vim source test_expr_utf8.vim source test_feedkeys.vim diff --git a/src/nvim/testdir/test_changedtick.vim b/src/nvim/testdir/test_changedtick.vim new file mode 100644 index 0000000000..3a91bb54aa --- /dev/null +++ b/src/nvim/testdir/test_changedtick.vim @@ -0,0 +1,57 @@ +" Tests for b:changedtick + +func Test_changedtick_increments() + new + " New buffer has an empty line, tick starts at 2. + let expected = 2 + call assert_equal(expected, b:changedtick) + call assert_equal(expected, b:['changedtick']) + call setline(1, 'hello') + let expected += 1 + call assert_equal(expected, b:changedtick) + call assert_equal(expected, b:['changedtick']) + undo + " Somehow undo counts as two changes. + let expected += 2 + call assert_equal(expected, b:changedtick) + call assert_equal(expected, b:['changedtick']) + bwipe! +endfunc + +func Test_changedtick_dict_entry() + let d = b: + call assert_equal(b:changedtick, d['changedtick']) +endfunc + +func Test_changedtick_bdel() + new + let bnr = bufnr('%') + let v = b:changedtick + bdel + " Delete counts as a change too. + call assert_equal(v + 1, getbufvar(bnr, 'changedtick')) +endfunc + +func Test_changedtick_islocked() + call assert_equal(0, islocked('b:changedtick')) + let d = b: + call assert_equal(0, islocked('d.changedtick')) +endfunc + +func Test_changedtick_fixed() + call assert_fails('let b:changedtick = 4', 'E46:') + call assert_fails('let b:["changedtick"] = 4', 'E46:') + + call assert_fails('lockvar b:changedtick', 'E940:') + call assert_fails('lockvar b:["changedtick"]', 'E46:') + call assert_fails('unlockvar b:changedtick', 'E940:') + call assert_fails('unlockvar b:["changedtick"]', 'E46:') + call assert_fails('unlet b:changedtick', 'E795:') + call assert_fails('unlet b:["changedtick"]', 'E46:') + + let d = b: + call assert_fails('lockvar d["changedtick"]', 'E46:') + call assert_fails('unlockvar d["changedtick"]', 'E46:') + call assert_fails('unlet d["changedtick"]', 'E46:') + +endfunc diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index 0ce034b63e..398e9ab331 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -311,3 +311,45 @@ func! Test_mode() bwipe! iunmap endfunc + +func Test_getbufvar() + let bnr = bufnr('%') + let b:var_num = '1234' + let def_num = '5678' + call assert_equal('1234', getbufvar(bnr, 'var_num')) + call assert_equal('1234', getbufvar(bnr, 'var_num', def_num)) + + let bd = getbufvar(bnr, '') + call assert_equal('1234', bd['var_num']) + call assert_true(exists("bd['changedtick']")) + call assert_equal(2, len(bd)) + + let bd2 = getbufvar(bnr, '', def_num) + call assert_equal(bd, bd2) + + unlet b:var_num + call assert_equal(def_num, getbufvar(bnr, 'var_num', def_num)) + call assert_equal('', getbufvar(bnr, 'var_num')) + + let bd = getbufvar(bnr, '') + call assert_equal(1, len(bd)) + let bd = getbufvar(bnr, '',def_num) + call assert_equal(1, len(bd)) + + call assert_equal('', getbufvar(9999, '')) + call assert_equal(def_num, getbufvar(9999, '', def_num)) + unlet def_num + + call assert_equal(0, getbufvar(bnr, '&autoindent')) + call assert_equal(0, getbufvar(bnr, '&autoindent', 1)) + + " Open new window with forced option values + set fileformats=unix,dos + new ++ff=dos ++bin ++enc=iso-8859-2 + call assert_equal('dos', getbufvar(bufnr('%'), '&fileformat')) + call assert_equal(1, getbufvar(bufnr('%'), '&bin')) + call assert_equal('iso-8859-2', getbufvar(bufnr('%'), '&fenc')) + close + + set fileformats& +endfunc -- cgit From c5f9762b7e40d23e6a0cfc8f808761a084223859 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 1 Jan 2018 16:46:03 +0100 Subject: vim-patch:8.0.0336: flags of :substitute not sufficiently tested Problem: Flags of :substitute not sufficiently tested. Solution: Test up to two letter flag combinations. (James McCoy, closes vim/vim#1479) https://github.com/vim/vim/commit/8c50d50b6e19b755d7bad7b2724d14ead29364a7 --- src/nvim/testdir/test_substitute.vim | 67 ++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_substitute.vim b/src/nvim/testdir/test_substitute.vim index e2b6de03c3..a3bc04dcd0 100644 --- a/src/nvim/testdir/test_substitute.vim +++ b/src/nvim/testdir/test_substitute.vim @@ -39,3 +39,70 @@ function! Test_multiline_subst() call assert_equal('xxxxx', getline(13)) enew! endfunction + +function! Test_substitute_variants() + " Validate that all the 2-/3-letter variants which embed the flags into the + " command name actually work. + enew! + let ln = 'Testing string' + let variants = [ + \ { 'cmd': ':s/Test/test/c', 'exp': 'testing string', 'prompt': 'y' }, + \ { 'cmd': ':s/foo/bar/ce', 'exp': ln }, + \ { 'cmd': ':s/t/r/cg', 'exp': 'Tesring srring', 'prompt': 'a' }, + \ { 'cmd': ':s/t/r/ci', 'exp': 'resting string', 'prompt': 'y' }, + \ { 'cmd': ':s/t/r/cI', 'exp': 'Tesring string', 'prompt': 'y' }, + \ { 'cmd': ':s/t/r/cn', 'exp': ln }, + \ { 'cmd': ':s/t/r/cp', 'exp': 'Tesring string', 'prompt': 'y' }, + \ { 'cmd': ':s/t/r/cl', 'exp': 'Tesring string', 'prompt': 'y' }, + \ { 'cmd': ':s/t/r/gc', 'exp': 'Tesring srring', 'prompt': 'a' }, + \ { 'cmd': ':s/foo/bar/ge', 'exp': ln }, + \ { 'cmd': ':s/t/r/g', 'exp': 'Tesring srring' }, + \ { 'cmd': ':s/t/r/gi', 'exp': 'resring srring' }, + \ { 'cmd': ':s/t/r/gI', 'exp': 'Tesring srring' }, + \ { 'cmd': ':s/t/r/gn', 'exp': ln }, + \ { 'cmd': ':s/t/r/gp', 'exp': 'Tesring srring' }, + \ { 'cmd': ':s/t/r/gl', 'exp': 'Tesring srring' }, + \ { 'cmd': ':s//r/gr', 'exp': 'Testr strr' }, + \ { 'cmd': ':s/t/r/ic', 'exp': 'resting string', 'prompt': 'y' }, + \ { 'cmd': ':s/foo/bar/ie', 'exp': ln }, + \ { 'cmd': ':s/t/r/i', 'exp': 'resting string' }, + \ { 'cmd': ':s/t/r/iI', 'exp': 'Tesring string' }, + \ { 'cmd': ':s/t/r/in', 'exp': ln }, + \ { 'cmd': ':s/t/r/ip', 'exp': 'resting string' }, + \ { 'cmd': ':s//r/ir', 'exp': 'Testr string' }, + \ { 'cmd': ':s/t/r/Ic', 'exp': 'Tesring string', 'prompt': 'y' }, + \ { 'cmd': ':s/foo/bar/Ie', 'exp': ln }, + \ { 'cmd': ':s/t/r/Ig', 'exp': 'Tesring srring' }, + \ { 'cmd': ':s/t/r/Ii', 'exp': 'resting string' }, + \ { 'cmd': ':s/t/r/I', 'exp': 'Tesring string' }, + \ { 'cmd': ':s/t/r/Ip', 'exp': 'Tesring string' }, + \ { 'cmd': ':s/t/r/Il', 'exp': 'Tesring string' }, + \ { 'cmd': ':s//r/Ir', 'exp': 'Testr string' }, + \ { 'cmd': ':s//r/rc', 'exp': 'Testr string', 'prompt': 'y' }, + \ { 'cmd': ':s//r/rg', 'exp': 'Testr strr' }, + \ { 'cmd': ':s//r/ri', 'exp': 'Testr string' }, + \ { 'cmd': ':s//r/rI', 'exp': 'Testr string' }, + \ { 'cmd': ':s//r/rn', 'exp': 'Testing string' }, + \ { 'cmd': ':s//r/rp', 'exp': 'Testr string' }, + \ { 'cmd': ':s//r/rl', 'exp': 'Testr string' }, + \ { 'cmd': ':s//r/r', 'exp': 'Testr string' }, + \] + + for var in variants + for run in [1, 2] + let cmd = var.cmd + if run == 2 && cmd =~ "/.*/.*/." + " Change :s/from/to/{flags} to :s{flags} + let cmd = substitute(cmd, '/.*/', '', '') + endif + call setline(1, [ln]) + let msg = printf('using "%s"', cmd) + let @/='ing' + let v:errmsg = '' + call feedkeys(cmd . "\" . get(var, 'prompt', ''), 'ntx') + " No error should exist (matters for testing e flag) + call assert_equal('', v:errmsg, msg) + call assert_equal(var.exp, getline('.'), msg) + endfor + endfor +endfunction -- cgit From 60716371e97dae916c6525e9ba840aae562069bb Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 1 Jan 2018 19:38:18 +0100 Subject: tui: support TERM=konsole-256color TERM=konsole-256color is recognized by ncurses. TERM=konsole-xterm might be more clever, but should not be necessary (for Nvim at least), we already special-case Konsole in various places. We may need to clean up some areas that currently assume Konsole always "pretends xterm" (`TERM=xterm-256color`), though I didn't find any such cases. ref #6403 ref https://github.com/neovim/neovim/issues/6403#issuecomment-348713346 --- src/nvim/tui/terminfo.c | 4 ++-- src/nvim/tui/tui.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/tui/terminfo.c b/src/nvim/tui/terminfo.c index 492c1c5e9c..2f07e83158 100644 --- a/src/nvim/tui/terminfo.c +++ b/src/nvim/tui/terminfo.c @@ -90,8 +90,8 @@ bool terminfo_is_term_family(const char *term, const char *family) size_t tlen = strlen(term); size_t flen = strlen(family); return tlen >= flen - && 0 == memcmp(term, family, flen) \ - // Per the commentary in terminfo, minus sign is the suffix separator. + && 0 == memcmp(term, family, flen) + // Per commentary in terminfo, minus is the only valid suffix separator. && ('\0' == term[flen] || '-' == term[flen]); } diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index dbe1222dc0..df5b41a64b 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -222,7 +222,8 @@ static void terminfo_start(UI *ui) const char *vte_version_env = os_getenv("VTE_VERSION"); long vte_version = vte_version_env ? strtol(vte_version_env, NULL, 10) : 0; bool iterm_env = termprg && strstr(termprg, "iTerm.app"); - bool konsole = os_getenv("KONSOLE_PROFILE_NAME") + bool konsole = terminfo_is_term_family(term, "konsole") + || os_getenv("KONSOLE_PROFILE_NAME") || os_getenv("KONSOLE_DBUS_SESSION"); patch_terminfo_bugs(data, term, colorterm, vte_version, konsole, iterm_env); -- cgit From b86e44aa358c2164bebddbb4ed9640b000323c6b Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 1 Jan 2018 23:11:31 -0500 Subject: vim-patch:8.0.0160: EMSG() is sometimes used where it should be IEMSG() Problem: EMSG() is sometimes used for internal errors. Solution: Change them to IEMSG(). (Dominique Pelle) And a few more. https://github.com/vim/vim/commit/de33011ec623fd562419dede6bf465b5b9881a20 --- src/nvim/if_cscope.c | 2 +- src/nvim/regexp_nfa.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 654b4630c5..303a9bd92b 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -1370,7 +1370,7 @@ static char *cs_manage_matches(char **matches, char **contexts, cs_print_tags_priv(mp, cp, cnt); break; default: /* should not reach here */ - (void)EMSG(_("E570: fatal error in cs_manage_matches")); + IEMSG(_("E570: fatal error in cs_manage_matches")); return NULL; } diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index 93ba9ce097..bc3ad57dde 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -1263,7 +1263,7 @@ static int nfa_regatom(void) rc_did_emsg = TRUE; return FAIL; } - EMSGN("INTERNAL: Unknown character class char: %" PRId64, c); + IEMSGN("INTERNAL: Unknown character class char: %" PRId64, c); return FAIL; } /* When '.' is followed by a composing char ignore the dot, so that @@ -4414,7 +4414,7 @@ static int check_char_class(int class, int c) default: /* should not be here :P */ - EMSGN(_(e_ill_char_class), class); + IEMSGN(_(e_ill_char_class), class); return FAIL; } return FAIL; @@ -5993,7 +5993,7 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, #ifdef REGEXP_DEBUG if (c < 0) - EMSGN("INTERNAL: Negative state char: %" PRId64, c); + IEMSGN("INTERNAL: Negative state char: %" PRId64, c); #endif result = (c == curc); @@ -6464,9 +6464,9 @@ static regprog_T *nfa_regcomp(char_u *expr, int re_flags) if (postfix == NULL) { /* TODO: only give this error for debugging? */ if (post_ptr >= post_end) - EMSGN("Internal error: estimated max number " - "of states insufficient: %" PRId64, - post_end - post_start); + IEMSGN("Internal error: estimated max number " + "of states insufficient: %" PRId64, + post_end - post_start); goto fail; /* Cascaded (syntax?) error */ } -- cgit From 5f5011e8f67e6c26ec0c04d2f390bca392dba648 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Mon, 1 Jan 2018 23:17:31 -0500 Subject: lint --- src/nvim/if_cscope.c | 2 +- src/nvim/regexp_nfa.c | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/if_cscope.c b/src/nvim/if_cscope.c index 303a9bd92b..773e29693c 100644 --- a/src/nvim/if_cscope.c +++ b/src/nvim/if_cscope.c @@ -1369,7 +1369,7 @@ static char *cs_manage_matches(char **matches, char **contexts, case Print: cs_print_tags_priv(mp, cp, cnt); break; - default: /* should not reach here */ + default: // should not reach here IEMSG(_("E570: fatal error in cs_manage_matches")); return NULL; } diff --git a/src/nvim/regexp_nfa.c b/src/nvim/regexp_nfa.c index bc3ad57dde..c520ef5fb9 100644 --- a/src/nvim/regexp_nfa.c +++ b/src/nvim/regexp_nfa.c @@ -4413,7 +4413,7 @@ static int check_char_class(int class, int c) break; default: - /* should not be here :P */ + // should not be here :P IEMSGN(_(e_ill_char_class), class); return FAIL; } @@ -5992,8 +5992,9 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, int c = t->state->c; #ifdef REGEXP_DEBUG - if (c < 0) + if (c < 0) { IEMSGN("INTERNAL: Negative state char: %" PRId64, c); + } #endif result = (c == curc); @@ -6462,12 +6463,13 @@ static regprog_T *nfa_regcomp(char_u *expr, int re_flags) * (and count its size). */ postfix = re2post(); if (postfix == NULL) { - /* TODO: only give this error for debugging? */ - if (post_ptr >= post_end) + // TODO(vim): only give this error for debugging? + if (post_ptr >= post_end) { IEMSGN("Internal error: estimated max number " "of states insufficient: %" PRId64, post_end - post_start); - goto fail; /* Cascaded (syntax?) error */ + } + goto fail; // Cascaded (syntax?) error } /* -- cgit From d63c3d9d105b7d81ad397e784b33d3dec7073338 Mon Sep 17 00:00:00 2001 From: Paul Rigge Date: Sat, 30 Dec 2017 20:53:01 -0800 Subject: Add assertion in set_var_lval for null pointer. If the lval is a index into a list, li should not be null. --- src/nvim/eval.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 33f8ffb738..f30840041b 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2417,6 +2417,7 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, if (ri == NULL || (!lp->ll_empty2 && lp->ll_n2 == lp->ll_n1)) { break; } + assert(lp->ll_li != NULL); if (TV_LIST_ITEM_NEXT(lp->ll_list, lp->ll_li) == NULL) { // Need to add an empty item. tv_list_append_number(lp->ll_list, 0); -- cgit From dea7a41138674b45e8cfd5c1d713d4048987c830 Mon Sep 17 00:00:00 2001 From: Paul Rigge Date: Sat, 30 Dec 2017 22:17:31 -0800 Subject: Add another const to tv_copy Clang static analyzer had trouble with filter_map in eval.c because tv_copy could, in principle, change the v_type of argvars[0]. It saw a potential null pointer going somewhere it shouldn't as a result. The from argument in tv_copy should be const, which also cleans up the static analyzer's complaint. --- src/nvim/eval/typval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 21bb84a945..ac6c8c8aa6 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -2153,7 +2153,7 @@ void tv_free(typval_T *tv) /// /// @param[in] from Location to copy from. /// @param[out] to Location to copy to. -void tv_copy(typval_T *const from, typval_T *const to) +void tv_copy(const typval_T *const from, typval_T *const to) { to->v_type = from->v_type; to->v_lock = VAR_UNLOCKED; -- cgit From 65ec4ea62972e021065d5a5be83b04bb8da2561a Mon Sep 17 00:00:00 2001 From: Paul Rigge Date: Mon, 1 Jan 2018 20:20:57 -0800 Subject: Add assertions for watchers The clang static analyzer convinced itself lp->ll_newkey could be NULL. This adds an assertion that checks this doesn't actually happen, as well as a parallel assertion for di->di_key. --- src/nvim/eval.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f30840041b..555a0506d9 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2480,9 +2480,11 @@ static void set_var_lval(lval_T *lp, char_u *endp, typval_T *rettv, notify: if (watched) { if (oldtv.v_type == VAR_UNKNOWN) { + assert(lp->ll_newkey != NULL); tv_dict_watcher_notify(dict, (char *)lp->ll_newkey, lp->ll_tv, NULL); } else { dictitem_T *di = lp->ll_di; + assert(di->di_key != NULL); tv_dict_watcher_notify(dict, (char *)di->di_key, lp->ll_tv, &oldtv); tv_clear(&oldtv); } -- cgit From 2e630d261157dbb902768ba8ef8346ee1eb41eb7 Mon Sep 17 00:00:00 2001 From: Paul Rigge Date: Mon, 1 Jan 2018 21:15:22 -0800 Subject: Refactor profiling check in call_user_func. do_profiling is a global variable, and as such the clang static analyzer has trouble making arguments about it. This commit does one comparison against do_profiling and puts the result in a local variable. This prevents errors from the value of do_profiling changing between comparisons. --- src/nvim/eval.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 555a0506d9..1c4dda0716 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -21254,15 +21254,17 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, } } + const bool do_profiling_yes = do_profiling == PROF_YES; + bool func_not_yet_profiling_but_should = - do_profiling == PROF_YES + do_profiling_yes && !fp->uf_profiling && has_profiling(FALSE, fp->uf_name, NULL); if (func_not_yet_profiling_but_should) func_do_profile(fp); bool func_or_func_caller_profiling = - do_profiling == PROF_YES + do_profiling_yes && (fp->uf_profiling || (fc->caller != NULL && fc->caller->func->uf_profiling)); @@ -21272,7 +21274,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, fp->uf_tm_children = profile_zero(); } - if (do_profiling == PROF_YES) { + if (do_profiling_yes) { script_prof_save(&wait_start); } @@ -21348,7 +21350,7 @@ void call_user_func(ufunc_T *fp, int argcount, typval_T *argvars, sourcing_name = save_sourcing_name; sourcing_lnum = save_sourcing_lnum; current_SID = save_current_SID; - if (do_profiling == PROF_YES) + if (do_profiling_yes) script_prof_restore(&wait_start); if (p_verbose >= 12 && sourcing_name != NULL) { -- cgit From 1bbe6d0a3015007bf67fc81caab86859a0e2d2bd Mon Sep 17 00:00:00 2001 From: Paul Rigge Date: Mon, 1 Jan 2018 22:45:35 -0800 Subject: Add null pointer assertions for do_unlet_var. --- src/nvim/eval.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 1c4dda0716..186fa0da76 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2900,6 +2900,7 @@ static int do_unlet_var(lval_T *const lp, char_u *const name_end, int forceit) lp->ll_name_len))) { return FAIL; } else if (lp->ll_range) { + assert(lp->ll_list != NULL); // Delete a range of List items. listitem_T *const first_li = lp->ll_li; listitem_T *last_li = first_li; @@ -2926,6 +2927,7 @@ static int do_unlet_var(lval_T *const lp, char_u *const name_end, int forceit) } else { // unlet a Dictionary item. dict_T *d = lp->ll_dict; + assert(d != NULL); dictitem_T *di = lp->ll_di; bool watched = tv_dict_is_watched(d); char *key = NULL; -- cgit From 88d643eb36693bcbbac24ec3d6f63a316a452402 Mon Sep 17 00:00:00 2001 From: Paul Rigge Date: Mon, 1 Jan 2018 23:22:13 -0800 Subject: Add null check when adding variable to dict. --- src/nvim/eval.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 186fa0da76..155b816b33 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -19016,6 +19016,9 @@ static void set_var(const char *name, const size_t name_len, typval_T *const tv, return; } + // Make sure dict is valid + assert(dict != NULL); + v = xmalloc(sizeof(dictitem_T) + strlen(varname)); STRCPY(v->di_key, varname); if (tv_dict_add(dict, v) == FAIL) { -- cgit From 0a881575dab1af7bf70b3c85385f71997efe8258 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2018 19:15:40 +0100 Subject: vim-patch:8.0.0955: Test_existent_file() fails on some file systems Problem: Test_existent_file() fails on some file systems. Solution: Run the test again with a sleep when the test fails without a sleep. (James McCoy, closes vim/vim#1984) https://github.com/vim/vim/commit/82de3c2c036bc89c2d9bdea236e0a7f1208a5571 --- src/nvim/testdir/test_stat.vim | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_stat.vim b/src/nvim/testdir/test_stat.vim index dee0d13e84..1239fe9427 100644 --- a/src/nvim/testdir/test_stat.vim +++ b/src/nvim/testdir/test_stat.vim @@ -1,20 +1,41 @@ " Tests for stat functions and checktime -func Test_existent_file() +func CheckFileTime(doSleep) let fname = 'Xtest.tmp' + let result = 0 let ts = localtime() + if a:doSleep + sleep 1 + endif let fl = ['Hello World!'] call writefile(fl, fname) let tf = getftime(fname) + if a:doSleep + sleep 1 + endif let te = localtime() - call assert_true(ts <= tf && tf <= te) - call assert_equal(strlen(fl[0] . "\n"), getfsize(fname)) - call assert_equal('file', getftype(fname)) - call assert_equal('rw-', getfperm(fname)[0:2]) + let time_correct = (ts <= tf && tf <= te) + if a:doSleep || time_correct + call assert_true(time_correct) + call assert_equal(strlen(fl[0] . "\n"), getfsize(fname)) + call assert_equal('file', getftype(fname)) + call assert_equal('rw-', getfperm(fname)[0:2]) + let result = 1 + endif call delete(fname) + return result +endfunc + +func Test_existent_file() + " On some systems the file timestamp is rounded to a multiple of 2 seconds. + " We need to sleep to handle that, but that makes the test slow. First try + " without the sleep, and if it fails try again with the sleep. + if CheckFileTime(0) == 0 + call CheckFileTime(1) + endif endfunc func Test_existent_directory() -- cgit From 7c4bb23ff38a459911a742657572bc273e528ddf Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 3 Jan 2018 19:57:22 +0100 Subject: defaults: do :filetype stuff unless explicitly "off" Until now, the default `:filetype ...` setup was skipped if the user config touched `:filetype` in any way (including implicitly via `:syntax on`). No one needs that, and it's very confusing. Instead, proceed with `:filetype ... on` unless the user explicitly called `:filetype ... off`. closes #7765 --- src/nvim/ex_docmd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index a0ede4f3c5..2fa8db6b82 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -9718,17 +9718,18 @@ static void ex_filetype(exarg_T *eap) EMSG2(_(e_invarg2), arg); } -/// Do ":filetype plugin indent on" if user did not already do some -/// permutation thereof. +/// Set all :filetype options ON if user did not explicitly set any to OFF. void filetype_maybe_enable(void) { - if (filetype_detect == kNone - && filetype_plugin == kNone - && filetype_indent == kNone) { + if (filetype_detect == kNone) { source_runtime((char_u *)FILETYPE_FILE, true); filetype_detect = kTrue; + } + if (filetype_plugin == kNone) { source_runtime((char_u *)FTPLUGIN_FILE, true); filetype_plugin = kTrue; + } + if (filetype_indent == kNone) { source_runtime((char_u *)INDENT_FILE, true); filetype_indent = kTrue; } -- cgit From c82e7c75fe4c127a2886e22891794a9f12bff530 Mon Sep 17 00:00:00 2001 From: Marvim the Paranoid Android Date: Sat, 6 Jan 2018 16:35:19 +0100 Subject: version.c: update [ci skip] (#7780) --- src/nvim/version.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/version.c b/src/nvim/version.c index e35b803b4e..996c06c902 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -480,7 +480,7 @@ static const int included_patches[] = { // 958, // 957, // 956, - // 955, + 955, // 954, // 953, // 952, @@ -778,7 +778,7 @@ static const int included_patches[] = { // 660, // 659, // 658, - // 657, + 657, // 656, // 655, // 654, @@ -794,14 +794,14 @@ static const int included_patches[] = { // 644, // 643, // 642, - // 641, + 641, // 640, // 639, // 638, // 637, // 636, // 635, - // 634, + 634, // 633, // 632, // 631, @@ -827,7 +827,7 @@ static const int included_patches[] = { // 611, // 610, // 609, - // 608, + 608, 607, 606, 605, @@ -844,7 +844,7 @@ static const int included_patches[] = { // 594, // 593, // 592, - // 591, + 591, 590, // 589, // 588, @@ -1096,12 +1096,12 @@ static const int included_patches[] = { // 342, 341, // 340, - // 339, + 339, // 338, // 337, - // 336, - // 335, - // 334, + 336, + 335, + 334, 333, // 332, 331, @@ -1120,8 +1120,8 @@ static const int included_patches[] = { // 318, // 317, // 316, - // 315, - // 314, + 315, + 314, // 313, // 312, 311, @@ -1275,7 +1275,7 @@ static const int included_patches[] = { 163, 162, 161, - // 160, + 160, 159, 158, 157, -- cgit From b61a305039a58ac0c2ff095b22e4eb6d7ccfc89e Mon Sep 17 00:00:00 2001 From: ckelsel Date: Mon, 8 Jan 2018 12:23:33 +0800 Subject: vim-patch:8.0.0351: no test for concatenating an empty string Problem: No test for concatenating an empty string that results from out of bounds indexing. Solution: Add a simple test. https://github.com/vim/vim/commit/218426896cbb2129aa4e85803ea97c5b57df1eaa --- src/nvim/testdir/test_expr.vim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim index d32facaa98..ad967c528c 100644 --- a/src/nvim/testdir/test_expr.vim +++ b/src/nvim/testdir/test_expr.vim @@ -439,3 +439,8 @@ func Test_funcref() call assert_equal(2, OneByRef()) call assert_fails('echo funcref("{")', 'E475:') endfunc + +func Test_empty_concatenate() + call assert_equal('b', 'a'[4:0] . 'b') + call assert_equal('b', 'b' . 'a'[4:0]) +endfunc -- cgit From e182a8c8363a72fe3204a24f5f82cd129c8ad9ef Mon Sep 17 00:00:00 2001 From: ckelsel Date: Mon, 8 Jan 2018 12:27:09 +0800 Subject: vim-patch:8.0.0352: not easy to see when a typval needs to be cleared Problem: The condition for when a typval needs to be cleared is too complicated. Solution: Init the type to VAR_UNKNOWN and clear it always. https://github.com/vim/vim/commit/f06e5a549f42396be3478ccc1b5f03be64e1173e --- src/nvim/eval.c | 53 ++++++++++++++++++----------------------------------- 1 file changed, 18 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 73bfcd4291..f34b6db8d8 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -2084,6 +2084,8 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv, * Loop until no more [idx] or .key is following. */ lp->ll_tv = &v->di_tv; + var1.v_type = VAR_UNKNOWN; + var2.v_type = VAR_UNKNOWN; while (*p == '[' || (*p == '.' && lp->ll_tv->v_type == VAR_DICT)) { if (!(lp->ll_tv->v_type == VAR_LIST && lp->ll_tv->vval.v_list != NULL) && !(lp->ll_tv->v_type == VAR_DICT @@ -2134,9 +2136,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv, if (!quiet) { EMSG(_(e_dictrange)); } - if (!empty1) { - tv_clear(&var1); - } + tv_clear(&var1); return NULL; } if (rettv != NULL && (rettv->v_type != VAR_LIST @@ -2144,9 +2144,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv, if (!quiet) { emsgf(_("E709: [:] requires a List value")); } - if (!empty1) { - tv_clear(&var1); - } + tv_clear(&var1); return NULL; } p = skipwhite(p + 1); @@ -2155,16 +2153,12 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv, } else { lp->ll_empty2 = false; if (eval1(&p, &var2, true) == FAIL) { // Recursive! - if (!empty1) { - tv_clear(&var1); - } + tv_clear(&var1); return NULL; } if (!tv_check_str(&var2)) { // Not a number or string. - if (!empty1) { - tv_clear(&var1); - } + tv_clear(&var1); tv_clear(&var2); return NULL; } @@ -2177,12 +2171,8 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv, if (!quiet) { emsgf(_(e_missbrac)); } - if (!empty1) { - tv_clear(&var1); - } - if (lp->ll_range && !lp->ll_empty2) { - tv_clear(&var2); - } + tv_clear(&var1); + tv_clear(&var2); return NULL; } @@ -2236,9 +2226,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv, if (!quiet) { emsgf(_(e_dictkey), key); } - if (len == -1) { - tv_clear(&var1); - } + tv_clear(&var1); return NULL; } if (len == -1) { @@ -2246,32 +2234,28 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv, } else { lp->ll_newkey = vim_strnsave(key, len); } - if (len == -1) { - tv_clear(&var1); - } + tv_clear(&var1); break; // existing variable, need to check if it can be changed } else if (!(flags & GLV_READ_ONLY) && var_check_ro(lp->ll_di->di_flags, (const char *)name, (size_t)(p - name))) { - if (len == -1) { - tv_clear(&var1); - } + tv_clear(&var1); return NULL; } - if (len == -1) { - tv_clear(&var1); - } + tv_clear(&var1); lp->ll_tv = &lp->ll_di->di_tv; } else { // Get the number and item for the only or first index of the List. if (empty1) { lp->ll_n1 = 0; } else { - lp->ll_n1 = (long)tv_get_number(&var1); // Is number or string. - tv_clear(&var1); + // Is number or string. + lp->ll_n1 = (long)tv_get_number(&var1); } + tv_clear(&var1); + lp->ll_dict = NULL; lp->ll_list = lp->ll_tv->vval.v_list; lp->ll_li = tv_list_find(lp->ll_list, lp->ll_n1); @@ -2282,9 +2266,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv, } } if (lp->ll_li == NULL) { - if (lp->ll_range && !lp->ll_empty2) { - tv_clear(&var2); - } + tv_clear(&var2); if (!quiet) { EMSGN(_(e_listidx), lp->ll_n1); } @@ -2326,6 +2308,7 @@ static char_u *get_lval(char_u *const name, typval_T *const rettv, } } + tv_clear(&var1); return p; } -- cgit From b58c17f8df95d7626aec57de36781daa277314ee Mon Sep 17 00:00:00 2001 From: dvejmz Date: Sat, 21 Oct 2017 16:48:47 +0100 Subject: vim-patch:8.0.0198 Problem: Some syntax arguments take effect even after "if 0". (Taylor Venable) Solution: Properly skip the syntax statements. Make "syn case" and "syn conceal" report the current state. Fix that "syn clear" didn't reset the conceal flag. Add tests for :syntax skipping properly. https://github.com/vim/vim/commit/de318c5c35ed0d65fd2a07196cb8acd5ee6d9bf8 --- src/nvim/syntax.c | 75 +++++++++++++++------- src/nvim/testdir/test_syntax.vim | 132 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 185 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index d1a5f0bd1c..2222f41c78 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -3019,12 +3019,19 @@ static void syn_cmd_conceal(exarg_T *eap, int syncing) return; next = skiptowhite(arg); - if (STRNICMP(arg, "on", 2) == 0 && next - arg == 2) + if (*arg == NUL) { + if (curwin->w_s->b_syn_conceal) { + MSG(_("syn conceal on")); + } else { + MSG(_("syn conceal off")); + } + } else if (STRNICMP(arg, "on", 2) == 0 && next - arg == 2) { curwin->w_s->b_syn_conceal = TRUE; - else if (STRNICMP(arg, "off", 3) == 0 && next - arg == 3) + } else if (STRNICMP(arg, "off", 3) == 0 && next - arg == 3) { curwin->w_s->b_syn_conceal = FALSE; - else + } else { EMSG2(_("E390: Illegal argument: %s"), arg); + } } /* @@ -3040,12 +3047,19 @@ static void syn_cmd_case(exarg_T *eap, int syncing) return; next = skiptowhite(arg); - if (STRNICMP(arg, "match", 5) == 0 && next - arg == 5) + if (*arg == NUL) { + if (curwin->w_s->b_syn_ic) { + MSG(_("syntax case ignore")); + } else { + MSG(_("syntax case match")); + } + } else if (STRNICMP(arg, "match", 5) == 0 && next - arg == 5) { curwin->w_s->b_syn_ic = FALSE; - else if (STRNICMP(arg, "ignore", 6) == 0 && next - arg == 6) + } else if (STRNICMP(arg, "ignore", 6) == 0 && next - arg == 6) { curwin->w_s->b_syn_ic = TRUE; - else + } else { EMSG2(_("E390: Illegal argument: %s"), arg); + } } /* @@ -3061,7 +3075,15 @@ static void syn_cmd_spell(exarg_T *eap, int syncing) return; next = skiptowhite(arg); - if (STRNICMP(arg, "toplevel", 8) == 0 && next - arg == 8) { + if (*arg == NUL) { + if (curwin->w_s->b_syn_spell == SYNSPL_TOP) { + MSG(_("syntax spell toplevel")); + } else if (curwin->w_s->b_syn_spell == SYNSPL_NOTOP) { + MSG(_("syntax spell notoplevel")); + } else { + MSG(_("syntax spell default")); + } + } else if (STRNICMP(arg, "toplevel", 8) == 0 && next - arg == 8) { curwin->w_s->b_syn_spell = SYNSPL_TOP; } else if (STRNICMP(arg, "notoplevel", 10) == 0 && next - arg == 10) { curwin->w_s->b_syn_spell = SYNSPL_NOTOP; @@ -3125,6 +3147,7 @@ void syntax_clear(synblock_T *block) block->b_syn_ic = FALSE; /* Use case, by default */ block->b_syn_spell = SYNSPL_DEFAULT; /* default spell checking */ block->b_syn_containedin = FALSE; + block->b_syn_conceal = FALSE; /* free the keywords */ clear_keywtab(&block->b_keywtab); @@ -4004,7 +4027,8 @@ static char_u * get_syn_options ( char_u *arg, /* next argument to be checked */ syn_opt_arg_T *opt, /* various things */ - int *conceal_char + int *conceal_char, + int skip /* TRUE if skipping over command */ ) { char_u *gname_start, *gname; @@ -4080,13 +4104,13 @@ get_syn_options ( EMSG(_("E395: contains argument not accepted here")); return NULL; } - if (get_id_list(&arg, 8, &opt->cont_list) == FAIL) + if (get_id_list(&arg, 8, &opt->cont_list, skip) == FAIL) return NULL; } else if (flagtab[fidx].argtype == 2) { - if (get_id_list(&arg, 11, &opt->cont_in_list) == FAIL) + if (get_id_list(&arg, 11, &opt->cont_in_list, skip) == FAIL) return NULL; } else if (flagtab[fidx].argtype == 3) { - if (get_id_list(&arg, 9, &opt->next_list) == FAIL) + if (get_id_list(&arg, 9, &opt->next_list, skip) == FAIL) return NULL; } else if (flagtab[fidx].argtype == 11 && arg[5] == '=') { /* cchar=? */ @@ -4257,7 +4281,11 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing) rest = get_group_name(arg, &group_name_end); if (rest != NULL) { - syn_id = syn_check_group(arg, (int)(group_name_end - arg)); + if (eap->skip) { + syn_id = -1; + } else { + syn_id = syn_check_group(arg, (int)(group_name_end - arg)); + } if (syn_id != 0) { // Allocate a buffer, for removing backslashes in the keyword. keyword_copy = xmalloc(STRLEN(rest) + 1); @@ -4276,7 +4304,7 @@ static void syn_cmd_keyword(exarg_T *eap, int syncing) cnt = 0; p = keyword_copy; for (; rest != NULL && !ends_excmd(*rest); rest = skipwhite(rest)) { - rest = get_syn_options(rest, &syn_opt_arg, &conceal_char); + rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); if (rest == NULL || ends_excmd(*rest)) { break; } @@ -4375,7 +4403,7 @@ syn_cmd_match ( syn_opt_arg.cont_list = NULL; syn_opt_arg.cont_in_list = NULL; syn_opt_arg.next_list = NULL; - rest = get_syn_options(rest, &syn_opt_arg, &conceal_char); + rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); /* get the pattern. */ init_syn_patterns(); @@ -4385,7 +4413,7 @@ syn_cmd_match ( syn_opt_arg.flags |= HL_HAS_EOL; /* Get options after the pattern */ - rest = get_syn_options(rest, &syn_opt_arg, &conceal_char); + rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); if (rest != NULL) { /* all arguments are valid */ /* @@ -4502,7 +4530,7 @@ syn_cmd_region ( */ while (rest != NULL && !ends_excmd(*rest)) { /* Check for option arguments */ - rest = get_syn_options(rest, &syn_opt_arg, &conceal_char); + rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); if (rest == NULL || ends_excmd(*rest)) break; @@ -4926,12 +4954,14 @@ static void syn_cmd_cluster(exarg_T *eap, int syncing) break; clstr_list = NULL; - if (get_id_list(&rest, opt_len, &clstr_list) == FAIL) { + if (get_id_list(&rest, opt_len, &clstr_list, eap->skip) == FAIL) { EMSG2(_(e_invarg2), rest); break; } - syn_combine_list(&SYN_CLSTR(curwin->w_s)[scl_id].scl_list, - &clstr_list, list_op); + if (scl_id >= 0) { + syn_combine_list(&SYN_CLSTR(curwin->w_s)[scl_id].scl_list, + &clstr_list, list_op); + } got_clstr = TRUE; } @@ -5181,8 +5211,9 @@ static int get_id_list ( char_u **arg, int keylen, /* length of keyword */ - short **list /* where to store the resulting list, if not + short **list, /* where to store the resulting list, if not NULL, the list is silently skipped! */ + int skip ) { char_u *p = NULL; @@ -5251,7 +5282,9 @@ get_id_list ( id = SYNID_CONTAINED; id += current_syn_inc_tag; } else if (name[1] == '@') { - id = syn_check_cluster(name + 2, (int)(end - p - 1)); + if (!skip) { + id = syn_check_cluster(name + 2, (int)(end - p - 1)); + } } else { /* * Handle full group name. diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 6c084dd2a7..64b3c14d73 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -157,4 +157,134 @@ func Test_syntax_completion() call feedkeys(":syn match \\\"\", 'tx') call assert_match('^"syn match Boolean Character ', @:) -endfunc \ No newline at end of file +endfunc + +func Test_syntax_arg_skipped() + syn clear + syntax case ignore + if 0 + syntax case match + endif + call assert_match('case ignore', execute('syntax case')) + + syn keyword Foo foo + call assert_match('Foo', execute('syntax')) + syn clear + call assert_match('case match', execute('syntax case')) + call assert_notmatch('Foo', execute('syntax')) + + if has('conceal') + syn clear + syntax conceal on + if 0 + syntax conceal off + endif + call assert_match('conceal on', execute('syntax conceal')) + syn clear + call assert_match('conceal off', execute('syntax conceal')) + endif + + syntax region Tar start=// + if 0 + syntax region NotTest start=// contains=@Spell + endif + call assert_match('Tar', execute('syntax')) + call assert_notmatch('NotTest', execute('syntax')) + call assert_notmatch('Spell', execute('syntax')) + + hi Foo ctermfg=blue + let a = execute('hi Foo') + if 0 + syntax rest + endif + call assert_equal(a, execute('hi Foo')) + + set ft=tags + syn off + if 0 + syntax enable + endif + call assert_match('No Syntax items defined', execute('syntax')) + syntax enable + call assert_match('tagComment', execute('syntax')) + set ft= + + syn clear + if 0 + syntax include @Spell nothing + endif + call assert_notmatch('Spell', execute('syntax')) + + syn clear + syn iskeyword 48-57,$,_ + call assert_match('48-57,$,_', execute('syntax iskeyword')) + if 0 + syn clear + syn iskeyword clear + endif + call assert_match('48-57,$,_', execute('syntax iskeyword')) + syn iskeyword clear + call assert_match('not set', execute('syntax iskeyword')) + syn iskeyword 48-57,$,_ + syn clear + call assert_match('not set', execute('syntax iskeyword')) + + syn clear + syn keyword Foo foo + if 0 + syn keyword NotAdded bar + endif + call assert_match('Foo', execute('syntax')) + call assert_notmatch('NotAdded', execute('highlight')) + + syn clear + syn keyword Foo foo + call assert_match('Foo', execute('syntax')) + call assert_match('Foo', execute('syntax list')) + call assert_notmatch('Foo', execute('if 0 | syntax | endif')) + call assert_notmatch('Foo', execute('if 0 | syntax list | endif')) + + syn clear + syn match Fopi /asdf/ + if 0 + syn match Fopx /asdf/ + endif + call assert_match('Fopi', execute('syntax')) + call assert_notmatch('Fopx', execute('syntax')) + + syn clear + syn spell toplevel + call assert_match('spell toplevel', execute('syntax spell')) + if 0 + syn spell notoplevel + endif + call assert_match('spell toplevel', execute('syntax spell')) + syn spell notoplevel + call assert_match('spell notoplevel', execute('syntax spell')) + syn spell default + call assert_match('spell default', execute('syntax spell')) + + syn clear + if 0 + syntax cluster Spell + endif + call assert_notmatch('Spell', execute('syntax')) + + syn clear + syn keyword Foo foo + syn sync ccomment + syn sync maxlines=5 + if 0 + syn sync maxlines=11 + endif + call assert_match('on C-style comments', execute('syntax sync')) + call assert_match('maximal 5 lines', execute('syntax sync')) + syn clear + syn keyword Foo foo + if 0 + syn sync ccomment + endif + call assert_notmatch('on C-style comments', execute('syntax sync')) + + syn clear +endfunc -- cgit From 889bc3c20cf308b2bda43358639b739fe987e1ec Mon Sep 17 00:00:00 2001 From: dvejmz Date: Mon, 8 Jan 2018 19:37:24 +0000 Subject: vim-patch:8.0.0200: some syntax arguments are not tested Problem: Some syntax arguments are not tested. Solution: Add more syntax command tests. https://github.com/vim/vim/commit/58f60ca2fcd2858faac84e386b3ccf5ced75084d --- src/nvim/testdir/test_syntax.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 64b3c14d73..636bdb8a4d 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -184,6 +184,10 @@ func Test_syntax_arg_skipped() call assert_match('conceal off', execute('syntax conceal')) endif + syntax conceal on + syntax conceal off + call assert_match('conceal off', execute('syntax conceal')) + syntax region Tar start=// if 0 syntax region NotTest start=// contains=@Spell -- cgit From 7f70c5f7b7fd0c0241613f1cc189b5e26a7642dc Mon Sep 17 00:00:00 2001 From: dvejmz Date: Mon, 8 Jan 2018 21:37:12 +0000 Subject: vim-patch:8.0.0201: completion of highlight groups includes cleared names Problem: When completing a group name for a highlight or syntax command cleared groups are included. Solution: Skip groups that have been cleared. https://github.com/vim/vim/commit/d61e8aaae57bd66279def479462bf11c22ec2f1c --- src/nvim/syntax.c | 19 +++++++++++++++-- src/nvim/testdir/test_syntax.vim | 45 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 58 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 2222f41c78..b274e22caa 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -52,6 +52,7 @@ static bool did_syntax_onoff = false; struct hl_group { char_u *sg_name; ///< highlight group name char_u *sg_name_u; ///< uppercase of sg_name + int sg_cleared; ///< "hi clear" was used int sg_attr; ///< Screen attr @see ATTR_ENTRY int sg_link; ///< link to this highlight group ID int sg_set; ///< combination of flags in \ref SG_SET @@ -6490,6 +6491,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) HL_TABLE()[from_id - 1].sg_set |= SG_LINK; HL_TABLE()[from_id - 1].sg_link = to_id; HL_TABLE()[from_id - 1].sg_scriptID = current_SID; + HL_TABLE()[from_id - 1].sg_cleared = false; redraw_all_later(SOME_VALID); } } @@ -6872,6 +6874,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) error = true; break; } + HL_TABLE()[idx].sg_cleared = false; // When highlighting has been given for a group, don't link it. if (!init || !(HL_TABLE()[idx].sg_set & SG_LINK)) { @@ -6953,6 +6956,8 @@ static int hl_has_settings(int idx, int check_link) */ static void highlight_clear(int idx) { + HL_TABLE()[idx].sg_cleared = true; + HL_TABLE()[idx].sg_attr = 0; HL_TABLE()[idx].sg_cterm = 0; HL_TABLE()[idx].sg_cterm_bold = FALSE; @@ -7763,10 +7768,20 @@ const char *get_highlight_name(expand_T *const xp, const int idx) } else if (idx == highlight_ga.ga_len + include_none + include_default + 1 && include_link != 0) { return "clear"; - } else if (idx < 0 || idx >= highlight_ga.ga_len) { + } else if (idx < 0) { return NULL; } - return (const char *)HL_TABLE()[idx].sg_name; + + /* Items are never removed from the table, skip the ones that were cleared. + */ + int current_idx = idx; + while (current_idx < highlight_ga.ga_len && HL_TABLE()[current_idx].sg_cleared) { + ++current_idx; + } + if (current_idx >= highlight_ga.ga_len) { + return NULL; + } + return (const char *)HL_TABLE()[current_idx].sg_name; } color_name_table_T color_name_table[] = { diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 636bdb8a4d..39259fe680 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -152,6 +152,12 @@ func Test_syntax_completion() call feedkeys(":syn sync \\\"\", 'tx') call assert_equal('"syn sync ccomment clear fromstart linebreaks= linecont lines= match maxlines= minlines= region', @:) + " Check that clearing "Aap" avoids it showing up before Boolean. + hi Aap ctermfg=blue + call feedkeys(":syn list \\\"\", 'tx') + call assert_match('^"syn list Aap Boolean Character ', @:) + hi clear Aap + call feedkeys(":syn list \\\"\", 'tx') call assert_match('^"syn list Boolean Character ', @:) @@ -188,11 +194,11 @@ func Test_syntax_arg_skipped() syntax conceal off call assert_match('conceal off', execute('syntax conceal')) - syntax region Tar start=// + syntax region Bar start=// if 0 syntax region NotTest start=// contains=@Spell endif - call assert_match('Tar', execute('syntax')) + call assert_match('Bar', execute('syntax')) call assert_notmatch('NotTest', execute('syntax')) call assert_notmatch('Spell', execute('syntax')) @@ -202,6 +208,8 @@ func Test_syntax_arg_skipped() syntax rest endif call assert_equal(a, execute('hi Foo')) + hi clear Bar + hi clear Foo set ft=tags syn off @@ -283,8 +291,7 @@ func Test_syntax_arg_skipped() endif call assert_match('on C-style comments', execute('syntax sync')) call assert_match('maximal 5 lines', execute('syntax sync')) - syn clear - syn keyword Foo foo + syn sync clear if 0 syn sync ccomment endif @@ -292,3 +299,33 @@ func Test_syntax_arg_skipped() syn clear endfunc + +func Test_invalid_arg() + call assert_fails('syntax case asdf', 'E390:') + call assert_fails('syntax conceal asdf', 'E390:') + call assert_fails('syntax spell asdf', 'E390:') +endfunc + +func Test_syn_sync() + syntax region HereGroup start=/this/ end=/that/ + syntax sync match SyncHere grouphere HereGroup "pattern" + call assert_match('SyncHere', execute('syntax sync')) + syn sync clear + call assert_notmatch('SyncHere', execute('syntax sync')) + syn clear +endfunc + +func Test_syn_clear() + syntax keyword Foo foo + syntax keyword Bar tar + call assert_match('Foo', execute('syntax')) + call assert_match('Bar', execute('syntax')) + syn clear Foo + call assert_notmatch('Foo', execute('syntax')) + call assert_match('Bar', execute('syntax')) + syn clear Foo Bar + call assert_notmatch('Foo', execute('syntax')) + call assert_notmatch('Bar', execute('syntax')) + hi clear Foo + hi clear Bar +endfunc -- cgit From e888439f5589d00f2ac545e38a29924f91dad38e Mon Sep 17 00:00:00 2001 From: dvejmz Date: Mon, 8 Jan 2018 22:36:05 +0000 Subject: vim-patch:8.0.0202: no test for invalid syntax group name Problem: No test for invalid syntax group name. Solution: Add a test for group name error and warning. https://github.com/vim/vim/commit/4007ed4a5e8c34197078e9d5718bd1d4a429dd23 --- src/nvim/testdir/test_syntax.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_syntax.vim b/src/nvim/testdir/test_syntax.vim index 39259fe680..6456ca2b23 100644 --- a/src/nvim/testdir/test_syntax.vim +++ b/src/nvim/testdir/test_syntax.vim @@ -329,3 +329,14 @@ func Test_syn_clear() hi clear Foo hi clear Bar endfunc + +func Test_invalid_name() + syn clear + syn keyword Nop yes + call assert_fails("syntax keyword Wr\x17ong bar", 'E669:') + syntax keyword @Wrong bar + call assert_match('W18:', execute('1messages')) + syn clear + hi clear Nop + hi clear @Wrong +endfunc -- cgit From b23fc444b52a7ea10ffce4eca01d9429859147c9 Mon Sep 17 00:00:00 2001 From: dvejmz Date: Mon, 8 Jan 2018 22:40:21 +0000 Subject: vim-patch:8.0.0204: compiler warns for uninitialized variable Problem: Compiler warns for uninitialized variable. (Tony Mechelynck) Solution: When skipping set "id" to -1. https://github.com/vim/vim/commit/eb46f8fa14a586779f55b1c7f1648f559618322e --- src/nvim/syntax.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index b274e22caa..cf68971f76 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -5283,7 +5283,9 @@ get_id_list ( id = SYNID_CONTAINED; id += current_syn_inc_tag; } else if (name[1] == '@') { - if (!skip) { + if (skip) { + id = -1; + } else { id = syn_check_cluster(name + 2, (int)(end - p - 1)); } } else { -- cgit From 34de6d33c9e4ea7b2c67319eafe8345db7fe0151 Mon Sep 17 00:00:00 2001 From: dvejmz Date: Tue, 9 Jan 2018 22:58:24 +0000 Subject: lint --- src/nvim/syntax.c | 73 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index cf68971f76..01d2728f3d 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -52,7 +52,7 @@ static bool did_syntax_onoff = false; struct hl_group { char_u *sg_name; ///< highlight group name char_u *sg_name_u; ///< uppercase of sg_name - int sg_cleared; ///< "hi clear" was used + int sg_cleared; ///< "hi clear" was used int sg_attr; ///< Screen attr @see ATTR_ENTRY int sg_link; ///< link to this highlight group ID int sg_set; ///< combination of flags in \ref SG_SET @@ -3027,9 +3027,9 @@ static void syn_cmd_conceal(exarg_T *eap, int syncing) MSG(_("syn conceal off")); } } else if (STRNICMP(arg, "on", 2) == 0 && next - arg == 2) { - curwin->w_s->b_syn_conceal = TRUE; + curwin->w_s->b_syn_conceal = true; } else if (STRNICMP(arg, "off", 3) == 0 && next - arg == 3) { - curwin->w_s->b_syn_conceal = FALSE; + curwin->w_s->b_syn_conceal = false; } else { EMSG2(_("E390: Illegal argument: %s"), arg); } @@ -3055,9 +3055,9 @@ static void syn_cmd_case(exarg_T *eap, int syncing) MSG(_("syntax case match")); } } else if (STRNICMP(arg, "match", 5) == 0 && next - arg == 5) { - curwin->w_s->b_syn_ic = FALSE; + curwin->w_s->b_syn_ic = false; } else if (STRNICMP(arg, "ignore", 6) == 0 && next - arg == 6) { - curwin->w_s->b_syn_ic = TRUE; + curwin->w_s->b_syn_ic = true; } else { EMSG2(_("E390: Illegal argument: %s"), arg); } @@ -3144,11 +3144,11 @@ static void syn_cmd_iskeyword(exarg_T *eap, int syncing) */ void syntax_clear(synblock_T *block) { - block->b_syn_error = FALSE; /* clear previous error */ - block->b_syn_ic = FALSE; /* Use case, by default */ - block->b_syn_spell = SYNSPL_DEFAULT; /* default spell checking */ - block->b_syn_containedin = FALSE; - block->b_syn_conceal = FALSE; + block->b_syn_error = false; // clear previous error + block->b_syn_ic = false; // Use case, by default + block->b_syn_spell = SYNSPL_DEFAULT; // default spell checking + block->b_syn_containedin = false; + block->b_syn_conceal = false; /* free the keywords */ clear_keywtab(&block->b_keywtab); @@ -4025,11 +4025,11 @@ get_group_name ( * Return NULL for any error; */ static char_u * -get_syn_options ( - char_u *arg, /* next argument to be checked */ - syn_opt_arg_T *opt, /* various things */ +get_syn_options( + char_u *arg, // next argument to be checked + syn_opt_arg_T *opt, // various things int *conceal_char, - int skip /* TRUE if skipping over command */ + int skip // TRUE if skipping over command ) { char_u *gname_start, *gname; @@ -4105,14 +4105,17 @@ get_syn_options ( EMSG(_("E395: contains argument not accepted here")); return NULL; } - if (get_id_list(&arg, 8, &opt->cont_list, skip) == FAIL) + if (get_id_list(&arg, 8, &opt->cont_list, skip) == FAIL) { return NULL; + } } else if (flagtab[fidx].argtype == 2) { - if (get_id_list(&arg, 11, &opt->cont_in_list, skip) == FAIL) + if (get_id_list(&arg, 11, &opt->cont_in_list, skip) == FAIL) { return NULL; + } } else if (flagtab[fidx].argtype == 3) { - if (get_id_list(&arg, 9, &opt->next_list, skip) == FAIL) + if (get_id_list(&arg, 9, &opt->next_list, skip) == FAIL) { return NULL; + } } else if (flagtab[fidx].argtype == 11 && arg[5] == '=') { /* cchar=? */ if (has_mbyte) { @@ -4410,10 +4413,11 @@ syn_cmd_match ( init_syn_patterns(); memset(&item, 0, sizeof(item)); rest = get_syn_pattern(rest, &item); - if (vim_regcomp_had_eol() && !(syn_opt_arg.flags & HL_EXCLUDENL)) + if (vim_regcomp_had_eol() && !(syn_opt_arg.flags & HL_EXCLUDENL)) { syn_opt_arg.flags |= HL_HAS_EOL; + } - /* Get options after the pattern */ + // Get options after the pattern rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); if (rest != NULL) { /* all arguments are valid */ @@ -4526,14 +4530,13 @@ syn_cmd_region ( syn_opt_arg.cont_in_list = NULL; syn_opt_arg.next_list = NULL; - /* - * get the options, patterns and matchgroup. - */ + // get the options, patterns and matchgroup. while (rest != NULL && !ends_excmd(*rest)) { - /* Check for option arguments */ + // Check for option arguments rest = get_syn_options(rest, &syn_opt_arg, &conceal_char, eap->skip); - if (rest == NULL || ends_excmd(*rest)) + if (rest == NULL || ends_excmd(*rest)) { break; + } /* must be a pattern or matchgroup then */ key_end = rest; @@ -4963,7 +4966,7 @@ static void syn_cmd_cluster(exarg_T *eap, int syncing) syn_combine_list(&SYN_CLSTR(curwin->w_s)[scl_id].scl_list, &clstr_list, list_op); } - got_clstr = TRUE; + got_clstr = true; } if (got_clstr) { @@ -5211,9 +5214,9 @@ static void syn_cmd_sync(exarg_T *eap, int syncing) static int get_id_list ( char_u **arg, - int keylen, /* length of keyword */ - short **list, /* where to store the resulting list, if not - NULL, the list is silently skipped! */ + int keylen, // length of keyword + int16_t **list, // where to store the resulting list, if not + // NULL, the list is silently skipped! int skip ) { @@ -6493,7 +6496,7 @@ void do_highlight(const char *line, const bool forceit, const bool init) HL_TABLE()[from_id - 1].sg_set |= SG_LINK; HL_TABLE()[from_id - 1].sg_link = to_id; HL_TABLE()[from_id - 1].sg_scriptID = current_SID; - HL_TABLE()[from_id - 1].sg_cleared = false; + HL_TABLE()[from_id - 1].sg_cleared = false; redraw_all_later(SOME_VALID); } } @@ -7774,14 +7777,14 @@ const char *get_highlight_name(expand_T *const xp, const int idx) return NULL; } - /* Items are never removed from the table, skip the ones that were cleared. - */ - int current_idx = idx; - while (current_idx < highlight_ga.ga_len && HL_TABLE()[current_idx].sg_cleared) { - ++current_idx; + // Items are never removed from the table, skip the ones that were cleared. + int current_idx = idx; + while (current_idx < highlight_ga.ga_len + && HL_TABLE()[current_idx].sg_cleared) { + current_idx++; } if (current_idx >= highlight_ga.ga_len) { - return NULL; + return NULL; } return (const char *)HL_TABLE()[current_idx].sg_name; } -- cgit From c095f83116eb8ef87983ca5fea61053755fbc4e5 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 5 Jan 2018 11:17:21 +0100 Subject: api: change nvim_command_output behavior Implement nvim_command_output with `execute({cmd},"silent")`. Behavior changes: - does not provoke any hit-enter prompt - no longer prepends a newline char - does not capture some noise (like the "[New File]" message, see the change to tabnewentered_spec.lua) Technically ("bug-for-bug") this a breaking change. But the previous behavior of nvim_command_output meant that it probably wasn't used for anything outside of tests. Also remove the undocumented `v:command_output` variable which was a hack introduced only for the purposes of nvim_command_output. closes #7726 --- src/nvim/api/vim.c | 40 +++++++++++++++++++++++++++++++--------- src/nvim/eval.c | 1 - src/nvim/eval.h | 1 - 3 files changed, 31 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 172f2ce18e..8929bc5b9b 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -43,14 +43,15 @@ #endif /// Executes an ex-command. -/// On VimL error: Returns the VimL error; v:errmsg is not updated. +/// +/// On parse error: forwards the Vim error; does not update v:errmsg. +/// On runtime error: forwards the Vim error; does not update v:errmsg. /// /// @param command Ex-command string -/// @param[out] err Error details (including actual VimL error), if any +/// @param[out] err Error details (Vim error), if any void nvim_command(String command, Error *err) FUNC_API_SINCE(1) { - // Run the command try_start(); do_cmdline_cmd(command.data); update_screen(VALID); @@ -207,18 +208,39 @@ String nvim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, return cstr_as_string(ptr); } -String nvim_command_output(String str, Error *err) +/// Executes an ex-command and returns its (non-error) output. +/// Shell |:!| output is not captured. +/// +/// On parse error: forwards the Vim error; does not update v:errmsg. +/// On runtime error: forwards the Vim error; does not update v:errmsg. +/// +/// @param command Ex-command string +/// @param[out] err Error details (Vim error), if any +String nvim_command_output(String command, Error *err) FUNC_API_SINCE(1) { - do_cmdline_cmd("redir => v:command_output"); - nvim_command(str, err); - do_cmdline_cmd("redir END"); - + Array args = ARRAY_DICT_INIT; + ADD(args, STRING_OBJ(copy_string(command))); + ADD(args, STRING_OBJ(cstr_to_string("silent"))); + String fn = cstr_to_string("execute"); + Object rv = nvim_call_function(fn, args, err); + api_free_string(fn); + api_free_array(args); if (ERROR_SET(err)) { + assert(rv.type == kObjectTypeNil); return (String)STRING_INIT; } - return cstr_to_string((char *)get_vim_var_str(VV_COMMAND_OUTPUT)); + assert(rv.type == kObjectTypeString); + // execute() always(?) prepends a newline; remove it. + if (rv.data.string.size > 1) { + assert(rv.data.string.data[0] == '\n'); + String *s = &rv.data.string; + s->size--; + memmove(s->data, s->data + 1, s->size); + s->data[s->size] = '\0'; + } + return rv.data.string; } /// Evaluates a VimL expression (:help expression). diff --git a/src/nvim/eval.c b/src/nvim/eval.c index f34b6db8d8..875f323a28 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -402,7 +402,6 @@ static struct vimvar { VV(VV_OLDFILES, "oldfiles", VAR_LIST, 0), VV(VV_WINDOWID, "windowid", VAR_NUMBER, VV_RO_SBX), VV(VV_PROGPATH, "progpath", VAR_STRING, VV_RO), - VV(VV_COMMAND_OUTPUT, "command_output", VAR_STRING, 0), VV(VV_COMPLETED_ITEM, "completed_item", VAR_DICT, VV_RO), VV(VV_OPTION_NEW, "option_new", VAR_STRING, VV_RO), VV(VV_OPTION_OLD, "option_old", VAR_STRING, VV_RO), diff --git a/src/nvim/eval.h b/src/nvim/eval.h index 0c0a6881f6..b798eae187 100644 --- a/src/nvim/eval.h +++ b/src/nvim/eval.h @@ -86,7 +86,6 @@ typedef enum { VV_OLDFILES, VV_WINDOWID, VV_PROGPATH, - VV_COMMAND_OUTPUT, VV_COMPLETED_ITEM, VV_OPTION_NEW, VV_OPTION_OLD, -- cgit From 5055d4a755d3c100cddf51bded77abca04beb971 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Tue, 9 Jan 2018 10:36:25 +0100 Subject: api: nvim_command_output: direct impl --- src/nvim/README.md | 57 +++++++++++++++++++++++++++++++++++++++++------------- src/nvim/api/vim.c | 46 ++++++++++++++++++++++++++----------------- src/nvim/eval.c | 3 +-- 3 files changed, 73 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/nvim/README.md b/src/nvim/README.md index da87a0208e..1ece92e44d 100644 --- a/src/nvim/README.md +++ b/src/nvim/README.md @@ -1,10 +1,22 @@ -Nvim core source -================ +Nvim core +========= Module-specific details are documented at the top of each module (`terminal.c`, -`screen.c`, ...). +`screen.c`, …). -See `:help development` for more guidelines. +See `:help dev` for guidelines. + +Filename conventions +-------------------- + +The source files use extensions to hint about their purpose. + +- `*.c`, `*.generated.c` - full C files, with all includes, etc. +- `*.c.h` - parametrized C files, contain all necessary includes, but require + defining macros before actually using. Example: `typval_encode.c.h` +- `*.h` - full headers, with all includes. Does *not* apply to `*.generated.h`. +- `*.h.generated.h` - exported functions’ declarations. +- `*.c.generated.h` - static functions’ declarations. Logs ---- @@ -20,17 +32,36 @@ UI events are logged at level 0 (`DEBUG_LOG_LEVEL`). rm -rf build/ make CMAKE_EXTRA_FLAGS="-DMIN_LOG_LEVEL=0" -Filename conventions --------------------- +Build with ASAN +--------------- -The source files use extensions to hint about their purpose. +Building Nvim with Clang sanitizers (Address Sanitizer: ASan, Undefined +Behavior Sanitizer: UBSan, Memory Sanitizer: MSan, Thread Sanitizer: TSan) is +a good way to catch undefined behavior, leaks and other errors as soon as they +happen. It's significantly faster than Valgrind. -- `*.c`, `*.generated.c` - full C files, with all includes, etc. -- `*.c.h` - parametrized C files, contain all necessary includes, but require - defining macros before actually using. Example: `typval_encode.c.h` -- `*.h` - full headers, with all includes. Does *not* apply to `*.generated.h`. -- `*.h.generated.h` - exported functions’ declarations. -- `*.c.generated.h` - static functions’ declarations. +Requires clang 3.4 or later: + + clang --version + +Build Nvim with sanitizer instrumentation: + + CC=clang make CMAKE_EXTRA_FLAGS="-DCLANG_ASAN_UBSAN=ON" + +Create a directory to store logs: + + mkdir -p "$HOME/logs" + +Enable the sanitizer(s) via these environment variables: + + # Change to detect_leaks=1 to detect memory leaks (slower). + export ASAN_OPTIONS="detect_leaks=0:log_path=$HOME/logs/asan" + export ASAN_SYMBOLIZER_PATH=/usr/lib/llvm-5.0/bin/llvm-symbolizer + + export MSAN_SYMBOLIZER_PATH=/usr/lib/llvm-5.0/bin/llvm-symbolizer + export TSAN_OPTIONS="external_symbolizer_path=/usr/lib/llvm-5.0/bin/llvm-symbolizer log_path=${HOME}/logs/tsan" + +Logs will be written to `${HOME}/logs/*san.PID`. TUI debugging ------------- diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 8929bc5b9b..0e7cc428d4 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -219,28 +219,38 @@ String nvim_replace_termcodes(String str, Boolean from_part, Boolean do_lt, String nvim_command_output(String command, Error *err) FUNC_API_SINCE(1) { - Array args = ARRAY_DICT_INIT; - ADD(args, STRING_OBJ(copy_string(command))); - ADD(args, STRING_OBJ(cstr_to_string("silent"))); - String fn = cstr_to_string("execute"); - Object rv = nvim_call_function(fn, args, err); - api_free_string(fn); - api_free_array(args); + const int save_msg_silent = msg_silent; + garray_T *const save_capture_ga = capture_ga; + garray_T capture_local; + ga_init(&capture_local, 1, 80); + + try_start(); + msg_silent++; + capture_ga = &capture_local; + do_cmdline_cmd(command.data); + capture_ga = save_capture_ga; + msg_silent = save_msg_silent; + try_end(err); + if (ERROR_SET(err)) { - assert(rv.type == kObjectTypeNil); - return (String)STRING_INIT; + goto theend; } - assert(rv.type == kObjectTypeString); - // execute() always(?) prepends a newline; remove it. - if (rv.data.string.size > 1) { - assert(rv.data.string.data[0] == '\n'); - String *s = &rv.data.string; - s->size--; - memmove(s->data, s->data + 1, s->size); - s->data[s->size] = '\0'; + if (capture_local.ga_len > 1) { + // redir always(?) prepends a newline; remove it. + char *s = capture_local.ga_data; + assert(s[0] == '\n'); + memmove(s, s + 1, (size_t)capture_local.ga_len); + s[capture_local.ga_len - 1] = '\0'; + return (String) { // Caller will free the memory. + .data = s, + .size = (size_t)(capture_local.ga_len - 1), + }; } - return rv.data.string; + +theend: + ga_clear(&capture_local); + return (String)STRING_INIT; } /// Evaluates a VimL expression (:help expression). diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 875f323a28..2e8bf18f2d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -8116,8 +8116,7 @@ static void f_execute(typval_T *argvars, typval_T *rettv, FunPtr fptr) ga_append(capture_ga, NUL); rettv->v_type = VAR_STRING; - rettv->vval.v_string = vim_strsave(capture_ga->ga_data); - ga_clear(capture_ga); + rettv->vval.v_string = capture_ga->ga_data; capture_ga = save_capture_ga; } -- cgit From 18d244eded434e6bc47b351ef00088378883bf1d Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 11 Jan 2018 01:32:41 +0100 Subject: coverity/169163: decode_string: Null pointer deref *** CID 169163: Null pointer dereferences (FORWARD_NULL) /src/nvim/eval/decode.c: 290 in decode_string() 284 if (elw_ret == -1) { 285 tv_clear(&tv); 286 return (typval_T) { .v_type = VAR_UNKNOWN, .v_lock = VAR_UNLOCKED }; 287 } 288 return tv; 289 } else { >>> CID 169163: Null pointer dereferences (FORWARD_NULL) >>> Passing null pointer "s" to "xmemdupz", which dereferences it. (The dereference is assumed on the basis of the 'nonnull' parameter attribute.) 290 return (typval_T) { 291 .v_type = VAR_STRING, 292 .v_lock = VAR_UNLOCKED, 293 .vval = { .v_string = (char_u *)( 294 s_allocated ? (char *)s : xmemdupz(s, len)) }, 295 }; --- src/nvim/eval/decode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index af4e055d23..cd967ed5c5 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -285,7 +285,7 @@ typval_T decode_string(const char *const s, const size_t len, .v_type = VAR_STRING, .v_lock = VAR_UNLOCKED, .vval = { .v_string = (char_u *)( - s_allocated ? (char *)s : xmemdupz(s, len)) }, + (s == NULL || s_allocated) ? (char *)s : xmemdupz(s, len)) }, }; } } -- cgit From 624ac8aede93cc521d7ea27ae406ad4780642fcb Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 11 Jan 2018 01:36:37 +0100 Subject: coverity/161216: get_user_input: RETURN_LOCAL *** CID 161216: Memory - illegal accesses (RETURN_LOCAL) /src/nvim/eval.c: 11143 in get_user_input() 11137 rettv->vval.v_string = 11138 (char_u *)getcmdline_prompt(inputsecret_flag ? NUL : '@', p, echo_attr, 11139 xp_type, xp_arg, input_callback); 11140 ex_normal_busy = save_ex_normal_busy; 11141 callback_free(&input_callback); 11142 >>> CID 161216: Memory - illegal accesses (RETURN_LOCAL) >>> Using "cancelreturn", which points to an out-of-scope variable "def". 11143 if (rettv->vval.v_string == NULL && cancelreturn != NULL) { 11144 rettv->vval.v_string = (char_u *)xstrdup(cancelreturn); 11145 } 11146 11147 xfree(xp_arg); 11148 --- src/nvim/eval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 2e8bf18f2d..a642a3c0dd 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -11110,6 +11110,7 @@ void get_user_input(const typval_T *const argvars, char defstr_buf[NUMBUFLEN]; char cancelreturn_buf[NUMBUFLEN]; char xp_name_buf[NUMBUFLEN]; + char def[1] = { 0 }; if (argvars[0].v_type == VAR_DICT) { if (argvars[1].v_type != VAR_UNKNOWN) { emsgf(_("E5050: {opts} must be the only argument")); @@ -11124,7 +11125,6 @@ void get_user_input(const typval_T *const argvars, if (defstr == NULL) { return; } - char def[1] = { 0 }; cancelreturn = tv_dict_get_string_buf_chk(dict, S_LEN("cancelreturn"), cancelreturn_buf, def); if (cancelreturn == NULL) { // error -- cgit From 9ddeb6e187e6ef6045bf037e4225dc46c8efb693 Mon Sep 17 00:00:00 2001 From: KunMing Xie Date: Sun, 14 Jan 2018 02:26:21 +0800 Subject: vim-patch:8.0.0364 (#7837) vim-patch:8.0.0364: ]s does not move cursor with two spell errors in one line Problem: ]s does not move cursor with two spell errors in one line. (Manuel Ortega) Solution: Don't stop search immediately when wrapped, search the line first. (Ken Takata) Add a test. https://github.com/vim/vim/commit/d3f78dc9ebd729475a7f24a50a91112e300d5ac9 * disable spell test for now --- src/nvim/spell.c | 25 ++++++++++++++----------- src/nvim/testdir/Makefile | 1 + src/nvim/testdir/test_spell.vim | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 src/nvim/testdir/test_spell.vim (limited to 'src') diff --git a/src/nvim/spell.c b/src/nvim/spell.c index d2b2575f6a..b3e80bd768 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -1484,21 +1484,23 @@ spell_move_to ( return found_len; } - if (curline) + if (curline) { break; // only check cursor line + } + + // If we are back at the starting line and searched it again there + // is no match, give up. + if (lnum == wp->w_cursor.lnum && wrapped) { + break; + } // Advance to next line. if (dir == BACKWARD) { - // If we are back at the starting line and searched it again there - // is no match, give up. - if (lnum == wp->w_cursor.lnum && wrapped) - break; - - if (lnum > 1) - --lnum; - else if (!p_ws) + if (lnum > 1) { + lnum--; + } else if (!p_ws) { break; // at first line and 'nowrapscan' - else { + } else { // Wrap around to the end of the buffer. May search the // starting line again and accept the last match. lnum = wp->w_buffer->b_ml.ml_line_count; @@ -1523,8 +1525,9 @@ spell_move_to ( // If we are back at the starting line and there is no match then // give up. - if (lnum == wp->w_cursor.lnum && (!found_one || wrapped)) + if (lnum == wp->w_cursor.lnum && !found_one) { break; + } // Skip the characters at the start of the next line that were // included in a match crossing line boundaries. diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index 5af8dd20cd..a23dacba15 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -81,6 +81,7 @@ NEW_TESTS ?= \ test_search.res \ test_signs.res \ test_smartindent.res \ + test_spell.res \ test_stat.res \ test_startup.res \ test_startup_utf8.res \ diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim new file mode 100644 index 0000000000..334568aadb --- /dev/null +++ b/src/nvim/testdir/test_spell.vim @@ -0,0 +1,20 @@ +" Test spell checking +" TODO: move test58 tests here + +if v:true + finish +endif + +func Test_wrap_search() + new + call setline(1, ['The', '', 'A plong line with two zpelling mistakes', '', 'End']) + set spell wrapscan + normal ]s + call assert_equal('plong', expand('')) + normal ]s + call assert_equal('zpelling', expand('')) + normal ]s + call assert_equal('plong', expand('')) + bwipe! + set nospell +endfunc -- cgit From 8eb0888a5de2481e15fcae63fa477f0ac634c9f2 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 13 Jan 2018 19:26:30 +0100 Subject: vim-patch:8.0.0582: illegal memory access with z= command Problem: Illegal memory access with z= command. (Dominique Pelle) Solution: Avoid case folded text to be longer than the original text. Use MB_PTR2LEN() instead of MB_BYTE2LEN(). https://github.com/vim/vim/commit/5b276aa80e112ae1993bd43e28f599f257827c54 --- src/nvim/spell.c | 40 +++++++++++++++++++++------------------- src/nvim/testdir/test_spell.vim | 9 +++++++++ 2 files changed, 30 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/nvim/spell.c b/src/nvim/spell.c index b3e80bd768..d74360bcc0 100644 --- a/src/nvim/spell.c +++ b/src/nvim/spell.c @@ -2568,7 +2568,7 @@ static bool spell_iswordp(char_u *p, win_T *wp) int c; if (has_mbyte) { - l = MB_BYTE2LEN(*p); + l = MB_PTR2LEN(p); s = p; if (l == 1) { // be quick for ASCII @@ -3141,6 +3141,12 @@ spell_find_suggest ( STRLCPY(su->su_badword, su->su_badptr, su->su_badlen + 1); (void)spell_casefold(su->su_badptr, su->su_badlen, su->su_fbadword, MAXWLEN); + + // TODO(vim): make this work if the case-folded text is longer than the + // original text. Currently an illegal byte causes wrong pointer + // computations. + su->su_fbadword[su->su_badlen] = NUL; + // get caps flags for bad word su->su_badflags = badword_captype(su->su_badptr, su->su_badptr + su->su_badlen); @@ -4110,10 +4116,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so && goodword_ends) { int l; - if (has_mbyte) - l = MB_BYTE2LEN(fword[sp->ts_fidx]); - else - l = 1; + l = MB_PTR2LEN(fword + sp->ts_fidx); if (fword_ends) { // Copy the skipped character to preword. memmove(preword + sp->ts_prewordlen, @@ -4259,8 +4262,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so // Correct ts_fidx for the byte length of the // character (we didn't check that before). sp->ts_fidx = sp->ts_fcharstart - + MB_BYTE2LEN( - fword[sp->ts_fcharstart]); + + MB_PTR2LEN(fword + sp->ts_fcharstart); // For changing a composing character adjust // the score from SCORE_SUBST to @@ -4366,7 +4368,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so // results. if (has_mbyte) { c = mb_ptr2char(fword + sp->ts_fidx); - stack[depth].ts_fidx += MB_BYTE2LEN(fword[sp->ts_fidx]); + stack[depth].ts_fidx += MB_PTR2LEN(fword + sp->ts_fidx); if (enc_utf8 && utf_iscomposing(c)) stack[depth].ts_score -= SCORE_DEL - SCORE_DELCOMP; else if (c == mb_ptr2char(fword + stack[depth].ts_fidx)) @@ -4552,9 +4554,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so // Undo the STATE_SWAP swap: "21" -> "12". p = fword + sp->ts_fidx; if (has_mbyte) { - n = MB_BYTE2LEN(*p); + n = MB_PTR2LEN(p); c = mb_ptr2char(p + n); - memmove(p + MB_BYTE2LEN(p[n]), p, n); + memmove(p + MB_PTR2LEN(p + n), p, n); mb_char2bytes(c, p); } else { c = *p; @@ -4627,11 +4629,11 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so // Undo STATE_SWAP3: "321" -> "123" p = fword + sp->ts_fidx; if (has_mbyte) { - n = MB_BYTE2LEN(*p); + n = MB_PTR2LEN(p); c2 = mb_ptr2char(p + n); - fl = MB_BYTE2LEN(p[n]); + fl = MB_PTR2LEN(p + n); c = mb_ptr2char(p + n + fl); - tl = MB_BYTE2LEN(p[n + fl]); + tl = MB_PTR2LEN(p + n + fl); memmove(p + fl + tl, p, n); mb_char2bytes(c, p); mb_char2bytes(c2, p + tl); @@ -4690,10 +4692,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so // Undo ROT3L: "231" -> "123" p = fword + sp->ts_fidx; if (has_mbyte) { - n = MB_BYTE2LEN(*p); - n += MB_BYTE2LEN(p[n]); + n = MB_PTR2LEN(p); + n += MB_PTR2LEN(p + n); c = mb_ptr2char(p + n); - tl = MB_BYTE2LEN(p[n]); + tl = MB_PTR2LEN(p + n); memmove(p + tl, p, n); mb_char2bytes(c, p); } else { @@ -4743,9 +4745,9 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so p = fword + sp->ts_fidx; if (has_mbyte) { c = mb_ptr2char(p); - tl = MB_BYTE2LEN(*p); - n = MB_BYTE2LEN(p[tl]); - n += MB_BYTE2LEN(p[tl + n]); + tl = MB_PTR2LEN(p); + n = MB_PTR2LEN(p + tl); + n += MB_PTR2LEN(p + tl + n); memmove(p, p + tl, n); mb_char2bytes(c, p + n); } else { diff --git a/src/nvim/testdir/test_spell.vim b/src/nvim/testdir/test_spell.vim index 334568aadb..66be5c2441 100644 --- a/src/nvim/testdir/test_spell.vim +++ b/src/nvim/testdir/test_spell.vim @@ -18,3 +18,12 @@ func Test_wrap_search() bwipe! set nospell endfunc + +func Test_z_equal_on_invalid_utf8_word() + split + set spell + call setline(1, "\xff") + norm z= + set nospell + bwipe! +endfunc -- cgit From 9ea1752d60589e8fc5e7184144bc6d1c1b9f16a3 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 3 Jan 2018 00:00:16 +0300 Subject: *: Provide list length when allocating lists --- src/nvim/api/private/helpers.c | 2 +- src/nvim/channel.c | 37 +++---- src/nvim/eval.c | 225 ++++++++++++++++++++--------------------- src/nvim/eval/decode.c | 32 +++--- src/nvim/eval/typval.c | 18 +++- src/nvim/eval/typval.h | 19 ++++ src/nvim/ex_cmds2.c | 6 +- src/nvim/lua/converter.c | 7 +- src/nvim/main.c | 2 +- src/nvim/menu.c | 2 +- src/nvim/ops.c | 21 ++-- src/nvim/quickfix.c | 2 +- src/nvim/regexp.c | 4 +- src/nvim/shada.c | 2 +- src/nvim/tag.c | 2 +- src/nvim/undo.c | 29 +++--- src/nvim/window.c | 4 +- 17 files changed, 217 insertions(+), 197 deletions(-) (limited to 'src') diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 26ad7ac1a6..9baa996560 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -783,7 +783,7 @@ bool object_to_vim(Object obj, typval_T *tv, Error *err) break; case kObjectTypeArray: { - list_T *const list = tv_list_alloc(); + list_T *const list = tv_list_alloc((ptrdiff_t)obj.data.array.size); for (uint32_t i = 0; i < obj.data.array.size; i++) { Object item = obj.data.array.items[i]; diff --git a/src/nvim/channel.c b/src/nvim/channel.c index efef95de01..9d0a7d3c21 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -4,6 +4,7 @@ #include "nvim/api/ui.h" #include "nvim/channel.h" #include "nvim/eval.h" +#include "nvim/eval/encode.h" #include "nvim/event/socket.h" #include "nvim/msgpack_rpc/channel.h" #include "nvim/msgpack_rpc/server.h" @@ -522,32 +523,18 @@ err: return 0; } -/// NB: mutates buf in place! -static list_T *buffer_to_tv_list(char *buf, size_t count) +/// Convert binary byte array to a readfile()-style list +/// +/// @param[in] buf Array to convert. +/// @param[in] len Array length. +/// +/// @return [allocated] Converted list. +static inline list_T *buffer_to_tv_list(const char *const buf, const size_t len) + FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALWAYS_INLINE { - list_T *ret = tv_list_alloc(); - char *ptr = buf; - size_t remaining = count; - size_t off = 0; - - while (off < remaining) { - // append the line - if (ptr[off] == NL) { - tv_list_append_string(ret, ptr, (ssize_t)off); - size_t skip = off + 1; - ptr += skip; - remaining -= skip; - off = 0; - continue; - } - if (ptr[off] == NUL) { - // Translate NUL to NL - ptr[off] = NL; - } - off++; - } - tv_list_append_string(ret, ptr, (ssize_t)off); - return ret; + list_T *const l = tv_list_alloc(kListLenMayKnow); + encode_list_write(l, buf, len); + return l; } // vimscript job callbacks must be executed on Nvim main loop diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 2e8bf18f2d..ec32f1821d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -568,7 +568,7 @@ void eval_init(void) dict_T *const msgpack_types_dict = tv_dict_alloc(); for (size_t i = 0; i < ARRAY_SIZE(msgpack_type_names); i++) { - list_T *const type_list = tv_list_alloc(); + list_T *const type_list = tv_list_alloc(0); tv_list_set_lock(type_list, VAR_FIXED); tv_list_ref(type_list); dictitem_T *const di = tv_dict_item_alloc(msgpack_type_names[i]); @@ -591,7 +591,7 @@ void eval_init(void) dict_T *v_event = tv_dict_alloc(); v_event->dv_lock = VAR_FIXED; set_vim_var_dict(VV_EVENT, v_event); - set_vim_var_list(VV_ERRORS, tv_list_alloc()); + set_vim_var_list(VV_ERRORS, tv_list_alloc(kListLenUnknown)); set_vim_var_nr(VV_STDERR, CHAN_STDERR); set_vim_var_nr(VV_SEARCHFORWARD, 1L); set_vim_var_nr(VV_HLSEARCH, 1L); @@ -1546,6 +1546,7 @@ ex_let_vars ( assert(l != NULL); listitem_T *item = tv_list_first(l); + size_t rest_len = tv_list_len(l); while (*arg != ']') { arg = skipwhite(arg + 1); arg = ex_let_one(arg, TV_LIST_ITEM_TV(item), true, (const char_u *)",;]", @@ -1553,13 +1554,14 @@ ex_let_vars ( if (arg == NULL) { return FAIL; } + rest_len--; item = TV_LIST_ITEM_NEXT(l, item); arg = skipwhite(arg); if (*arg == ';') { /* Put the rest of the list (may be empty) in the var after ';'. * Create a new list for this. */ - list_T *const rest_list = tv_list_alloc(); + list_T *const rest_list = tv_list_alloc(rest_len); while (item != NULL) { tv_list_append_tv(rest_list, TV_LIST_ITEM_TV(item)); item = TV_LIST_ITEM_NEXT(l, item); @@ -4512,7 +4514,7 @@ eval_index ( if (!empty2 && (n2 < 0 || n2 + 1 < n1)) { n2 = -1; } - l = tv_list_alloc(); + l = tv_list_alloc(n2 - n1 + 1); item = tv_list_find(rettv->vval.v_list, n1); while (n1++ <= n2) { tv_list_append_tv(l, TV_LIST_ITEM_TV(item)); @@ -4870,7 +4872,7 @@ static int get_list_tv(char_u **arg, typval_T *rettv, int evaluate) list_T *l = NULL; if (evaluate) { - l = tv_list_alloc(); + l = tv_list_alloc(kListLenShouldKnow); } *arg = skipwhite(*arg + 1); @@ -6666,7 +6668,7 @@ static void f_argv(typval_T *argvars, typval_T *rettv, FunPtr fptr) } rettv->v_type = VAR_STRING; } else { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, ARGCOUNT); for (idx = 0; idx < ARGCOUNT; idx++) { tv_list_append_string(rettv->vval.v_list, (const char *)alist_name(&ARGLIST[idx]), -1); @@ -6776,7 +6778,7 @@ static void assert_error(garray_T *gap) if (vp->vv_type != VAR_LIST || vimvars[VV_ERRORS].vv_list == NULL) { // Make sure v:errors is a list. - set_vim_var_list(VV_ERRORS, tv_list_alloc()); + set_vim_var_list(VV_ERRORS, tv_list_alloc(1)); } tv_list_append_string(vimvars[VV_ERRORS].vv_list, (const char *)gap->ga_data, (ptrdiff_t)gap->ga_len); @@ -8225,7 +8227,7 @@ static void f_expand(typval_T *argvars, typval_T *rettv, FunPtr fptr) result = eval_vars((char_u *)s, (char_u *)s, &len, NULL, &errormsg, NULL); emsg_off--; if (rettv->v_type == VAR_LIST) { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, (result != NULL)); if (result != NULL) { tv_list_append_string(rettv->vval.v_list, (const char *)result, -1); } @@ -8248,8 +8250,8 @@ static void f_expand(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->vval.v_string = ExpandOne(&xpc, (char_u *)s, NULL, options, WILD_ALL); } else { - tv_list_alloc_ret(rettv); ExpandOne(&xpc, (char_u *)s, NULL, options, WILD_ALL_KEEP); + tv_list_alloc_ret(rettv, xpc.xp_numfiles); for (int i = 0; i < xpc.xp_numfiles; i++) { tv_list_append_string(rettv->vval.v_list, (const char *)xpc.xp_files[i], -1); @@ -8266,7 +8268,7 @@ static void f_expand(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// "menu_get(path [, modes])" function static void f_menu_get(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, kListLenMayKnow); int modes = MENU_ALL_MODES; if (argvars[1].v_type == VAR_STRING) { const char_u *const strmodes = (char_u *)tv_get_string(&argvars[1]); @@ -8427,7 +8429,7 @@ static void findfilendir(typval_T *argvars, typval_T *rettv, int find_what) } if (count < 0) { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, kListLenUnknown); } if (*fname != NUL && !error) { @@ -9108,7 +9110,7 @@ static void f_get(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } else if (strcmp(what, "args") == 0) { rettv->v_type = VAR_LIST; - if (tv_list_alloc_ret(rettv) != NULL) { + if (tv_list_alloc_ret(rettv, pt->pt_argc) != NULL) { for (int i = 0; i < pt->pt_argc; i++) { tv_list_append_tv(rettv->vval.v_list, &pt->pt_argv[i]); } @@ -9132,8 +9134,10 @@ static void f_get(typval_T *argvars, typval_T *rettv, FunPtr fptr) } /// Returns information about signs placed in a buffer as list of dicts. -static void get_buffer_signs(buf_T *buf, list_T *l) +static list_T *get_buffer_signs(buf_T *buf) + FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { + list_T *const l = tv_list_alloc(kListLenMayKnow); for (signlist_T *sign = buf->b_signlist; sign; sign = sign->next) { dict_T *const d = tv_dict_alloc(); @@ -9144,6 +9148,7 @@ static void get_buffer_signs(buf_T *buf, list_T *l) tv_list_append_dict(l, d); } + return l; } /// Returns buffer options, variables and other attributes in a dictionary. @@ -9167,7 +9172,7 @@ static dict_T *get_buffer_info(buf_T *buf) tv_dict_add_dict(dict, S_LEN("variables"), buf->b_vars); // List of windows displaying this buffer - list_T *const windows = tv_list_alloc(); + list_T *const windows = tv_list_alloc(kListLenMayKnow); FOR_ALL_TAB_WINDOWS(tp, wp) { if (wp->w_buffer == buf) { tv_list_append_number(windows, (varnumber_T)wp->handle); @@ -9177,9 +9182,7 @@ static dict_T *get_buffer_info(buf_T *buf) if (buf->b_signlist != NULL) { // List of signs placed in this buffer - list_T *const signs = tv_list_alloc(); - get_buffer_signs(buf, signs); - tv_dict_add_list(dict, S_LEN("signs"), signs); + tv_dict_add_list(dict, S_LEN("signs"), get_buffer_signs(buf)); } return dict; @@ -9193,7 +9196,7 @@ static void f_getbufinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr) bool sel_buflisted = false; bool sel_bufloaded = false; - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, kListLenMayKnow); // List of all the buffers or selected buffers if (argvars[0].v_type == VAR_DICT) { @@ -9252,35 +9255,31 @@ static void f_getbufinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr) */ static void get_buffer_lines(buf_T *buf, linenr_T start, linenr_T end, int retlist, typval_T *rettv) { - char_u *p; - - rettv->v_type = VAR_STRING; + rettv->v_type = (retlist ? VAR_LIST : VAR_STRING); rettv->vval.v_string = NULL; - if (retlist) { - tv_list_alloc_ret(rettv); - } - if (buf == NULL || buf->b_ml.ml_mfp == NULL || start < 0) + if (buf == NULL || buf->b_ml.ml_mfp == NULL || start < 0 || end < start) { + tv_list_alloc_ret(rettv, 0); return; + } - if (!retlist) { - if (start >= 1 && start <= buf->b_ml.ml_line_count) - p = ml_get_buf(buf, start, FALSE); - else - p = (char_u *)""; - rettv->vval.v_string = vim_strsave(p); - } else { - if (end < start) - return; - - if (start < 1) + if (retlist) { + if (start < 1) { start = 1; - if (end > buf->b_ml.ml_line_count) + } + if (end > buf->b_ml.ml_line_count) { end = buf->b_ml.ml_line_count; + } + tv_list_alloc_ret(rettv, end - start + 1); while (start <= end) { tv_list_append_string(rettv->vval.v_list, (const char *)ml_get_buf(buf, start++, false), -1); } + } else { + rettv->v_type = VAR_STRING; + rettv->vval.v_string = ((start >= 1 && start <= buf->b_ml.ml_line_count) + ? vim_strsave(ml_get_buf(buf, start, false)) + : NULL); } } @@ -9605,8 +9604,8 @@ static void f_getcompletion(typval_T *argvars, typval_T *rettv, FunPtr fptr) theend: pat = addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context); - tv_list_alloc_ret(rettv); ExpandOne(&xpc, pat, NULL, options, WILD_ALL_KEEP); + tv_list_alloc_ret(rettv, xpc.xp_numfiles); for (int i = 0; i < xpc.xp_numfiles; i++) { tv_list_append_string(rettv->vval.v_list, (const char *)xpc.xp_files[i], @@ -9900,7 +9899,7 @@ static void f_getline(typval_T *argvars, typval_T *rettv, FunPtr fptr) const linenr_T lnum = tv_get_lnum(argvars); if (argvars[1].v_type == VAR_UNKNOWN) { - end = 0; + end = lnum; retlist = false; } else { end = tv_get_lnum(&argvars[1]); @@ -9914,7 +9913,7 @@ static void get_qf_loc_list(int is_qf, win_T *wp, typval_T *what_arg, typval_T *rettv) { if (what_arg->v_type == VAR_UNKNOWN) { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, kListLenMayKnow); if (is_qf || wp != NULL) { (void)get_errorlist(wp, -1, rettv->vval.v_list); } @@ -9949,7 +9948,7 @@ static void f_getmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) matchitem_T *cur = curwin->w_match_head; int i; - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, kListLenMayKnow); while (cur != NULL) { dict_T *dict = tv_dict_alloc(); if (cur->match.regprog == NULL) { @@ -9962,7 +9961,7 @@ static void f_getmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (llpos->lnum == 0) { break; } - list_T *l = tv_list_alloc(); + list_T *const l = tv_list_alloc(1 + (llpos->col > 0 ? 2 : 0)); tv_list_append_number(l, (varnumber_T)llpos->lnum); if (llpos->col > 0) { tv_list_append_number(l, (varnumber_T)llpos->col); @@ -10011,7 +10010,7 @@ static void getpos_both(typval_T *argvars, typval_T *rettv, bool getcurpos) fp = var2fpos(&argvars[0], true, &fnum); } - list_T *l = tv_list_alloc_ret(rettv); + list_T *const l = tv_list_alloc_ret(rettv, 4 + (!!getcurpos)); tv_list_append_number(l, (fnum != -1) ? (varnumber_T)fnum : (varnumber_T)0); tv_list_append_number(l, ((fp != NULL) ? (varnumber_T)fp->lnum @@ -10084,10 +10083,10 @@ static void f_getreg(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (return_list) { rettv->v_type = VAR_LIST; - rettv->vval.v_list = + rettv->vval.v_list = get_reg_contents(regname, (arg2 ? kGRegExprSrc : 0) | kGRegList); if (rettv->vval.v_list == NULL) { - rettv->vval.v_list = tv_list_alloc(); + rettv->vval.v_list = tv_list_alloc(0); } tv_list_ref(rettv->vval.v_list); } else { @@ -10137,7 +10136,7 @@ static dict_T *get_tabpage_info(tabpage_T *tp, int tp_idx) tv_dict_add_nr(dict, S_LEN("tabnr"), tp_idx); - list_T *const l = tv_list_alloc(); + list_T *const l = tv_list_alloc(kListLenMayKnow); FOR_ALL_WINDOWS_IN_TAB(wp, tp) { tv_list_append_number(l, (varnumber_T)wp->handle); } @@ -10154,7 +10153,9 @@ static void f_gettabinfo(typval_T *argvars, typval_T *rettv, FunPtr fptr) { tabpage_T *tparg = NULL; - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, (argvars[0].v_type == VAR_UNKNOWN + ? 1 + : kListLenMayKnow)); if (argvars[0].v_type != VAR_UNKNOWN) { // Information about one tab page @@ -10253,7 +10254,7 @@ static void f_getwininfo(typval_T *argvars, typval_T *rettv, FunPtr fptr) { win_T *wparg = NULL; - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, kListLenMayKnow); if (argvars[0].v_type != VAR_UNKNOWN) { wparg = win_id2wp(argvars); @@ -10478,9 +10479,9 @@ static void f_glob(typval_T *argvars, typval_T *rettv, FunPtr fptr) rettv->vval.v_string = ExpandOne( &xpc, (char_u *)tv_get_string(&argvars[0]), NULL, options, WILD_ALL); } else { - tv_list_alloc_ret(rettv); ExpandOne(&xpc, (char_u *)tv_get_string(&argvars[0]), NULL, options, WILD_ALL_KEEP); + tv_list_alloc_ret(rettv, xpc.xp_numfiles); for (int i = 0; i < xpc.xp_numfiles; i++) { tv_list_append_string(rettv->vval.v_list, (const char *)xpc.xp_files[i], -1); @@ -10529,7 +10530,7 @@ static void f_globpath(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (rettv->v_type == VAR_STRING) { rettv->vval.v_string = ga_concat_strings_sep(&ga, "\n"); } else { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, ga.ga_len); for (int i = 0; i < ga.ga_len; i++) { tv_list_append_string(rettv->vval.v_list, ((const char **)(ga.ga_data))[i], -1); @@ -11429,7 +11430,7 @@ static void dict_list(typval_T *const tv, typval_T *const rettv, return; } - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, tv_dict_len(tv->vval.v_dict)); TV_DICT_ITER(tv->vval.v_dict, di, { typval_T tv = { .v_lock = VAR_UNLOCKED }; @@ -11446,7 +11447,7 @@ static void dict_list(typval_T *const tv, typval_T *const rettv, } case kDictListItems: { // items() - list_T *const sub_l = tv_list_alloc(); + list_T *const sub_l = tv_list_alloc(2); tv.v_type = VAR_LIST; tv.vval.v_list = sub_l; tv_list_ref(sub_l); @@ -11776,7 +11777,7 @@ static void f_jobwait(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } - list_T *rv = tv_list_alloc(); + list_T *const rv = tv_list_alloc(tv_list_len(args)); // restore the parent queue for any jobs still alive for (i = 0; i < tv_list_len(args); i++) { @@ -12204,12 +12205,12 @@ static void find_some_match(typval_T *const argvars, typval_T *const rettv, switch (type) { // matchlist(): return empty list when there are no matches. case kSomeMatchList: { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, kListLenMayKnow); break; } // matchstrpos(): return ["", -1, -1, -1] case kSomeMatchStrPos: { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, 4); tv_list_append_string(rettv->vval.v_list, "", 0); tv_list_append_number(rettv->vval.v_list, -1); tv_list_append_number(rettv->vval.v_list, -1); @@ -12516,10 +12517,12 @@ static void f_matchaddpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) */ static void f_matcharg(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - tv_list_alloc_ret(rettv); - const int id = tv_get_number(&argvars[0]); + tv_list_alloc_ret(rettv, (id >= 1 && id <= 3 + ? 2 + : 0)); + if (id >= 1 && id <= 3) { matchitem_T *const m = (matchitem_T *)get_match(curwin, id); @@ -12705,8 +12708,8 @@ static void f_msgpackdump(typval_T *argvars, typval_T *rettv, FunPtr fptr) EMSG2(_(e_listarg), "msgpackdump()"); return; } - list_T *ret_list = tv_list_alloc_ret(rettv); - list_T *list = argvars[0].vval.v_list; + list_T *const ret_list = tv_list_alloc_ret(rettv, kListLenMayKnow); + list_T *const list = argvars[0].vval.v_list; msgpack_packer *lpacker = msgpack_packer_new(ret_list, &encode_list_write); const char *const msg = _("msgpackdump() argument, index %i"); // Assume that translation will not take more then 4 times more space @@ -12730,8 +12733,8 @@ static void f_msgpackparse(typval_T *argvars, typval_T *rettv, FunPtr fptr) EMSG2(_(e_listarg), "msgpackparse()"); return; } - list_T *ret_list = tv_list_alloc_ret(rettv); - const list_T *list = argvars[0].vval.v_list; + list_T *const ret_list = tv_list_alloc_ret(rettv, kListLenMayKnow); + const list_T *const list = argvars[0].vval.v_list; if (tv_list_len(list) == 0) { return; } @@ -12986,7 +12989,7 @@ static void f_range(typval_T *argvars, typval_T *rettv, FunPtr fptr) } else if (stride > 0 ? end + 1 < start : end - 1 > start) { emsgf(_("E727: Start past end")); } else { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, (end - start) / stride); for (i = start; stride > 0 ? i <= end : i >= end; i += stride) { tv_list_append_number(rettv->vval.v_list, (varnumber_T)i); } @@ -13017,8 +13020,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } - tv_list_alloc_ret(rettv); - list_T *const l = rettv->vval.v_list; + list_T *const l = tv_list_alloc_ret(rettv, kListLenUnknown); // Always open the file in binary mode, library functions have a mind of // their own about CR-LF conversion. @@ -13231,7 +13233,7 @@ static void f_reltime(typval_T *argvars, typval_T *rettv, FunPtr fptr) STATIC_ASSERT(sizeof(u.prof) == sizeof(u) && sizeof(u.split) == sizeof(u), "type punning will produce incorrect results on this platform"); - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, 2); tv_list_append_number(rettv->vval.v_list, u.split.high); tv_list_append_number(rettv->vval.v_list, u.split.low); } @@ -13324,7 +13326,8 @@ static void f_remove(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (li == NULL) { // Didn't find "item2" after "item". emsgf(_(e_invrange)); } else { - tv_list_move_items(l, item, item2, tv_list_alloc_ret(rettv), cnt); + tv_list_move_items(l, item, item2, tv_list_alloc_ret(rettv, cnt), + cnt); } } } @@ -13354,7 +13357,7 @@ static void f_repeat(typval_T *argvars, typval_T *rettv, FunPtr fptr) { varnumber_T n = tv_get_number(&argvars[1]); if (argvars[0].v_type == VAR_LIST) { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, (n > 0) * n * tv_list_len(argvars[0].vval.v_list)); while (n-- > 0) { tv_list_extend(rettv->vval.v_list, argvars[0].vval.v_list, NULL); } @@ -14124,7 +14127,7 @@ static void f_searchpairpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) int lnum = 0; int col = 0; - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, 2); if (searchpair_cmn(argvars, &match_pos) > 0) { lnum = match_pos.lnum; @@ -14292,18 +14295,14 @@ do_searchpair ( static void f_searchpos(typval_T *argvars, typval_T *rettv, FunPtr fptr) { pos_T match_pos; - int lnum = 0; - int col = 0; - int n; int flags = 0; - tv_list_alloc_ret(rettv); + const int n = search_cmn(argvars, &match_pos, &flags); - n = search_cmn(argvars, &match_pos, &flags); - if (n > 0) { - lnum = match_pos.lnum; - col = match_pos.col; - } + tv_list_alloc_ret(rettv, 2 + (!!(flags & SP_SUBPAT))); + + const int lnum = (n > 0 ? match_pos.lnum : 0); + const int col = (n > 0 ? match_pos.col : 0); tv_list_append_number(rettv->vval.v_list, (varnumber_T)lnum); tv_list_append_number(rettv->vval.v_list, (varnumber_T)col); @@ -14319,7 +14318,7 @@ static void f_serverlist(typval_T *argvars, typval_T *rettv, FunPtr fptr) char **addrs = server_address_list(&n); // Copy addrs into a linked list. - list_T *l = tv_list_alloc_ret(rettv); + list_T *const l = tv_list_alloc_ret(rettv, n); for (size_t i = 0; i < n; i++) { tv_list_append_allocated_string(l, addrs[i]); } @@ -14715,7 +14714,7 @@ static void f_setmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr) dictitem_T *const di = tv_dict_find(d, S_LEN("pattern")); if (di == NULL) { if (s == NULL) { - s = tv_list_alloc(); + s = tv_list_alloc(9); } // match from matchaddpos() @@ -15531,8 +15530,6 @@ static void f_spellbadword(typval_T *argvars, typval_T *rettv, FunPtr fptr) hlf_T attr = HLF_COUNT; size_t len = 0; - tv_list_alloc_ret(rettv); - if (argvars[0].v_type == VAR_UNKNOWN) { // Find the start and length of the badly spelled word. len = spell_move_to(curwin, FORWARD, true, true, &attr); @@ -15557,6 +15554,7 @@ static void f_spellbadword(typval_T *argvars, typval_T *rettv, FunPtr fptr) } assert(len <= INT_MAX); + tv_list_alloc_ret(rettv, 2); tv_list_append_string(rettv->vval.v_list, word, len); tv_list_append_string(rettv->vval.v_list, (attr == HLF_SPB ? "bad" @@ -15573,35 +15571,36 @@ static void f_spellsuggest(typval_T *argvars, typval_T *rettv, FunPtr fptr) { bool typeerr = false; int maxcount; - garray_T ga; + garray_T ga = GA_EMPTY_INIT_VALUE; bool need_capital = false; - tv_list_alloc_ret(rettv); - if (curwin->w_p_spell && *curwin->w_s->b_p_spl != NUL) { const char *const str = tv_get_string(&argvars[0]); if (argvars[1].v_type != VAR_UNKNOWN) { maxcount = tv_get_number_chk(&argvars[1], &typeerr); if (maxcount <= 0) { - return; + goto f_spellsuggest_return; } if (argvars[2].v_type != VAR_UNKNOWN) { need_capital = tv_get_number_chk(&argvars[2], &typeerr); if (typeerr) { - return; + goto f_spellsuggest_return; } } - } else + } else { maxcount = 25; + } spell_suggest_list(&ga, (char_u *)str, maxcount, need_capital, false); + } - for (int i = 0; i < ga.ga_len; i++) { - char *p = ((char **)ga.ga_data)[i]; - tv_list_append_allocated_string(rettv->vval.v_list, p); - } - ga_clear(&ga); +f_spellsuggest_return: + tv_list_alloc_ret(rettv, (ptrdiff_t)ga.ga_len); + for (int i = 0; i < ga.ga_len; i++) { + char *const p = ((char **)ga.ga_data)[i]; + tv_list_append_allocated_string(rettv->vval.v_list, p); } + ga_clear(&ga); } static void f_split(typval_T *argvars, typval_T *rettv, FunPtr fptr) @@ -15633,10 +15632,11 @@ static void f_split(typval_T *argvars, typval_T *rettv, FunPtr fptr) pat = "[\\x01- ]\\+"; } - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, kListLenMayKnow); - if (typeerr) + if (typeerr) { return; + } regmatch.regprog = vim_regcomp((char_u *)pat, RE_MAGIC + RE_STRING); if (regmatch.regprog != NULL) { @@ -16263,7 +16263,6 @@ static void f_synconcealed(typval_T *argvars, typval_T *rettv, FunPtr fptr) memset(str, NUL, sizeof(str)); - tv_list_alloc_ret(rettv); if (lnum >= 1 && lnum <= curbuf->b_ml.ml_line_count && col >= 0 && (size_t)col <= STRLEN(ml_get(lnum)) && curwin->w_p_cole > 0) { (void)syn_get_id(curwin, lnum, col, false, NULL, false); @@ -16276,14 +16275,12 @@ static void f_synconcealed(typval_T *argvars, typval_T *rettv, FunPtr fptr) cchar = lcs_conceal; } if (cchar != NUL) { - if (has_mbyte) - (*mb_char2bytes)(cchar, str); - else - str[0] = cchar; + utf_char2bytes(cchar, str); } } } + tv_list_alloc_ret(rettv, 3); tv_list_append_number(rettv->vval.v_list, (syntax_flags & HL_CONCEAL) != 0); // -1 to auto-determine strlen tv_list_append_string(rettv->vval.v_list, (const char *)str, -1); @@ -16306,7 +16303,7 @@ static void f_synstack(typval_T *argvars, typval_T *rettv, FunPtr fptr) && lnum <= curbuf->b_ml.ml_line_count && col >= 0 && (size_t)col <= STRLEN(ml_get(lnum))) { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, kListLenMayKnow); (void)syn_get_id(curwin, lnum, col, false, NULL, true); int id; @@ -16322,7 +16319,7 @@ static list_T *string_to_list(const char *str, size_t len, const bool keepempty) if (!keepempty && str[len - 1] == NL) { len--; } - list_T *const list = tv_list_alloc(); + list_T *const list = tv_list_alloc(kListLenMayKnow); encode_list_write(list, str, len); return list; } @@ -16368,7 +16365,7 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv, if (res == NULL) { if (retlist) { // return an empty list when there's no output - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, 0); } else { rettv->vval.v_string = (char_u *) xstrdup(""); } @@ -16434,7 +16431,7 @@ static void f_tabpagebuflist(typval_T *argvars, typval_T *rettv, FunPtr fptr) } } if (wp != NULL) { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, kListLenMayKnow); while (wp != NULL) { tv_list_append_number(rettv->vval.v_list, wp->w_buffer->b_fnum); wp = wp->w_next; @@ -16532,7 +16529,7 @@ static void f_tagfiles(typval_T *argvars, typval_T *rettv, FunPtr fptr) char *fname; tagname_T tn; - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, kListLenUnknown); fname = xmalloc(MAXPATHL); bool first = true; @@ -16561,8 +16558,8 @@ static void f_taglist(typval_T *argvars, typval_T *rettv, FunPtr fptr) if (argvars[1].v_type != VAR_UNKNOWN) { fname = tv_get_string(&argvars[1]); } - (void)get_tags(tv_list_alloc_ret(rettv), (char_u *)tag_pattern, - (char_u *)fname); + (void)get_tags(tv_list_alloc_ret(rettv, kListLenUnknown), + (char_u *)tag_pattern, (char_u *)fname); } /* @@ -16803,7 +16800,9 @@ static void add_timer_info_all(typval_T *rettv) /// "timer_info([timer])" function static void f_timer_info(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, (argvars[0].v_type != VAR_UNKNOWN + ? 1 + : timers->table->n_occupied)); if (argvars[0].v_type != VAR_UNKNOWN) { if (argvars[0].v_type != VAR_NUMBER) { EMSG(_(e_number_exp)); @@ -17163,7 +17162,6 @@ static void f_undotree(typval_T *argvars, typval_T *rettv, FunPtr fptr) tv_dict_alloc_ret(rettv); dict_T *dict = rettv->vval.v_dict; - list_T *list; tv_dict_add_nr(dict, S_LEN("synced"), (varnumber_T)curbuf->b_u_synced); tv_dict_add_nr(dict, S_LEN("seq_last"), (varnumber_T)curbuf->b_u_seq_last); @@ -17173,9 +17171,7 @@ static void f_undotree(typval_T *argvars, typval_T *rettv, FunPtr fptr) tv_dict_add_nr(dict, S_LEN("time_cur"), (varnumber_T)curbuf->b_u_time_cur); tv_dict_add_nr(dict, S_LEN("save_cur"), (varnumber_T)curbuf->b_u_save_nr_cur); - list = tv_list_alloc(); - u_eval_tree(curbuf->b_u_oldhead, list); - tv_dict_add_list(dict, S_LEN("entries"), list); + tv_dict_add_list(dict, S_LEN("entries"), u_eval_tree(curbuf->b_u_oldhead)); } /* @@ -17234,7 +17230,7 @@ static void f_wildmenumode(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// "win_findbuf()" function static void f_win_findbuf(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - tv_list_alloc_ret(rettv); + tv_list_alloc_ret(rettv, kListLenMayKnow); win_findbuf(argvars, rettv->vval.v_list); } @@ -17253,8 +17249,7 @@ static void f_win_gotoid(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// "win_id2tabwin()" function static void f_win_id2tabwin(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - tv_list_alloc_ret(rettv); - win_id2tabwin(argvars, rettv->vval.v_list); + win_id2tabwin(argvars, rettv); } /// "win_id2win()" function @@ -22367,7 +22362,7 @@ static void script_host_eval(char *name, typval_T *argvars, typval_T *rettv) return; } - list_T *args = tv_list_alloc(); + list_T *args = tv_list_alloc(1); tv_list_append_string(args, (const char *)argvars[0].vval.v_string, -1); *rettv = eval_call_provider(name, "eval", args); } diff --git a/src/nvim/eval/decode.c b/src/nvim/eval/decode.c index af4e055d23..c729d00ae7 100644 --- a/src/nvim/eval/decode.c +++ b/src/nvim/eval/decode.c @@ -150,7 +150,7 @@ static inline int json_decoder_pop(ValuesStackItem obj, } obj_di->di_tv = obj.val; } else { - list_T *const kv_pair = tv_list_alloc(); + list_T *const kv_pair = tv_list_alloc(2); tv_list_append_list(last_container.special_val, kv_pair); tv_list_append_owned_tv(kv_pair, key.val); tv_list_append_owned_tv(kv_pair, obj.val); @@ -221,13 +221,18 @@ static inline int json_decoder_pop(ValuesStackItem obj, /// Create a new special dictionary that ought to represent a MAP /// /// @param[out] ret_tv Address where new special dictionary is saved. +/// @param[in] len Expected number of items to be populated before list +/// becomes accessible from VimL. It is still valid to +/// underpopulate a list, value only controls how many elements +/// will be allocated in advance. @see ListLenSpecials. /// /// @return [allocated] list which should contain key-value pairs. Return value /// may be safely ignored. -list_T *decode_create_map_special_dict(typval_T *const ret_tv) +list_T *decode_create_map_special_dict(typval_T *const ret_tv, + const ptrdiff_t len) FUNC_ATTR_NONNULL_ALL { - list_T *const list = tv_list_alloc(); + list_T *const list = tv_list_alloc(len); tv_list_ref(list); create_special_dict(ret_tv, kMPMap, ((typval_T) { .v_type = VAR_LIST, @@ -263,7 +268,7 @@ typval_T decode_string(const char *const s, const size_t len, ? ((s != NULL) && (memchr(s, NUL, len) != NULL)) : (bool)hasnul); if (really_hasnul) { - list_T *const list = tv_list_alloc(); + list_T *const list = tv_list_alloc(kListLenMayKnow); tv_list_ref(list); typval_T tv; create_special_dict(&tv, binary ? kMPBinary : kMPString, ((typval_T) { @@ -843,7 +848,7 @@ json_decode_string_cycle_start: break; } case '[': { - list_T *list = tv_list_alloc(); + list_T *list = tv_list_alloc(kListLenMayKnow); tv_list_ref(list); typval_T tv = { .v_type = VAR_LIST, @@ -864,7 +869,7 @@ json_decode_string_cycle_start: list_T *val_list = NULL; if (next_map_special) { next_map_special = false; - val_list = decode_create_map_special_dict(&tv); + val_list = decode_create_map_special_dict(&tv, kListLenMayKnow); } else { dict_T *dict = tv_dict_alloc(); dict->dv_refcount++; @@ -964,7 +969,7 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) .vval = { .v_number = (varnumber_T) mobj.via.u64 }, }; } else { - list_T *const list = tv_list_alloc(); + list_T *const list = tv_list_alloc(4); tv_list_ref(list); create_special_dict(rettv, kMPInteger, ((typval_T) { .v_type = VAR_LIST, @@ -987,7 +992,7 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) .vval = { .v_number = (varnumber_T) mobj.via.i64 }, }; } else { - list_T *const list = tv_list_alloc(); + list_T *const list = tv_list_alloc(4); tv_list_ref(list); create_special_dict(rettv, kMPInteger, ((typval_T) { .v_type = VAR_LIST, @@ -1033,7 +1038,7 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) break; } case MSGPACK_OBJECT_ARRAY: { - list_T *const list = tv_list_alloc(); + list_T *const list = tv_list_alloc((ptrdiff_t)mobj.via.array.size); tv_list_ref(list); *rettv = (typval_T) { .v_type = VAR_LIST, @@ -1085,9 +1090,10 @@ int msgpack_to_vim(const msgpack_object mobj, typval_T *const rettv) } break; msgpack_to_vim_generic_map: {} - list_T *const list = decode_create_map_special_dict(rettv); + list_T *const list = decode_create_map_special_dict( + rettv, (ptrdiff_t)mobj.via.map.size); for (size_t i = 0; i < mobj.via.map.size; i++) { - list_T *const kv_pair = tv_list_alloc(); + list_T *const kv_pair = tv_list_alloc(2); tv_list_append_list(list, kv_pair); typval_T key_tv = { .v_type = VAR_UNKNOWN }; @@ -1107,10 +1113,10 @@ msgpack_to_vim_generic_map: {} break; } case MSGPACK_OBJECT_EXT: { - list_T *const list = tv_list_alloc(); + list_T *const list = tv_list_alloc(2); tv_list_ref(list); tv_list_append_number(list, mobj.via.ext.type); - list_T *const ext_val_list = tv_list_alloc(); + list_T *const ext_val_list = tv_list_alloc(kListLenMayKnow); tv_list_append_list(list, ext_val_list); create_special_dict(rettv, kMPExt, ((typval_T) { .v_type = VAR_LIST, diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index ac6c8c8aa6..6f829be0b4 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -132,8 +132,14 @@ void tv_list_watch_fix(list_T *const l, const listitem_T *const item) /// /// Caller should take care of the reference count. /// +/// @param[in] len Expected number of items to be populated before list +/// becomes accessible from VimL. It is still valid to +/// underpopulate a list, value only controls how many elements +/// will be allocated in advance. Currently does nothing. +/// @see ListLenSpecials. +/// /// @return [allocated] new list. -list_T *tv_list_alloc(void) +list_T *tv_list_alloc(const ptrdiff_t len) FUNC_ATTR_NONNULL_RET { list_T *const list = xcalloc(1, sizeof(list_T)); @@ -521,7 +527,7 @@ list_T *tv_list_copy(const vimconv_T *const conv, list_T *const orig, return NULL; } - list_T *copy = tv_list_alloc(); + list_T *copy = tv_list_alloc(tv_list_len(orig)); tv_list_ref(copy); if (copyID != 0) { // Do this before adding the items, because one of the items may @@ -1817,12 +1823,16 @@ void tv_dict_set_keys_readonly(dict_T *const dict) /// Also sets reference count. /// /// @param[out] ret_tv Structure where list is saved. +/// @param[in] len Expected number of items to be populated before list +/// becomes accessible from VimL. It is still valid to +/// underpopulate a list, value only controls how many elements +/// will be allocated in advance. @see ListLenSpecials. /// /// @return [allocated] pointer to the created list. -list_T *tv_list_alloc_ret(typval_T *const ret_tv) +list_T *tv_list_alloc_ret(typval_T *const ret_tv, const ptrdiff_t len) FUNC_ATTR_NONNULL_ALL { - list_T *const l = tv_list_alloc(); + list_T *const l = tv_list_alloc(len); ret_tv->vval.v_list = l; ret_tv->v_type = VAR_LIST; ret_tv->v_lock = VAR_UNLOCKED; diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index c9a9a3e7e8..3993a384d2 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -31,6 +31,25 @@ typedef double float_T; /// Refcount for dict or list that should not be freed enum { DO_NOT_FREE_CNT = (INT_MAX / 2) }; +/// Additional values for tv_list_alloc() len argument +enum { + /// List length is not known in advance + /// + /// To be used when there is neither a way to know how many elements will be + /// needed nor are any educated guesses. + kListLenUnknown = -1, + /// List length *should* be known, but is actually not + /// + /// All occurrences of this value should be eventually removed. This is for + /// the case when the only reason why list length is not known is that it + /// would be hard to code without refactoring, but refactoring is needed. + kListLenShouldKnow = -2, + /// List length may be known in advance, but it requires too much effort + /// + /// To be used when it looks impractical to determine list length. + kListLenMayKnow = -3, +} ListLenSpecials; + /// Maximal possible value of varnumber_T variable #define VARNUMBER_MAX INT64_MAX #define UVARNUMBER_MAX UINT64_MAX diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index ec4ce63e17..28b021d4e4 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -3758,7 +3758,7 @@ static void script_host_execute(char *name, exarg_T *eap) char *const script = script_get(eap, &len); if (script != NULL) { - list_T *const args = tv_list_alloc(); + list_T *const args = tv_list_alloc(3); // script tv_list_append_allocated_string(args, script); // current range @@ -3773,7 +3773,7 @@ static void script_host_execute_file(char *name, exarg_T *eap) uint8_t buffer[MAXPATHL]; vim_FullName((char *)eap->arg, (char *)buffer, sizeof(buffer), false); - list_T *args = tv_list_alloc(); + list_T *args = tv_list_alloc(3); // filename tv_list_append_string(args, (const char *)buffer, -1); // current range @@ -3784,7 +3784,7 @@ static void script_host_execute_file(char *name, exarg_T *eap) static void script_host_do_range(char *name, exarg_T *eap) { - list_T *args = tv_list_alloc(); + list_T *args = tv_list_alloc(3); tv_list_append_number(args, (int)eap->line1); tv_list_append_number(args, (int)eap->line2); tv_list_append_string(args, (const char *)eap->arg, -1); diff --git a/src/nvim/lua/converter.c b/src/nvim/lua/converter.c index 61cb428923..9e3063b164 100644 --- a/src/nvim/lua/converter.c +++ b/src/nvim/lua/converter.c @@ -211,7 +211,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) size_t len; const char *s = lua_tolstring(lstate, -2, &len); if (cur.special) { - list_T *const kv_pair = tv_list_alloc(); + list_T *const kv_pair = tv_list_alloc(2); typval_T s_tv = decode_string(s, len, kTrue, false, false); if (s_tv.v_type == VAR_UNKNOWN) { @@ -321,7 +321,7 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) switch (table_props.type) { case kObjectTypeArray: { cur.tv->v_type = VAR_LIST; - cur.tv->vval.v_list = tv_list_alloc(); + cur.tv->vval.v_list = tv_list_alloc((ptrdiff_t)table_props.maxidx); tv_list_ref(cur.tv->vval.v_list); if (table_props.maxidx != 0) { cur.container = true; @@ -338,7 +338,8 @@ bool nlua_pop_typval(lua_State *lstate, typval_T *ret_tv) } else { cur.special = table_props.has_string_with_nul; if (table_props.has_string_with_nul) { - decode_create_map_special_dict(cur.tv); + decode_create_map_special_dict( + cur.tv, (ptrdiff_t)table_props.string_keys_num); assert(cur.tv->v_type == VAR_DICT); dictitem_T *const val_di = tv_dict_find(cur.tv->vval.v_dict, S_LEN("_VAL")); diff --git a/src/nvim/main.c b/src/nvim/main.c index 0b24023ad0..015df5d070 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -412,7 +412,7 @@ int main(int argc, char **argv) } // It's better to make v:oldfiles an empty list than NULL. if (get_vim_var_list(VV_OLDFILES) == NULL) { - set_vim_var_list(VV_OLDFILES, tv_list_alloc()); + set_vim_var_list(VV_OLDFILES, tv_list_alloc(0)); } /* diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 01c8e94bac..42417f75d5 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -714,7 +714,7 @@ static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes) } } else { // visit recursively all children - list_T *children_list = tv_list_alloc(); + list_T *const children_list = tv_list_alloc(kListLenMayKnow); for (menu = menu->children; menu != NULL; menu = menu->next) { dict_T *dic = menu_get_recursive(menu, modes); if (tv_dict_len(dict) > 0) { diff --git a/src/nvim/ops.c b/src/nvim/ops.c index a5e131190d..b606f10b88 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2564,7 +2564,7 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg) dict_T *dict = get_vim_var_dict(VV_EVENT); // the yanked text - list_T *list = tv_list_alloc(); + list_T *const list = tv_list_alloc((ptrdiff_t)reg->y_size); for (size_t i = 0; i < reg->y_size; i++) { tv_list_append_string(list, (const char *)reg->y_array[i], -1); } @@ -4854,7 +4854,7 @@ static void *get_reg_wrap_one_line(char_u *s, int flags) if (!(flags & kGRegList)) { return s; } - list_T *const list = tv_list_alloc(); + list_T *const list = tv_list_alloc(1); tv_list_append_allocated_string(list, (char *)s); return list; } @@ -4904,7 +4904,7 @@ void *get_reg_contents(int regname, int flags) return NULL; if (flags & kGRegList) { - list_T *list = tv_list_alloc(); + list_T *const list = tv_list_alloc((ptrdiff_t)reg->y_size); for (size_t i = 0; i < reg->y_size; i++) { tv_list_append_string(list, (const char *)reg->y_array[i], -1); } @@ -5593,7 +5593,7 @@ static bool get_clipboard(int name, yankreg_T **target, bool quiet) } free_register(reg); - list_T *const args = tv_list_alloc(); + list_T *const args = tv_list_alloc(1); const char regname = (char)name; tv_list_append_string(args, ®name, 1); @@ -5712,15 +5712,13 @@ static void set_clipboard(int name, yankreg_T *reg) return; } - list_T *lines = tv_list_alloc(); + list_T *const lines = tv_list_alloc( + (ptrdiff_t)reg->y_size + (reg->y_type != kMTCharWise)); for (size_t i = 0; i < reg->y_size; i++) { tv_list_append_string(lines, (const char *)reg->y_array[i], -1); } - list_T *args = tv_list_alloc(); - tv_list_append_list(args, lines); - char regtype; switch (reg->y_type) { case kMTLineWise: { @@ -5741,10 +5739,11 @@ static void set_clipboard(int name, yankreg_T *reg) assert(false); } } - tv_list_append_string(args, ®type, 1); - const char regname = (char)name; - tv_list_append_string(args, ®name, 1); + list_T *args = tv_list_alloc(3); + tv_list_append_list(args, lines); + tv_list_append_string(args, ®type, 1); + tv_list_append_string(args, ((char[]) { (char)name }), 1); (void)eval_call_provider("clipboard", "set", args); } diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 224e43008d..63252df3dc 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -4193,7 +4193,7 @@ int get_errorlist_properties(win_T *wp, dict_T *what, dict_T *retdict) } } if ((status == OK) && (flags & QF_GETLIST_ITEMS)) { - list_T *l = tv_list_alloc(); + list_T *l = tv_list_alloc(kListLenMayKnow); (void)get_errorlist(wp, qf_idx, l); tv_dict_add_list(retdict, S_LEN("items"), l); } diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c index ddc3681867..e4de43b49e 100644 --- a/src/nvim/regexp.c +++ b/src/nvim/regexp.c @@ -7044,7 +7044,7 @@ list_T *reg_submatch_list(int no) colnr_T scol = rsm.sm_mmatch->startpos[no].col; colnr_T ecol = rsm.sm_mmatch->endpos[no].col; - list = tv_list_alloc(); + list = tv_list_alloc(elnum - slnum + 1); s = (const char *)reg_getline_submatch(slnum) + scol; if (slnum == elnum) { @@ -7063,7 +7063,7 @@ list_T *reg_submatch_list(int no) if (s == NULL || rsm.sm_match->endp[no] == NULL) { return NULL; } - list = tv_list_alloc(); + list = tv_list_alloc(1); tv_list_append_string(list, s, (const char *)rsm.sm_match->endp[no] - s); } diff --git a/src/nvim/shada.c b/src/nvim/shada.c index ce9303f14d..c00fd912ec 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -1217,7 +1217,7 @@ static void shada_read(ShaDaReadDef *const sd_reader, const int flags) khash_t(fnamebufs) fname_bufs = KHASH_EMPTY_TABLE(fnamebufs); khash_t(strset) oldfiles_set = KHASH_EMPTY_TABLE(strset); if (get_old_files && (oldfiles_list == NULL || force)) { - oldfiles_list = tv_list_alloc(); + oldfiles_list = tv_list_alloc(kListLenUnknown); set_vim_var_list(VV_OLDFILES, oldfiles_list); } ShaDaReadResult srni_ret; diff --git a/src/nvim/tag.c b/src/nvim/tag.c index be9d621c7d..f23465e501 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -667,7 +667,7 @@ do_tag ( fname = xmalloc(MAXPATHL + 1); cmd = xmalloc(CMDBUFFSIZE + 1); - list = tv_list_alloc(); + list = tv_list_alloc(num_matches); for (i = 0; i < num_matches; ++i) { int len, cmd_len; diff --git a/src/nvim/undo.c b/src/nvim/undo.c index f611a3bb29..b902f82f31 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -2941,17 +2941,20 @@ bool curbufIsChanged(void) && (curbuf->b_changed || file_ff_differs(curbuf, true))); } -/* - * For undotree(): Append the list of undo blocks at "first_uhp" to "list". - * Recursive. - */ -void u_eval_tree(u_header_T *first_uhp, list_T *list) +/// Append the list of undo blocks to a newly allocated list +/// +/// For use in undotree(). Recursive. +/// +/// @param[in] first_uhp Undo blocks list to start with. +/// +/// @return [allocated] List with a representation of undo blocks. +list_T *u_eval_tree(const u_header_T *const first_uhp) + FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_RET { - u_header_T *uhp = first_uhp; - dict_T *dict; + list_T *const list = tv_list_alloc(kListLenMayKnow); - while (uhp != NULL) { - dict = tv_dict_alloc(); + for (const u_header_T *uhp = first_uhp; uhp != NULL; uhp = uhp->uh_prev.ptr) { + dict_T *const dict = tv_dict_alloc(); tv_dict_add_nr(dict, S_LEN("seq"), (varnumber_T)uhp->uh_seq); tv_dict_add_nr(dict, S_LEN("time"), (varnumber_T)uhp->uh_time); if (uhp == curbuf->b_u_newhead) { @@ -2965,14 +2968,12 @@ void u_eval_tree(u_header_T *first_uhp, list_T *list) } if (uhp->uh_alt_next.ptr != NULL) { - list_T *alt_list = tv_list_alloc(); - // Recursive call to add alternate undo tree. - u_eval_tree(uhp->uh_alt_next.ptr, alt_list); - tv_dict_add_list(dict, S_LEN("alt"), alt_list); + tv_dict_add_list(dict, S_LEN("alt"), u_eval_tree(uhp->uh_alt_next.ptr)); } tv_list_append_dict(list, dict); - uhp = uhp->uh_prev.ptr; } + + return list; } diff --git a/src/nvim/window.c b/src/nvim/window.c index b687781dfb..4dfc72f212 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5921,13 +5921,15 @@ void win_get_tabwin(handle_T id, int *tabnr, int *winnr) } } -void win_id2tabwin(typval_T *argvars, list_T *list) +void win_id2tabwin(typval_T *const argvars, typval_T *const rettv) { int winnr = 1; int tabnr = 1; handle_T id = (handle_T)tv_get_number(&argvars[0]); win_get_tabwin(id, &tabnr, &winnr); + + list_T *const list = tv_list_alloc_ret(rettv, 2); tv_list_append_number(list, tabnr); tv_list_append_number(list, winnr); } -- cgit From c10ae4bc8548ca170876e00489fb5d907801e553 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 3 Jan 2018 03:31:10 +0300 Subject: os/fileio: Fix some flag names in file_* functions documentation --- src/nvim/os/fileio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index 5d68473982..d294f9139b 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -39,9 +39,9 @@ /// @param[in] fname File name to open. /// @param[in] flags Flags, @see FileOpenFlags. Currently reading from and /// writing to the file at once is not supported, so either -/// FILE_WRITE_ONLY or FILE_READ_ONLY is required. +/// kFileWriteOnly or kFileReadOnly is required. /// @param[in] mode Permissions for the newly created file (ignored if flags -/// does not have FILE_CREATE\*). +/// does not have kFileCreate\*). /// /// @return Error code (@see os_strerror()) or 0. int file_open(FileDescriptor *const ret_fp, const char *const fname, @@ -120,7 +120,7 @@ int file_open_fd(FileDescriptor *const ret_fp, const int fd, const bool wr) /// @param[in] fname File name to open. /// @param[in] flags Flags, @see FileOpenFlags. /// @param[in] mode Permissions for the newly created file (ignored if flags -/// does not have FILE_CREATE\*). +/// does not have kFileCreate\*). /// /// @return [allocated] Opened file or NULL in case of error. FileDescriptor *file_open_new(int *const error, const char *const fname, -- cgit From 6a1557f2f496bf8e8f4dad7ed0d423051a7b65e2 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 3 Jan 2018 04:25:42 +0300 Subject: eval/typval: Log list actions New logging is guarded by cmake LOG_LIST_ACTIONS define. To make it more efficient it is allocated as a linked list with chunks of length 2^(7+chunk_num); that uses basically the same idea as behind increasing kvec length (make appending O(1) (amortized)), but reduces constant by not bothering to move memory around what realloc() would surely do: it is not like we need random access to log entries here to justify usage of a single continuous memory block. --- src/nvim/eval.c | 12 ++++++ src/nvim/eval.lua | 1 + src/nvim/eval/typval.c | 81 +++++++++++++++++++++++++++++++++++++++++ src/nvim/eval/typval.h | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/nvim/memory.c | 2 + 5 files changed, 195 insertions(+) (limited to 'src') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index ec32f1821d..55396b070d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -16665,6 +16665,18 @@ static void f_test_garbagecollect_now(typval_T *argvars, garbage_collect(true); } +// "test_write_list_log()" function +static void f_test_write_list_log(typval_T *const argvars, + typval_T *const rettv, + FunPtr fptr) +{ + const char *const fname = tv_get_string_chk(&argvars[0]); + if (fname == NULL) { + return; + } + list_write_log(fname); +} + bool callback_from_typval(Callback *const callback, typval_T *const arg) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT { diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua index 54cbc54d78..daa3b637a3 100644 --- a/src/nvim/eval.lua +++ b/src/nvim/eval.lua @@ -313,6 +313,7 @@ return { tempname={}, termopen={args={1, 2}}, test_garbagecollect_now={}, + test_write_list_log={args=1}, timer_info={args={0,1}}, timer_pause={args=2}, timer_start={args={2,3}}, diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 6f829be0b4..c8b550f902 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -31,6 +31,7 @@ #include "nvim/message.h" // TODO(ZyX-I): Move line_breakcheck out of misc1 #include "nvim/misc1.h" // For line_breakcheck +#include "nvim/os/fileio.h" #ifdef INCLUDE_GENERATED_DECLARATIONS # include "eval/typval.c.generated.h" @@ -45,6 +46,70 @@ bool tv_in_free_unref_items = false; const char *const tv_empty_string = ""; //{{{1 Lists +//{{{2 List log +#ifdef LOG_LIST_ACTIONS +ListLog *list_log_first = NULL; +ListLog *list_log_last = NULL; + +/// Write list log to the given file +/// +/// @param[in] fname File to write log to. Will be appended to if already +/// present. +void list_write_log(const char *const fname) + FUNC_ATTR_NONNULL_ALL +{ + FileDescriptor fp; + const int fo_ret = file_open(&fp, fname, kFileCreate|kFileAppend, 0600); + if (fo_ret != 0) { + emsgf(_("E5142: Failed to open file %s: %s"), fname, os_strerror(fo_ret)); + return; + } + for (ListLog *chunk = list_log_first; chunk != NULL;) { + for (size_t i = 0; i < chunk->size; i++) { + char buf[10 + 1 + ((16 + 3) * 3) + (8 + 2) + 2]; + // act : hex " c:" len "[]" "\n\0" + const ListLogEntry entry = chunk->entries[i]; + const size_t snp_len = (size_t)snprintf( + buf, sizeof(buf), + "%-10.10s: l:%016" PRIxPTR "[%08d] 1:%016" PRIxPTR " 2:%016" PRIxPTR + "\n", + entry.action, entry.l, entry.len, entry.li1, entry.li2); + assert(snp_len + 1 == sizeof(buf)); + const ptrdiff_t fw_ret = file_write(&fp, buf, snp_len); + if (fw_ret != (ptrdiff_t)snp_len) { + assert(fw_ret < 0); + if (i) { + memmove(chunk->entries, chunk->entries + i, + sizeof(chunk->entries[0]) * (chunk->size - i)); + chunk->size -= i; + } + emsgf(_("E5143: Failed to write to file %s: %s"), + fname, os_strerror((int)fw_ret)); + return; + } + } + list_log_first = chunk->next; + xfree(chunk); + chunk = list_log_first; + } + const int fc_ret = file_close(&fp, true); + if (fc_ret != 0) { + emsgf(_("E5144: Failed to close file %s: %s"), fname, os_strerror(fc_ret)); + } +} + +#ifdef EXITFREE +/// Free list log +void list_free_log(void) +{ + for (ListLog *chunk = list_log_first; chunk != NULL;) { + list_log_first = chunk->next; + xfree(chunk); + chunk = list_log_first; + } +} +#endif +#endif //{{{2 List item /// Allocate a list item @@ -151,6 +216,7 @@ list_T *tv_list_alloc(const ptrdiff_t len) list->lv_used_prev = NULL; list->lv_used_next = gc_first_list; gc_first_list = list; + list_log(list, NULL, (void *)(uintptr_t)len, "alloc"); return list; } @@ -180,6 +246,8 @@ void tv_list_init_static10(staticList10_T *const sl) li->li_prev = li - 1; li->li_next = li + 1; } + list_log((const list_T *)sl, &sl->sl_items[0], &sl->sl_items[SL_SIZE - 1], + "s10init"); #undef SL_SIZE } @@ -191,6 +259,7 @@ void tv_list_init_static(list_T *const l) { memset(l, 0, sizeof(*l)); l->lv_refcount = DO_NOT_FREE_CNT; + list_log(l, NULL, NULL, "sinit"); } /// Free items contained in a list @@ -199,6 +268,7 @@ void tv_list_init_static(list_T *const l) void tv_list_free_contents(list_T *const l) FUNC_ATTR_NONNULL_ALL { + list_log(l, NULL, NULL, "freecont"); for (listitem_T *item = l->lv_first; item != NULL; item = l->lv_first) { // Remove the item before deleting it. l->lv_first = item->li_next; @@ -228,6 +298,7 @@ void tv_list_free_list(list_T *const l) if (l->lv_used_next != NULL) { l->lv_used_next->lv_used_prev = l->lv_used_prev; } + list_log(l, NULL, NULL, "freelist"); xfree(l); } @@ -272,6 +343,7 @@ void tv_list_drop_items(list_T *const l, listitem_T *const item, listitem_T *const item2) FUNC_ATTR_NONNULL_ALL { + list_log(l, item, item2, "drop"); // Notify watchers. for (listitem_T *ip = item; ip != item2->li_next; ip = ip->li_next) { l->lv_len--; @@ -289,6 +361,7 @@ void tv_list_drop_items(list_T *const l, listitem_T *const item, item->li_prev->li_next = item2->li_next; } l->lv_idx_item = NULL; + list_log(l, l->lv_first, l->lv_last, "afterdrop"); } /// Like tv_list_drop_items, but also frees all removed items @@ -296,6 +369,7 @@ void tv_list_remove_items(list_T *const l, listitem_T *const item, listitem_T *const item2) FUNC_ATTR_NONNULL_ALL { + list_log(l, item, item2, "remove"); tv_list_drop_items(l, item, item2); for (listitem_T *li = item;;) { tv_clear(TV_LIST_ITEM_TV(li)); @@ -320,6 +394,7 @@ void tv_list_move_items(list_T *const l, listitem_T *const item, const int cnt) FUNC_ATTR_NONNULL_ALL { + list_log(l, item, item2, "move"); tv_list_drop_items(l, item, item2); item->li_prev = tgt_l->lv_last; item2->li_next = NULL; @@ -330,6 +405,7 @@ void tv_list_move_items(list_T *const l, listitem_T *const item, } tgt_l->lv_last = item2; tgt_l->lv_len += cnt; + list_log(tgt_l, tgt_l->lv_first, tgt_l->lv_last, "movetgt"); } /// Insert list item @@ -358,6 +434,7 @@ void tv_list_insert(list_T *const l, listitem_T *const ni, } item->li_prev = ni; l->lv_len++; + list_log(l, ni, item, "insert"); } } @@ -384,6 +461,7 @@ void tv_list_insert_tv(list_T *const l, typval_T *const tv, void tv_list_append(list_T *const l, listitem_T *const item) FUNC_ATTR_NONNULL_ALL { + list_log(l, item, NULL, "append"); if (l->lv_last == NULL) { // empty list l->lv_first = item; @@ -747,6 +825,7 @@ void tv_list_reverse(list_T *const l) if (tv_list_len(l) <= 1) { return; } + list_log(l, NULL, NULL, "reverse"); #define SWAP(a, b) \ do { \ tmp = a; \ @@ -785,6 +864,7 @@ void tv_list_item_sort(list_T *const l, ListSortItem *const ptrs, if (len <= 1) { return; } + list_log(l, NULL, NULL, "sort"); int i = 0; TV_LIST_ITER(l, li, { ptrs[i].item = li; @@ -873,6 +953,7 @@ listitem_T *tv_list_find(list_T *const l, int n) // Cache the used index. l->lv_idx = idx; l->lv_idx_item = item; + list_log(l, l->lv_idx_item, (void *)(uintptr_t)l->lv_idx, "find"); return item; } diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 3993a384d2..40a1738d9e 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -20,6 +20,9 @@ #include "nvim/gettext.h" #include "nvim/message.h" #include "nvim/macros.h" +#ifdef LOG_LIST_ACTIONS +# include "nvim/memory.h" +#endif /// Type used for VimL VAR_NUMBER values typedef int64_t varnumber_T; @@ -323,6 +326,96 @@ typedef struct { typedef int (*ListSorter)(const void *, const void *); +#ifdef LOG_LIST_ACTIONS + +/// List actions log entry +typedef struct { + uintptr_t l; ///< List log entry belongs to. + uintptr_t li1; ///< First list item log entry belongs to, if applicable. + uintptr_t li2; ///< Second list item log entry belongs to, if applicable. + int len; ///< List length when log entry was created. + const char *action; ///< Logged action. +} ListLogEntry; + +typedef struct list_log ListLog; + +/// List actions log +struct list_log { + ListLog *next; ///< Next chunk or NULL. + size_t capacity; ///< Number of entries in current chunk. + size_t size; ///< Current chunk size. + ListLogEntry entries[]; ///< Actual log entries. +}; + +extern ListLog *list_log_first; ///< First list log chunk, NULL if missing +extern ListLog *list_log_last; ///< Last list log chunk + +static inline ListLog *list_log_alloc(const size_t size) + REAL_FATTR_ALWAYS_INLINE REAL_FATTR_WARN_UNUSED_RESULT; + +/// Allocate a new log chunk and update globals +/// +/// @param[in] size Number of entries in a new chunk. +/// +/// @return [allocated] Newly allocated chunk. +static inline ListLog *list_log_new(const size_t size) +{ + ListLog *ret = xmalloc(offsetof(ListLog, entries) + + size * sizeof(ret->entries[0])); + ret->size = 0; + ret->capacity = size; + ret->next = NULL; + if (list_log_first == NULL) { + list_log_first = ret; + } else { + list_log_last->next = ret; + } + list_log_last = ret; + return ret; +} + +static inline void list_log(const list_T *const l, + const listitem_T *const li1, + const listitem_T *const li2, + const char *const action) + REAL_FATTR_ALWAYS_INLINE; + +/// Add new entry to log +/// +/// If last chunk was filled it uses twice as much memory to allocate the next +/// chunk. +/// +/// @param[in] l List to which entry belongs. +/// @param[in] li1 List item 1. +/// @param[in] li2 List item 2, often used for integers and not list items. +/// @param[in] action Logged action. +static inline void list_log(const list_T *const l, + const listitem_T *const li1, + const listitem_T *const li2, + const char *const action) +{ + ListLog *tgt; + if (list_log_first == NULL) { + tgt = list_log_new(128); + } else if (list_log_last->size == list_log_last->capacity) { + tgt = list_log_new(list_log_last->capacity * 2); + } else { + tgt = list_log_last; + } + tgt->entries[tgt->size++] = (ListLogEntry) { + .l = (uintptr_t)l, + .li1 = (uintptr_t)li1, + .li2 = (uintptr_t)li2, + .len = (l == NULL ? 0 : l->lv_len), + .action = action, + }; +} +#else +# define list_log(...) +# define list_write_log(...) +# define list_free_log() +#endif + // In a hashtab item "hi_key" points to "di_key" in a dictitem. // This avoids adding a pointer to the hashtab item. @@ -396,6 +489,7 @@ static inline int tv_list_len(const list_T *const l) /// @param[in] l List to check. static inline int tv_list_len(const list_T *const l) { + list_log(l, NULL, NULL, "len"); if (l == NULL) { return 0; } @@ -479,8 +573,10 @@ static inline listitem_T *tv_list_first(const list_T *const l) static inline listitem_T *tv_list_first(const list_T *const l) { if (l == NULL) { + list_log(l, NULL, NULL, "first"); return NULL; } + list_log(l, l->lv_first, NULL, "first"); return l->lv_first; } @@ -495,8 +591,10 @@ static inline listitem_T *tv_list_last(const list_T *const l) static inline listitem_T *tv_list_last(const list_T *const l) { if (l == NULL) { + list_log(l, NULL, NULL, "last"); return NULL; } + list_log(l, l->lv_last, NULL, "last"); return l->lv_last; } @@ -564,6 +662,7 @@ extern bool tv_in_free_unref_items; #define _TV_LIST_ITER_MOD(modifier, l, li, code) \ do { \ modifier list_T *const l_ = (l); \ + list_log(l_, NULL, NULL, "iter" #modifier); \ if (l_ != NULL) { \ for (modifier listitem_T *li = l_->lv_first; \ li != NULL; li = li->li_next) { \ diff --git a/src/nvim/memory.c b/src/nvim/memory.c index 328b96fd5c..a66ab6a3cc 100644 --- a/src/nvim/memory.c +++ b/src/nvim/memory.c @@ -559,6 +559,7 @@ void time_to_bytes(time_t time_, uint8_t buf[8]) #include "nvim/tag.h" #include "nvim/window.h" #include "nvim/os/os.h" +#include "nvim/eval/typval.h" /* * Free everything that we allocated. @@ -692,6 +693,7 @@ void free_all_mem(void) free_screenlines(); clear_hl_tables(); + list_free_log(); } #endif -- cgit From a8cb510a2ed2f53f60ba4b2e722f4bc64954c606 Mon Sep 17 00:00:00 2001 From: ZyX Date: Tue, 9 Jan 2018 12:39:15 +0300 Subject: channel: Make empty output be represented by `['']` again --- src/nvim/channel.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/nvim/channel.c b/src/nvim/channel.c index 9d0a7d3c21..265d4d8b89 100644 --- a/src/nvim/channel.c +++ b/src/nvim/channel.c @@ -533,6 +533,9 @@ static inline list_T *buffer_to_tv_list(const char *const buf, const size_t len) FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_ALWAYS_INLINE { list_T *const l = tv_list_alloc(kListLenMayKnow); + // Empty buffer should be represented by [''], encode_list_write() thinks + // empty list is fine for the case. + tv_list_append_string(l, "", 0); encode_list_write(l, buf, len); return l; } -- cgit From 4b8d6caf48e28730767ae87a985a345ed6f0d2b3 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 14 Jan 2018 20:50:05 +0800 Subject: vim-patch:8.0.0380: with 'linebreak' double wide char wraps badly Problem: With 'linebreak' set and 'breakat' includes ">" a double-wide character results in "<<" displayed. Solution: Check for the character not to be replaced. (Ozaki Kiichi, closes vim/vim#1456) https://github.com/vim/vim/commit/38632faf635f6434441827e136bceb5a930c59ad --- src/nvim/screen.c | 26 +++++++++++++------------- src/nvim/testdir/test_listlbr_utf8.vim | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/nvim/screen.c b/src/nvim/screen.c index ed96e98d32..8a29734025 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -3143,14 +3143,15 @@ win_line ( } --n_extra; } else { + int c0; + if (p_extra_free != NULL) { xfree(p_extra_free); p_extra_free = NULL; } - /* - * Get a character from the line itself. - */ - c = *ptr; + + // Get a character from the line itself. + c0 = c = *ptr; if (has_mbyte) { mb_c = c; if (enc_utf8) { @@ -3160,11 +3161,12 @@ win_line ( mb_utf8 = FALSE; if (mb_l > 1) { mb_c = utfc_ptr2char(ptr, u8cc); - /* Overlong encoded ASCII or ASCII with composing char - * is displayed normally, except a NUL. */ - if (mb_c < 0x80) - c = mb_c; - mb_utf8 = TRUE; + // Overlong encoded ASCII or ASCII with composing char + // is displayed normally, except a NUL. + if (mb_c < 0x80) { + c0 = c = mb_c; + } + mb_utf8 = true; /* At start of the line we can have a composing char. * Draw it as a space with a composing char. */ @@ -3428,10 +3430,8 @@ win_line ( char_attr = hl_combine_attr(char_attr, term_attrs[vcol]); } - /* - * Found last space before word: check for line break. - */ - if (wp->w_p_lbr && vim_isbreak(c) && !vim_isbreak(*ptr)) { + // Found last space before word: check for line break. + if (wp->w_p_lbr && c0 == c && vim_isbreak(c) && !vim_isbreak(*ptr)) { int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) : 0; char_u *p = ptr - (mb_off + 1); // TODO: is passing p for start of the line OK? diff --git a/src/nvim/testdir/test_listlbr_utf8.vim b/src/nvim/testdir/test_listlbr_utf8.vim index 980d67d49d..56a4cc9b31 100644 --- a/src/nvim/testdir/test_listlbr_utf8.vim +++ b/src/nvim/testdir/test_listlbr_utf8.vim @@ -194,6 +194,33 @@ func Test_multibyte_sign_and_colorcolumn() call s:close_windows() endfunc +func Test_illegal_byte_and_breakat() + call s:test_windows("setl sbr= brk+=<") + vert resize 18 + call setline(1, repeat("\x80", 6)) + redraw! + let lines = s:screen_lines([1, 2], winwidth(0)) + let expect = [ +\ "<80><80><80><80><8", +\ "0><80> ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows('setl brk&vim') +endfunc + +func Test_multibyte_wrap_and_breakat() + call s:test_windows("setl sbr= brk+=>") + call setline(1, repeat('a', 17) . repeat('ã‚', 2)) + redraw! + let lines = s:screen_lines([1, 2], winwidth(0)) + let expect = [ +\ "aaaaaaaaaaaaaaaaaã‚>", +\ "ã‚ ", +\ ] + call s:compare_lines(expect, lines) + call s:close_windows('setl brk&vim') +endfunc + func Test_chinese_char_on_wrap_column() call s:test_windows("setl nolbr wrap sbr=") syntax off -- cgit From 7faeaf9f243a8b955b73960d3bba9a34fce3132d Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 14 Jan 2018 20:50:49 +0800 Subject: vim-patch:8.0.0381: diff mode is not sufficiently tested Problem: Diff mode is not sufficiently tested. Solution: Add more diff mode tests. (Dominique Pelle, closes vim/vim#1515) https://github.com/vim/vim/commit/aeb661e1f4a491286ef7af8c3105aff1f3b16f1c --- src/nvim/testdir/test_diffmode.vim | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'src') diff --git a/src/nvim/testdir/test_diffmode.vim b/src/nvim/testdir/test_diffmode.vim index 8ee82bd538..c3d4be9cf9 100644 --- a/src/nvim/testdir/test_diffmode.vim +++ b/src/nvim/testdir/test_diffmode.vim @@ -272,3 +272,78 @@ func Test_setting_cursor() call delete('Xtest1') call delete('Xtest2') endfunc + +func Test_diff_move_to() + new + call setline(1, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) + diffthis + vnew + call setline(1, [1, '2x', 3, 4, 4, 5, '6x', 7, '8x', 9, '10x']) + diffthis + norm ]c + call assert_equal(2, line('.')) + norm 3]c + call assert_equal(9, line('.')) + norm 10]c + call assert_equal(11, line('.')) + norm [c + call assert_equal(9, line('.')) + norm 2[c + call assert_equal(5, line('.')) + norm 10[c + call assert_equal(2, line('.')) + %bwipe! +endfunc + +func Test_diffpatch() + " The patch program on MS-Windows may fail or hang. + if !executable('patch') || !has('unix') + return + endif + new + insert +*************** +*** 1,3 **** + 1 +! 2 + 3 +--- 1,4 ---- + 1 +! 2x + 3 ++ 4 +. + saveas Xpatch + bwipe! + new + call assert_fails('diffpatch Xpatch', 'E816:') + call setline(1, ['1', '2', '3']) + diffpatch Xpatch + call assert_equal(['1', '2x', '3', '4'], getline(1, '$')) + call delete('Xpatch') + bwipe! +endfunc + +func Test_diff_too_many_buffers() + for i in range(1, 8) + exe "new Xtest" . i + diffthis + endfor + new Xtest9 + call assert_fails('diffthis', 'E96:') + %bwipe! +endfunc + +func Test_diff_nomodifiable() + new + call setline(1, [1, 2, 3, 4]) + setl nomodifiable + diffthis + vnew + call setline(1, ['1x', 2, 3, 3, 4]) + diffthis + call assert_fails('norm dp', 'E793:') + setl nomodifiable + call assert_fails('norm do', 'E21:') + %bwipe! +endfunc -- cgit From fe4ba6995895f95f461d40eda356cc7e1dbb1abf Mon Sep 17 00:00:00 2001 From: ckelsel Date: Sun, 14 Jan 2018 20:52:51 +0800 Subject: vim-patch:8.0.0385: no tests for arabic Problem: No tests for arabic. Solution: Add a first test for arabic. (Dominique Pelle, closes vim/vim#1518) https://github.com/vim/vim/commit/b5e8377364110ee70090274da15d202778e96a64 --- src/nvim/testdir/Makefile | 1 + src/nvim/testdir/test_arabic.vim | 92 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 src/nvim/testdir/test_arabic.vim (limited to 'src') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index a23dacba15..0c25945274 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -40,6 +40,7 @@ SCRIPTS ?= $(SCRIPTS_DEFAULT) # Tests using runtest.vim. # Keep test_alot*.res as the last one, sort the others. NEW_TESTS ?= \ + test_arabic.vim \ test_autocmd.res \ test_bufwintabinfo.res \ test_changedtick.res \ diff --git a/src/nvim/testdir/test_arabic.vim b/src/nvim/testdir/test_arabic.vim new file mode 100644 index 0000000000..b9e033462e --- /dev/null +++ b/src/nvim/testdir/test_arabic.vim @@ -0,0 +1,92 @@ +" Simplistic testing of Arabic mode. + +if !has('arabic') + finish +endif + +set encoding=utf-8 +scriptencoding utf-8 + +" Return list of utf8 sequences of each character at line lnum. +" Combining characters are treated as a single item. +func GetCharsUtf8(lnum) + call cursor(a:lnum, 1) + let chars = [] + let numchars = strchars(getline('.'), 1) + for i in range(1, numchars) + exe 'norm ' i . '|' + call add(chars, execute('norm g8')) + endfor + return chars +endfunc + +func Test_arabic_toggle() + set arabic + call assert_equal(1, &rightleft) + call assert_equal(1, &arabicshape) + call assert_equal('arabic', &keymap) + call assert_equal(1, &delcombine) + + set iminsert=1 imsearch=1 + set arabic& + call assert_equal(0, &rightleft) + call assert_equal(1, &arabicshape) + call assert_equal('arabic', &keymap) + call assert_equal(1, &delcombine) + call assert_equal(0, &iminsert) + call assert_equal(-1, &imsearch) + + set arabicshape& keymap= delcombine& +endfunc + +func Test_arabic_input() + new + set arabic + " Typing sghl in Arabic insert mode should show the + " Arabic word 'Salaam' i.e. 'peace'. + call feedkeys('isghl', 'tx') + redraw + call assert_equal([ + \ "\nd8 b3 ", + \ "\nd9 84 + d8 a7 ", + \ "\nd9 85 "], GetCharsUtf8(1)) + + " Without shaping, it should give individual Arabic letters. + set noarabicshape + redraw + call assert_equal([ + \ "\nd8 b3 ", + \ "\nd9 84 ", + \ "\nd8 a7 ", + \ "\nd9 85 "], GetCharsUtf8(1)) + + set arabicshape& + set arabic& + bwipe! +endfunc + +func Test_arabic_toggle_keymap() + new + set arabic + call feedkeys("i12\12\12", 'tx') + redraw + call assert_equal('١٢12١٢', getline('.')) + set arabic& + bwipe! +endfunc + +func Test_delcombine() + new + set arabic + call feedkeys("isghl\\", 'tx') + redraw + call assert_equal(["\nd8 b3 ", "\nd9 84 "], GetCharsUtf8(1)) + + " Now the same with nodelcombine + set nodelcombine + %d + call feedkeys("isghl\\", 'tx') + call assert_equal(["\nd8 b3 "], GetCharsUtf8(1)) + set arabic& + bwipe! +endfunc -- cgit From fc97e9fbdf372e52370ca8640422327d8a0c8cb5 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Mon, 15 Jan 2018 17:32:54 +0800 Subject: vim-patch:8.0.0389: test for arabic does not check what is displayed Problem: Test for arabic does not check what is displayed. Solution: Improve what is asserted. (Dominique Pelle, closes vim/vim#1523) Add a first shaping test. https://github.com/vim/vim/commit/5342f00ff95ed0256b8183063a83d72112f1243c --- src/nvim/testdir/test_arabic.vim | 89 +++++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/nvim/testdir/test_arabic.vim b/src/nvim/testdir/test_arabic.vim index b9e033462e..9e648a9617 100644 --- a/src/nvim/testdir/test_arabic.vim +++ b/src/nvim/testdir/test_arabic.vim @@ -1,21 +1,23 @@ " Simplistic testing of Arabic mode. -if !has('arabic') +if !has('arabic') || !has('multi_byte') finish endif -set encoding=utf-8 -scriptencoding utf-8 +source view_util.vim -" Return list of utf8 sequences of each character at line lnum. +" Return list of Unicode characters at line lnum. " Combining characters are treated as a single item. -func GetCharsUtf8(lnum) +func s:get_chars(lnum) call cursor(a:lnum, 1) let chars = [] let numchars = strchars(getline('.'), 1) for i in range(1, numchars) exe 'norm ' i . '|' - call add(chars, execute('norm g8')) + let c=execute('ascii') + let c=substitute(c, '\n\?<.\{-}Hex\s*', 'U+', 'g') + let c=substitute(c, ',\s*Octal\s*\d*', '', 'g') + call add(chars, c) endfor return chars endfunc @@ -43,25 +45,28 @@ func Test_arabic_input() new set arabic " Typing sghl in Arabic insert mode should show the - " Arabic word 'Salaam' i.e. 'peace'. - call feedkeys('isghl', 'tx') - redraw + " Arabic word 'Salaam' i.e. 'peace', spelled: + " SEEN, LAM, ALEF, MEEM. + " See: https://www.mediawiki.org/wiki/VisualEditor/Typing/Right-to-left + call feedkeys('isghl!', 'tx') + call assert_match("^ *!\uFEE1\uFEFC\uFEB3$", ScreenLines(1, &columns)[0]) call assert_equal([ - \ "\nd8 b3 ", - \ "\nd9 84 + d8 a7 ", - \ "\nd9 85 "], GetCharsUtf8(1)) + \ 'U+0633', + \ 'U+0644 U+0627', + \ 'U+0645', + \ 'U+21'], s:get_chars(1)) " Without shaping, it should give individual Arabic letters. set noarabicshape - redraw + call assert_match("^ *!\u0645\u0627\u0644\u0633$", ScreenLines(1, &columns)[0]) call assert_equal([ - \ "\nd8 b3 ", - \ "\nd9 84 ", - \ "\nd8 a7 ", - \ "\nd9 85 "], GetCharsUtf8(1)) + \ 'U+0633', + \ 'U+0644', + \ 'U+0627', + \ 'U+0645', + \ 'U+21'], s:get_chars(1)) - set arabicshape& - set arabic& + set arabic& arabicshape& bwipe! endfunc @@ -69,7 +74,7 @@ func Test_arabic_toggle_keymap() new set arabic call feedkeys("i12\12\12", 'tx') - redraw + call assert_match("^ *٢١21٢١$", ScreenLines(1, &columns)[0]) call assert_equal('١٢12١٢', getline('.')) set arabic& bwipe! @@ -79,14 +84,50 @@ func Test_delcombine() new set arabic call feedkeys("isghl\\", 'tx') - redraw - call assert_equal(["\nd8 b3 ", "\nd9 84 "], GetCharsUtf8(1)) + call assert_match("^ *\uFEDE\uFEB3$", ScreenLines(1, &columns)[0]) + call assert_equal(['U+0633', 'U+0644'], s:get_chars(1)) - " Now the same with nodelcombine + " Now the same with 'nodelcombine' set nodelcombine %d call feedkeys("isghl\\", 'tx') - call assert_equal(["\nd8 b3 "], GetCharsUtf8(1)) + call assert_match("^ *\uFEB1$", ScreenLines(1, &columns)[0]) + call assert_equal(['U+0633'], s:get_chars(1)) set arabic& bwipe! endfunc + +let s:a_YEH_HAMZA = "\u0626" +let s:a_i_YEH_HAMZA = "\ufe8b" + +let s:a_HAMZA = "\u0621" +let s:a_s_HAMZA = "\ufe80" + +let s:a_ALEF_MADDA = "\u0622" +let s:a_s_ALEF_MADDA = "\ufe81" + +let s:a_ALEF_HAMZA_ABOVE = "\u0623" +let s:a_s_ALEF_HAMZA_ABOVE = "\ufe83" + +let s:a_GHAIN = "\u063a" +let s:a_f_GHAIN = "\ufece" +let s:a_s_GHAIN = "\ufecd" + +func Test_shape_initial() + new + set arabicshape + + " Shaping arabic {testchar} non-arabic Uses chg_c_a2i(). + " pair[0] = testchar, pair[1] = next-result, pair[2] = current-result + for pair in [[s:a_YEH_HAMZA, s:a_f_GHAIN, s:a_i_YEH_HAMZA], + \ [s:a_HAMZA, s:a_s_GHAIN, s:a_s_HAMZA], + \ [s:a_ALEF_MADDA, s:a_s_GHAIN, s:a_s_ALEF_MADDA], + \ [s:a_ALEF_HAMZA_ABOVE, s:a_s_GHAIN, s:a_s_ALEF_HAMZA_ABOVE], + \ ] + call setline(1, s:a_GHAIN . pair[0] . ' ') + call assert_equal([pair[1] . pair[2] . ' '], ScreenLines(1, 3)) + endfor + + set arabicshape& + bwipe! +endfunc -- cgit From 770ec228c7e47c63ba549e67bfdaae9aa574ecce Mon Sep 17 00:00:00 2001 From: ckelsel Date: Mon, 15 Jan 2018 17:33:34 +0800 Subject: vim-patch:8.0.0391: arabic support is verbose and not well tested Problem: Arabic support is verbose and not well tested. Solution: Simplify the code. Add more tests. https://github.com/vim/vim/commit/5f53dd3f747711be90879fa2f22a207970b86750 --- src/nvim/arabic.c | 382 ++++++++------------------------------- src/nvim/testdir/test_arabic.vim | 359 +++++++++++++++++++++++++++++++++++- 2 files changed, 425 insertions(+), 316 deletions(-) (limited to 'src') diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c index 1ef51d2a2a..f0370af704 100644 --- a/src/nvim/arabic.c +++ b/src/nvim/arabic.c @@ -393,323 +393,93 @@ static bool A_is_f(int cur_c) // Change shape - from ISO-8859-6/Isolated to Form-B Isolated static int chg_c_a2s(int cur_c) { - int tempc; - switch (cur_c) { - case a_HAMZA: - tempc = a_s_HAMZA; - break; - - case a_ALEF_MADDA: - tempc = a_s_ALEF_MADDA; - break; - - case a_ALEF_HAMZA_ABOVE: - tempc = a_s_ALEF_HAMZA_ABOVE; - break; - - case a_WAW_HAMZA: - tempc = a_s_WAW_HAMZA; - break; - - case a_ALEF_HAMZA_BELOW: - tempc = a_s_ALEF_HAMZA_BELOW; - break; - - case a_YEH_HAMZA: - tempc = a_s_YEH_HAMZA; - break; - - case a_ALEF: - tempc = a_s_ALEF; - break; - - case a_TEH_MARBUTA: - tempc = a_s_TEH_MARBUTA; - break; - - case a_DAL: - tempc = a_s_DAL; - break; - - case a_THAL: - tempc = a_s_THAL; - break; - - case a_REH: - tempc = a_s_REH; - break; - - case a_ZAIN: - tempc = a_s_ZAIN; - break; - - case a_TATWEEL: // exceptions - tempc = cur_c; - break; - - case a_WAW: - tempc = a_s_WAW; - break; - - case a_ALEF_MAKSURA: - tempc = a_s_ALEF_MAKSURA; - break; - - case a_BEH: - tempc = a_s_BEH; - break; - - case a_TEH: - tempc = a_s_TEH; - break; - - case a_THEH: - tempc = a_s_THEH; - break; - - case a_JEEM: - tempc = a_s_JEEM; - break; - - case a_HAH: - tempc = a_s_HAH; - break; - - case a_KHAH: - tempc = a_s_KHAH; - break; - - case a_SEEN: - tempc = a_s_SEEN; - break; - - case a_SHEEN: - tempc = a_s_SHEEN; - break; - - case a_SAD: - tempc = a_s_SAD; - break; - - case a_DAD: - tempc = a_s_DAD; - break; - - case a_TAH: - tempc = a_s_TAH; - break; - - case a_ZAH: - tempc = a_s_ZAH; - break; - - case a_AIN: - tempc = a_s_AIN; - break; - - case a_GHAIN: - tempc = a_s_GHAIN; - break; - - case a_FEH: - tempc = a_s_FEH; - break; - - case a_QAF: - tempc = a_s_QAF; - break; - - case a_KAF: - tempc = a_s_KAF; - break; - - case a_LAM: - tempc = a_s_LAM; - break; - - case a_MEEM: - tempc = a_s_MEEM; - break; - - case a_NOON: - tempc = a_s_NOON; - break; - - case a_HEH: - tempc = a_s_HEH; - break; - - case a_YEH: - tempc = a_s_YEH; - break; - - default: - tempc = 0; + case a_HAMZA: return a_s_HAMZA; + case a_ALEF_MADDA: return a_s_ALEF_MADDA; + case a_ALEF_HAMZA_ABOVE: return a_s_ALEF_HAMZA_ABOVE; + case a_WAW_HAMZA: return a_s_WAW_HAMZA; + case a_ALEF_HAMZA_BELOW: return a_s_ALEF_HAMZA_BELOW; + case a_YEH_HAMZA: return a_s_YEH_HAMZA; + case a_ALEF: return a_s_ALEF; + case a_TEH_MARBUTA: return a_s_TEH_MARBUTA; + case a_DAL: return a_s_DAL; + case a_THAL: return a_s_THAL; + case a_REH: return a_s_REH; + case a_ZAIN: return a_s_ZAIN; + case a_TATWEEL: return cur_c; // exceptions + case a_WAW: return a_s_WAW; + case a_ALEF_MAKSURA: return a_s_ALEF_MAKSURA; + case a_BEH: return a_s_BEH; + case a_TEH: return a_s_TEH; + case a_THEH: return a_s_THEH; + case a_JEEM: return a_s_JEEM; + case a_HAH: return a_s_HAH; + case a_KHAH: return a_s_KHAH; + case a_SEEN: return a_s_SEEN; + case a_SHEEN: return a_s_SHEEN; + case a_SAD: return a_s_SAD; + case a_DAD: return a_s_DAD; + case a_TAH: return a_s_TAH; + case a_ZAH: return a_s_ZAH; + case a_AIN: return a_s_AIN; + case a_GHAIN: return a_s_GHAIN; + case a_FEH: return a_s_FEH; + case a_QAF: return a_s_QAF; + case a_KAF: return a_s_KAF; + case a_LAM: return a_s_LAM; + case a_MEEM: return a_s_MEEM; + case a_NOON: return a_s_NOON; + case a_HEH: return a_s_HEH; + case a_YEH: return a_s_YEH; } - return tempc; + return 0; } // Change shape - from ISO-8859-6/Isolated to Initial static int chg_c_a2i(int cur_c) { - int tempc; - switch (cur_c) { - case a_YEH_HAMZA: - tempc = a_i_YEH_HAMZA; - break; - - case a_HAMZA: // exceptions - tempc = a_s_HAMZA; - break; - - case a_ALEF_MADDA: // exceptions - tempc = a_s_ALEF_MADDA; - break; - - case a_ALEF_HAMZA_ABOVE: // exceptions - tempc = a_s_ALEF_HAMZA_ABOVE; - break; - - case a_WAW_HAMZA: // exceptions - tempc = a_s_WAW_HAMZA; - break; - - case a_ALEF_HAMZA_BELOW: // exceptions - tempc = a_s_ALEF_HAMZA_BELOW; - break; - - case a_ALEF: // exceptions - tempc = a_s_ALEF; - break; - - case a_TEH_MARBUTA: // exceptions - tempc = a_s_TEH_MARBUTA; - break; - - case a_DAL: // exceptions - tempc = a_s_DAL; - break; - - case a_THAL: // exceptions - tempc = a_s_THAL; - break; - - case a_REH: // exceptions - tempc = a_s_REH; - break; - - case a_ZAIN: // exceptions - tempc = a_s_ZAIN; - break; - - case a_TATWEEL: // exceptions - tempc = cur_c; - break; - - case a_WAW: // exceptions - tempc = a_s_WAW; - break; - - case a_ALEF_MAKSURA: // exceptions - tempc = a_s_ALEF_MAKSURA; - break; - - case a_BEH: - tempc = a_i_BEH; - break; - - case a_TEH: - tempc = a_i_TEH; - break; - - case a_THEH: - tempc = a_i_THEH; - break; - - case a_JEEM: - tempc = a_i_JEEM; - break; - - case a_HAH: - tempc = a_i_HAH; - break; - - case a_KHAH: - tempc = a_i_KHAH; - break; - - case a_SEEN: - tempc = a_i_SEEN; - break; - - case a_SHEEN: - tempc = a_i_SHEEN; - break; - - case a_SAD: - tempc = a_i_SAD; - break; - - case a_DAD: - tempc = a_i_DAD; - break; - - case a_TAH: - tempc = a_i_TAH; - break; - - case a_ZAH: - tempc = a_i_ZAH; - break; - - case a_AIN: - tempc = a_i_AIN; - break; - - case a_GHAIN: - tempc = a_i_GHAIN; - break; - - case a_FEH: - tempc = a_i_FEH; - break; - - case a_QAF: - tempc = a_i_QAF; - break; - - case a_KAF: - tempc = a_i_KAF; - break; - - case a_LAM: - tempc = a_i_LAM; - break; - - case a_MEEM: - tempc = a_i_MEEM; - break; - - case a_NOON: - tempc = a_i_NOON; - break; - - case a_HEH: - tempc = a_i_HEH; - break; - - case a_YEH: - tempc = a_i_YEH; - break; - - default: - tempc = 0; + case a_YEH_HAMZA: return a_i_YEH_HAMZA; + case a_HAMZA: return a_s_HAMZA; // exceptions + case a_ALEF_MADDA: return a_s_ALEF_MADDA; // exceptions + case a_ALEF_HAMZA_ABOVE: return a_s_ALEF_HAMZA_ABOVE; // exceptions + case a_WAW_HAMZA: return a_s_WAW_HAMZA; // exceptions + case a_ALEF_HAMZA_BELOW: return a_s_ALEF_HAMZA_BELOW; // exceptions + case a_ALEF: return a_s_ALEF; // exceptions + case a_TEH_MARBUTA: return a_s_TEH_MARBUTA; // exceptions + case a_DAL: return a_s_DAL; // exceptions + case a_THAL: return a_s_THAL; // exceptions + case a_REH: return a_s_REH; // exceptions + case a_ZAIN: return a_s_ZAIN; // exceptions + case a_TATWEEL: return cur_c; // exceptions + case a_WAW: return a_s_WAW; // exceptions + case a_ALEF_MAKSURA: return a_s_ALEF_MAKSURA; // exceptions + case a_BEH: return a_i_BEH; + case a_TEH: return a_i_TEH; + case a_THEH: return a_i_THEH; + case a_JEEM: return a_i_JEEM; + case a_HAH: return a_i_HAH; + case a_KHAH: return a_i_KHAH; + case a_SEEN: return a_i_SEEN; + case a_SHEEN: return a_i_SHEEN; + case a_SAD: return a_i_SAD; + case a_DAD: return a_i_DAD; + case a_TAH: return a_i_TAH; + case a_ZAH: return a_i_ZAH; + case a_AIN: return a_i_AIN; + case a_GHAIN: return a_i_GHAIN; + case a_FEH: return a_i_FEH; + case a_QAF: return a_i_QAF; + case a_KAF: return a_i_KAF; + case a_LAM: return a_i_LAM; + case a_MEEM: return a_i_MEEM; + case a_NOON: return a_i_NOON; + case a_HEH: return a_i_HEH; + case a_YEH: return a_i_YEH; } - return tempc; + return 0; } // Change shape - from ISO-8859-6/Isolated to Medial diff --git a/src/nvim/testdir/test_arabic.vim b/src/nvim/testdir/test_arabic.vim index 9e648a9617..9a16833a4c 100644 --- a/src/nvim/testdir/test_arabic.vim +++ b/src/nvim/testdir/test_arabic.vim @@ -97,32 +97,265 @@ func Test_delcombine() bwipe! endfunc +" Values from src/arabic.h (not all used yet) +let s:a_COMMA = "\u060C" +let s:a_SEMICOLON = "\u061B" +let s:a_QUESTION = "\u061F" +let s:a_HAMZA = "\u0621" +let s:a_ALEF_MADDA = "\u0622" +let s:a_ALEF_HAMZA_ABOVE = "\u0623" +let s:a_WAW_HAMZA = "\u0624" +let s:a_ALEF_HAMZA_BELOW = "\u0625" let s:a_YEH_HAMZA = "\u0626" -let s:a_i_YEH_HAMZA = "\ufe8b" +let s:a_ALEF = "\u0627" +let s:a_BEH = "\u0628" +let s:a_TEH_MARBUTA = "\u0629" +let s:a_TEH = "\u062a" +let s:a_THEH = "\u062b" +let s:a_JEEM = "\u062c" +let s:a_HAH = "\u062d" +let s:a_KHAH = "\u062e" +let s:a_DAL = "\u062f" +let s:a_THAL = "\u0630" +let s:a_REH = "\u0631" +let s:a_ZAIN = "\u0632" +let s:a_SEEN = "\u0633" +let s:a_SHEEN = "\u0634" +let s:a_SAD = "\u0635" +let s:a_DAD = "\u0636" +let s:a_TAH = "\u0637" +let s:a_ZAH = "\u0638" +let s:a_AIN = "\u0639" +let s:a_GHAIN = "\u063a" +let s:a_TATWEEL = "\u0640" +let s:a_FEH = "\u0641" +let s:a_QAF = "\u0642" +let s:a_KAF = "\u0643" +let s:a_LAM = "\u0644" +let s:a_MEEM = "\u0645" +let s:a_NOON = "\u0646" +let s:a_HEH = "\u0647" +let s:a_WAW = "\u0648" +let s:a_ALEF_MAKSURA = "\u0649" +let s:a_YEH = "\u064a" -let s:a_HAMZA = "\u0621" -let s:a_s_HAMZA = "\ufe80" +let s:a_FATHATAN = "\u064b" +let s:a_DAMMATAN = "\u064c" +let s:a_KASRATAN = "\u064d" +let s:a_FATHA = "\u064e" +let s:a_DAMMA = "\u064f" +let s:a_KASRA = "\u0650" +let s:a_SHADDA = "\u0651" +let s:a_SUKUN = "\u0652" -let s:a_ALEF_MADDA = "\u0622" -let s:a_s_ALEF_MADDA = "\ufe81" +let s:a_MADDA_ABOVE = "\u0653" +let s:a_HAMZA_ABOVE = "\u0654" +let s:a_HAMZA_BELOW = "\u0655" -let s:a_ALEF_HAMZA_ABOVE = "\u0623" -let s:a_s_ALEF_HAMZA_ABOVE = "\ufe83" +let s:a_ZERO = "\u0660" +let s:a_ONE = "\u0661" +let s:a_TWO = "\u0662" +let s:a_THREE = "\u0663" +let s:a_FOUR = "\u0664" +let s:a_FIVE = "\u0665" +let s:a_SIX = "\u0666" +let s:a_SEVEN = "\u0667" +let s:a_EIGHT = "\u0668" +let s:a_NINE = "\u0669" +let s:a_PERCENT = "\u066a" +let s:a_DECIMAL = "\u066b" +let s:a_THOUSANDS = "\u066c" +let s:a_STAR = "\u066d" +let s:a_MINI_ALEF = "\u0670" -let s:a_GHAIN = "\u063a" -let s:a_f_GHAIN = "\ufece" +let s:a_s_FATHATAN = "\ufe70" +let s:a_m_TATWEEL_FATHATAN = "\ufe71" +let s:a_s_DAMMATAN = "\ufe72" + +let s:a_s_KASRATAN = "\ufe74" + +let s:a_s_FATHA = "\ufe76" +let s:a_m_FATHA = "\ufe77" +let s:a_s_DAMMA = "\ufe78" +let s:a_m_DAMMA = "\ufe79" +let s:a_s_KASRA = "\ufe7a" +let s:a_m_KASRA = "\ufe7b" +let s:a_s_SHADDA = "\ufe7c" +let s:a_m_SHADDA = "\ufe7d" +let s:a_s_SUKUN = "\ufe7e" +let s:a_m_SUKUN = "\ufe7f" + +let s:a_s_HAMZA = "\ufe80" +let s:a_s_ALEF_MADDA = "\ufe81" +let s:a_f_ALEF_MADDA = "\ufe82" +let s:a_s_ALEF_HAMZA_ABOVE = "\ufe83" +let s:a_f_ALEF_HAMZA_ABOVE = "\ufe84" +let s:a_s_WAW_HAMZA = "\ufe85" +let s:a_f_WAW_HAMZA = "\ufe86" +let s:a_s_ALEF_HAMZA_BELOW = "\ufe87" +let s:a_f_ALEF_HAMZA_BELOW = "\ufe88" +let s:a_s_YEH_HAMZA = "\ufe89" +let s:a_f_YEH_HAMZA = "\ufe8a" +let s:a_i_YEH_HAMZA = "\ufe8b" +let s:a_m_YEH_HAMZA = "\ufe8c" +let s:a_s_ALEF = "\ufe8d" +let s:a_f_ALEF = "\ufe8e" +let s:a_s_BEH = "\ufe8f" +let s:a_f_BEH = "\ufe90" +let s:a_i_BEH = "\ufe91" +let s:a_m_BEH = "\ufe92" +let s:a_s_TEH_MARBUTA = "\ufe93" +let s:a_f_TEH_MARBUTA = "\ufe94" +let s:a_s_TEH = "\ufe95" +let s:a_f_TEH = "\ufe96" +let s:a_i_TEH = "\ufe97" +let s:a_m_TEH = "\ufe98" +let s:a_s_THEH = "\ufe99" +let s:a_f_THEH = "\ufe9a" +let s:a_i_THEH = "\ufe9b" +let s:a_m_THEH = "\ufe9c" +let s:a_s_JEEM = "\ufe9d" +let s:a_f_JEEM = "\ufe9e" +let s:a_i_JEEM = "\ufe9f" +let s:a_m_JEEM = "\ufea0" +let s:a_s_HAH = "\ufea1" +let s:a_f_HAH = "\ufea2" +let s:a_i_HAH = "\ufea3" +let s:a_m_HAH = "\ufea4" +let s:a_s_KHAH = "\ufea5" +let s:a_f_KHAH = "\ufea6" +let s:a_i_KHAH = "\ufea7" +let s:a_m_KHAH = "\ufea8" +let s:a_s_DAL = "\ufea9" +let s:a_f_DAL = "\ufeaa" +let s:a_s_THAL = "\ufeab" +let s:a_f_THAL = "\ufeac" +let s:a_s_REH = "\ufead" +let s:a_f_REH = "\ufeae" +let s:a_s_ZAIN = "\ufeaf" +let s:a_f_ZAIN = "\ufeb0" +let s:a_s_SEEN = "\ufeb1" +let s:a_f_SEEN = "\ufeb2" +let s:a_i_SEEN = "\ufeb3" +let s:a_m_SEEN = "\ufeb4" +let s:a_s_SHEEN = "\ufeb5" +let s:a_f_SHEEN = "\ufeb6" +let s:a_i_SHEEN = "\ufeb7" +let s:a_m_SHEEN = "\ufeb8" +let s:a_s_SAD = "\ufeb9" +let s:a_f_SAD = "\ufeba" +let s:a_i_SAD = "\ufebb" +let s:a_m_SAD = "\ufebc" +let s:a_s_DAD = "\ufebd" +let s:a_f_DAD = "\ufebe" +let s:a_i_DAD = "\ufebf" +let s:a_m_DAD = "\ufec0" +let s:a_s_TAH = "\ufec1" +let s:a_f_TAH = "\ufec2" +let s:a_i_TAH = "\ufec3" +let s:a_m_TAH = "\ufec4" +let s:a_s_ZAH = "\ufec5" +let s:a_f_ZAH = "\ufec6" +let s:a_i_ZAH = "\ufec7" +let s:a_m_ZAH = "\ufec8" +let s:a_s_AIN = "\ufec9" +let s:a_f_AIN = "\ufeca" +let s:a_i_AIN = "\ufecb" +let s:a_m_AIN = "\ufecc" let s:a_s_GHAIN = "\ufecd" +let s:a_f_GHAIN = "\ufece" +let s:a_i_GHAIN = "\ufecf" +let s:a_m_GHAIN = "\ufed0" +let s:a_s_FEH = "\ufed1" +let s:a_f_FEH = "\ufed2" +let s:a_i_FEH = "\ufed3" +let s:a_m_FEH = "\ufed4" +let s:a_s_QAF = "\ufed5" +let s:a_f_QAF = "\ufed6" +let s:a_i_QAF = "\ufed7" +let s:a_m_QAF = "\ufed8" +let s:a_s_KAF = "\ufed9" +let s:a_f_KAF = "\ufeda" +let s:a_i_KAF = "\ufedb" +let s:a_m_KAF = "\ufedc" +let s:a_s_LAM = "\ufedd" +let s:a_f_LAM = "\ufede" +let s:a_i_LAM = "\ufedf" +let s:a_m_LAM = "\ufee0" +let s:a_s_MEEM = "\ufee1" +let s:a_f_MEEM = "\ufee2" +let s:a_i_MEEM = "\ufee3" +let s:a_m_MEEM = "\ufee4" +let s:a_s_NOON = "\ufee5" +let s:a_f_NOON = "\ufee6" +let s:a_i_NOON = "\ufee7" +let s:a_m_NOON = "\ufee8" +let s:a_s_HEH = "\ufee9" +let s:a_f_HEH = "\ufeea" +let s:a_i_HEH = "\ufeeb" +let s:a_m_HEH = "\ufeec" +let s:a_s_WAW = "\ufeed" +let s:a_f_WAW = "\ufeee" +let s:a_s_ALEF_MAKSURA = "\ufeef" +let s:a_f_ALEF_MAKSURA = "\ufef0" +let s:a_s_YEH = "\ufef1" +let s:a_f_YEH = "\ufef2" +let s:a_i_YEH = "\ufef3" +let s:a_m_YEH = "\ufef4" +let s:a_s_LAM_ALEF_MADDA_ABOVE = "\ufef5" +let s:a_f_LAM_ALEF_MADDA_ABOVE = "\ufef6" +let s:a_s_LAM_ALEF_HAMZA_ABOVE = "\ufef7" +let s:a_f_LAM_ALEF_HAMZA_ABOVE = "\ufef8" +let s:a_s_LAM_ALEF_HAMZA_BELOW = "\ufef9" +let s:a_f_LAM_ALEF_HAMZA_BELOW = "\ufefa" +let s:a_s_LAM_ALEF = "\ufefb" +let s:a_f_LAM_ALEF = "\ufefc" + +let s:a_BYTE_ORDER_MARK = "\ufeff" func Test_shape_initial() new set arabicshape - " Shaping arabic {testchar} non-arabic Uses chg_c_a2i(). + " Shaping arabic {testchar} non-arabic Tests chg_c_a2i(). " pair[0] = testchar, pair[1] = next-result, pair[2] = current-result for pair in [[s:a_YEH_HAMZA, s:a_f_GHAIN, s:a_i_YEH_HAMZA], \ [s:a_HAMZA, s:a_s_GHAIN, s:a_s_HAMZA], \ [s:a_ALEF_MADDA, s:a_s_GHAIN, s:a_s_ALEF_MADDA], \ [s:a_ALEF_HAMZA_ABOVE, s:a_s_GHAIN, s:a_s_ALEF_HAMZA_ABOVE], + \ [s:a_WAW_HAMZA, s:a_s_GHAIN, s:a_s_WAW_HAMZA], + \ [s:a_ALEF_HAMZA_BELOW, s:a_s_GHAIN, s:a_s_ALEF_HAMZA_BELOW], + \ [s:a_ALEF, s:a_s_GHAIN, s:a_s_ALEF], + \ [s:a_TEH_MARBUTA, s:a_s_GHAIN, s:a_s_TEH_MARBUTA], + \ [s:a_DAL, s:a_s_GHAIN, s:a_s_DAL], + \ [s:a_THAL, s:a_s_GHAIN, s:a_s_THAL], + \ [s:a_REH, s:a_s_GHAIN, s:a_s_REH], + \ [s:a_ZAIN, s:a_s_GHAIN, s:a_s_ZAIN], + \ [s:a_TATWEEL, s:a_f_GHAIN, s:a_TATWEEL], + \ [s:a_WAW, s:a_s_GHAIN, s:a_s_WAW], + \ [s:a_ALEF_MAKSURA, s:a_s_GHAIN, s:a_s_ALEF_MAKSURA], + \ [s:a_BEH, s:a_f_GHAIN, s:a_i_BEH], + \ [s:a_TEH, s:a_f_GHAIN, s:a_i_TEH], + \ [s:a_THEH, s:a_f_GHAIN, s:a_i_THEH], + \ [s:a_JEEM, s:a_f_GHAIN, s:a_i_JEEM], + \ [s:a_HAH, s:a_f_GHAIN, s:a_i_HAH], + \ [s:a_KHAH, s:a_f_GHAIN, s:a_i_KHAH], + \ [s:a_SEEN, s:a_f_GHAIN, s:a_i_SEEN], + \ [s:a_SHEEN, s:a_f_GHAIN, s:a_i_SHEEN], + \ [s:a_SAD, s:a_f_GHAIN, s:a_i_SAD], + \ [s:a_DAD, s:a_f_GHAIN, s:a_i_DAD], + \ [s:a_TAH, s:a_f_GHAIN, s:a_i_TAH], + \ [s:a_ZAH, s:a_f_GHAIN, s:a_i_ZAH], + \ [s:a_AIN, s:a_f_GHAIN, s:a_i_AIN], + \ [s:a_GHAIN, s:a_f_GHAIN, s:a_i_GHAIN], + \ [s:a_FEH, s:a_f_GHAIN, s:a_i_FEH], + \ [s:a_QAF, s:a_f_GHAIN, s:a_i_QAF], + \ [s:a_KAF, s:a_f_GHAIN, s:a_i_KAF], + \ [s:a_LAM, s:a_f_GHAIN, s:a_i_LAM], + \ [s:a_MEEM, s:a_f_GHAIN, s:a_i_MEEM], + \ [s:a_NOON, s:a_f_GHAIN, s:a_i_NOON], + \ [s:a_HEH, s:a_f_GHAIN, s:a_i_HEH], + \ [s:a_YEH, s:a_f_GHAIN, s:a_i_YEH], \ ] call setline(1, s:a_GHAIN . pair[0] . ' ') call assert_equal([pair[1] . pair[2] . ' '], ScreenLines(1, 3)) @@ -131,3 +364,109 @@ func Test_shape_initial() set arabicshape& bwipe! endfunc + +func Test_shape_isolated() + new + set arabicshape + + " Shaping non-arabic {testchar} non-arabic Tests chg_c_a2s(). + " pair[0] = testchar, pair[1] = current-result + for pair in [[s:a_HAMZA, s:a_s_HAMZA], + \ [s:a_ALEF_MADDA, s:a_s_ALEF_MADDA], + \ [s:a_ALEF_HAMZA_ABOVE, s:a_s_ALEF_HAMZA_ABOVE], + \ [s:a_WAW_HAMZA, s:a_s_WAW_HAMZA], + \ [s:a_ALEF_HAMZA_BELOW, s:a_s_ALEF_HAMZA_BELOW], + \ [s:a_YEH_HAMZA, s:a_s_YEH_HAMZA], + \ [s:a_ALEF, s:a_s_ALEF], + \ [s:a_TEH_MARBUTA, s:a_s_TEH_MARBUTA], + \ [s:a_DAL, s:a_s_DAL], + \ [s:a_THAL, s:a_s_THAL], + \ [s:a_REH, s:a_s_REH], + \ [s:a_ZAIN, s:a_s_ZAIN], + \ [s:a_TATWEEL, s:a_TATWEEL], + \ [s:a_WAW, s:a_s_WAW], + \ [s:a_ALEF_MAKSURA, s:a_s_ALEF_MAKSURA], + \ [s:a_BEH, s:a_s_BEH], + \ [s:a_TEH, s:a_s_TEH], + \ [s:a_THEH, s:a_s_THEH], + \ [s:a_JEEM, s:a_s_JEEM], + \ [s:a_HAH, s:a_s_HAH], + \ [s:a_KHAH, s:a_s_KHAH], + \ [s:a_SEEN, s:a_s_SEEN], + \ [s:a_SHEEN, s:a_s_SHEEN], + \ [s:a_SAD, s:a_s_SAD], + \ [s:a_DAD, s:a_s_DAD], + \ [s:a_TAH, s:a_s_TAH], + \ [s:a_ZAH, s:a_s_ZAH], + \ [s:a_AIN, s:a_s_AIN], + \ [s:a_GHAIN, s:a_s_GHAIN], + \ [s:a_FEH, s:a_s_FEH], + \ [s:a_QAF, s:a_s_QAF], + \ [s:a_KAF, s:a_s_KAF], + \ [s:a_LAM, s:a_s_LAM], + \ [s:a_MEEM, s:a_s_MEEM], + \ [s:a_NOON, s:a_s_NOON], + \ [s:a_HEH, s:a_s_HEH], + \ [s:a_YEH, s:a_s_YEH], + \ ] + call setline(1, ' ' . pair[0] . ' ') + call assert_equal([' ' . pair[1] . ' '], ScreenLines(1, 3)) + endfor + + set arabicshape& + bwipe! +endfunc + +func Test_shape_medial() + new + set arabicshape + + " Shaping arabic {testchar} arabic Tests chg_c_a2m(). + " pair[0] = testchar, pair[1] = next-result, pair[2] = current-result, + " pair[3] = previous-result + for pair in [[s:a_HAMZA, s:a_s_GHAIN, s:a_s_HAMZA, s:a_s_BEH], + \[s:a_ALEF_MADDA, s:a_s_GHAIN, s:a_f_ALEF_MADDA, s:a_i_BEH], + \[s:a_ALEF_HAMZA_ABOVE, s:a_s_GHAIN, s:a_f_ALEF_HAMZA_ABOVE, s:a_i_BEH], + \[s:a_WAW_HAMZA, s:a_s_GHAIN, s:a_f_WAW_HAMZA, s:a_i_BEH], + \[s:a_ALEF_HAMZA_BELOW, s:a_s_GHAIN, s:a_f_ALEF_HAMZA_BELOW, s:a_i_BEH], + \[s:a_YEH_HAMZA, s:a_f_GHAIN, s:a_m_YEH_HAMZA, s:a_i_BEH], + \[s:a_ALEF, s:a_s_GHAIN, s:a_f_ALEF, s:a_i_BEH], + \[s:a_BEH, s:a_f_GHAIN, s:a_m_BEH, s:a_i_BEH], + \[s:a_TEH_MARBUTA, s:a_s_GHAIN, s:a_f_TEH_MARBUTA, s:a_i_BEH], + \[s:a_TEH, s:a_f_GHAIN, s:a_m_TEH, s:a_i_BEH], + \[s:a_THEH, s:a_f_GHAIN, s:a_m_THEH, s:a_i_BEH], + \[s:a_JEEM, s:a_f_GHAIN, s:a_m_JEEM, s:a_i_BEH], + \[s:a_HAH, s:a_f_GHAIN, s:a_m_HAH, s:a_i_BEH], + \[s:a_KHAH, s:a_f_GHAIN, s:a_m_KHAH, s:a_i_BEH], + \[s:a_DAL, s:a_s_GHAIN, s:a_f_DAL, s:a_i_BEH], + \[s:a_THAL, s:a_s_GHAIN, s:a_f_THAL, s:a_i_BEH], + \[s:a_REH, s:a_s_GHAIN, s:a_f_REH, s:a_i_BEH], + \[s:a_ZAIN, s:a_s_GHAIN, s:a_f_ZAIN, s:a_i_BEH], + \[s:a_SEEN, s:a_f_GHAIN, s:a_m_SEEN, s:a_i_BEH], + \[s:a_SHEEN, s:a_f_GHAIN, s:a_m_SHEEN, s:a_i_BEH], + \[s:a_SAD, s:a_f_GHAIN, s:a_m_SAD, s:a_i_BEH], + \[s:a_DAD, s:a_f_GHAIN, s:a_m_DAD, s:a_i_BEH], + \[s:a_TAH, s:a_f_GHAIN, s:a_m_TAH, s:a_i_BEH], + \[s:a_ZAH, s:a_f_GHAIN, s:a_m_ZAH, s:a_i_BEH], + \[s:a_AIN, s:a_f_GHAIN, s:a_m_AIN, s:a_i_BEH], + \[s:a_GHAIN, s:a_f_GHAIN, s:a_m_GHAIN, s:a_i_BEH], + \[s:a_TATWEEL, s:a_f_GHAIN, s:a_TATWEEL, s:a_i_BEH], + \[s:a_FEH, s:a_f_GHAIN, s:a_m_FEH, s:a_i_BEH], + \[s:a_QAF, s:a_f_GHAIN, s:a_m_QAF, s:a_i_BEH], + \[s:a_KAF, s:a_f_GHAIN, s:a_m_KAF, s:a_i_BEH], + \[s:a_LAM, s:a_f_GHAIN, s:a_m_LAM, s:a_i_BEH], + \[s:a_MEEM, s:a_f_GHAIN, s:a_m_MEEM, s:a_i_BEH], + \[s:a_NOON, s:a_f_GHAIN, s:a_m_NOON, s:a_i_BEH], + \[s:a_HEH, s:a_f_GHAIN, s:a_m_HEH, s:a_i_BEH], + \[s:a_WAW, s:a_s_GHAIN, s:a_f_WAW, s:a_i_BEH], + \[s:a_ALEF_MAKSURA, s:a_s_GHAIN, s:a_f_ALEF_MAKSURA, s:a_i_BEH], + \[s:a_YEH, s:a_f_GHAIN, s:a_m_YEH, s:a_i_BEH], + \ ] + call setline(1, s:a_GHAIN . pair[0] . s:a_BEH) + call assert_equal([pair[1] . pair[2] . pair[3]], ScreenLines(1, 3)) + endfor + + set arabicshape& + bwipe! +endfunc + -- cgit From b9f3805447f9e0ff277aa655dfb9513f41db5ce6 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Mon, 15 Jan 2018 18:19:38 +0800 Subject: vim-patch:8.0.0406: arabic shaping code is verbose Problem: The arabic shaping code is verbose. Solution: Shorten the code without changing the functionality. https://github.com/vim/vim/commit/7f73b54631af3f0e6f0acd1a1b4c9e8436784705 --- src/nvim/arabic.c | 688 +++++++++++------------------------------------------- 1 file changed, 135 insertions(+), 553 deletions(-) (limited to 'src') diff --git a/src/nvim/arabic.c b/src/nvim/arabic.c index f0370af704..e120e6d492 100644 --- a/src/nvim/arabic.c +++ b/src/nvim/arabic.c @@ -432,7 +432,6 @@ static int chg_c_a2s(int cur_c) case a_HEH: return a_s_HEH; case a_YEH: return a_s_YEH; } - return 0; } @@ -478,176 +477,57 @@ static int chg_c_a2i(int cur_c) case a_HEH: return a_i_HEH; case a_YEH: return a_i_YEH; } - return 0; } // Change shape - from ISO-8859-6/Isolated to Medial static int chg_c_a2m(int cur_c) { - int tempc; - switch (cur_c) { - case a_HAMZA: // exception - tempc = a_s_HAMZA; - break; - - case a_ALEF_MADDA: // exception - tempc = a_f_ALEF_MADDA; - break; - - case a_ALEF_HAMZA_ABOVE: // exception - tempc = a_f_ALEF_HAMZA_ABOVE; - break; - - case a_WAW_HAMZA: // exception - tempc = a_f_WAW_HAMZA; - break; - - case a_ALEF_HAMZA_BELOW: // exception - tempc = a_f_ALEF_HAMZA_BELOW; - break; - - case a_YEH_HAMZA: - tempc = a_m_YEH_HAMZA; - break; - - case a_ALEF: // exception - tempc = a_f_ALEF; - break; - - case a_BEH: - tempc = a_m_BEH; - break; - - case a_TEH_MARBUTA: // exception - tempc = a_f_TEH_MARBUTA; - break; - - case a_TEH: - tempc = a_m_TEH; - break; - - case a_THEH: - tempc = a_m_THEH; - break; - - case a_JEEM: - tempc = a_m_JEEM; - break; - - case a_HAH: - tempc = a_m_HAH; - break; - - case a_KHAH: - tempc = a_m_KHAH; - break; - - case a_DAL: // exception - tempc = a_f_DAL; - break; - - case a_THAL: // exception - tempc = a_f_THAL; - break; - - case a_REH: // exception - tempc = a_f_REH; - break; - - case a_ZAIN: // exception - tempc = a_f_ZAIN; - break; - - case a_SEEN: - tempc = a_m_SEEN; - break; - - case a_SHEEN: - tempc = a_m_SHEEN; - break; - - case a_SAD: - tempc = a_m_SAD; - break; - - case a_DAD: - tempc = a_m_DAD; - break; - - case a_TAH: - tempc = a_m_TAH; - break; - - case a_ZAH: - tempc = a_m_ZAH; - break; - - case a_AIN: - tempc = a_m_AIN; - break; - - case a_GHAIN: - tempc = a_m_GHAIN; - break; - - case a_TATWEEL: // exception - tempc = cur_c; - break; - - case a_FEH: - tempc = a_m_FEH; - break; - - case a_QAF: - tempc = a_m_QAF; - break; - - case a_KAF: - tempc = a_m_KAF; - break; - - case a_LAM: - tempc = a_m_LAM; - break; - - case a_MEEM: - tempc = a_m_MEEM; - break; - - case a_NOON: - tempc = a_m_NOON; - break; - - case a_HEH: - tempc = a_m_HEH; - break; - - case a_WAW: // exception - tempc = a_f_WAW; - break; - - case a_ALEF_MAKSURA: // exception - tempc = a_f_ALEF_MAKSURA; - break; - - case a_YEH: - tempc = a_m_YEH; - break; - - default: - tempc = 0; + case a_HAMZA: return a_s_HAMZA; // exception + case a_ALEF_MADDA: return a_f_ALEF_MADDA; // exception + case a_ALEF_HAMZA_ABOVE: return a_f_ALEF_HAMZA_ABOVE; // exception + case a_WAW_HAMZA: return a_f_WAW_HAMZA; // exception + case a_ALEF_HAMZA_BELOW: return a_f_ALEF_HAMZA_BELOW; // exception + case a_YEH_HAMZA: return a_m_YEH_HAMZA; + case a_ALEF: return a_f_ALEF; // exception + case a_BEH: return a_m_BEH; + case a_TEH_MARBUTA: return a_f_TEH_MARBUTA; // exception + case a_TEH: return a_m_TEH; + case a_THEH: return a_m_THEH; + case a_JEEM: return a_m_JEEM; + case a_HAH: return a_m_HAH; + case a_KHAH: return a_m_KHAH; + case a_DAL: return a_f_DAL; // exception + case a_THAL: return a_f_THAL; // exception + case a_REH: return a_f_REH; // exception + case a_ZAIN: return a_f_ZAIN; // exception + case a_SEEN: return a_m_SEEN; + case a_SHEEN: return a_m_SHEEN; + case a_SAD: return a_m_SAD; + case a_DAD: return a_m_DAD; + case a_TAH: return a_m_TAH; + case a_ZAH: return a_m_ZAH; + case a_AIN: return a_m_AIN; + case a_GHAIN: return a_m_GHAIN; + case a_TATWEEL: return cur_c; // exception + case a_FEH: return a_m_FEH; + case a_QAF: return a_m_QAF; + case a_KAF: return a_m_KAF; + case a_LAM: return a_m_LAM; + case a_MEEM: return a_m_MEEM; + case a_NOON: return a_m_NOON; + case a_HEH: return a_m_HEH; + case a_WAW: return a_f_WAW; // exception + case a_ALEF_MAKSURA: return a_f_ALEF_MAKSURA; // exception + case a_YEH: return a_m_YEH; } - - return tempc; + return 0; } // Change shape - from ISO-8859-6/Isolated to final static int chg_c_a2f(int cur_c) { - int tempc; - // NOTE: these encodings need to be accounted for // // a_f_ALEF_MADDA; @@ -658,280 +538,87 @@ static int chg_c_a2f(int cur_c) // a_f_LAM_ALEF_HAMZA_BELOW; switch (cur_c) { - case a_HAMZA: // exception - tempc = a_s_HAMZA; - break; - - case a_ALEF_MADDA: - tempc = a_f_ALEF_MADDA; - break; - - case a_ALEF_HAMZA_ABOVE: - tempc = a_f_ALEF_HAMZA_ABOVE; - break; - - case a_WAW_HAMZA: - tempc = a_f_WAW_HAMZA; - break; - - case a_ALEF_HAMZA_BELOW: - tempc = a_f_ALEF_HAMZA_BELOW; - break; - - case a_YEH_HAMZA: - tempc = a_f_YEH_HAMZA; - break; - - case a_ALEF: - tempc = a_f_ALEF; - break; - - case a_BEH: - tempc = a_f_BEH; - break; - - case a_TEH_MARBUTA: - tempc = a_f_TEH_MARBUTA; - break; - - case a_TEH: - tempc = a_f_TEH; - break; - - case a_THEH: - tempc = a_f_THEH; - break; - - case a_JEEM: - tempc = a_f_JEEM; - break; - - case a_HAH: - tempc = a_f_HAH; - break; - - case a_KHAH: - tempc = a_f_KHAH; - break; - - case a_DAL: - tempc = a_f_DAL; - break; - - case a_THAL: - tempc = a_f_THAL; - break; - - case a_REH: - tempc = a_f_REH; - break; - - case a_ZAIN: - tempc = a_f_ZAIN; - break; - - case a_SEEN: - tempc = a_f_SEEN; - break; - - case a_SHEEN: - tempc = a_f_SHEEN; - break; - - case a_SAD: - tempc = a_f_SAD; - break; - - case a_DAD: - tempc = a_f_DAD; - break; - - case a_TAH: - tempc = a_f_TAH; - break; - - case a_ZAH: - tempc = a_f_ZAH; - break; - - case a_AIN: - tempc = a_f_AIN; - break; - - case a_GHAIN: - tempc = a_f_GHAIN; - break; - - case a_TATWEEL: // exception - tempc = cur_c; - break; - - case a_FEH: - tempc = a_f_FEH; - break; - - case a_QAF: - tempc = a_f_QAF; - break; - - case a_KAF: - tempc = a_f_KAF; - break; - - case a_LAM: - tempc = a_f_LAM; - break; - - case a_MEEM: - tempc = a_f_MEEM; - break; - - case a_NOON: - tempc = a_f_NOON; - break; - - case a_HEH: - tempc = a_f_HEH; - break; - - case a_WAW: - tempc = a_f_WAW; - break; - - case a_ALEF_MAKSURA: - tempc = a_f_ALEF_MAKSURA; - break; - - case a_YEH: - tempc = a_f_YEH; - break; - - default: - tempc = 0; + case a_HAMZA: return a_s_HAMZA; // exception + case a_ALEF_MADDA: return a_f_ALEF_MADDA; + case a_ALEF_HAMZA_ABOVE: return a_f_ALEF_HAMZA_ABOVE; + case a_WAW_HAMZA: return a_f_WAW_HAMZA; + case a_ALEF_HAMZA_BELOW: return a_f_ALEF_HAMZA_BELOW; + case a_YEH_HAMZA: return a_f_YEH_HAMZA; + case a_ALEF: return a_f_ALEF; + case a_BEH: return a_f_BEH; + case a_TEH_MARBUTA: return a_f_TEH_MARBUTA; + case a_TEH: return a_f_TEH; + case a_THEH: return a_f_THEH; + case a_JEEM: return a_f_JEEM; + case a_HAH: return a_f_HAH; + case a_KHAH: return a_f_KHAH; + case a_DAL: return a_f_DAL; + case a_THAL: return a_f_THAL; + case a_REH: return a_f_REH; + case a_ZAIN: return a_f_ZAIN; + case a_SEEN: return a_f_SEEN; + case a_SHEEN: return a_f_SHEEN; + case a_SAD: return a_f_SAD; + case a_DAD: return a_f_DAD; + case a_TAH: return a_f_TAH; + case a_ZAH: return a_f_ZAH; + case a_AIN: return a_f_AIN; + case a_GHAIN: return a_f_GHAIN; + case a_TATWEEL: return cur_c; // exception + case a_FEH: return a_f_FEH; + case a_QAF: return a_f_QAF; + case a_KAF: return a_f_KAF; + case a_LAM: return a_f_LAM; + case a_MEEM: return a_f_MEEM; + case a_NOON: return a_f_NOON; + case a_HEH: return a_f_HEH; + case a_WAW: return a_f_WAW; + case a_ALEF_MAKSURA: return a_f_ALEF_MAKSURA; + case a_YEH: return a_f_YEH; } - - return tempc; + return 0; } // Change shape - from Initial to Medial static int chg_c_i2m(int cur_c) { - int tempc; - switch (cur_c) { - case a_i_YEH_HAMZA: - tempc = a_m_YEH_HAMZA; - break; - - case a_i_BEH: - tempc = a_m_BEH; - break; - - case a_i_TEH: - tempc = a_m_TEH; - break; - - case a_i_THEH: - tempc = a_m_THEH; - break; - - case a_i_JEEM: - tempc = a_m_JEEM; - break; - - case a_i_HAH: - tempc = a_m_HAH; - break; - - case a_i_KHAH: - tempc = a_m_KHAH; - break; - - case a_i_SEEN: - tempc = a_m_SEEN; - break; - - case a_i_SHEEN: - tempc = a_m_SHEEN; - break; - - case a_i_SAD: - tempc = a_m_SAD; - break; - - case a_i_DAD: - tempc = a_m_DAD; - break; - - case a_i_TAH: - tempc = a_m_TAH; - break; - - case a_i_ZAH: - tempc = a_m_ZAH; - break; - - case a_i_AIN: - tempc = a_m_AIN; - break; - - case a_i_GHAIN: - tempc = a_m_GHAIN; - break; - - case a_i_FEH: - tempc = a_m_FEH; - break; - - case a_i_QAF: - tempc = a_m_QAF; - break; - - case a_i_KAF: - tempc = a_m_KAF; - break; - - case a_i_LAM: - tempc = a_m_LAM; - break; - - case a_i_MEEM: - tempc = a_m_MEEM; - break; - - case a_i_NOON: - tempc = a_m_NOON; - break; - - case a_i_HEH: - tempc = a_m_HEH; - break; - - case a_i_YEH: - tempc = a_m_YEH; - break; - - default: - tempc = 0; + case a_i_YEH_HAMZA: return a_m_YEH_HAMZA; + case a_i_BEH: return a_m_BEH; + case a_i_TEH: return a_m_TEH; + case a_i_THEH: return a_m_THEH; + case a_i_JEEM: return a_m_JEEM; + case a_i_HAH: return a_m_HAH; + case a_i_KHAH: return a_m_KHAH; + case a_i_SEEN: return a_m_SEEN; + case a_i_SHEEN: return a_m_SHEEN; + case a_i_SAD: return a_m_SAD; + case a_i_DAD: return a_m_DAD; + case a_i_TAH: return a_m_TAH; + case a_i_ZAH: return a_m_ZAH; + case a_i_AIN: return a_m_AIN; + case a_i_GHAIN: return a_m_GHAIN; + case a_i_FEH: return a_m_FEH; + case a_i_QAF: return a_m_QAF; + case a_i_KAF: return a_m_KAF; + case a_i_LAM: return a_m_LAM; + case a_i_MEEM: return a_m_MEEM; + case a_i_NOON: return a_m_NOON; + case a_i_HEH: return a_m_HEH; + case a_i_YEH: return a_m_YEH; } - - return tempc; + return 0; } // Change shape - from Final to Medial static int chg_c_f2m(int cur_c) { - int tempc; - switch (cur_c) { // NOTE: these encodings are multi-positional, no ? // case a_f_ALEF_MADDA: // case a_f_ALEF_HAMZA_ABOVE: // case a_f_ALEF_HAMZA_BELOW: - case a_f_YEH_HAMZA: - tempc = a_m_YEH_HAMZA; - break; - + case a_f_YEH_HAMZA: return a_m_YEH_HAMZA; case a_f_WAW_HAMZA: // exceptions case a_f_ALEF: case a_f_TEH_MARBUTA: @@ -941,165 +628,60 @@ static int chg_c_f2m(int cur_c) case a_f_ZAIN: case a_f_WAW: case a_f_ALEF_MAKSURA: - tempc = cur_c; - break; - - case a_f_BEH: - tempc = a_m_BEH; - break; - - case a_f_TEH: - tempc = a_m_TEH; - break; - - case a_f_THEH: - tempc = a_m_THEH; - break; - - case a_f_JEEM: - tempc = a_m_JEEM; - break; - - case a_f_HAH: - tempc = a_m_HAH; - break; - - case a_f_KHAH: - tempc = a_m_KHAH; - break; - - case a_f_SEEN: - tempc = a_m_SEEN; - break; - - case a_f_SHEEN: - tempc = a_m_SHEEN; - break; - - case a_f_SAD: - tempc = a_m_SAD; - break; - - case a_f_DAD: - tempc = a_m_DAD; - break; - - case a_f_TAH: - tempc = a_m_TAH; - break; - - case a_f_ZAH: - tempc = a_m_ZAH; - break; - - case a_f_AIN: - tempc = a_m_AIN; - break; - - case a_f_GHAIN: - tempc = a_m_GHAIN; - break; - - case a_f_FEH: - tempc = a_m_FEH; - break; - - case a_f_QAF: - tempc = a_m_QAF; - break; - - case a_f_KAF: - tempc = a_m_KAF; - break; - - case a_f_LAM: - tempc = a_m_LAM; - break; - - case a_f_MEEM: - tempc = a_m_MEEM; - break; - - case a_f_NOON: - tempc = a_m_NOON; - break; - - case a_f_HEH: - tempc = a_m_HEH; - break; - - case a_f_YEH: - tempc = a_m_YEH; - break; - + return cur_c; + case a_f_BEH: return a_m_BEH; + case a_f_TEH: return a_m_TEH; + case a_f_THEH: return a_m_THEH; + case a_f_JEEM: return a_m_JEEM; + case a_f_HAH: return a_m_HAH; + case a_f_KHAH: return a_m_KHAH; + case a_f_SEEN: return a_m_SEEN; + case a_f_SHEEN: return a_m_SHEEN; + case a_f_SAD: return a_m_SAD; + case a_f_DAD: return a_m_DAD; + case a_f_TAH: return a_m_TAH; + case a_f_ZAH: return a_m_ZAH; + case a_f_AIN: return a_m_AIN; + case a_f_GHAIN: return a_m_GHAIN; + case a_f_FEH: return a_m_FEH; + case a_f_QAF: return a_m_QAF; + case a_f_KAF: return a_m_KAF; + case a_f_LAM: return a_m_LAM; + case a_f_MEEM: return a_m_MEEM; + case a_f_NOON: return a_m_NOON; + case a_f_HEH: return a_m_HEH; + case a_f_YEH: return a_m_YEH; // NOTE: these encodings are multi-positional, no ? // case a_f_LAM_ALEF_MADDA_ABOVE: // case a_f_LAM_ALEF_HAMZA_ABOVE: // case a_f_LAM_ALEF_HAMZA_BELOW: // case a_f_LAM_ALEF: - default: - tempc = 0; } - - return tempc; + return 0; } // Change shape - from Combination (2 char) to an Isolated. static int chg_c_laa2i(int hid_c) { - int tempc; - switch (hid_c) { - case a_ALEF_MADDA: - tempc = a_s_LAM_ALEF_MADDA_ABOVE; - break; - - case a_ALEF_HAMZA_ABOVE: - tempc = a_s_LAM_ALEF_HAMZA_ABOVE; - break; - - case a_ALEF_HAMZA_BELOW: - tempc = a_s_LAM_ALEF_HAMZA_BELOW; - break; - - case a_ALEF: - tempc = a_s_LAM_ALEF; - break; - - default: - tempc = 0; + case a_ALEF_MADDA: return a_s_LAM_ALEF_MADDA_ABOVE; + case a_ALEF_HAMZA_ABOVE: return a_s_LAM_ALEF_HAMZA_ABOVE; + case a_ALEF_HAMZA_BELOW: return a_s_LAM_ALEF_HAMZA_BELOW; + case a_ALEF: return a_s_LAM_ALEF; } - - return tempc; + return 0; } // Change shape - from Combination-Isolated to Final. static int chg_c_laa2f(int hid_c) { - int tempc; - switch (hid_c) { - case a_ALEF_MADDA: - tempc = a_f_LAM_ALEF_MADDA_ABOVE; - break; - - case a_ALEF_HAMZA_ABOVE: - tempc = a_f_LAM_ALEF_HAMZA_ABOVE; - break; - - case a_ALEF_HAMZA_BELOW: - tempc = a_f_LAM_ALEF_HAMZA_BELOW; - break; - - case a_ALEF: - tempc = a_f_LAM_ALEF; - break; - - default: - tempc = 0; + case a_ALEF_MADDA: return a_f_LAM_ALEF_MADDA_ABOVE; + case a_ALEF_HAMZA_ABOVE: return a_f_LAM_ALEF_HAMZA_ABOVE; + case a_ALEF_HAMZA_BELOW: return a_f_LAM_ALEF_HAMZA_BELOW; + case a_ALEF: return a_f_LAM_ALEF; } - - return tempc; + return 0; } // Do "half-shaping" on character "c". Return zero if no shaping. -- cgit From 63bb7198dfded8a5c37195ebc8503516a1eda0f3 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Mon, 15 Jan 2018 19:27:10 +0800 Subject: vim-patch:8.0.0398: illegal memory access with "t" Problem: Illegal memory access with "t". Solution: Use strncmp() instead of memcmp(). (Dominique Pelle, closes vim/vim#1528) https://github.com/vim/vim/commit/66727e16079fbac6db3897b5c3736ec9fba995bb --- src/nvim/search.c | 8 ++++---- src/nvim/testdir/test_search.vim | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/search.c b/src/nvim/search.c index 1eb1a25a19..0a266382ec 100644 --- a/src/nvim/search.c +++ b/src/nvim/search.c @@ -1382,13 +1382,13 @@ int searchc(cmdarg_T *cap, int t_cmd) col -= (*mb_head_off)(p, p + col - 1) + 1; } if (lastc_bytelen == 1) { - if (p[col] == c && stop) + if (p[col] == c && stop) { break; - } else { - if (memcmp(p + col, lastc_bytes, lastc_bytelen) == 0 && stop) + } + } else if (STRNCMP(p + col, lastc_bytes, lastc_bytelen) == 0 && stop) { break; } - stop = TRUE; + stop = true; } } else { for (;; ) { diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index a333e7f206..03112df46f 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -298,3 +298,10 @@ func Test_searchpair() q! endfunc +func Test_searchc() + " These commands used to cause memory overflow in searchc(). + new + norm ixx + exe "norm 0t\u93cf" + bw! +endfunc -- cgit From 28998cfd815abd690ffa0b9bab786263af619008 Mon Sep 17 00:00:00 2001 From: ckelsel Date: Mon, 15 Jan 2018 19:41:29 +0800 Subject: vim-patch:8.0.0402: :map completion does not have Problem: :map completion does not have . (Dominique Pelle) Solution: Recognize in completion. Add a test. https://github.com/vim/vim/commit/cf5fdf7d1689ecb145b634dcb9c6e9fc60f63869 --- src/nvim/getchar.c | 23 +++++++++++++++-------- src/nvim/testdir/test_cmdline.vim | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 1b5d3472ab..7df1bf8429 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -3366,6 +3366,10 @@ set_context_in_map_cmd ( arg = skipwhite(arg + 8); continue; } + if (STRNCMP(arg, "", 9) == 0) { + arg = skipwhite(arg + 9); + continue; + } if (STRNCMP(arg, "