]> granicus.if.org Git - vim/commitdiff
patch 8.1.0021: clang warns for undefined behavior v8.1.0021
authorBram Moolenaar <Bram@vim.org>
Wed, 23 May 2018 18:30:56 +0000 (20:30 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 23 May 2018 18:30:56 +0000 (20:30 +0200)
Problem:    Clang warns for undefined behavior.
Solution:   Move #ifdef outside of sprintf() call.(suggestion by Michael
            Jarvis, closes #2956)

src/term.c
src/version.c

index 8b69cc41a534bb00912f3efc0ad5deb311a16fe3..4bb8030cbe223dc9223875c2c3c8f7e6a8325aac 100644 (file)
@@ -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
index 616a169e5979a1851b41032b2b3b723d0b774caf..3208eca446af02ddb9557af3f64918687beac7b8 100644 (file)
@@ -761,6 +761,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    21,
 /**/
     20,
 /**/