* Awk print statement alters the argument variable's content
@ 2017-01-12 12:26 Lundberg Christer
2017-01-13 8:31 ` Brian Inglis
0 siblings, 1 reply; 3+ messages in thread
From: Lundberg Christer @ 2017-01-12 12:26 UTC (permalink / raw)
To: cygwin
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
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Awk print statement alters the argument variable's content
2017-01-12 12:26 Awk print statement alters the argument variable's content Lundberg Christer
@ 2017-01-13 8:31 ` Brian Inglis
2017-01-13 9:49 ` Corinna Vinschen
0 siblings, 1 reply; 3+ messages in thread
From: Brian Inglis @ 2017-01-13 8:31 UTC (permalink / raw)
To: cygwin
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Awk print statement alters the argument variable's content
2017-01-13 8:31 ` Brian Inglis
@ 2017-01-13 9:49 ` Corinna Vinschen
0 siblings, 0 replies; 3+ messages in thread
From: Corinna Vinschen @ 2017-01-13 9:49 UTC (permalink / raw)
To: cygwin
[-- Attachment #1: Type: text/plain, Size: 1248 bytes --]
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-13 9:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-12 12:26 Awk print statement alters the argument variable's content Lundberg Christer
2017-01-13 8:31 ` Brian Inglis
2017-01-13 9:49 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).