delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2018/06/15/10:39:49

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:date:from:to:message-id:subject:mime-version
:content-type:content-transfer-encoding; q=dns; s=default; b=Ki+
wc5wZPLbr4GL7Ls2rChqahnG1JUO2tRhNG3lyKoiHPMInupBSU5NWbpYO9LiKp1O
QtzCyaDxDV7rLvMRXiI7n2Z2O4/x7Cz1KmJxA21b0ThyRfEfdeLr1RZyKBUYg1No
lUxSRrr2XD9iBgj6aLcQ1kJTAFxey6/l/7zMA12c=
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:date:from:to:message-id:subject:mime-version
:content-type:content-transfer-encoding; s=default; bh=Puf8/wjSQ
LqjrZ/nKJraHFMty1Y=; b=CCcmCnUhYFYlmIqL9ZEFBiKUcisXoKCfvyFDJoj6B
hbwx3RY8rKChS4ew7uKz3WKwFAXnL5+pq7HWs+Cbl65PnSKuXjJ3xjseR+G/82C+
b/LJK8iVnvXbkxW0QgRYHwI1zY5TqtUxdXuxFZt//5z3cNYSngBi2fcKaIpUFRyn
d4=
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=4.1 required=5.0 tests=BAYES_50,FREEMAIL_FROM,FROM_MISSP_FREEMAIL,FROM_MISSP_XPRIO,RCVD_IN_SBL_CSS,SPF_PASS autolearn=no version=3.3.2 spammy=HX-Priority:Normal, H*UA:NetEase, H*x:NetEase, 163.com
X-HELO: m12-246.163.com
Date: Fri, 15 Jun 2018 22:39:29 +0800
From: "tuyanyi"<tuyanyi AT 163 DOT com>
To: "cygwin"<cygwin AT cygwin DOT com>
Message-ID: <2bfeabde.39a8.16403e31153.Coremail.tuyanyi@163.com>
Subject: 2.10.0: Cygwin now can not work well with a file in dos format.
MIME-Version: 1.0
X-CM-TRANSID:98KowAC3v2OizyNbkCELAA--.42459W :
X-CM-SenderInfo: pwx1t0l1l6il2tof0z/1tbiKwlm+1QHKISlwAABsk

Hi,
I've faced a problem when deal with a text file now, the old version work very well, but the new version, it wont.

1, There is a file named test.txt which in dos format(CRLF), and the content is as follows,
456467987564654654
456467987564654654
456467987564654654
456467987564654655
456467987564654656
456467987564654657
456467987564654658
456467987564654659
456467987564654660
456467987564654661
456467987564654662
456467987564654663
456467987564654664
456467987564654665

I've written a awk script named stat.awk to count each line of test.txt.
#!/bin/awk -f
BEGIN {
	list[""] = ""
	delete list
}
{
	list[$0]++
}
END {
	for(l in list)
	{
		print l ":" list[l]
	}
}

In cygwin 2.874, the output is correct.
$ ./stat.awk test.txt
456467987564654659:1
456467987564654660:1
456467987564654661:1
456467987564654662:1
456467987564654663:1
456467987564654654:3
456467987564654664:1
456467987564654655:1
456467987564654665:1
456467987564654656:1
456467987564654657:1
456467987564654658:1

But, in version 2.10.0, the output is as follows, it's not what I want.
$ ./stat.awk test.txt
:16467987564654663
:16467987564654658
:16467987564654664
:16467987564654659
:36467987564654654
456467987564654665:1
:16467987564654660
:16467987564654655
:16467987564654661
:16467987564654656
:16467987564654662
:16467987564654657

Finally, I run dos2unix to convert this file into unix format, and then run stat.awk, and this time the output is correct.
$ ./stat.awk test.txt
456467987564654659:1
456467987564654660:1
456467987564654661:1
456467987564654662:1
456467987564654663:1
456467987564654654:3
456467987564654664:1
456467987564654655:1
456467987564654665:1
456467987564654656:1
456467987564654657:1
456467987564654658:1

I was wonder, what have changed between version 2.10.0 and 2.874,  or is it possible to modify a configure to fix this in 2.10.0?

By the way, my OS is Window 7 64bit, and I installed a 64bit Cygwin with version 2.10.0 .

Thank you very much!

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