On 3/18/2022 8:29 PM, Kaz Kylheku wrote:
$ cppawk -f foo.cwk
/dev/sda1
$ cat foo.cwk
#include "awkloop.h"
function main()
{
awkloop ("/proc/mounts") {
rule ($3 != "ext4") { nextrec }
rule ($2 == "/") { print $1 }
}
}
BEGIN {
main()
}
$ cat awkloop.h
#define awkloop(file) for (; getline < file || (close(file) && 0); )
That would spin off into an infinite loop if getline failed since it'd
then return a negative number which is non-zero and therefore considered
"true" in a conditional context. `getline < file` needs to be `(getline
< file) > 0`. See
http://awk.freeshell.org/AllAboutGetline.
Ed.
#define nextrec continue
#define rule(cond) if (cond)
:)
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)