| 1 |
# Date: Mon, 28 Jul 2008 17:25:32 +0200 |
| 2 |
# From: Dirk Zimoch <[email protected]> |
| 3 |
# Subject: match() prevents numeric strings from beeing treated numerically |
| 4 |
# To: [email protected] |
| 5 |
# Message-id: <[email protected]> |
| 6 |
# |
| 7 |
# In gawk version 3.1.5, numeric user input that is parsed with match() is not |
| 8 |
# recognized as "numeric string" any more. I.e. mixed string-numeric comparison |
| 9 |
# does not work any more. In version 3.1.1, it worked. (Even though the |
| 10 |
# documentation never explicitly mentioned this behavior for match(), as it does |
| 11 |
# for split(). But is says that "user input" should be treated that way.) |
| 12 |
# |
| 13 |
# awk 'BEGIN{match(".5",/.*/,a);print a[0]==.5?"OK":"FAULT"}' |
| 14 |
# |
| 15 |
# Version 3.1.1 prints OK, version 3.1.5 prints FAULT. |
| 16 |
# |
| 17 |
# awk '{match($0,/.*/,a);print a[0]==a[0]+0?"OK":"FAULT"}' << EOF |
| 18 |
# 5 |
| 19 |
# 5.0 |
| 20 |
# 0.5 |
| 21 |
# .5 |
| 22 |
# EOF |
| 23 |
# |
| 24 |
# Version 3.1.1 prints |
| 25 |
# OK |
| 26 |
# OK |
| 27 |
# OK |
| 28 |
# OK |
| 29 |
# |
| 30 |
# Version 3.1.5 prints |
| 31 |
# OK |
| 32 |
# FAULT |
| 33 |
# OK |
| 34 |
# FAULT |
| 35 |
# |
| 36 |
# |
| 37 |
# -- |
| 38 |
# Dr. Dirk Zimoch |
| 39 |
# Paul Scherrer Institut, WBGB/006 |
| 40 |
# 5232 Villigen PSI, Switzerland |
| 41 |
# Phone +41 56 310 5182 |
| 42 |
# |
| 43 |
{ |
| 44 |
match($0,/.*/,a) |
| 45 |
print a[0] == a[0]+0 ? "OK" : "FAULT" |
| 46 |
} |