| 1 |
# Date: Tue, 04 Jul 2006 21:06:14 +0200 (MEST) |
| 2 |
# From: Heiner Marxen <[email protected]> |
| 3 |
# Subject: conversion error |
| 4 |
# To: [email protected] |
| 5 |
# Message-id: <[email protected]> |
| 6 |
# |
| 7 |
# Hello, |
| 8 |
# |
| 9 |
# The following awk script fails for gawk 3.1.4 and 3.1.5. |
| 10 |
# Older versions did not do this, but I cannot say, how old they were. |
| 11 |
# |
| 12 |
BEGIN { |
| 13 |
if( 0 ) { #ok |
| 14 |
t = "8" |
| 15 |
}else { #fails |
| 16 |
t = "" |
| 17 |
t = t "8" |
| 18 |
} |
| 19 |
printf("8 = %d\n", 0+t) # ok without this line |
| 20 |
t = t "8" # does not invalidate numeric interpretation |
| 21 |
printf("88 = %s\n", 0+t) |
| 22 |
## The above prints "88 = 8" with gawk 3.1.4 and 3.1.5 |
| 23 |
} |
| 24 |
# |
| 25 |
# |
| 26 |
# The following one-liner already exhibits the bug: |
| 27 |
# |
| 28 |
# gawk 'BEGIN{t=""; t=t "8";printf("8=%d\n", 0+t);t=t "8";printf("88=%s\n", 0+t)}' |
| 29 |
# |
| 30 |
# |
| 31 |
# Preliminary observation: under somewhat strange conditions a variable |
| 32 |
# does retain its numeric interpretation although something is appended to it. |
| 33 |
# -- |
| 34 |
# Heiner Marxen http://www.drb.insel.de/~heiner/ |
| 35 |
# |