Sync OpenBSD patchset 470:

Twaek this slightly to avoid confusing use of flags variable.
This commit is contained in:
Tiago Cunha 2009-10-28 23:16:30 +00:00
parent 745fd16452
commit c529c02ac0

19
tty.c
View File

@ -1,4 +1,4 @@
/* $Id: tty.c,v 1.165 2009-10-28 23:15:32 tcunha Exp $ */
/* $Id: tty.c,v 1.166 2009-10-28 23:16:30 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -1184,13 +1184,12 @@ void
tty_colours(struct tty *tty, const struct grid_cell *gc, int *attr)
{
struct grid_cell *tc = &tty->cell;
u_char fg = gc->fg, bg = gc->bg;
int flags, have_ax;
int fg_default, bg_default;
u_char fg = gc->fg, bg = gc->bg, flags = gc->flags;
int have_ax, fg_default, bg_default;
/* No changes? Nothing is necessary. */
flags = (gc->flags ^ tc->flags) & (GRID_FLAG_FG256|GRID_FLAG_BG256);
if (fg == tc->fg && bg == tc->bg && flags == 0)
if (fg == tc->fg && bg == tc->bg &&
((flags ^ tc->flags) & (GRID_FLAG_FG256|GRID_FLAG_BG256)) == 0)
return;
/*
@ -1199,8 +1198,8 @@ tty_colours(struct tty *tty, const struct grid_cell *gc, int *attr)
* case if only one is default need to fall onward to set the other
* colour.
*/
fg_default = (fg == 8 && !(gc->flags & GRID_FLAG_FG256));
bg_default = (bg == 8 && !(gc->flags & GRID_FLAG_BG256));
fg_default = (fg == 8 && !(flags & GRID_FLAG_FG256));
bg_default = (bg == 8 && !(flags & GRID_FLAG_BG256));
if (fg_default || bg_default) {
/*
* If don't have AX but do have op, send sgr0 (op can't
@ -1236,7 +1235,7 @@ tty_colours(struct tty *tty, const struct grid_cell *gc, int *attr)
/* Set the foreground colour. */
if (!fg_default && (fg != tc->fg ||
((gc->flags & GRID_FLAG_FG256) != (tc->flags & GRID_FLAG_FG256))))
((flags & GRID_FLAG_FG256) != (tc->flags & GRID_FLAG_FG256))))
tty_colours_fg(tty, gc, attr);
/*
@ -1244,7 +1243,7 @@ tty_colours(struct tty *tty, const struct grid_cell *gc, int *attr)
* tty_colour_fg() can call tty_reset().
*/
if (!bg_default && (bg != tc->bg ||
((gc->flags & GRID_FLAG_BG256) != (tc->flags & GRID_FLAG_BG256))))
((flags & GRID_FLAG_BG256) != (tc->flags & GRID_FLAG_BG256))))
tty_colours_bg(tty, gc, attr);
}