bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] zerofile


From: arnold
Subject: Re: [bug-gawk] zerofile
Date: Wed, 22 May 2013 13:48:09 -0600
User-agent: Heirloom mailx 12.4 7/29/08

Hi.

So, I still don't completely understand. It looks to me like you're
saying that with the zerofile.awk in the gawk 4.0.2 distribution you
got syntax errors.

The file awklib/eg/lib/zerofile.awk is part of the distribution; it's
extracted automatically from the manual.

For me it works just fine:

        $ ./gawk --version | sed 1q
        GNU Awk 4.0.2

        $ cat zf.awk
        function zerofile(name, ind)
        {
                printf("zerofile(%s, %d) called\n", name, ind)
        }

        $ cat demo.awk 
        { printf("%s:%d: %s\n", FILENAME, FNR, $0) }

        $ ./gawk -f awklib/eg/lib/zerofile.awk -f zf.awk -f demo.awk \
        > /dev/null zf.awk /dev/null
        zerofile(/dev/null, 1) called
        zf.awk:1: function zerofile(name, ind)
        zf.awk:2: {
        zf.awk:3:       printf("zerofile(%s, %d) called\n", name, ind)
        zf.awk:4: }
        zerofile(/dev/null, 3) called

I downloaded the tarball and did a fresh build just to be sure.

If I misunderstood, then please clarify further.

Thanks,

Arnold

david ward <address@hidden> wrote:

> The emails have got garbled. The first email I sent was correct in all
> details. However, I did not make sufficiently clear that I was making
> minor adjustments  to the zerofile function in the manual in order for it
> to work. I thought the comment I made in the code was sufficient.
> Unfortunately, in trying to explain myself by showing the results of
> running the original and adjusted zerofile (late at night) I made a number
> of typos, but the main ones was putting ARGC instead of ARGV. . You are
> looking at the uncorrected emails.The first email in this conversation was
> the  last of my corrections
>
> ST|ART FROM HERE- FORGET MY OTHER EMAILS
>  This my zerofile function( an over-statement, I am just making minor
> adjustments). I spent some time with this function because I wanted to
> make sure I understood when the post increments took effect
> ORIGINAL zerofile WITH MINOR ADJUSTMENTS( the original in manual 4.0.2
> produces a syntax error)
> #zerofile2.awk
>
>      # 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) #  alteration:get syntax error for
> ARGV[Argind]
>
>      }
>
>      ARGIND != Argind { Argind = ARGIND }
>
>      END {
>
>          if (ARGIND > Argind)
>             zf2=ARGV[Argind]
>              for (Argind++; Argind <= ARGIND; Argind++)
>                  zerofile(zf2, Argind)
>
>      }
> # zerofilef2f.awk
> #!/usr/bin/gawk -f
> function zerofile(zf, Argind )
> {
>    print ARGIND,Argind, ARGV[Argind]
>
> }
>
> ~-> cd ~/gawk/awkscripts/
> ~/gawk/awkscripts-> gawk -f zerofile2.awk  -f zerofile2f.awk  --source '{
> print}'   empty nonempty empty2
> 2 1 empty
> This the contents of nonempty text file
> 3 3 empty2
> ~/gawk/awkscripts->
>
> best wishes
> david
>
>
> On Wed, May 22, 2013 at 6:56 AM, <address@hidden> wrote:
>
> > Hi.
> >
> > Something got lost somewhere, possibly due to the fact that your initial
> > mails came in garbled.
> >
> > So I am not really sure what you were asking about, to be honest. I
> > will make a guess, below, but if that is not right, please let me know
> > what is not clear.
> >
> > >              zerofile(zf, Argind) #  alteration:get syntax error for
> > > ARGC[Argind]
> >
> > ARGC is not an array, so that is why ARGC[Argind] produces an error.
> > If you were to use ARGV[Argind], it would work.
> >
> > If I haven't understood you, can you please start over again?
> >
> > Thank you,
> >
> > Arnold
> >



reply via email to

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