diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2012-11-27 22:39:58 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2012-11-27 22:39:58 +0200 |
commit | db20bfeba4c618f380315e18e6433fb6b8e63c26 (patch) | |
tree | d09dc26e43b519983c473a88fdc1ab64fc938bbb /builtin.c | |
parent | a2e0c35036b884486d05cbb4f71fc041dd30b98b (diff) | |
download | egawk-db20bfeba4c618f380315e18e6433fb6b8e63c26.tar.gz egawk-db20bfeba4c618f380315e18e6433fb6b8e63c26.tar.bz2 egawk-db20bfeba4c618f380315e18e6433fb6b8e63c26.zip |
Change fflush() behavior to match BWK and document.
Diffstat (limited to 'builtin.c')
-rw-r--r-- | builtin.c | 26 |
1 files changed, 21 insertions, 5 deletions
@@ -182,24 +182,40 @@ do_fflush(int nargs) int status = 0; const char *file; - /* fflush() --- flush stdout */ + /* + * November, 2012. + * It turns out that circa 2002, when BWK + * added fflush() and fflush("") to his awk, he made both of + * them flush everything. + * + * Now, with our inside agent getting ready to try to get fflush() + * standardized in POSIX, we are going to make our awk consistent + * with his. This should not really affect anyone, as flushing + * everything also flushes stdout. + * + * So. Once upon a time: + * fflush() --- flush stdout + * fflush("") --- flush everything + * Now, both calls flush everything. + */ + + /* fflush() */ if (nargs == 0) { - if (output_fp != stdout) - (void) fflush(output_fp); - status = fflush(stdout); + status = flush_io(); return make_number((AWKNUM) status); } tmp = POP_STRING(); file = tmp->stptr; - /* fflush("") --- flush all */ + /* fflush("") */ if (tmp->stlen == 0) { status = flush_io(); DEREF(tmp); return make_number((AWKNUM) status); } + /* fflush("/some/path") */ rp = getredirect(tmp->stptr, tmp->stlen); status = -1; if (rp != NULL) { |