diff options
Diffstat (limited to 'src/nvim/digraph.c')
| -rw-r--r-- | src/nvim/digraph.c | 50 | 
1 files changed, 31 insertions, 19 deletions
| diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 560205fe7d..9e475bf66c 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1,3 +1,6 @@ +// 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 +  /// @file digraph.c  ///  /// code for digraphs @@ -790,6 +793,7 @@ static digr_T digraphdefault[] =    { '/', '-', 0x2020 },    { '/', '=', 0x2021 },    { '.', '.', 0x2025 }, +  { ',', '.', 0x2026 },    { '%', '0', 0x2030 },    { '1', '\'', 0x2032 },    { '2', '\'', 0x2033 }, @@ -1569,7 +1573,8 @@ int getdigraph(int char1, int char2, int meta_char)    if (((retval = getexactdigraph(char1, char2, meta_char)) == char2)        && (char1 != char2) -      && ((retval = getexactdigraph(char2, char1, meta_char)) == char1)) { +      && ((retval = getexactdigraph(char2, char1, meta_char))  // -V764 +          == char1)) {      return char2;    }    return retval; @@ -1675,11 +1680,7 @@ static void printdigraph(digr_T *dp)    int list_width; -  if ((dy_flags & DY_UHEX) || has_mbyte) { -    list_width = 13; -  } else { -    list_width = 11; -  } +  list_width = 13;    if (dp->result != 0) {      if (msg_col > Columns - list_width) { @@ -1695,21 +1696,23 @@ static void printdigraph(digr_T *dp)        }      } -    p = buf; +    p = &buf[0];      *p++ = dp->char1;      *p++ = dp->char2;      *p++ = ' '; +    *p = NUL; +    msg_outtrans(buf); +    p = buf; -    if (has_mbyte) { -      // add a space to draw a composing char on -      if (enc_utf8 && utf_iscomposing(dp->result)) { -        *p++ = ' '; -      } -      p += (*mb_char2bytes)(dp->result, p); -    } else { -      *p++ = (char_u)dp->result; +    // add a space to draw a composing char on +    if (utf_iscomposing(dp->result)) { +      *p++ = ' ';      } +    p += (*mb_char2bytes)(dp->result, p); +    *p = NUL; +    msg_outtrans_attr(buf, hl_attr(HLF_8)); +    p = buf;      if (char2cells(dp->result) == 1) {        *p++ = ' ';      } @@ -1844,6 +1847,16 @@ void ex_loadkeymap(exarg_T *eap)    status_redraw_curbuf();  } +/// Frees the buf_T.b_kmap_ga field of a buffer. +void keymap_ga_clear(garray_T *kmap_ga) +{ +  kmap_T *kp = (kmap_T *)kmap_ga->ga_data; +  for (int i = 0; i < kmap_ga->ga_len; i++) { +    xfree(kp[i].from); +    xfree(kp[i].to); +  } +} +  /// Stop using 'keymap'.  static void keymap_unload(void)  { @@ -1861,12 +1874,11 @@ static void keymap_unload(void)    // clear the ":lmap"s    kp = (kmap_T *)curbuf->b_kmap_ga.ga_data; -  for (int i = 0; i < curbuf->b_kmap_ga.ga_len; ++i) { +  for (int i = 0; i < curbuf->b_kmap_ga.ga_len; i++) {      vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s", kp[i].from); -    (void)do_map(1, buf, LANGMAP, FALSE); -    xfree(kp[i].from); -    xfree(kp[i].to); +    (void)do_map(1, buf, LANGMAP, false);    } +  keymap_ga_clear(&curbuf->b_kmap_ga);    p_cpo = save_cpo; | 
