aboutsummaryrefslogtreecommitdiff
path: root/libio/libio.h
diff options
context:
space:
mode:
Diffstat (limited to 'libio/libio.h')
-rw-r--r--libio/libio.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/libio/libio.h b/libio/libio.h
index c3dd640b2f..410794f77c 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -287,10 +287,23 @@ extern int __overflow __P ((_IO_FILE *, int));
&& __underflow (_fp) == EOF ? EOF \
: *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) \
+#ifdef __GNUC__
+# define _IO_putc_unlocked(_ch, _fp) \
+ (__extension__ \
+ ({ unsigned char _chl = (_ch); \
+ (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end \
+ || (_chl == '\n' && ((_fp)->_flags & _IO_LINE_BUF))) \
+ ? __overflow (_fp, (unsigned char) _chl) \
+ : (unsigned char) (*(_fp)->_IO_write_ptr++ = _chl)); }))
+#else
+# define _IO_putc_unlocked(_ch, _fp) \
(((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \
? __overflow (_fp, (unsigned char) (_ch)) \
- : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
+ : ((unsigned char) (*(_fp)->_IO_write_ptr = (_ch)) == '\n' \
+ && ((_fp)->_flags & _IO_LINE_BUF) \
+ ? __overflow (_fp, (unsigned char) *(_fp)->_IO_write_ptr) \
+ : (unsigned char) (*(_fp)->_IO_write_ptr++)))
+#endif
#define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
#define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)