diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /sys/libc/cflsbuf.c | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/libc/cflsbuf.c')
-rw-r--r-- | sys/libc/cflsbuf.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sys/libc/cflsbuf.c b/sys/libc/cflsbuf.c new file mode 100644 index 00000000..9547b0c2 --- /dev/null +++ b/sys/libc/cflsbuf.c @@ -0,0 +1,43 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. +*/ + +#define import_spp +#define import_libc +#define import_xnames +#define import_stdio +#include <iraf.h> + + +/* C_FLSBUF -- Flush the FIO file buffer. Called by the PUTC macro to flush +** the file buffer when it fills. The function value returned is either the +** first char written to the buffer (passed as an argument) or EOF in the +** event of an error. +*/ +int +c_flsbuf ( + unsigned int ch, /* char which caused the fault */ + FILE *fp /* output file */ +) +{ + register int buf_not_full; + XINT fd = fileno(fp); + XINT nreserve = 1; + + + /* If we were called due to flush on newline and there is space in + * the buffer, put the ch in the buffer before flushing. + */ + buf_not_full = (fp->_iop < fp->_otop); + if (buf_not_full) + Memc[fp->_iop++] = (unsigned)ch; + + iferr (FLSBUF (&fd, &nreserve)) { + fp->_fflags |= _FERR; + return (EOF); + } + + if (!buf_not_full) + Memc[fp->_iop++] = (unsigned)ch; + + return (ch); +} |