delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/01/13/03:31:56

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:to:from:reply-to:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=doq/0aWinKSnuW4B
mv3jr5cT0nJF/ms7wz1NNsKRTclL2WVulvYUCz0EXIpbkQvedHCOVcEHGvKxM4SF
jqTBkbFUDD6+XtlzUJeagHOxZxaCA2yh3Vs8410wPZ7AGkolHag8MV8NaoX5U4QB
Cp8BTbelA4C38+Ygw38+LCoSqoA=
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:to:from:reply-to:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=lsGpTDoCiNASOpvFLVAH+O
uZ1cU=; b=mZ0x4WqJcbIJ1/pl3JI8Wp3VyTfdxbrdp5yX4JLonoK1tDWe1FCPBD
PChqQGMJlzm7FbpT46qowGDS5h9kF8bpTTwEziDyJONDF5P8T1YuBLyaaY0DlAwP
DYGMbCpZo8gky4h06agraAWzOI7qguxkD7HBrqqybehVQDMg2PT4U=
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=1.1 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=Hx-spam-relays-external:shaw.ca, H*r:shaw.ca, H*RU:shaw.ca, H*r:sk:smtp-ou
X-HELO: smtp-out-no.shaw.ca
X-Authority-Analysis: v=2.2 cv=WoZbCZXv c=1 sm=1 tr=0 a=WqCeCkldcEjBO3QZneQsCg==:117 a=WqCeCkldcEjBO3QZneQsCg==:17 a=IkcTkHD0fZMA:10 a=8_s0q9X8g8MAhruEE-IA:9 a=NFZ2p6yzomWdq3zG:21 a=aoH2MP0v50YxvgF-:21 a=QEXdDO2ut3YA:10
Subject: Re: Awk print statement alters the argument variable's content
References: <2241d4bbc7904b6aaf52d33fa820eab2 AT SESOEX0018 DOT global DOT scd DOT scania DOT com>
To: cygwin AT cygwin DOT com
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca
Message-ID: <779832c0-e4dd-4528-aba2-ead6cae681b2@SystematicSw.ab.ca>
Date: Fri, 13 Jan 2017 01:31:35 -0700
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0
MIME-Version: 1.0
In-Reply-To: <2241d4bbc7904b6aaf52d33fa820eab2@SESOEX0018.global.scd.scania.com>
X-CMAE-Envelope: MS4wfD8HK7NMn23C/znExwE6+CkGbAjYZD1cyh4xAYd6Ab8zruGrKxj1numjquAoDy1QrSU7QGT+QoozA/wiBn8KS09zcX2XqBcQ3LGJM85IJTO0D9U4zpvw c6p+PghCVnPzzeIZUJun2s07Slug0yW+oyynNVIDiQP6Sl2l/RZ/DTY9onpUMcC/eIKVFt+X5NnNsg==
X-IsSubscribed: yes

On 2017-01-12 05:26, Lundberg Christer wrote:
> This program run with GNU awk 4.1.4 (currently installed with
> Cygwin):
> 
>   awk '
>     BEGIN { OFMT="%.8g"
>             buf = 1+0.1
>             buf = buf "a"
>             print "Length before print:", length(buf)
>             print buf " "
>             print buf
>             print buf " "
>             print "Length after print:", length(buf)
>           }
>   '
> 
> produces the following output on our system:
> 
> Length before print: 4
> 1.1a 
> 1.1
> 1.1 
> Length after print: 3
> 
> so it appears that the "print buf" statement unexpectedly alters the
> content of buf.
> With awk 4.1.3, we got the expected output
> 
> Length before print: 4
> 1.1a 
> 1.1a
> 1.1a 
> Length after print: 4

Confirmed problem with any OFMT except default or %.6g, also goes 
away if you change awk line 3 to: buf = "" buf "a":
 
$ uname -srvmo
CYGWIN_NT-10.0 2.6.1(0.305/5/3) 2016-12-16 11:55 x86_64 Cygwin
$ awk --version
GNU Awk 4.1.4, API: 1.1 (GNU MPFR 3.1.5, GNU MP 6.1.1)
Copyright (C) 1989, 1991-2016 Free Software Foundation.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

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