aboutsummaryrefslogtreecommitdiffstats
path: root/test/widesub4.awk
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-07-16 14:49:57 +0300
committerArnold D. Robbins <arnold@skeeve.com>2010-07-16 14:49:57 +0300
commit6a2caf2157d87b4b582b2494bdd7d6a688dd0b1f (patch)
tree9a2862cc11be4832f188cfbdce175120ceba5024 /test/widesub4.awk
parent315bd501ca696bc3e3c938b4604d8dac7a6f512f (diff)
downloadegawk-6a2caf2157d87b4b582b2494bdd7d6a688dd0b1f.tar.gz
egawk-6a2caf2157d87b4b582b2494bdd7d6a688dd0b1f.tar.bz2
egawk-6a2caf2157d87b4b582b2494bdd7d6a688dd0b1f.zip
Move to gawk-3.1.6.
Diffstat (limited to 'test/widesub4.awk')
-rw-r--r--test/widesub4.awk54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/widesub4.awk b/test/widesub4.awk
new file mode 100644
index 00000000..c917aacb
--- /dev/null
+++ b/test/widesub4.awk
@@ -0,0 +1,54 @@
+# Date: Sun, 28 May 2006 11:20:58 +0200
+# From: Frantisek Hanzlik <franta@hanzlici.cz>
+# Subject: sub() function do'nt alter string length in awk 3.1.5
+# To: bug-gawk@gnu.org
+# Message-id: <44796B7A.3050908@hanzlici.cz>
+#
+# Hello,
+# I not know when it is my mistake or gawk bug - in simple example below
+# I delete some chars from string variable, and after this string is
+# modified, but its length is unchanged.
+#
+# awk 'BEGIN{A="1234567890abcdef";
+# for (i=1;i<6;i++){print length(A),"A=" A ".";sub("....","",A)}
+# }'
+# 16 A=1234567890abcdef.
+# 16 A=567890abcdef.
+# 16 A=90abcdef.
+# 16 A=cdef.
+# 16 A=.
+#
+# When I use gensub() instead of sub(), result is as I expected:
+#
+# awk 'BEGIN{A="1234567890abcdef";
+# for (i=1;i<6;i++){print length(A),"A=" A ".";A=gensub("....","",1,A)}
+# }'
+# 16 A=1234567890abcdef.
+# 12 A=567890abcdef.
+# 8 A=90abcdef.
+# 4 A=cdef.
+# 0 A=.
+#
+# OS/GAWK versions:
+# - GNU/Linux kernel 2.6.16-1.2122_FC5 #1 i686, Fedora Core 5 distro
+# - glibc-2.4-8
+# - GNU Awk 3.1.5
+#
+# Yours sincerely
+# Frantisek Hanzlík
+#
+# == Lucní 502 Linux/Unix, Novell, Internet Tel: +420-373729699 ==
+# == 33209 Stenovice e-mail:franta@hanzlici.cz Fax: +420-373729699 ==
+# == Czech Republic http://hanzlici.cz/ GSM: +420-604117319 ==
+#
+#
+#
+# #####################################################################################
+# This Mail Was Scanned by 012.net AntiVirus Service3- Powered by TrendMicro Interscan
+#
+BEGIN{A="1234567890abcdef";
+ for (i=1;i<6;i++){print length(A),"A=" A ".";sub("....","",A)}
+}
+BEGIN{A="1234567890abcdef";
+ for (i=1;i<6;i++){print length(A),"A=" A ".";A=gensub("....","",1,A)}
+}