xref: /illumos-gate/usr/src/test/util-tests/tests/awk/gnu/gsubtst7.awk (revision e982f11fb2fc266a3d04a69ea3edcf51f44b1e0f)
1# From bug-gawk-bounces+arnold=skeeve.com@gnu.org  Tue Jul 12 08:18:24 2011
2# Return-Path: <bug-gawk-bounces+arnold=skeeve.com@gnu.org>
3# Received: from localhost (localhost [127.0.0.1])
4# 	by skeeve.com (8.14.3/8.14.3) with ESMTP id p6C5HArm002260
5# 	for <arnold@localhost>; Tue, 12 Jul 2011 08:18:23 +0300
6# X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on sls-af11p1
7# X-Spam-Level:
8# X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DNS_FROM_OPENWHOIS,
9# 	RCVD_IN_DNSWL_MED autolearn=ham version=3.2.5
10# X-Envelope-From: bug-gawk-bounces+arnold=skeeve.com@gnu.org
11# Received: from server1.f7.net [66.148.120.132]
12# 	by localhost with IMAP (fetchmail-6.3.11)
13# 	for <arnold@localhost> (single-drop); Tue, 12 Jul 2011 08:18:23 +0300 (IDT)
14# Received: from lists.gnu.org (lists.gnu.org [140.186.70.17])
15# 	by freefriends.org (8.14.4/8.14.4) with ESMTP id p6BIYi4t032040;
16# 	Mon, 11 Jul 2011 14:34:48 -0400
17# Received: from localhost ([::1]:38787 helo=lists.gnu.org)
18# 	by lists.gnu.org with esmtp (Exim 4.71)
19# 	(envelope-from <bug-gawk-bounces+arnold=skeeve.com@gnu.org>)
20# 	id 1QgLJb-0004tM-Eg
21# 	for arnold@skeeve.com; Mon, 11 Jul 2011 14:34:43 -0400
22# Received: from eggs.gnu.org ([140.186.70.92]:54022)
23# 	by lists.gnu.org with esmtp (Exim 4.71)
24# 	(envelope-from <kornet@camk.edu.pl>) id 1QgD0R-0004Vi-HZ
25# 	for bug-gawk@gnu.org; Mon, 11 Jul 2011 05:42:24 -0400
26# Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
27# 	(envelope-from <kornet@camk.edu.pl>) id 1QgD0Q-0000SE-8u
28# 	for bug-gawk@gnu.org; Mon, 11 Jul 2011 05:42:23 -0400
29# Received: from moat.camk.edu.pl ([148.81.175.50]:34696)
30# 	by eggs.gnu.org with esmtp (Exim 4.71)
31# 	(envelope-from <kornet@camk.edu.pl>) id 1QgD0P-0000Px-V3
32# 	for bug-gawk@gnu.org; Mon, 11 Jul 2011 05:42:22 -0400
33# Received: from localhost (localhost.localdomain [127.0.0.1])
34# 	by moat.camk.edu.pl (Postfix) with ESMTP id 72C1D5F004C
35# 	for <bug-gawk@gnu.org>; Mon, 11 Jul 2011 11:42:13 +0200 (CEST)
36# X-Virus-Scanned: amavisd-new at camk.edu.pl
37# Received: from moat.camk.edu.pl ([127.0.0.1])
38# 	by localhost (liam.camk.edu.pl [127.0.0.1]) (amavisd-new, port 10024)
39# 	with LMTP id oh+-Yw+zHhK6 for <bug-gawk@gnu.org>;
40# 	Mon, 11 Jul 2011 11:42:07 +0200 (CEST)
41# Received: from gatekeeper.camk.edu.pl (gatekeeper.camk.edu.pl [192.168.1.23])
42# 	by moat.camk.edu.pl (Postfix) with ESMTP id 89AA55F0046
43# 	for <bug-gawk@gnu.org>; Mon, 11 Jul 2011 11:42:07 +0200 (CEST)
44# Received: by gatekeeper.camk.edu.pl (Postfix, from userid 1293)
45# 	id 796C8809FB; Mon, 11 Jul 2011 11:42:07 +0200 (CEST)
46# Date: Mon, 11 Jul 2011 11:42:07 +0200
47# From: Kacper Kornet <draenog@pld-linux.org>
48# To: bug-gawk@gnu.org
49# Message-ID: <20110711094207.GA2616@camk.edu.pl>
50# MIME-Version: 1.0
51# Content-Type: text/plain; charset=iso-8859-2
52# Content-Disposition: inline
53# User-Agent: Mutt/1.5.20 (2009-06-14)
54# X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
55# X-Received-From: 148.81.175.50
56# X-Mailman-Approved-At: Mon, 11 Jul 2011 14:34:26 -0400
57# Subject: [bug-gawk] Change in behavior of gsub inside loop
58# X-BeenThere: bug-gawk@gnu.org
59# X-Mailman-Version: 2.1.14
60# Precedence: list
61# List-Id: "Bug reports and all discussion about gawk." <bug-gawk.gnu.org>
62# List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gawk>,
63# 	<mailto:bug-gawk-request@gnu.org?subject=unsubscribe>
64# List-Archive: </archive/html/bug-gawk>
65# List-Post: <mailto:bug-gawk@gnu.org>
66# List-Help: <mailto:bug-gawk-request@gnu.org?subject=help>
67# List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gawk>,
68# 	<mailto:bug-gawk-request@gnu.org?subject=subscribe>
69# Errors-To: bug-gawk-bounces+arnold=skeeve.com@gnu.org
70# Sender: bug-gawk-bounces+arnold=skeeve.com@gnu.org
71# Status: R
72#
73# Hi,
74#
75# I have observed the following changed behavior between gawk-3.8.1 and
76# gakw-4.0.0. While in the former
77#
78# echo -ne ' aaa' | gawk '{for (c = 1; c <= NF; c++) {gsub("foo", "bar", $c); print}}'
79#
80# prints:
81#
82#  aaa
83#
84# the gawk-4.0.0 does not preserve the leading spaces and prints:
85#
86# aaa
87#
88# Best regards,
89# --
90#   Kacper
91#
92{for (c = 1; c <= NF; c++) {gsub("foo", "bar", $c); print}}
93