patch 7.4.2243

Problem:    Warning for assigning negative value to unsigned. (Danek Duvall)
Solution:   Make cterm_normal_fg_gui_color and _bg_ guicolor_T, cast to long_u
            only when an unsigned is needed.
This commit is contained in:
Bram Moolenaar
2016-08-22 23:04:33 +02:00
parent 17f1347b86
commit 1b58cdd160
18 changed files with 66 additions and 66 deletions

View File

@@ -368,8 +368,8 @@ EXTERN int cterm_normal_fg_color INIT(= 0);
EXTERN int cterm_normal_fg_bold INIT(= 0); EXTERN int cterm_normal_fg_bold INIT(= 0);
EXTERN int cterm_normal_bg_color INIT(= 0); EXTERN int cterm_normal_bg_color INIT(= 0);
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
EXTERN long_u cterm_normal_fg_gui_color INIT(= INVALCOLOR); EXTERN guicolor_T cterm_normal_fg_gui_color INIT(= INVALCOLOR);
EXTERN long_u cterm_normal_bg_gui_color INIT(= INVALCOLOR); EXTERN guicolor_T cterm_normal_bg_gui_color INIT(= INVALCOLOR);
#endif #endif
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD

View File

@@ -4741,7 +4741,7 @@ gui_get_color(char_u *name)
int int
gui_get_lightness(guicolor_T pixel) gui_get_lightness(guicolor_T pixel)
{ {
long_u rgb = gui_mch_get_rgb(pixel); long_u rgb = (long_u)gui_mch_get_rgb(pixel);
return (int)( (((rgb >> 16) & 0xff) * 299) return (int)( (((rgb >> 16) & 0xff) * 299)
+ (((rgb >> 8) & 0xff) * 587) + (((rgb >> 8) & 0xff) * 587)

View File

@@ -7020,7 +7020,7 @@ gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)
/* /*
* Return the RGB value of a pixel as long. * Return the RGB value of a pixel as long.
*/ */
long_u guicolor_T
gui_mch_get_rgb(guicolor_T pixel) gui_mch_get_rgb(guicolor_T pixel)
{ {
#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,0,0)
@@ -7031,9 +7031,10 @@ gui_mch_get_rgb(guicolor_T pixel)
gdk_colormap_query_color(gtk_widget_get_colormap(gui.drawarea), gdk_colormap_query_color(gtk_widget_get_colormap(gui.drawarea),
(unsigned long)pixel, &color); (unsigned long)pixel, &color);
return (((unsigned)color.red & 0xff00) << 8) return (guicolor_T)(
(((unsigned)color.red & 0xff00) << 8)
| ((unsigned)color.green & 0xff00) | ((unsigned)color.green & 0xff00)
| (((unsigned)color.blue & 0xff00) >> 8); | (((unsigned)color.blue & 0xff00) >> 8));
#endif #endif
} }

View File

@@ -5181,10 +5181,10 @@ gui_mch_start_blink(void)
/* /*
* Return the RGB value of a pixel as long. * Return the RGB value of a pixel as long.
*/ */
long_u guicolor_T
gui_mch_get_rgb(guicolor_T pixel) gui_mch_get_rgb(guicolor_T pixel)
{ {
return (Red(pixel) << 16) + (Green(pixel) << 8) + Blue(pixel); return (guicolor_T)((Red(pixel) << 16) + (Green(pixel) << 8) + Blue(pixel));
} }

View File

@@ -1933,10 +1933,11 @@ gui_mch_setmouse(int x, int y)
/* /*
* Return the RGB value of a pixel as a long. * Return the RGB value of a pixel as a long.
*/ */
long_u guicolor_T
gui_mch_get_rgb(guicolor_T pixel) gui_mch_get_rgb(guicolor_T pixel)
{ {
return PgRGB(PgRedValue(pixel), PgGreenValue(pixel), PgBlueValue(pixel)); return (guicolor_T)(PgRGB(PgRedValue(pixel),
PgGreenValue(pixel), PgBlueValue(pixel)));
} }
void void

View File

@@ -2263,11 +2263,11 @@ SaveInst(HINSTANCE hInst)
/* /*
* Return the RGB value of a pixel as a long. * Return the RGB value of a pixel as a long.
*/ */
long_u guicolor_T
gui_mch_get_rgb(guicolor_T pixel) gui_mch_get_rgb(guicolor_T pixel)
{ {
return (GetRValue(pixel) << 16) + (GetGValue(pixel) << 8) return (guicolor_T)((GetRValue(pixel) << 16) + (GetGValue(pixel) << 8)
+ GetBValue(pixel); + GetBValue(pixel));
} }
#if defined(FEAT_GUI_DIALOG) || defined(PROTO) #if defined(FEAT_GUI_DIALOG) || defined(PROTO)

View File

@@ -3095,7 +3095,7 @@ gui_x11_blink_cb(
/* /*
* Return the RGB value of a pixel as a long. * Return the RGB value of a pixel as a long.
*/ */
long_u guicolor_T
gui_mch_get_rgb(guicolor_T pixel) gui_mch_get_rgb(guicolor_T pixel)
{ {
XColor xc; XColor xc;
@@ -3105,8 +3105,8 @@ gui_mch_get_rgb(guicolor_T pixel)
xc.pixel = pixel; xc.pixel = pixel;
XQueryColor(gui.dpy, colormap, &xc); XQueryColor(gui.dpy, colormap, &xc);
return ((xc.red & 0xff00) << 8) + (xc.green & 0xff00) return (guicolor_T)(((xc.red & 0xff00) << 8) + (xc.green & 0xff00)
+ ((unsigned)xc.blue >> 8); + ((unsigned)xc.blue >> 8));
} }
/* /*

View File

@@ -66,7 +66,7 @@ void gui_mch_menu_grey(vimmenu_T *menu, int grey);
void gui_mch_menu_hidden(vimmenu_T *menu, int hidden); void gui_mch_menu_hidden(vimmenu_T *menu, int hidden);
void gui_mch_draw_menubar(void); void gui_mch_draw_menubar(void);
void gui_mch_enable_scrollbar(scrollbar_T *sb, int flag); void gui_mch_enable_scrollbar(scrollbar_T *sb, int flag);
long_u gui_mch_get_rgb(guicolor_T pixel); guicolor_T gui_mch_get_rgb(guicolor_T pixel);
void gui_mch_getmouse(int *x, int *y); void gui_mch_getmouse(int *x, int *y);
void gui_mch_setmouse(int x, int y); void gui_mch_setmouse(int x, int y);
void gui_mch_mousehide(int hide); void gui_mch_mousehide(int hide);

View File

@@ -78,7 +78,7 @@ void gui_mch_menu_grey(vimmenu_T *menu, int grey);
void gui_mch_menu_hidden(vimmenu_T *menu, int hidden); void gui_mch_menu_hidden(vimmenu_T *menu, int hidden);
void gui_mch_draw_menubar(void); void gui_mch_draw_menubar(void);
int gui_mch_get_lightness(guicolor_T pixel); int gui_mch_get_lightness(guicolor_T pixel);
long_u gui_mch_get_rgb(guicolor_T pixel); guicolor_T gui_mch_get_rgb(guicolor_T pixel);
int gui_mch_get_mouse_x(void); int gui_mch_get_mouse_x(void);
int gui_mch_get_mouse_y(void); int gui_mch_get_mouse_y(void);
void gui_mch_setmouse(int x, int y); void gui_mch_setmouse(int x, int y);

View File

@@ -25,7 +25,7 @@ void mch_set_mouse_shape(int shape);
void gui_mch_mousehide(int hide); void gui_mch_mousehide(int hide);
void gui_mch_getmouse(int *x, int *y); void gui_mch_getmouse(int *x, int *y);
void gui_mch_setmouse(int x, int y); void gui_mch_setmouse(int x, int y);
long_u gui_mch_get_rgb(guicolor_T pixel); guicolor_T gui_mch_get_rgb(guicolor_T pixel);
void gui_mch_new_colors(void); void gui_mch_new_colors(void);
guicolor_T gui_mch_get_color(char_u *name); guicolor_T gui_mch_get_color(char_u *name);
void gui_mch_set_fg_color(guicolor_T color); void gui_mch_set_fg_color(guicolor_T color);

View File

@@ -35,7 +35,7 @@ void gui_mch_enable_menu(int flag);
void gui_mch_set_menu_pos(int x, int y, int w, int h); void gui_mch_set_menu_pos(int x, int y, int w, int h);
void gui_mch_menu_hidden(vimmenu_T *menu, int hidden); void gui_mch_menu_hidden(vimmenu_T *menu, int hidden);
void gui_mch_draw_menubar(void); void gui_mch_draw_menubar(void);
long_u gui_mch_get_rgb(guicolor_T pixel); guicolor_T gui_mch_get_rgb(guicolor_T pixel);
void gui_mch_activate_window(void); void gui_mch_activate_window(void);
void gui_mch_show_toolbar(int showit); void gui_mch_show_toolbar(int showit);
void gui_mch_show_tabline(int showit); void gui_mch_show_tabline(int showit);

View File

@@ -24,7 +24,7 @@ void gui_mch_free_fontset(GuiFontset fontset);
GuiFontset gui_mch_get_fontset(char_u *name, int giveErrorIfMissing, int fixed_width); GuiFontset gui_mch_get_fontset(char_u *name, int giveErrorIfMissing, int fixed_width);
int fontset_height(XFontSet fs); int fontset_height(XFontSet fs);
int fontset_height2(XFontSet fs); int fontset_height2(XFontSet fs);
guicolor_T gui_mch_get_color(char_u *reqname); guicolor_T gui_mch_get_color(char_u *name);
void gui_mch_set_fg_color(guicolor_T color); void gui_mch_set_fg_color(guicolor_T color);
void gui_mch_set_bg_color(guicolor_T color); void gui_mch_set_bg_color(guicolor_T color);
void gui_mch_set_sp_color(guicolor_T color); void gui_mch_set_sp_color(guicolor_T color);
@@ -58,7 +58,7 @@ int gui_mch_is_blink_off(void);
void gui_mch_set_blinking(long waittime, long on, long off); void gui_mch_set_blinking(long waittime, long on, long off);
void gui_mch_stop_blink(void); void gui_mch_stop_blink(void);
void gui_mch_start_blink(void); void gui_mch_start_blink(void);
long_u gui_mch_get_rgb(guicolor_T pixel); guicolor_T gui_mch_get_rgb(guicolor_T pixel);
void gui_x11_callbacks(Widget textArea, Widget vimForm); void gui_x11_callbacks(Widget textArea, Widget vimForm);
void gui_mch_getmouse(int *x, int *y); void gui_mch_getmouse(int *x, int *y);
void gui_mch_setmouse(int x, int y); void gui_mch_setmouse(int x, int y);

View File

@@ -1,7 +1,7 @@
/* term.c */ /* term.c */
guicolor_T termgui_mch_get_color(char_u *name); guicolor_T termgui_mch_get_color(char_u *name);
guicolor_T termgui_get_color(char_u *name); guicolor_T termgui_get_color(char_u *name);
long_u termgui_mch_get_rgb(guicolor_T color); guicolor_T termgui_mch_get_rgb(guicolor_T color);
int set_termname(char_u *term); int set_termname(char_u *term);
void set_mouse_termcode(int n, char_u *s); void set_mouse_termcode(int n, char_u *s);
void del_mouse_termcode(int n); void del_mouse_termcode(int n);
@@ -25,8 +25,8 @@ void term_set_winpos(int x, int y);
void term_set_winsize(int width, int height); void term_set_winsize(int width, int height);
void term_fg_color(int n); void term_fg_color(int n);
void term_bg_color(int n); void term_bg_color(int n);
void term_fg_rgb_color(long_u rgb); void term_fg_rgb_color(guicolor_T rgb);
void term_bg_rgb_color(long_u rgb); void term_bg_rgb_color(guicolor_T rgb);
void term_settitle(char_u *title); void term_settitle(char_u *title);
void ttest(int pairs); void ttest(int pairs);
void add_long_to_buf(long_u val, char_u *dst); void add_long_to_buf(long_u val, char_u *dst);

View File

@@ -7865,7 +7865,7 @@ screen_start_highlight(int attr)
else if (aep != NULL && cterm_normal_fg_bold && else if (aep != NULL && cterm_normal_fg_bold &&
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
(p_tgc ? (p_tgc ?
(aep->ae_u.cterm.fg_rgb != (long_u)INVALCOLOR): (aep->ae_u.cterm.fg_rgb != INVALCOLOR):
#endif #endif
(t_colors > 1 && aep->ae_u.cterm.fg_color) (t_colors > 1 && aep->ae_u.cterm.fg_color)
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
@@ -7894,9 +7894,9 @@ screen_start_highlight(int attr)
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
if (p_tgc) if (p_tgc)
{ {
if (aep->ae_u.cterm.fg_rgb != (long_u)INVALCOLOR) if (aep->ae_u.cterm.fg_rgb != INVALCOLOR)
term_fg_rgb_color(aep->ae_u.cterm.fg_rgb); term_fg_rgb_color(aep->ae_u.cterm.fg_rgb);
if (aep->ae_u.cterm.bg_rgb != (long_u)INVALCOLOR) if (aep->ae_u.cterm.bg_rgb != INVALCOLOR)
term_bg_rgb_color(aep->ae_u.cterm.bg_rgb); term_bg_rgb_color(aep->ae_u.cterm.bg_rgb);
} }
else else
@@ -7956,8 +7956,8 @@ screen_stop_highlight(void)
if (aep != NULL && if (aep != NULL &&
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
(p_tgc ? (p_tgc ?
(aep->ae_u.cterm.fg_rgb != (long_u)INVALCOLOR || (aep->ae_u.cterm.fg_rgb != INVALCOLOR
aep->ae_u.cterm.bg_rgb != (long_u)INVALCOLOR): || aep->ae_u.cterm.bg_rgb != INVALCOLOR):
#endif #endif
(aep->ae_u.cterm.fg_color || aep->ae_u.cterm.bg_color) (aep->ae_u.cterm.fg_color || aep->ae_u.cterm.bg_color)
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
@@ -8014,9 +8014,9 @@ screen_stop_highlight(void)
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
if (p_tgc) if (p_tgc)
{ {
if (cterm_normal_fg_gui_color != (long_u)INVALCOLOR) if (cterm_normal_fg_gui_color != INVALCOLOR)
term_fg_rgb_color(cterm_normal_fg_gui_color); term_fg_rgb_color(cterm_normal_fg_gui_color);
if (cterm_normal_bg_gui_color != (long_u)INVALCOLOR) if (cterm_normal_bg_gui_color != INVALCOLOR)
term_bg_rgb_color(cterm_normal_bg_gui_color); term_bg_rgb_color(cterm_normal_bg_gui_color);
} }
else else
@@ -8049,10 +8049,9 @@ reset_cterm_colors(void)
{ {
/* set Normal cterm colors */ /* set Normal cterm colors */
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
if (p_tgc ? if (p_tgc ? (cterm_normal_fg_gui_color != INVALCOLOR
(cterm_normal_fg_gui_color != (long_u)INVALCOLOR || cterm_normal_bg_gui_color != INVALCOLOR)
|| cterm_normal_bg_gui_color != (long_u)INVALCOLOR): : (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0))
(cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0))
#else #else
if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0) if (cterm_normal_fg_color > 0 || cterm_normal_bg_color > 0)
#endif #endif
@@ -8983,7 +8982,7 @@ can_clear(char_u *p)
|| gui.in_use || gui.in_use
#endif #endif
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
|| (p_tgc && cterm_normal_bg_gui_color == (long_u)INVALCOLOR) || (p_tgc && cterm_normal_bg_gui_color == INVALCOLOR)
|| (!p_tgc && cterm_normal_bg_color == 0) || (!p_tgc && cterm_normal_bg_color == 0)
#else #else
|| cterm_normal_bg_color == 0 || cterm_normal_bg_color == 0

View File

@@ -92,8 +92,7 @@ typedef struct {
# ifdef FEAT_XCLIPBOARD # ifdef FEAT_XCLIPBOARD
# include <X11/Intrinsic.h> # include <X11/Intrinsic.h>
# endif # endif
# define guicolor_T long_u /* avoid error in prototypes and # define guicolor_T long
* make FEAT_TERMGUICOLORS work */
# define INVALCOLOR ((guicolor_T)0x1ffffff) # define INVALCOLOR ((guicolor_T)0x1ffffff)
#endif #endif
@@ -929,8 +928,8 @@ typedef struct attr_entry
short_u fg_color; /* foreground color number */ short_u fg_color; /* foreground color number */
short_u bg_color; /* background color number */ short_u bg_color; /* background color number */
# ifdef FEAT_TERMGUICOLORS # ifdef FEAT_TERMGUICOLORS
long_u fg_rgb; /* foreground color RGB */ guicolor_T fg_rgb; /* foreground color RGB */
long_u bg_rgb; /* background color RGB */ guicolor_T bg_rgb; /* background color RGB */
# endif # endif
} cterm; } cterm;
# ifdef FEAT_GUI # ifdef FEAT_GUI

View File

@@ -8488,7 +8488,7 @@ color_name2handle(char_u *name)
return gui.norm_pixel; return gui.norm_pixel;
#endif #endif
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
if (cterm_normal_fg_gui_color != (long_u)INVALCOLOR) if (cterm_normal_fg_gui_color != INVALCOLOR)
return cterm_normal_fg_gui_color; return cterm_normal_fg_gui_color;
/* Guess that the foreground is black or white. */ /* Guess that the foreground is black or white. */
return GUI_GET_COLOR((char_u *)(*p_bg == 'l' ? "black" : "white")); return GUI_GET_COLOR((char_u *)(*p_bg == 'l' ? "black" : "white"));
@@ -8503,7 +8503,7 @@ color_name2handle(char_u *name)
return gui.back_pixel; return gui.back_pixel;
#endif #endif
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
if (cterm_normal_bg_gui_color != (long_u)INVALCOLOR) if (cterm_normal_bg_gui_color != INVALCOLOR)
return cterm_normal_bg_gui_color; return cterm_normal_bg_gui_color;
/* Guess that the background is white or black. */ /* Guess that the background is white or black. */
return GUI_GET_COLOR((char_u *)(*p_bg == 'l' ? "white" : "black")); return GUI_GET_COLOR((char_u *)(*p_bg == 'l' ? "white" : "black"));
@@ -8782,9 +8782,9 @@ hl_combine_attr(int char_attr, int prim_attr)
if (spell_aep->ae_u.cterm.bg_color > 0) if (spell_aep->ae_u.cterm.bg_color > 0)
new_en.ae_u.cterm.bg_color = spell_aep->ae_u.cterm.bg_color; new_en.ae_u.cterm.bg_color = spell_aep->ae_u.cterm.bg_color;
#ifdef FEAT_TERMGUICOLORS #ifdef FEAT_TERMGUICOLORS
if (spell_aep->ae_u.cterm.fg_rgb != (long_u)INVALCOLOR) if (spell_aep->ae_u.cterm.fg_rgb != INVALCOLOR)
new_en.ae_u.cterm.fg_rgb = spell_aep->ae_u.cterm.fg_rgb; new_en.ae_u.cterm.fg_rgb = spell_aep->ae_u.cterm.fg_rgb;
if (spell_aep->ae_u.cterm.bg_rgb != (long_u)INVALCOLOR) if (spell_aep->ae_u.cterm.bg_rgb != INVALCOLOR)
new_en.ae_u.cterm.bg_rgb = spell_aep->ae_u.cterm.bg_rgb; new_en.ae_u.cterm.bg_rgb = spell_aep->ae_u.cterm.bg_rgb;
#endif #endif
} }
@@ -9076,7 +9076,7 @@ highlight_color(
color = HL_TABLE()[id - 1].sg_gui_bg; color = HL_TABLE()[id - 1].sg_gui_bg;
if (color == INVALCOLOR) if (color == INVALCOLOR)
return NULL; return NULL;
rgb = GUI_MCH_GET_RGB(color); rgb = (long_u)GUI_MCH_GET_RGB(color);
sprintf((char *)buf, "#%02x%02x%02x", sprintf((char *)buf, "#%02x%02x%02x",
(unsigned)(rgb >> 16), (unsigned)(rgb >> 16),
(unsigned)(rgb >> 8) & 255, (unsigned)(rgb >> 8) & 255,

View File

@@ -77,9 +77,6 @@ struct builtin_term
static struct builtin_term *find_builtin_term(char_u *name); static struct builtin_term *find_builtin_term(char_u *name);
static void parse_builtin_tcap(char_u *s); static void parse_builtin_tcap(char_u *s);
static void term_color(char_u *s, int n); static void term_color(char_u *s, int n);
#ifdef FEAT_TERMGUICOLORS
static void term_rgb_color(char_u *s, long_u rgb);
#endif
static void gather_termleader(void); static void gather_termleader(void);
#ifdef FEAT_TERMRESPONSE #ifdef FEAT_TERMRESPONSE
static void req_codes_from_term(void); static void req_codes_from_term(void);
@@ -1282,10 +1279,10 @@ termgui_get_color(char_u *name)
return t; return t;
} }
long_u guicolor_T
termgui_mch_get_rgb(guicolor_T color) termgui_mch_get_rgb(guicolor_T color)
{ {
return (long_u)color; return color;
} }
#endif #endif
@@ -2634,24 +2631,13 @@ term_color(char_u *s, int n)
} }
#if defined(FEAT_TERMGUICOLORS) || defined(PROTO) #if defined(FEAT_TERMGUICOLORS) || defined(PROTO)
void
term_fg_rgb_color(long_u rgb)
{
term_rgb_color(T_8F, rgb);
}
void #define RED(rgb) (((long_u)(rgb) >> 16) & 0xFF)
term_bg_rgb_color(long_u rgb) #define GREEN(rgb) (((long_u)(rgb) >> 8) & 0xFF)
{ #define BLUE(rgb) (((long_u)(rgb) ) & 0xFF)
term_rgb_color(T_8B, rgb);
}
#define RED(rgb) ((rgb>>16)&0xFF)
#define GREEN(rgb) ((rgb>> 8)&0xFF)
#define BLUE(rgb) ((rgb )&0xFF)
static void static void
term_rgb_color(char_u *s, long_u rgb) term_rgb_color(char_u *s, guicolor_T rgb)
{ {
#define MAX_COLOR_STR_LEN 100 #define MAX_COLOR_STR_LEN 100
char buf[MAX_COLOR_STR_LEN]; char buf[MAX_COLOR_STR_LEN];
@@ -2660,6 +2646,18 @@ term_rgb_color(char_u *s, long_u rgb)
(char *)s, RED(rgb), GREEN(rgb), BLUE(rgb)); (char *)s, RED(rgb), GREEN(rgb), BLUE(rgb));
OUT_STR(buf); OUT_STR(buf);
} }
void
term_fg_rgb_color(guicolor_T rgb)
{
term_rgb_color(T_8F, rgb);
}
void
term_bg_rgb_color(guicolor_T rgb)
{
term_rgb_color(T_8B, rgb);
}
#endif #endif
#if (defined(FEAT_TITLE) && (defined(UNIX) || defined(VMS) \ #if (defined(FEAT_TITLE) && (defined(UNIX) || defined(VMS) \

View File

@@ -763,6 +763,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 */
/**/
2243,
/**/ /**/
2242, 2242,
/**/ /**/