From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 34912 invoked by alias); 13 Jan 2017 08:31:40 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 34886 invoked by uid 89); 13 Jan 2017 08:31:39 -0000 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 Received: from smtp-out-no.shaw.ca (HELO smtp-out-no.shaw.ca) (64.59.134.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 13 Jan 2017 08:31:38 +0000 Received: from [192.168.1.100] ([174.0.238.184]) by shaw.ca with SMTP id RxGpcEJgdC8pGRxGqcEWbt; Fri, 13 Jan 2017 01:31:36 -0700 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@SESOEX0018.global.scd.scania.com> To: cygwin@cygwin.com From: Brian Inglis Reply-To: Brian.Inglis@SystematicSw.ab.ca Message-ID: <779832c0-e4dd-4528-aba2-ead6cae681b2@SystematicSw.ab.ca> Date: Fri, 13 Jan 2017 08:31:00 -0000 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> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfD8HK7NMn23C/znExwE6+CkGbAjYZD1cyh4xAYd6Ab8zruGrKxj1numjquAoDy1QrSU7QGT+QoozA/wiBn8KS09zcX2XqBcQ3LGJM85IJTO0D9U4zpvw c6p+PghCVnPzzeIZUJun2s07Slug0yW+oyynNVIDiQP6Sl2l/RZ/DTY9onpUMcC/eIKVFt+X5NnNsg== X-IsSubscribed: yes X-SW-Source: 2017-01/txt/msg00136.txt.bz2 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