summaryrefslogtreecommitdiff
path: root/test/strnum1.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/strnum1.awk
parent315bd501ca696bc3e3c938b4604d8dac7a6f512f (diff)
downloadgawk-6a2caf2157d87b4b582b2494bdd7d6a688dd0b1f.tar.gz
Move to gawk-3.1.6.gawk-3.1.6
Diffstat (limited to 'test/strnum1.awk')
-rw-r--r--test/strnum1.awk35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/strnum1.awk b/test/strnum1.awk
new file mode 100644
index 00000000..e9cbdaf6
--- /dev/null
+++ b/test/strnum1.awk
@@ -0,0 +1,35 @@
+# Date: Tue, 04 Jul 2006 21:06:14 +0200 (MEST)
+# From: Heiner Marxen <Heiner.Marxen@DrB.Insel.DE>
+# Subject: conversion error
+# To: bug-gawk@gnu.org
+# Message-id: <200607041906.k64J6Eqa019360@drb9.drb.insel.de>
+#
+# Hello,
+#
+# The following awk script fails for gawk 3.1.4 and 3.1.5.
+# Older versions did not do this, but I cannot say, how old they were.
+#
+BEGIN {
+ if( 0 ) { #ok
+ t = "8"
+ }else { #fails
+ t = ""
+ t = t "8"
+ }
+ printf("8 = %d\n", 0+t) # ok without this line
+ t = t "8" # does not invalidate numeric interpretation
+ printf("88 = %s\n", 0+t)
+ ## The above prints "88 = 8" with gawk 3.1.4 and 3.1.5
+}
+#
+#
+# The following one-liner already exhibits the bug:
+#
+# gawk 'BEGIN{t=""; t=t "8";printf("8=%d\n", 0+t);t=t "8";printf("88=%s\n", 0+t)}'
+#
+#
+# Preliminary observation: under somewhat strange conditions a variable
+# does retain its numeric interpretation although something is appended to it.
+# --
+# Heiner Marxen http://www.drb.insel.de/~heiner/
+#