From: Paul Eggert Date: Mon, 4 Apr 2011 09:04:33 +0000 (-0700) Subject: * process.c (read_process_output): Do adaptive read buffering even if carryover. X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~394^2~27 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=82eaa3332cd0568b8e8f3f3dc3438dab61b7cc1d;p=emacs.git * process.c (read_process_output): Do adaptive read buffering even if carryover. --- diff --git a/src/ChangeLog b/src/ChangeLog index c4c7e4e4abc..6c28e61a718 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -4,6 +4,7 @@ (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. diff --git a/src/process.c b/src/process.c index 50a068b2339..33f41c4a8f0 100644 --- a/src/process.c +++ b/src/process.c @@ -5162,15 +5162,22 @@ read_process_output (Lisp_Object proc, register int channel) } 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) { @@ -5184,7 +5191,7 @@ read_process_output (Lisp_Object proc, register int channel) 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) @@ -5198,22 +5205,13 @@ read_process_output (Lisp_Object proc, register int channel) } } #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;