public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
To: cygwin@cygwin.com
Subject: Re: textmode for stdout, what is "correct" now?
Date: Mon, 18 Feb 2019 15:13:00 -0000	[thread overview]
Message-ID: <1c318746-170e-a0ba-e42f-e97199cb288f@ssi-schaefer.com> (raw)
In-Reply-To: <20190218131514.GX4256@calimero.vinschen.de>

On 2/18/19 2:15 PM, Corinna Vinschen wrote:
> On Feb 18 12:47, Michael Haubenwallner wrote:
>> On 2/18/19 11:26 AM, Corinna Vinschen wrote:
>>> On Feb 18 10:40, Michael Haubenwallner wrote:
>>>> On 2/16/19 6:43 PM, Corinna Vinschen wrote:
>>>>> I really miss the problem you're trying to solve here.  Why should an
>>>>> application setting O_BINARY explicitely revert this decision on the
>>>>> same file descriptor?  That doesn't make sense.
>>>>
>>>> Well, it's not necessarily about really switching binary mode on and off,
>>>> it's more about avoiding breakage when applications try to intuitively
>>>> follow the original API, even if that actually causes the call to
>>>> setmode(fd, O_TEXT) to be redundant.
>>>>
>>>> OTOH, this question also would apply to native Win32 applications, so why
>>>> do people call setmode(fd, O_TEXT) with any DOS based platform at all?
>>>>
>>>> IMO, unfortunately we're not in a position to modify the intention of the
>>>> original API.  And finally, I do want to stop discussions like this one
>>>> with application developers like openssl, as soon as we can argue like:
>>>> "Cygwin does not use \r internally, but does support text mode mounts,
>>>> so we had to invent the Cygwin text mode, which may or may not use \r.
>>>> Hence you get the Cygwin text mode with O_TEXT, and if you really are
>>>> in some 'unix2dos' position, please use the new O_DOSTEXT mode instead."
>>>>
>>>> However, agreed this does not seem to be trivial to implement.  Yet I
>>>> will look into it when there is a chance for a patches to be accepted.

<<snip>>
> 
> No, wait.  This is getting a bit out of hand.  The fact that we have to
> handle two different read modes in Cygwin is already bad enough.  I'm
> not really looking forward to add another read mode for which I don't
> see an obvious need.  You don't really expect lots of upstream devs to
> happily pick up on such a change with two new O_ open flags *just* for
> Cygwin, do you?

Agreed, nope.

It turns out that setmode(fd, 0) is what I'm looking for,
and there is no need to change anything in the API.

So rather than not using setmode(), we should tell upstream to not use
O_TEXT but zero instead, which might be easier to accept for them.

> You have two modes for input and three for output:
> 
> - input O_BINARY  -> only \n
> - input O_TEXT    -> \n and \r\n
> 
> - output 0        -> generates \n or \r\n depending on mount mode
> - output O_BINARY -> generates \n
> - output O_TEXT   -> generates \r\n

Erm, even for input there is mode 0: strips \r depending on mount mode.
This actually is without using setmode() at all.
Shouldn't the default (mode 0) behave like O_TEXT for input?

Thanks!
/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

  reply	other threads:[~2019-02-18 14:46 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-14 16:05 Michael Haubenwallner
2019-02-14 18:51 ` Corinna Vinschen
2019-02-15  9:31   ` Michael Haubenwallner
2019-02-15 10:28     ` Corinna Vinschen
2019-02-15 12:48       ` Michael Haubenwallner
2019-02-15 12:49         ` Corinna Vinschen
2019-02-15 18:25           ` Michael Haubenwallner
2019-02-15 20:35             ` Corinna Vinschen
2019-02-16  9:39               ` Michael Haubenwallner
2019-02-16  9:40                 ` Corinna Vinschen
2019-02-16 17:40                   ` Michael Haubenwallner
2019-02-17  0:11                     ` Corinna Vinschen
2019-02-18 10:01                       ` Michael Haubenwallner
2019-02-18 10:43                         ` Corinna Vinschen
2019-02-18 12:15                           ` Michael Haubenwallner
2019-02-18 13:39                             ` Corinna Vinschen
2019-02-18 15:13                               ` Michael Haubenwallner [this message]
2019-02-18 16:04                                 ` Corinna Vinschen
2019-02-15 14:20         ` Andrey Repin
2019-02-15 18:50           ` portable use of dos2unix WAS: " Michael Haubenwallner
2019-02-15 19:14             ` Andrey Repin
2019-02-15 19:43               ` Michael Haubenwallner
2019-02-15 20:50                 ` Andrey Repin
2019-02-15 21:21                 ` Corinna Vinschen
2019-02-18 10:09                   ` Michael Haubenwallner
2019-02-18 10:26                     ` Corinna Vinschen
2019-02-18 13:07                     ` Jeffrey Walton
2019-02-15 21:32                 ` Brian Inglis
2019-02-16  6:09 ` Jeffrey Walton
2019-02-16  9:45   ` Corinna Vinschen

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=1c318746-170e-a0ba-e42f-e97199cb288f@ssi-schaefer.com \
    --to=michael.haubenwallner@ssi-schaefer.com \
    --cc=cygwin@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).