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/nvim/message.c') 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/nvim/message.c') 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/nvim/message.c') 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