[Patch] bug # 514 deja vu (cygwin console color handling)

Thomas Wolff towo@computer.org
Wed Nov 22 17:21:00 GMT 2006

I noticed that the reverse color bug
shows up again in recent cygwin1.dll updates. My previous patch 
is still in the source but additional code apparently has the same 
effect of rendering output unreadable; the effect is the following:
* foreground is set bright
* screen mode is set to reverse
* cygwin wrongly assumes that the reverse foreground colour (which 
  actually used to be the non-bright background color) should be 
  set to bright, which is obviously a wrong idea and often results 
  in a contrast that renders the output almost unreadable

The attached shell script test514 demonstrates the bug.
The attached patch is an attempt to fix the bug again.
Unfortunately, I could not compile it due to the following mysterious 
make error:

make[4]: Entering directory `/usr/src/cygwin-1.5.22-patch/i686-pc-cygwin/newlib'
rm -f libm.a
ln libm/libm.a libm.a >/dev/null 2>/dev/null || cp libm/libm.a libm.a
rm -rf libc.a libg.a tmp
mkdir tmp
cd tmp; \
         ar x ../libm.a lib_a-s_isinf.o lib_a-sf_isinf.o lib_a-s_isnan.o lib_a-sf_isnan.o lib_a-s_isinfd.o lib_a-sf_isinff.o lib_a-s_isnand.o lib_a-sf_isnanf.o lib_a-s_nan.o lib_a-sf_nan.o lib_a-s_ldexp.o lib_a-sf_ldexp.o lib_a-s_frexp.o lib_a-sf_frexp.o lib_a-s_modf.o lib_a-sf_modf.o lib_a-s_scalbn.o lib_a-sf_scalbn.o lib_a-s_finite.o lib_a-sf_finite.o lib_a-s_copysign.o lib_a-sf_copysign.o lib_a-s_infconst.o ; \
         ar x ../libc/libc.a ; \
         ar rc ../libc.a *.o
/bin/sh: line 3: /bin/ar: Argument list too long
make[4]: *** [libc.a] Error 126

I would appreciate if someone (who can successfully compile cygwin1.dll) 
could check the patch, please, and the result.

Thanks a lot.

2006-11-22  Thomas Wolff  <towo@computer.org>

* fhandler_console.cc (set_color): Avoid (again) inappropriate intensity 
     interchanging that used to render reverse output unreadable 
     when (non-reversed) text is bright.
     See http://sourceware.org/bugzilla/show_bug.cgi?id=514

-------------- next part --------------
--- cygwin-1.5.22-1/winsup/cygwin/fhandler_console.cc	2006-07-03 17:29:10.001000000 +0200
+++ cygwin-1.5.22-patch/winsup/cygwin/fhandler_console.cc	2006-11-22 17:37:15.518677900 +0100
@@ -948,6 +948,8 @@ dev_console::set_color (HANDLE h)
 	       (save_fg & FOREGROUND_BLUE  ? BACKGROUND_BLUE  : 0) |
+  /* apply attributes */
   if (underline)
     win_fg = underline_color;
   /* emulate blink with bright background */
@@ -956,7 +958,12 @@ dev_console::set_color (HANDLE h)
   if (intensity == INTENSITY_INVISIBLE)
     win_fg = win_bg;
   else if (intensity == INTENSITY_BOLD)
+    /* apply foreground intensity only in non-reverse mode! */
+    if (reverse) 
+      win_bg |= BACKGROUND_INTENSITY;
+    else
+      win_fg |= FOREGROUND_INTENSITY;
   current_win32_attr = win_fg | win_bg;
   if (h)
     SetConsoleTextAttribute (h, current_win32_attr);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test514
Type: application/octet-stream
Size: 225 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20061122/d20b661f/attachment.obj>

More information about the Cygwin-patches mailing list