bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gawk] zerofile


From: david ward
Subject: [bug-gawk] zerofile
Date: Fri, 17 May 2013 08:39:09 +0100

I want to re-submit this bug because I made some silly mistakes when typing the emails previously
The following files produced this:~/gawk/awkscripts-> gawk  --source '{ print } ' nonempty
This the contents of nonempty text file
~/gawk/awkscripts->
~/gawk/awkscripts-> gawk -f zerofile.awk  -f zerofilef.awk  --source '{ print }'empty nonempty empty2
gawk: zerofilef.awk:2: function zerofile(ARGC[Argind, Argind )
gawk: zerofilef.awk:2:                       ^ syntax error
gawk: zerofilef.awk:2: error: function `zerofile': can't use special variable `ARGC' as a function parameter
~/gawk/awkscripts->
This was produced by using the zerofile.awk in manual for 4.0.2
#zerofilef.awk
#!/usr/bin/gawk -f
function zerofile(ARGC[Argind, Argind )
{
   print ARGIND,Argind, ARGC[Argind]
 
}
This was produced by the following files:

/gawk/awkscripts-> gawk -f zerofile2.awk -f zerofilef2.awk  --source '{print}' empty nonempty empty2
2 1 empty
This the contents of nonempty text file
3 3 empty2
~/gawk/awkscripts->
!/usr/bin/gawk -f

    
     # zerofile.awk --- library file to process empty input files
    
    
     BEGIN { Argind = 0 }
    
     ARGIND > Argind + 1 {
         zf=ARGV[Argind]
         for (Argind++; Argind < ARGIND; Argind++)
             zerofile(zf, Argind) # get syntax error for ARGC[Argind]
               
     }
    
     ARGIND != Argind { Argind = ARGIND }
    
     END {
       
         if (ARGIND > Argind)
            zf2=ARGV[Argind]
             for (Argind++; Argind <= ARGIND; Argind++)
                 zerofile(zf2, Argind)
                 
     }
#zerofile2.awk
#!/usr/bin/gawk -f
function zerofile(check, Argind )
{
   print ARGIND,Argind, ARGV[Argind]
 
}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]