From dan@kulesh.obluda.cz  Sat Jul 16 09:56:52 2005
Return-Path: <dan@kulesh.obluda.cz>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0F5C316A41C
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 16 Jul 2005 09:56:52 +0000 (GMT)
	(envelope-from dan@kulesh.obluda.cz)
Received: from kulesh.obluda.cz (kulesh.obluda.cz [193.179.22.243])
	by mx1.FreeBSD.org (Postfix) with ESMTP id CD61A43D45
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 16 Jul 2005 09:56:50 +0000 (GMT)
	(envelope-from dan@kulesh.obluda.cz)
Received: from kulesh.obluda.cz (localhost.eunet.cz [127.0.0.1])
	by kulesh.obluda.cz (8.13.4/8.13.4) with ESMTP id j6G9umvO053419
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 16 Jul 2005 11:56:48 +0200 (CEST)
	(envelope-from dan@kulesh.obluda.cz)
Received: (from root@localhost)
	by kulesh.obluda.cz (8.13.4/8.13.1/Submit) id j6G9ulKJ053415;
	Sat, 16 Jul 2005 11:56:47 +0200 (CEST)
	(envelope-from dan)
Message-Id: <200507160956.j6G9ulKJ053415@kulesh.obluda.cz>
Date: Sat, 16 Jul 2005 11:56:47 +0200 (CEST)
From: Dan Lukes <dan@obluda.cz>
Reply-To: Dan Lukes <dan@obluda.cz>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [ PATCH ] vidcontrol can't switch mode and color during one
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         83553
>Category:       bin
>Synopsis:       [patch] vidcontrol can't switch mode and color during one
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    rodrigc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jul 16 10:00:31 GMT 2005
>Closed-Date:    Mon May 22 19:09:40 GMT 2006
>Last-Modified:  Mon May 22 19:09:40 GMT 2006
>Originator:     Dan Lukes
>Release:        FreeBSD 6.0-BETA1 i386
>Organization:
Obludarium
>Environment:
System: FreeBSD 6.0-BETA1 #0: Sat Jul 16 00:42:20 CEST 2005 i386

>Description:
	vidcontrol didn't change colors when video mode change requested

	It's because get_{normal|reverse}_color()/set_colors() logic is
broken

	Original get_*_color() functions set color immediatelly, doesn't
store color codes into {normal|reverse}_{fore|back}_color variables nor
raising value of colors_changed

	Unfortunatelly, on the end of program run, when mode changed, the
set_color() has been called. It set colors to {normal|reverse}_{fore|back}_color 
as obtained during initialization (e.g. it set's back original colors)

	Note, the colors_changed variable isn't changed within code anywhere.
It's clear sign the thinks are broken somewhat.

>How-To-Repeat:
	run 'vidcontrol <a mode> <a color>'
	mode changes, color remain unchanged
>Fix:

	get_{normal|reverse}_color() store obtained colors into 
{normal|reverse}_{fore|back}_color variables and sets 
colors_changed to 1

	On end of run the set_color() process changes as requested.

	Please note the get_{normal|reverse}_color() still apply changes
immediatelly also. It's for backward compatibility. Original code allow the
vidcontrol call with '<color> <mode>' (althought the manual page mention the reverse
order only). The order is important during background color changes.

--- patch begins here ---
--- usr.sbin/vidcontrol/vidcontrol.c.ORIG	Fri Jul 15 17:03:40 2005
+++ usr.sbin/vidcontrol/vidcontrol.c	Sat Jul 16 10:47:44 2005
@@ -715,11 +715,14 @@
 	if (*_index < argc && (color = get_color_number(argv[*_index])) != -1) {
 		(*_index)++;
 		fprintf(stderr, "\033[=%dF", color);
+		normal_fore_color=color;
+		colors_changed = 1;
 		if (*_index < argc
 		    && (color = get_color_number(argv[*_index])) != -1
 		    && color < 8) {
 			(*_index)++;
 			fprintf(stderr, "\033[=%dG", color);
+			normal_back_color=color;
 		}
 	}
 }
@@ -736,11 +739,14 @@
 
 	if ((color = get_color_number(argv[*(_index)-1])) != -1) {
 		fprintf(stderr, "\033[=%dH", color);
+		revers_fore_color=color;
+		colors_changed = 1;
 		if (*_index < argc
 		    && (color = get_color_number(argv[*_index])) != -1
 		    && color < 8) {
 			(*_index)++;
 			fprintf(stderr, "\033[=%dI", color);
+			revers_back_color=color;
 		}
 	}
 }
--- patch ends here ---
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: rodrigc 
State-Changed-When: Sun Sep 18 16:57:00 GMT 2005 
State-Changed-Why:  
Patched applied in -CURRENT.  MFC reminder. 


Responsible-Changed-From-To: freebsd-bugs->rodrigc 
Responsible-Changed-By: rodrigc 
Responsible-Changed-When: Sun Sep 18 16:57:00 GMT 2005 
Responsible-Changed-Why:  
Patched applied in -CURRENT.  MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=83553 
State-Changed-From-To: patched->closed 
State-Changed-By: rodrigc 
State-Changed-When: Mon May 22 19:07:22 UTC 2006 
State-Changed-Why:  
Fix is in CURRENT and RELENG_6. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=83553 
>Unformatted:
 run
