diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 14:52:31 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2010-07-16 14:52:31 +0300 |
commit | 3ba50a15ebd976f7a88393e2e45dc14b6478b9a9 (patch) | |
tree | 6a6bbe6bed1141051fefe94b2d39eacd4854235a /test/funlen.awk | |
parent | 6a2caf2157d87b4b582b2494bdd7d6a688dd0b1f (diff) | |
download | egawk-3ba50a15ebd976f7a88393e2e45dc14b6478b9a9.tar.gz egawk-3ba50a15ebd976f7a88393e2e45dc14b6478b9a9.tar.bz2 egawk-3ba50a15ebd976f7a88393e2e45dc14b6478b9a9.zip |
Move to gawk-3.1.7.
Diffstat (limited to 'test/funlen.awk')
-rw-r--r-- | test/funlen.awk | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/test/funlen.awk b/test/funlen.awk new file mode 100644 index 00000000..e881fcbf --- /dev/null +++ b/test/funlen.awk @@ -0,0 +1,69 @@ +# Date: Sat, 15 Mar 2008 16:21:19 +0100 +# From: Hermann Peifer <peifer@gmx.net> +# Subject: [Fwd: Gawk length(array) bug] +# To: bug-gawk@gnu.org +# Cc: Aharon Robbins <arnold@skeeve.com> +# Message-id: <47DBE96F.1060406@gmx.net> +# +# See below. Regards, Hermann +# +# -------- Original Message -------- +# Subject: Re: Gawk length(array) question +# Date: Sat, 15 Mar 2008 08:02:03 -0500 +# From: Ed Morton <morton@lsupcaemnt.com> +# Newsgroups: comp.lang.awk +# References: <47DBAE29.4050709@gmx.eu> +# +# On 3/15/2008 6:08 AM, Hermann Peifer wrote: +# > Hi All, +# > +# > The Gawk man page says: +# > > Starting with version 3.1.5, as a non-standard extension, +# > > with an array argument, length() returns the number +# > > of elements in the array. +# > +# > It looks like Gawk's length(array) extension does not work inside +# > functions. Is this a bug or feature or am I missing something? See the +# > example below. I am using GNU Awk 3.1.6 +# > +# > $ cat testdata +# > CD NAME +# > AT Austria +# > BG Bulgaria +# > CH Switzerland +# > DE Germany +# > EE Estonia +# > FR France +# > GR Greece +# > +# > $ cat test.awk +# > +# Populate array +NR > 1 { array[$1] = $2 } + +# Print array length and call function A +END { print "array:",length(array) ; A(array) } + +function A(array_A) { print "array_A:", length(array_A) } +# > +# > $ gawk -f test.awk testdata +# > array: 7 +# > gawk: test.awk:8: (FILENAME=data FNR=8) fatal: attempt to use array +# > `array_A (from array)' in a scalar context +# > +# > BTW, there is no such error if I have asort(array_A) or asorti(array_A) +# > inside the function. +# > +# > Hermann +# +# I get the same result with gawk 3.1.6 for cygwin. Obviously you can work +# around +# it since asort() returns the number of elements in an array just like +# length() +# is supposed to (or "for (i in array) lgth++" if you don't want to be +# gawk-specific) but it does seem like a bug. Anyone know if there's a list of +# known gawk bugs on-line somewhere? +# +# Ed. +# +# |