summaryrefslogtreecommitdiff
path: root/test/redfilnm.awk
diff options
context:
space:
mode:
authorKim Kibum <kb0929.kim@samsung.com>2012-05-21 17:42:43 +0900
committerKim Kibum <kb0929.kim@samsung.com>2012-05-21 17:42:43 +0900
commit4a2c24a45b7af1aa715eae442c7ef3d91e7dde6d (patch)
tree5431ff1d419d4ee35f8bd3cb3ebd5e334c2a737e /test/redfilnm.awk
parentc22a3ed09b982b93feb23655eba7b55fa27885cb (diff)
downloadgawk-4a2c24a45b7af1aa715eae442c7ef3d91e7dde6d.tar.gz
gawk-4a2c24a45b7af1aa715eae442c7ef3d91e7dde6d.tar.bz2
gawk-4a2c24a45b7af1aa715eae442c7ef3d91e7dde6d.zip
Upload Tizen:Base source
Diffstat (limited to 'test/redfilnm.awk')
-rw-r--r--test/redfilnm.awk98
1 files changed, 98 insertions, 0 deletions
diff --git a/test/redfilnm.awk b/test/redfilnm.awk
new file mode 100644
index 0000000..83cb6aa
--- /dev/null
+++ b/test/redfilnm.awk
@@ -0,0 +1,98 @@
+#Date: Tue, 18 May 1999 12:48:07 -0500 (CDT)
+#From: Darrel Hankerson <hankedr@dms.auburn.edu>
+#To: arnold@gnu.org
+#Subject: [christopher.procter@bt.com: RE: Getline bug in Gawk 3.0.3]
+#
+#Here's a reply that came directly to me. --darrel
+#
+#
+#From: christopher.procter@bt.com
+#To: hankedr@dms.auburn.edu
+#Subject: RE: Getline bug in Gawk 3.0.3
+#Date: Tue, 18 May 1999 18:42:28 +0100
+#
+#Sorry that was me getting carried away and cut and pasting the wrong thing
+#into my email
+#
+#The real problem seems to be that :
+#BEGIN {
+#for (i=1;i<10;i++){
+# while((getline < "hello.txt")>0){
+# print $0
+# }
+# close("hello.txt")
+# }
+#}
+#works (printing the contents of hello.txt 9 times), where as:-
+#
+#END{
+#for (i=1;i<10;i++){
+# while((getline < "hello.txt")>0){
+# print $0
+# }
+# close("hello.txt")
+# }
+#}
+#
+#doesn't, (it prints out hello.txt once followed by the iteration numbers
+#from 1 to 9).
+#The only difference is that one is in the BEGIN block and one in the END
+#block.
+#
+#Sorry about the first post, I'm not a bad awk programmer, just a tired one
+#:)
+#
+#chris
+#
+#> -----Original Message-----
+#> From: Darrel Hankerson [SMTP:hankedr@dms.auburn.edu]
+#> Sent: 18 May 1999 18:28
+#> To: christopher.procter@bt.com
+#> Subject: Re: Getline bug in Gawk 3.0.3
+#>
+#> Could you clarify? Your first script uses an apparently undefined
+#> variable f.
+#>
+#>
+#> christopher.procter@bt.com writes:
+#>
+#> BEGIN {
+#> for (i=1;i<10;i++){
+#> while((getline < "hello.txt")>0){
+#> print $0
+#> }
+#> close(f)
+#> }
+#> }
+#>
+#> refuses to close the file and so prints the contents of hello.txt just
+#> once.
+#> However:-
+#>
+#> BEGIN {
+#> f="hello.txt"
+#> for (i=1;i<10;i++){
+#> while((getline < f)>0){
+#> print $0
+#> }
+#> close(f)
+#> }
+#> }
+#>
+#> works as advertised (printing the contents of hello.txt 9 times)
+#> It seems like a bug in the close statement.
+#>
+#> --
+#> --Darrel Hankerson hankedr@mail.auburn.edu
+#
+
+# srcdir is assigned on command line --- ADR
+END {
+ f = srcdir "/redfilnm.in"
+ for (i = 1; i < 10; i++){
+ while((getline < f) > 0){
+ print $0
+ }
+ close(f)
+ }
+}