public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH 3/3] fhandler_pty_slave::setup_locale: respect charset == "UTF-8"
Date: Tue, 8 Sep 2020 09:55:44 +0200	[thread overview]
Message-ID: <20200908075544.GN4127@calimero.vinschen.de> (raw)
In-Reply-To: <20200907224056.bdd8818cd7013248b41871a4@nifty.ne.jp>

On Sep  7 22:40, Takashi Yano via Cygwin-patches wrote:
> Here is a summary of my points:
> 
> [Senario 1]
> 1) Start mintty (UTF-8).
> 2) Start another mintty by 
>      mintty -o charset=SJIS
>    from the first mintty.
> 
> [Senario 2]
>   int pm = getpt();
>   if (fork()) {
>     [do the master operations]
>   } else {
>     setsid();
>     ps = open(ptsname(pm), O_RDWR);
>     close(pm);
>     dup2(ps, 0);
>     dup2(ps, 1);
>     dup2(ps, 2);
>     close(ps);
>     setenv("LANG", "ja_JP.SJIS", 1);
>     [exec shell]
>   }
> 
> 
> Q1) cygheap or tty shared memory?
> 
> Consider senario 1. If the term_code_page is in cygheap,
> it is inherited to child process. Therefore, the second
> mintty cannot update term_code_page while locale is changed.
> 
> Consider senario 2. Since only the child process knows the
> locale, master (parent process) cannot get term_code_page
> if it is in cygheap.
> 
> Q2) Is checking environment necessary?
> 
> As for senario 2, setlocale() is not called. So it is
> necessary to check environment to know locale.
> 
> Q3) Where and when should term_code_page be set?
> 
> In senario 2, LANG is set just before exec() in the CHILD
> process. Therefore, term_code_page should be determined
> in the child_info_spawn:worker or in the execed process.

What bugs me here is that in scenario 1, the codeset of the master side
is the defining factor, while in case 2 the slave side is the defining
factor.

Actually, the only defining factor is the codeset of the master side of
the pty.  If the master side interprets all input as utf-8, then the
slave side should either send utf-8, or live with the consequences.
It's the task of the *user* on the slave side, to set the env setting
matching to the master side.

I tend to agree with Johannes.  We should not enforce a codepage setting
inside Cygwin.  The bytes should go to the master side and the master
side interprets them.  If native apps produce garbage, well, I'm not
overly sympathetic.  Especially given the fact that even Microsoft is
now doing a lot to switch to UTF-8 as much as possible.  It's the only
sane option anyway.


Corinna

  reply	other threads:[~2020-09-08  7:55 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-01 16:19 Johannes Schindelin
2020-09-02  6:06 ` Johannes Schindelin
2020-09-02  8:30 ` Corinna Vinschen
2020-09-02  8:38   ` Corinna Vinschen
2020-09-02 10:54     ` Takashi Yano
2020-09-02 15:24       ` Corinna Vinschen
2020-09-02 16:09         ` Corinna Vinschen
2020-09-02 16:25         ` Takashi Yano
2020-09-02 16:38           ` Corinna Vinschen
2020-09-03 17:59             ` Corinna Vinschen
2020-09-04  9:21               ` Takashi Yano
2020-09-04 12:44                 ` Corinna Vinschen
2020-09-04 14:05                   ` Brian Inglis
2020-09-04 14:50                   ` Takashi Yano
2020-09-04 19:22                     ` Corinna Vinschen
2020-09-05  8:43                       ` Takashi Yano
2020-09-05 11:15                         ` Takashi Yano
2020-09-05 14:15                           ` Takashi Yano
2020-09-06  8:57                             ` Takashi Yano
2020-09-06 10:15                               ` Takashi Yano
2020-09-06 16:04                                 ` Takashi Yano
2020-09-07  4:45                                   ` Takashi Yano
2020-09-07  9:08                                     ` Corinna Vinschen
2020-09-07  9:54                                       ` Takashi Yano
2020-09-07  9:59                                         ` Takashi Yano
2020-09-08  8:40                                     ` Corinna Vinschen
2020-09-08  9:45                                       ` Takashi Yano
2020-09-08 19:16                                         ` Corinna Vinschen
2020-09-10 13:08                                         ` Takashi Yano
2020-09-07  8:27                           ` Corinna Vinschen
2020-09-07  8:38                             ` Takashi Yano
2020-09-07  9:09                               ` Corinna Vinschen
2020-09-07  8:26                         ` Corinna Vinschen
2020-09-07  9:36                           ` Takashi Yano
2020-09-07 18:24                             ` Takashi Yano
2020-09-07 21:08                             ` Johannes Schindelin
2020-09-08  4:52                               ` Brian Inglis
2020-09-07 10:27                           ` Takashi Yano
2020-09-07 13:40                             ` Takashi Yano
2020-09-08  7:55                               ` Corinna Vinschen [this message]
2020-09-06 10:28                   ` Takashi Yano
2020-09-07  8:33                     ` Corinna Vinschen
2020-09-02  9:41   ` Takashi Yano
2020-09-02  6:26     ` Johannes Schindelin
2020-09-02 13:06       ` Takashi Yano
2020-09-02  9:12         ` Johannes Schindelin
2020-09-02 14:52           ` Takashi Yano
2020-09-04 10:03 ` Takashi Yano
2020-09-04  6:23   ` Johannes Schindelin
2020-09-04 15:03     ` Takashi Yano
2020-09-07 21:17       ` Johannes Schindelin
2020-09-08  8:16         ` Takashi Yano
2020-09-09  7:21           ` Corinna Vinschen
2020-09-10  0:15             ` Takashi Yano
2020-09-10 12:34               ` Takashi Yano
2020-09-11  9:05                 ` Corinna Vinschen
2020-09-11  9:23                   ` Corinna Vinschen
2020-09-10 14:04               ` Corinna Vinschen
2020-09-10 14:16                 ` Takashi Yano
2020-09-10 14:18                   ` Takashi Yano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200908075544.GN4127@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin-patches@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).