summaryrefslogtreecommitdiff
path: root/src/callproc.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2005-06-06 02:39:45 +0000
committerMiles Bader <miles@gnu.org>2005-06-06 02:39:45 +0000
commitfdffd346262841cb194225ea0acd8059c57ec2d4 (patch)
treed8b3699131f7d1b94bc46c7d8be62af6b8b5ebfe /src/callproc.c
parenta5c508fe3a3f456c987283156315d0384d38fe9e (diff)
parenta9b4333620eb259e974445066a8e64cee0c21d69 (diff)
downloademacs-fdffd346262841cb194225ea0acd8059c57ec2d4.tar.gz
emacs-fdffd346262841cb194225ea0acd8059c57ec2d4.tar.bz2
emacs-fdffd346262841cb194225ea0acd8059c57ec2d4.zip
Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-57
Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 324-352) - Merge from gnus--rel--5.10 - Update from CVS - etc/emacs-buffer.gdb: Remove RCS keywords * gnus--rel--5.10 (patch 70-79) - Update from CVS - Merge from emacs--cvs-trunk--0
Diffstat (limited to 'src/callproc.c')
-rw-r--r--src/callproc.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/callproc.c b/src/callproc.c
index c410b5a121b..524f6a6a078 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -218,9 +218,10 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
int fd[2];
int filefd;
register int pid;
- char buf[16384];
- char *bufptr = buf;
- int bufsize = sizeof buf;
+#define CALLPROC_BUFFER_SIZE_MIN (16 * 1024)
+#define CALLPROC_BUFFER_SIZE_MAX (4 * CALLPROC_BUFFER_SIZE_MIN)
+ char buf[CALLPROC_BUFFER_SIZE_MAX];
+ int bufsize = CALLPROC_BUFFER_SIZE_MIN;
int count = SPECPDL_INDEX ();
register const unsigned char **new_argv
@@ -753,7 +754,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
nread = carryover;
while (nread < bufsize - 1024)
{
- int this_read = emacs_read (fd[0], bufptr + nread,
+ int this_read = emacs_read (fd[0], buf + nread,
bufsize - nread);
if (this_read < 0)
@@ -779,7 +780,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
{
if (NILP (current_buffer->enable_multibyte_characters)
&& ! CODING_MAY_REQUIRE_DECODING (&process_coding))
- insert_1_both (bufptr, nread, nread, 0, 1, 0);
+ insert_1_both (buf, nread, nread, 0, 1, 0);
else
{ /* We have to decode the input. */
Lisp_Object buf;
@@ -826,17 +827,13 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
if (process_coding.mode & CODING_MODE_LAST_BLOCK)
break;
+#if (CALLPROC_BUFFER_SIZE_MIN != CALLPROC_BUFFER_SIZE_MAX)
/* Make the buffer bigger as we continue to read more data,
- but not past 64k. */
- if (bufsize < 64 * 1024 && total_read > 32 * bufsize)
- {
- char *tempptr;
- bufsize *= 2;
-
- tempptr = (char *) alloca (bufsize);
- bcopy (bufptr, tempptr, bufsize / 2);
- bufptr = tempptr;
- }
+ but not past CALLPROC_BUFFER_SIZE_MAX. */
+ if (bufsize < CALLPROC_BUFFER_SIZE_MAX && total_read > 32 * bufsize)
+ if ((bufsize *= 2) > CALLPROC_BUFFER_SIZE_MAX)
+ bufsize = CALLPROC_BUFFER_SIZE_MAX;
+#endif
if (display_p)
{