@@ -793,10 +793,8 @@ static struct builtin_term builtin_termcaps[] =
793793# endif
794794# endif
795795
796- # if defined(UNIX ) || defined (ALL_BUILTIN_TCAPS ) || defined (SOME_BUILTIN_TCAPS ) || defined (__EMX__ ) || defined (FEAT_TERMTRUECOLOR )
797- {(int )KS_NAME , "xterm" },
798- # endif
799796# if defined(UNIX ) || defined (ALL_BUILTIN_TCAPS ) || defined (SOME_BUILTIN_TCAPS ) || defined (__EMX__ )
797+ {(int )KS_NAME , "xterm" },
800798 {(int )KS_CE , IF_EB ("\033[K" , ESC_STR "[K" )},
801799 {(int )KS_AL , IF_EB ("\033[L" , ESC_STR "[L" )},
802800# ifdef TERMINFO
@@ -861,6 +859,11 @@ static struct builtin_term builtin_termcaps[] =
861859 {(int )KS_CRV , IF_EB ("\033[>c" , ESC_STR "[>c" )},
862860 {(int )KS_RBG , IF_EB ("\033]11;?\007" , ESC_STR "]11;?\007" )},
863861 {(int )KS_U7 , IF_EB ("\033[6n" , ESC_STR "[6n" )},
862+ # ifdef FEAT_TERMTRUECOLOR
863+ /* These are printf strings, not terminal codes. */
864+ {(int )KS_8F , IF_EB ("\033[38;2;%lu;%lu;%lum" , ESC_STR "[38;2;%lu;%lu;%lum" )},
865+ {(int )KS_8B , IF_EB ("\033[48;2;%lu;%lu;%lum" , ESC_STR "[48;2;%lu;%lu;%lum" )},
866+ # endif
864867
865868 {K_UP , IF_EB ("\033O*A" , ESC_STR "O*A" )},
866869 {K_DOWN , IF_EB ("\033O*B" , ESC_STR "O*B" )},
@@ -944,10 +947,6 @@ static struct builtin_term builtin_termcaps[] =
944947 {TERMCAP2KEY ('F' , 'Q' ), IF_EB ("\033[57;*~" , ESC_STR "[57;*~" )}, /* F36 */
945948 {TERMCAP2KEY ('F' , 'R' ), IF_EB ("\033[58;*~" , ESC_STR "[58;*~" )}, /* F37 */
946949# endif
947- # ifdef FEAT_TERMTRUECOLOR
948- {(int )KS_8F , IF_EB ("\033[38;2;%lu;%lu;%lum" , ESC_STR "[38;2;%lu;%lu;%lum" )},
949- {(int )KS_8B , IF_EB ("\033[48;2;%lu;%lu;%lum" , ESC_STR "[48;2;%lu;%lu;%lum" )},
950- # endif
951950
952951# if defined(UNIX ) || defined (ALL_BUILTIN_TCAPS )
953952/*
@@ -1272,6 +1271,7 @@ struct rgbcolor_table_S {
12721271 char_u * color_name ;
12731272 guicolor_T color ;
12741273};
1274+
12751275static struct rgbcolor_table_S rgb_table [] = {
12761276 {(char_u * )"black" , RGB (0x00 , 0x00 , 0x00 )},
12771277 {(char_u * )"blue" , RGB (0x00 , 0x00 , 0xD4 )},
@@ -1354,7 +1354,7 @@ termtrue_mch_get_color(char_u *name)
13541354 else
13551355 {
13561356 /* Check if the name is one of the colors we know */
1357- for (i = 0 ; i < sizeof (rgb_table ) / sizeof (rgb_table [0 ]); i ++ )
1357+ for (i = 0 ; i < ( int )( sizeof (rgb_table ) / sizeof (rgb_table [0 ]) ); i ++ )
13581358 if (STRICMP (name , rgb_table [i ].color_name ) == 0 )
13591359 return rgb_table [i ].color ;
13601360 }
@@ -1382,9 +1382,8 @@ termtrue_mch_get_color(char_u *name)
13821382 {
13831383 int len ;
13841384 int pos ;
1385- char * color ;
13861385
1387- fgets (line , LINE_LEN , fd );
1386+ ( void ) fgets (line , LINE_LEN , fd );
13881387 len = strlen (line );
13891388
13901389 if (len <= 1 || line [len - 1 ] != '\n' )
@@ -1396,9 +1395,7 @@ termtrue_mch_get_color(char_u *name)
13961395 if (i != 3 )
13971396 continue ;
13981397
1399- color = line + pos ;
1400-
1401- if (STRICMP (color , name ) == 0 )
1398+ if (STRICMP (line + pos , name ) == 0 )
14021399 {
14031400 fclose (fd );
14041401 return (guicolor_T ) RGB (r , g , b );
@@ -2803,9 +2800,11 @@ term_bg_rgb_color(long_u rgb)
28032800 static void
28042801term_rgb_color (char_u * s , long_u rgb )
28052802{
2806- char buf [7 + 3 * 3 + 2 + 1 + 1 ];
2803+ #define MAX_COLOR_STR_LEN 100
2804+ char buf [MAX_COLOR_STR_LEN ];
28072805
2808- sprintf (buf , (char * )s , RED (rgb ), GREEN (rgb ), BLUE (rgb ));
2806+ vim_snprintf (buf , MAX_COLOR_STR_LEN ,
2807+ (char * )s , RED (rgb ), GREEN (rgb ), BLUE (rgb ));
28092808 OUT_STR (buf );
28102809}
28112810#endif
0 commit comments