This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Awk print statement alters the argument variable's content


On Jan 13 01:31, Brian Inglis wrote:
> 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":

It's an upstream bug.  I asked on the gawk ML.


Thanks,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]