/[emacs]/emacs/src/callproc.c
ViewVC logotype

Diff of /emacs/src/callproc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.206 by monnier, Thu Mar 24 19:09:58 2005 UTC revision 1.207 by kfstorm, Fri Jun 3 23:02:40 2005 UTC
# Line 218  usage: (call-process PROGRAM &optional I Line 218  usage: (call-process PROGRAM &optional I
218    int fd[2];    int fd[2];
219    int filefd;    int filefd;
220    register int pid;    register int pid;
221    char buf[16384];  #define CALLPROC_BUFFER_SIZE_MIN (16 * 1024)
222    char *bufptr = buf;  #define CALLPROC_BUFFER_SIZE_MAX (4 * CALLPROC_BUFFER_SIZE_MIN)
223    int bufsize = sizeof buf;    char buf[CALLPROC_BUFFER_SIZE_MAX];
224      int bufsize = CALLPROC_BUFFER_SIZE_MIN;
225    int count = SPECPDL_INDEX ();    int count = SPECPDL_INDEX ();
226    
227    register const unsigned char **new_argv    register const unsigned char **new_argv
# Line 765  usage: (call-process PROGRAM &optional I Line 766  usage: (call-process PROGRAM &optional I
766          nread = carryover;          nread = carryover;
767          while (nread < bufsize - 1024)          while (nread < bufsize - 1024)
768            {            {
769              int this_read = emacs_read (fd[0], bufptr + nread,              int this_read = emacs_read (fd[0], buf + nread,
770                                          bufsize - nread);                                          bufsize - nread);
771    
772              if (this_read < 0)              if (this_read < 0)
# Line 790  usage: (call-process PROGRAM &optional I Line 791  usage: (call-process PROGRAM &optional I
791          if (!NILP (buffer))          if (!NILP (buffer))
792            {            {
793              if (! CODING_MAY_REQUIRE_DECODING (&process_coding))              if (! CODING_MAY_REQUIRE_DECODING (&process_coding))
794                insert_1_both (bufptr, nread, nread, 0, 1, 0);                insert_1_both (buf, nread, nread, 0, 1, 0);
795              else              else
796                {                 /* We have to decode the input.  */                {                 /* We have to decode the input.  */
797                  int size;                  int size;
# Line 807  usage: (call-process PROGRAM &optional I Line 808  usage: (call-process PROGRAM &optional I
808                     requires text-encoding detection.  */                     requires text-encoding detection.  */
809                  if (process_coding.type == coding_type_undecided)                  if (process_coding.type == coding_type_undecided)
810                    {                    {
811                      detect_coding (&process_coding, bufptr, nread);                      detect_coding (&process_coding, buf, nread);
812                      if (process_coding.composing != COMPOSITION_DISABLED)                      if (process_coding.composing != COMPOSITION_DISABLED)
813                        /* We have not yet allocated the composition                        /* We have not yet allocated the composition
814                           data because the coding type was undecided.  */                           data because the coding type was undecided.  */
# Line 816  usage: (call-process PROGRAM &optional I Line 817  usage: (call-process PROGRAM &optional I
817                  if (process_coding.cmp_data)                  if (process_coding.cmp_data)
818                    process_coding.cmp_data->char_offset = PT;                    process_coding.cmp_data->char_offset = PT;
819    
820                  decode_coding (&process_coding, bufptr, decoding_buf,                  decode_coding (&process_coding, buf, decoding_buf,
821                                 nread, size);                                 nread, size);
822    
823                  if (display_on_the_fly                  if (display_on_the_fly
# Line 905  usage: (call-process PROGRAM &optional I Line 906  usage: (call-process PROGRAM &optional I
906                  if (carryover > 0)                  if (carryover > 0)
907                    /* As CARRYOVER should not be that large, we had                    /* As CARRYOVER should not be that large, we had
908                       better avoid overhead of bcopy.  */                       better avoid overhead of bcopy.  */
909                    BCOPY_SHORT (bufptr + process_coding.consumed, bufptr,                    BCOPY_SHORT (buf + process_coding.consumed, buf,
910                                 carryover);                                 carryover);
911                  if (process_coding.result == CODING_FINISH_INSUFFICIENT_CMP)                  if (process_coding.result == CODING_FINISH_INSUFFICIENT_CMP)
912                    {                    {
# Line 922  usage: (call-process PROGRAM &optional I Line 923  usage: (call-process PROGRAM &optional I
923          if (process_coding.mode & CODING_MODE_LAST_BLOCK)          if (process_coding.mode & CODING_MODE_LAST_BLOCK)
924            break;            break;
925    
926    #if (CALLPROC_BUFFER_SIZE_MIN != CALLPROC_BUFFER_SIZE_MAX)
927          /* Make the buffer bigger as we continue to read more data,          /* Make the buffer bigger as we continue to read more data,
928             but not past 64k.  */             but not past CALLPROC_BUFFER_SIZE_MAX.  */
929          if (bufsize < 64 * 1024 && total_read > 32 * bufsize)          if (bufsize < CALLPROC_BUFFER_SIZE_MAX && total_read > 32 * bufsize)
930            {            if ((bufsize *= 2) > CALLPROC_BUFFER_SIZE_MAX)
931              char *tempptr;              bufsize = CALLPROC_BUFFER_SIZE_MAX;
932              bufsize *= 2;  #endif
   
             tempptr = (char *) alloca (bufsize);  
             bcopy (bufptr, tempptr, bufsize / 2);  
             bufptr = tempptr;  
           }  
933    
934          if (display_p)          if (display_p)
935            {            {

Legend:
Removed from v.1.206  
changed lines
  Added in v.1.207

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26