public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] Cygwin: pty: Add workaround for ISO-2022 and ISCII in convert_mb_str().
@ 2020-09-11 10:54 Takashi Yano
  2020-09-11 12:08 ` Corinna Vinschen
  0 siblings, 1 reply; 13+ messages in thread
From: Takashi Yano @ 2020-09-11 10:54 UTC (permalink / raw)
  To: cygwin-patches

- In convert_mb_str(), exclude ISO-2022 and ISCII from the processing
  for the case that the multibyte char is splitted in the middle.
  The reason is as follows.
  * ISO-2022 is too complicated to handle correctly.
  * Not sure what to do with ISCII.
---
 winsup/cygwin/fhandler_tty.cc | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 37d033bbe..ee5c6a90a 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -117,6 +117,9 @@ CreateProcessW_Hooked
   return CreateProcessW_Orig (n, c, pa, ta, inh, f, e, d, si, pi);
 }
 
+#define IS_ISO_2022(x) ( (x) >= 50220 && (x) <= 50229 )
+#define IS_ISCII(x) ( (x) >= 57002 && (x) <= 57011 )
+
 static void
 convert_mb_str (UINT cp_to, char *ptr_to, size_t *len_to,
 		UINT cp_from, const char *ptr_from, size_t len_from,
@@ -126,8 +129,10 @@ convert_mb_str (UINT cp_to, char *ptr_to, size_t *len_to,
   tmp_pathbuf tp;
   wchar_t *wbuf = tp.w_get ();
   int wlen = 0;
-  if (cp_from == CP_UTF7)
-    /* MB_ERR_INVALID_CHARS does not work properly for UTF-7.
+  if (cp_from == CP_UTF7 || IS_ISO_2022 (cp_from) || IS_ISCII (cp_from))
+    /* - MB_ERR_INVALID_CHARS does not work properly for UTF-7.
+       - ISO-2022 is too complicated to handle correctly.
+       - FIXME: Not sure what to do for ISCII.
        Therefore, just convert string without checking */
     wlen = MultiByteToWideChar (cp_from, 0, ptr_from, len_from,
 				wbuf, NT_MAX_PATH);
-- 
2.28.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-10-13 11:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-11 10:54 [PATCH] Cygwin: pty: Add workaround for ISO-2022 and ISCII in convert_mb_str() Takashi Yano
2020-09-11 12:08 ` Corinna Vinschen
2020-09-11 12:35   ` Takashi Yano
2020-09-11 14:06     ` Corinna Vinschen
2020-09-11 15:10       ` Thomas Wolff
2020-09-11 15:18         ` Thomas Wolff
2020-09-11 16:05       ` Takashi Yano
2020-09-11 17:38         ` Takashi Yano
2020-09-11 18:37           ` Takashi Yano
2020-09-11 18:57             ` Corinna Vinschen
2020-09-11 19:11               ` Takashi Yano
2020-10-13 11:44                 ` Corinna Vinschen
2020-09-11 18:14         ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).