Mercurial > vim
comparison src/term.c @ 8975:9c097bfad637 v7.4.1773
commit https://github.com/vim/vim/commit/380130f1e18da92a44372728fe044f56db58585b
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Apr 22 11:24:43 2016 +0200
patch 7.4.1773
Problem: Compiler warnings. (Dominique Pelle)
Solution: Add UNUSED. Add type cast. Avoid a buffer overflow.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 22 Apr 2016 11:30:07 +0200 |
parents | c83e2c1e7f2b |
children | b3da1ec8d156 |
comparison
equal
deleted
inserted
replaced
8974:b4b7ed0932dd | 8975:9c097bfad637 |
---|---|
1270 # define RGB(r, g, b) ((r<<16) | (g<<8) | (b)) | 1270 # define RGB(r, g, b) ((r<<16) | (g<<8) | (b)) |
1271 struct rgbcolor_table_S { | 1271 struct rgbcolor_table_S { |
1272 char_u *color_name; | 1272 char_u *color_name; |
1273 guicolor_T color; | 1273 guicolor_T color; |
1274 }; | 1274 }; |
1275 | |
1275 static struct rgbcolor_table_S rgb_table[] = { | 1276 static struct rgbcolor_table_S rgb_table[] = { |
1276 {(char_u *)"black", RGB(0x00, 0x00, 0x00)}, | 1277 {(char_u *)"black", RGB(0x00, 0x00, 0x00)}, |
1277 {(char_u *)"blue", RGB(0x00, 0x00, 0xD4)}, | 1278 {(char_u *)"blue", RGB(0x00, 0x00, 0xD4)}, |
1278 {(char_u *)"brown", RGB(0x80, 0x40, 0x40)}, | 1279 {(char_u *)"brown", RGB(0x80, 0x40, 0x40)}, |
1279 {(char_u *)"cyan", RGB(0x02, 0xAB, 0xEA)}, | 1280 {(char_u *)"cyan", RGB(0x02, 0xAB, 0xEA)}, |
1352 return color; | 1353 return color; |
1353 } | 1354 } |
1354 else | 1355 else |
1355 { | 1356 { |
1356 /* Check if the name is one of the colors we know */ | 1357 /* Check if the name is one of the colors we know */ |
1357 for (i = 0; i < sizeof(rgb_table) / sizeof(rgb_table[0]); i++) | 1358 for (i = 0; i < (int)(sizeof(rgb_table) / sizeof(rgb_table[0])); i++) |
1358 if (STRICMP(name, rgb_table[i].color_name) == 0) | 1359 if (STRICMP(name, rgb_table[i].color_name) == 0) |
1359 return rgb_table[i].color; | 1360 return rgb_table[i].color; |
1360 } | 1361 } |
1361 | 1362 |
1362 /* | 1363 /* |
1382 { | 1383 { |
1383 int len; | 1384 int len; |
1384 int pos; | 1385 int pos; |
1385 char *color; | 1386 char *color; |
1386 | 1387 |
1387 fgets(line, LINE_LEN, fd); | 1388 ignored = fgets(line, LINE_LEN, fd); |
1388 len = strlen(line); | 1389 len = strlen(line); |
1389 | 1390 |
1390 if (len <= 1 || line[len-1] != '\n') | 1391 if (len <= 1 || line[len-1] != '\n') |
1391 continue; | 1392 continue; |
1392 | 1393 |
2801 #define BLUE(rgb) ((rgb )&0xFF) | 2802 #define BLUE(rgb) ((rgb )&0xFF) |
2802 | 2803 |
2803 static void | 2804 static void |
2804 term_rgb_color(char_u *s, long_u rgb) | 2805 term_rgb_color(char_u *s, long_u rgb) |
2805 { | 2806 { |
2806 char buf[7+3*3+2+1+1]; | 2807 #define MAX_COLOR_STR_LEN 100 |
2807 | 2808 char buf[MAX_COLOR_STR_LEN]; |
2808 sprintf(buf, (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb)); | 2809 |
2810 vim_snprintf(buf, MAX_KEY_CODE_LEN, | |
2811 (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb)); | |
2809 OUT_STR(buf); | 2812 OUT_STR(buf); |
2810 } | 2813 } |
2811 #endif | 2814 #endif |
2812 | 2815 |
2813 #if (defined(FEAT_TITLE) && (defined(UNIX) || defined(VMS) \ | 2816 #if (defined(FEAT_TITLE) && (defined(UNIX) || defined(VMS) \ |