public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Lundberg Christer <christer.lundberg@scania.com>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: Awk print statement alters the argument variable's content
Date: Thu, 12 Jan 2017 12:26:00 -0000	[thread overview]
Message-ID: <2241d4bbc7904b6aaf52d33fa820eab2@SESOEX0018.global.scd.scania.com> (raw)

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

             reply	other threads:[~2017-01-12 12:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-12 12:26 Lundberg Christer [this message]
2017-01-13  8:31 ` Brian Inglis
2017-01-13  9:49   ` Corinna Vinschen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2241d4bbc7904b6aaf52d33fa820eab2@SESOEX0018.global.scd.scania.com \
    --to=christer.lundberg@scania.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).