- && SP_PARM != 0
- && SP_PARM->_cleanup) {
- char tmp = (char) ch;
- /*
- * POSIX says write() is safe in a signal handler, but the
- * buffered I/O is not.
- */
- if (write(fileno(NC_OUTPUT(SP_PARM)), &tmp, 1) == -1)
- rc = ERR;
+ && SP_PARM != 0) {
+ if (SP_PARM->out_buffer != 0) {
+ if (SP_PARM->out_inuse + 1 >= SP_PARM->out_limit)
+ NCURSES_SP_NAME(_nc_flush) (NCURSES_SP_ARG);
+ SP_PARM->out_buffer[SP_PARM->out_inuse++] = (char) ch;
+ } else {
+ char tmp = (char) ch;
+ /*
+ * POSIX says write() is safe in a signal handler, but the
+ * buffered I/O is not.
+ */
+ if (write(fileno(NC_OUTPUT(SP_PARM)), &tmp, (size_t) 1) == -1)
+ rc = ERR;
+ }