(exec_sentinel): Remove vars that were set but not used.
(create_pty): Remove unnecessary "volatile"s.
(Fnetwork_interface_info): Avoid possibility of int overflow.
+ (read_process_output): Do adaptive read buffering even if carryover.
* bytecode.c (exec_byte_code): Rename local to avoid shadowing.
}
else
#endif
- if (proc_buffered_char[channel] < 0)
{
+ int buffered = 0 <= proc_buffered_char[channel];
+ if (buffered)
+ {
+ chars[carryover] = proc_buffered_char[channel];
+ proc_buffered_char[channel] = -1;
+ }
#ifdef HAVE_GNUTLS
if (XPROCESS (proc)->gnutls_p)
nbytes = emacs_gnutls_read (channel, XPROCESS (proc),
- chars + carryover, readmax);
+ chars + carryover + buffered,
+ readmax - buffered);
else
#endif
- nbytes = emacs_read (channel, chars + carryover, readmax);
+ nbytes = emacs_read (channel, chars + carryover + buffered,
+ readmax - buffered);
#ifdef ADAPTIVE_READ_BUFFERING
if (nbytes > 0 && p->adaptive_read_buffering)
{
delay += READ_OUTPUT_DELAY_INCREMENT * 2;
}
}
- else if (delay > 0 && (nbytes == readmax))
+ else if (delay > 0 && nbytes == readmax - buffered)
{
delay -= READ_OUTPUT_DELAY_INCREMENT;
if (delay == 0)
}
}
#endif
- }
- else
- {
- chars[carryover] = proc_buffered_char[channel];
- proc_buffered_char[channel] = -1;
-#ifdef HAVE_GNUTLS
- if (XPROCESS (proc)->gnutls_p)
- nbytes = emacs_gnutls_read (channel, XPROCESS (proc),
- chars + carryover + 1, readmax - 1);
- else
-#endif
- nbytes = emacs_read (channel, chars + carryover + 1, readmax - 1);
- if (nbytes < 0)
- nbytes = 1;
- else
- nbytes = nbytes + 1;
+ if (buffered)
+ {
+ if (nbytes < 0)
+ nbytes = 1;
+ else
+ nbytes = nbytes + 1;
+ }
}
p->decoding_carryover = 0;