Skip to content

Commit

Permalink
patch 8.1.0021: clang warns for undefined behavior
Browse files Browse the repository at this point in the history
Problem:    Clang warns for undefined behavior.
Solution:   Move #ifdef outside of sprintf() call.(suggestion by Michael
            Jarvis, closes #2956)
  • Loading branch information
brammool committed May 23, 2018
1 parent 0b0f099 commit d315cf5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/term.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2872,14 +2872,15 @@ term_color(char_u *s, int n)
#else #else
char *format = "%s%s%%dm"; char *format = "%s%s%%dm";
#endif #endif
sprintf(buf, format, char *lead = i == 2 ? (
i == 2 ?
#if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS) #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
s[1] == '|' ? IF_EB("\033|", ESC_STR "|") : s[1] == '|' ? IF_EB("\033|", ESC_STR "|") :
#endif #endif
IF_EB("\033[", ESC_STR "[") : "\233", IF_EB("\033[", ESC_STR "[")) : "\233";
s[i] == '3' ? (n >= 16 ? "38;5;" : "9") char *tail = s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
: (n >= 16 ? "48;5;" : "10")); : (n >= 16 ? "48;5;" : "10");

sprintf(buf, format, lead, tail);
OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8)); OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8));
} }
else else
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ static char *(features[]) =


static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
21,
/**/ /**/
20, 20,
/**/ /**/
Expand Down

0 comments on commit d315cf5

Please sign in to comment.