delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/06/14/12:08:26

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:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=tH4sWifttGU0pMre
MxyxNar1yJWtv0QOYHKY+Y22IGqJPhO1tCkZQ0stYA+OLvPhH9p+6stMp4HNVofk
eRxPa6NxTgbHlzVRaAePK1XEn9nCrhJPDN/UAxBsQLqScvwwVZ0oOoLf/3pIgbDB
Qv6X/xgGzQcjc6ul4qhDKsuGvyE=
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:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=z/TPmrsAdc+vjjvrEuTura
lvjg8=; b=BK8aAeB88XFdEQ9yL8NWmqqrBXrBkoc3srTNwsjj/Rou7C14VJSfh+
iLqmJ244j6ko+kLf95pNn5QXvkRBh7pSoi0DJ65HNIJXsb9f6kA7L+vnp5gIlZgZ
DcNynnBEpsV93FAk+LDaQVmPFLLEKv8JDy46kOOvF7MCZxB4jLG+c=
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-Virus-Found: No
X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=inglis, Inglis, fscanf, aspx
X-HELO: mail-it0-f54.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=rNFK4UHl8qopP03zGO7FsibKNWIr5aVYOGarGYWLFRo=; b=ifKrBxg0Z7JAoOSjrDM7pnlHnyUd1oKqFQkkGl0Zu7dZje91A+yu79VYWR1DASMMOd 4bBUyGFK0OFu7+nw8FJcl5aMyWP0IWSI8BIYXOKSkzpN8GFki37xcTTElXj0KkfDK9t+ C9yAjtIU4ja8A7uVYmvwczpYsDfmPFI4UihhVjUztYqQpS5S+Egf4vk1hw8snw5c64v9 T33aJ6RYDtT8WVkdTCYW0bGWJemvNYZZ39hNb0O5JZRFRDoxDrP1aXavlKkB7G7gVRd+ lpLXlibjZDen4+5w/3Ioyhq1pdmpAWO1U1V9vUCy0znj54gGSORZUM7hvC/T77/dCMVy 3I0w==
X-Gm-Message-State: AKS2vOxC9obOmqU043bnle2+kGv+POYhsQdyd3H+FhnJ7NEC8mM8u125 b9HCuB1lLhWE1RhH
X-Received: by 10.36.48.146 with SMTP id q140mr682271itq.59.1497456450901; Wed, 14 Jun 2017 09:07:30 -0700 (PDT)
Subject: Re: CR-LF handling behavior of SED changed recently - this breaks a lot of MinGW cross build scripts
To: cygwin AT cygwin DOT com
References: <0F7D3B1B3C4B894D824F5B822E3E5A175B2636E4 AT IRSMSX103 DOT ger DOT corp DOT intel DOT com> <a53282b6-d00c-aad8-76a6-26b4089a9623 AT redhat DOT com> <0F7D3B1B3C4B894D824F5B822E3E5A175B26CE47 AT IRSMSX102 DOT ger DOT corp DOT intel DOT com> <59399CC5 DOT 60900 AT tlinx DOT org> <417f84ac-5d9f-dc50-e912-973e90b8a128 AT redhat DOT com> <0F7D3B1B3C4B894D824F5B822E3E5A175B26F278 AT IRSMSX102 DOT ger DOT corp DOT intel DOT com> <34b26965-34c2-b5f0-a3f2-b2c3df344b08 AT gmail DOT com> <0F7D3B1B3C4B894D824F5B822E3E5A175B270518 AT IRSMSX102 DOT ger DOT corp DOT intel DOT com> <5313de97-d9bd-d9c9-cb4a-254a3eadcf4a AT redhat DOT com> <dfe98b04-27cf-af72-5e96-7a65460c1e53 AT gmail DOT com> <3100fec0-bed0-f2fd-fe3c-11e5580d80f0 AT redhat DOT com> <bef25d9b-c648-5dcc-d757-abf451907ce1 AT gmail DOT com> <e0792ccf-ad17-dbed-794b-a06b6716e852 AT SystematicSw DOT ab DOT ca>
From: cyg Simple <cygsimple AT gmail DOT com>
Message-ID: <9d085703-04a5-3191-fd6b-7b06f407b47b@gmail.com>
Date: Wed, 14 Jun 2017 12:07:31 -0400
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1
MIME-Version: 1.0
In-Reply-To: <e0792ccf-ad17-dbed-794b-a06b6716e852@SystematicSw.ab.ca>
X-IsSubscribed: yes

On 6/13/2017 1:34 PM, Brian Inglis wrote:
> On 2017-06-13 08:11, cyg Simple wrote:
>> On 6/10/2017 10:30 PM, Eric Blake wrote:
>>> On 06/10/2017 08:48 AM, cyg Simple wrote:
>>>> Uhm, 'wt' and 'wb' came from MS itself.
>>> Not quite. fopen(,"wb") comes from POSIX.  "wt" is probably a microsoft
>>> extension, but it is certainly not in POSIX nor in glibc.
>> I think it's a C standard so it should be in glibc.  It may be mentioned
>> in the POSIX standard as in support of the C standard.
>>>>  GNU GCC was adapted to allow it
>>> Huh? It's not whether the compiler allows it, but whether libc allows
>>> it.  ALL libc that are remotely close to POSIX compliant support
>>> fopen(,"wb"), but only Windows platforms (and NOT glibc) support
>>> fopen(,"wt").
>> Looking at http://www.cplusplus.com/reference/cstdio/fopen/ I see:
>> "If additional characters follow the sequence, the behavior depends on
>> the library implementation: some implementations may ignore additional
>> characters so that for example an additional "t" (sometimes used to
>> explicitly state a text file) is accepted."
>> There is also a lot of discussion about the topic at:
>> https://stackoverflow.com/questions/229924/difference-between-files-writen-in-binary-and-text-mode
>> As for glibc, it will just ignore the extra character but it allows the
>> use of "wt"; it just means nothing to that C runtime library. It does
>> aide in portable code though.
>> As for me conflating GCC with a C runtime - please forgive my lapse in
>> memory.
> 
> There's no need for open mode "t", as text is the default mode unless
> "b" is specified, and assuming you use "cooked" line I/O functions like
> fgets/fputs, not "raw" binary I/O like fread/fwrite; fscanf ignores all
> line terminators unless you use formats like "%c" which could see them.
> 

That isn't exactly true based on the MSDN[1] the "t" manages the CTRL-Z
EOF marker.  However, I agree that it worthless.  But regardless the C
standard states that "t" or whatever extra character can be added and
left to the implementing library to interpret or ignored.  If the C
runtime library doesn't use it or ignore it then it isn't complying to
the C standard.

[1] https://msdn.microsoft.com/en-us/library/yeby3zcb(v=vs.140).aspx

"t
Open in text (translated) mode. In this mode, CTRL+Z is interpreted as
an EOF character on input. In files that are opened for reading/writing
by using "a+", fopen checks for a CTRL+Z at the end of the file and
removes it, if it is possible. This is done because using fseek and
ftell to move within a file that ends with CTRL+Z may cause fseek to
behave incorrectly near the end of the file."

-- 
cyg Simple

--
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