[PATCH] Cygwin: console: Ignore 0x00 on write().

Lavrentiev, Anton (NIH/NLM/NCBI) [C] via cygwin-patches cygwin-patches@cygwin.com
Thu Feb 20 18:11:00 GMT 2020


JFYI:

Both 0x00 (NUL) and 0x7F (DEL) used to be the filler characters, and were ignored by most (hardware) terminals from the very early days.

HTH,
Anton

> -----Original Message-----
> From: cygwin-patches-owner@cygwin.com <cygwin-patches-owner@cygwin.com> On
> Behalf Of Takashi Yano
> Sent: Thursday, February 20, 2020 6:52 AM
> To: cygwin-patches@cygwin.com
> Cc: Takashi Yano <takashi.yano@nifty.ne.jp>
> Subject: [PATCH] Cygwin: console: Ignore 0x00 on write().
> 
> - In xterm compatible mode, 0x00 on write() behaves incompatible
>   with real xterm. In xterm, 0x00 completely ignored. Therefore,
>   0x00 is ignored by console with this patch.
> ---
>  winsup/cygwin/fhandler_console.cc | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/winsup/cygwin/fhandler_console.cc
> b/winsup/cygwin/fhandler_console.cc
> index 66e645aa1..705ce696e 100644
> --- a/winsup/cygwin/fhandler_console.cc
> +++ b/winsup/cygwin/fhandler_console.cc
> @@ -1794,6 +1794,16 @@ bool fhandler_console::write_console (PWCHAR buf,
> DWORD len, DWORD& done)
>  	  len -= 4;
>  	}
>      }
> +  /* Workaround for ^@ (0x00) handling in xterm compatible mode. */
> +  if (wincap.has_con_24bit_colors () && !con_is_legacy)
> +    {
> +      WCHAR *p = buf;
> +      while ((p = wmemchr (p, L'\0', len - (p - buf))))
> +	{
> +	  memmove (p, p+1, (len - (p+1 - buf))*sizeof (WCHAR));
> +	  len --;
> +	}
> +    }
> 
>    if (con.iso_2022_G1
>  	? con.vt100_graphics_mode_G1
> --
> 2.21.0



More information about the Cygwin-patches mailing list