diff options
-rw-r--r-- | cppawk.1 | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -104,6 +104,31 @@ Print the larger of field 1 or 2: #define max(a, b) ((a) > (b) ? (a) : (b)) { print max($1, $2) /* C comment */ } #awk comment' +Implement awk-like processing loop within function, to process +/proc/mounts: + + #include "awkloop.h" + + function main() + { + awkloop ("/proc/mounts") { + rule ($3 != "ext4") { nextrec } + rule ($2 == "/") { print $1 } + } + } + + BEGIN { + main() + } + +Where +.BI awkloop.h +contains: + + #define awkloop(file) for (; getline < file || (close(file) && 0); ) + #define nextrec continue + #define rule(cond) if (cond) + .SH "SEE ALSO" awk(1), cpp(6) .SH BUGS |