delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/02/16/12:14:35

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:references:from:to:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=QNgEyUyDwgN+9C20
YCD5SYiJwvyUfF8Js9qYqk54oqN4GHbvD085XLu1PATgW9kdguDzdtG1StyDKSBg
4wT06vjjGWCCe+54jVZG1XBTMzoT7aSE2sLozFt4oNny3XC5y23WsCJjU/E57bVJ
/kzVCz19+CA3oAJPv8BeN5tnFf8=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:subject:references:from:to:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=/8b+FCRo0d1yEXw5TBG1HZ
uyT6c=; b=C1Hq7FjFp/kiOcMU97Mf9ru2CwB3GI3eixXnxR0YdcWeMrmlhyKUY3
I5EIOOEnFvHzJE4/2jYkWelOlQdeB7w2T8s2luq8H6yPtdgORxepJnySIt3I/RAh
1DlUKkumwUkj15Q6V/qcXtFazz/T/U2A5sS9kM+raPLJOXWXLn9v8=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=family
X-HELO: smtpout.aon.at
X-A1Mail-Track-Id: 1550337242:16265:smarthub79:62.47.252.194:1
Subject: Re: textmode for stdout, what is "correct" now?
References: <739ed5ce-6902-d702-e152-65dc2c1da667 AT ssi-schaefer DOT com> <20190214162002 DOT GA4950 AT calimero DOT vinschen DOT de> <6aa280c2-4769-0772-91d9-c73a3a3d9680 AT ssi-schaefer DOT com> <20190215102251 DOT GA2702 AT calimero DOT vinschen DOT de> <f7345109-5b22-a342-df1e-940e236c2397 AT ssi-schaefer DOT com> <20190215124844 DOT GE2702 AT calimero DOT vinschen DOT de> <6d02258d-115d-135c-1404-1b02eec34045 AT ssi-schaefer DOT com> <20190215203108 DOT GN2702 AT calimero DOT vinschen DOT de> <f1372893-842b-93e1-f0f2-3a9f3ac02e20 AT ssi-schaefer DOT com> <20190216093855 DOT GR2702 AT calimero DOT vinschen DOT de>
From: Michael Haubenwallner <michael DOT haubenwallner AT ssi-schaefer DOT com>
To: cygwin AT cygwin DOT com
Message-ID: <863f060b-9c2f-1c78-30e8-c1486d567f74@ssi-schaefer.com>
Date: Sat, 16 Feb 2019 18:13:49 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0
MIME-Version: 1.0
In-Reply-To: <20190216093855.GR2702@calimero.vinschen.de>

On 2/16/19 10:38 AM, Corinna Vinschen wrote:
> On Feb 16 09:19, Michael Haubenwallner wrote:
>> On 2/15/19 9:31 PM, Corinna Vinschen wrote:
>>> On Feb 15 19:07, Michael Haubenwallner wrote:
>>>> On 2/15/19 1:48 PM, Corinna Vinschen wrote:
>>>>> On Feb 15 13:03, Michael Haubenwallner wrote:
>>>>>> On 2/15/19 11:22 AM, Corinna Vinschen wrote:
>>>>>>> On Feb 15 08:56, Michael Haubenwallner wrote:
>>>>>>>> On 2/14/19 5:20 PM, Corinna Vinschen wrote:
>>>>>>>>> On Feb 14 16:23, Michael Haubenwallner wrote:
>>>>>>>>>> Hi,
>>>>>>>>>> [SNIP]
>>>>>>>> Down the line in their BIO module they do use setmode(fd, O_TEXT),
>>>>>>>> which is the one that does introduce the \r, as far as I know.
>>>>>>>
>>>>>>> This one is not so nice.  Somebody should tell upstream we only
>>>>>>> want explicit O_BINARY these days, but no explicit O_TEXT.
>>>>
>>>> To me it sounds strange to use the one but not the other:
>>>>
>>>> If we don't want O_TEXT at all, isn't O_BINARY obsolete as well,
>>>> so the advise should be to use neither - just like real *nix?
>>>
>>> No, on text mode mounts O_BINARY makes sure that the result is
>>> actually a binary file.
>>>
>>>> A consequence then might be to deprecate (or even remove) them
>>>> from the public API header files.
>>>
>>> As long as we have text mode mounts, no.
>>
>> Ah... So this feels like a semantic confusion around setmode(O_TEXT):
>>
>> For the fopen() API family, POSIX says that conforming platforms should
>> accept (and eventually ignore) the 'b' character in the mode argument.
>> But note that there is no 't' character specified here.
>>
>> So with the fopen() API family, application developers are able to
>> enable or disable binary mode, but are _not_ able to explicitly
>> enable or disable text mode.
>>
>> Unfortunately, the setmode() API is semantically different, because it
>> does not allow to disable binary mode, but to "enable text mode" instead.
>>
>> So with the setmode() API, when application developers want to disable
>> binary mode, their only option is to "enable text mode".
> 
> setmode(fd, O_BINARY) works on Cygwin.

Well... true.

What I'm trying to say is that restoring the *default* mode is currently 
broken, because traditionally the default mode simply is called "text
mode" - which is enough for DOS only systems, but confusing in Cygwin.

As for Cygwin the default mode is more complex, we may want to call it
something like the "Cygwin text mode" instead.  Consequently, the mode
that does force \r should be called the "DOS text mode".

Whether the "Cygwin text mode" is with or without \r depends on some
other property like the text mount.

However, after setting the "binary mode", libraries like openssl BIO
want to be able to restore the "non-binary mode" - whatever name it
may have.  So they use the only available API: setmode(fd, O_TEXT).
And IMO they're right to expect the "Cygwin text mode" on Cygwin.

If they really need the "DOS text mode", they either should handle the
\r in binary mode - or we provide some new setmode(fd, O_DOSTEXT) API.

In hope to be more clear now,
/haubi/

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019