changeset 14007:5d6e8dedfc73 v8.1.0021

patch 8.1.0021: clang warns for undefined behavior commit https://github.com/vim/vim/commit/d315cf551f1d15609c4d7cf724e471de55f5cdac Author: Bram Moolenaar <Bram@vim.org> Date: Wed May 23 20:30:56 2018 +0200 patch 8.1.0021: clang warns for undefined behavior Problem: Clang warns for undefined behavior. Solution: Move #ifdef outside of sprintf() call.(suggestion by Michael Jarvis, closes #2956)
author Christian Brabandt <cb@256bit.org>
date Wed, 23 May 2018 20:45:06 +0200
parents 665fe1f419b0
children e773aacfc5bb
files src/term.c src/version.c
diffstat 2 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/term.c
+++ b/src/term.c
@@ -2872,14 +2872,15 @@ term_color(char_u *s, int n)
 #else
 	char *format = "%s%s%%dm";
 #endif
-	sprintf(buf, format,
-		i == 2 ?
+	char *lead = i == 2 ? (
 #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
-		s[1] == '|' ? IF_EB("\033|", ESC_STR "|") :
+		    s[1] == '|' ? IF_EB("\033|", ESC_STR "|") :
 #endif
-		IF_EB("\033[", ESC_STR "[") : "\233",
-		s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
-			    : (n >= 16 ? "48;5;" : "10"));
+		    IF_EB("\033[", ESC_STR "[")) : "\233";
+	char *tail = s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
+				 : (n >= 16 ? "48;5;" : "10");
+
+	sprintf(buf, format, lead, tail);
 	OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8));
     }
     else
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    21,
+/**/
     20,
 /**/
     19,