help-gawk
[Top][All Lists]
Advanced

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

Re: readdir extension on windows with getline


From: Eli Zaretskii
Subject: Re: readdir extension on windows with getline
Date: Fri, 27 Jan 2023 09:14:44 +0200

> Date: Thu, 26 Jan 2023 16:46:20 -0500
> From: "Andrew J. Schorr" <aschorr@telemetry-investments.com>
> Cc: jim.dailey@alumni.utexas.net, help-gawk@gnu.org
> 
> > This is why readdir works for the command-line arguments: we don't
> > try to open the file and bail out immediately when we fail.
> 
> Now I understand. Thanks for the additional explanation.

You're welcome.

Btw, the original script does have one bug:

     PathCount = split(ENVIRON["AWKPATH"],AwkPath,/;/)
     for (i = 1; i <= PathCount; i++) {
         while (getline < AwkPath[i]) {  <<<<<<<<<<<<<<<<<<<<<<<
             split($0,Data,/\//)
             print Data[2]
         }
     }

The line I indicated with "<<<<<<<<<<<<" should be

      while ((getline < AwkPath[i]) > 0)

because a negative return from getline means a failure.  With that
change, and the patch I posted, the script works as expected, showing
all the files in AWKPATH directories.



reply via email to

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