comparison src/callproc.c @ 20724:e34b99d443b1

(Fcall_process): Use raw-text instead of emacs-mule when enable-multibyte-characters is nil. Adjusted for the change of encode_coding and decode_coding.
author Kenichi Handa <handa@m17n.org>
date Thu, 22 Jan 1998 01:26:45 +0000
parents 7d5ca0b58282
children 140b6fdd53d0
comparison
equal deleted inserted replaced
20723:a0df1e68fc76 20724:e34b99d443b1
283 { 283 {
284 val = Qnil; 284 val = Qnil;
285 if (!NILP (Vcoding_system_for_read)) 285 if (!NILP (Vcoding_system_for_read))
286 val = Vcoding_system_for_read; 286 val = Vcoding_system_for_read;
287 else if (NILP (current_buffer->enable_multibyte_characters)) 287 else if (NILP (current_buffer->enable_multibyte_characters))
288 val = Qemacs_mule; 288 val = Qraw_text;
289 else 289 else
290 { 290 {
291 if (!EQ (coding_systems, Qt)) 291 if (!EQ (coding_systems, Qt))
292 { 292 {
293 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); 293 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2);
445 for (i = 4; i < nargs; i++) 445 for (i = 4; i < nargs; i++)
446 { 446 {
447 int size = encoding_buffer_size (&argument_coding, 447 int size = encoding_buffer_size (&argument_coding,
448 XSTRING (args[i])->size_byte); 448 XSTRING (args[i])->size_byte);
449 unsigned char *dummy1 = (unsigned char *) alloca (size); 449 unsigned char *dummy1 = (unsigned char *) alloca (size);
450 int produced, dummy; 450 int dummy;
451 451
452 /* The Irix 4.0 compiler barfs if we eliminate dummy. */ 452 /* The Irix 4.0 compiler barfs if we eliminate dummy. */
453 new_argv[i - 3] = dummy1; 453 new_argv[i - 3] = dummy1;
454 produced = encode_coding (&argument_coding, 454 encode_coding (&argument_coding,
455 XSTRING (args[i])->data, 455 XSTRING (args[i])->data,
456 new_argv[i - 3], 456 new_argv[i - 3],
457 XSTRING (args[i])->size_byte, 457 XSTRING (args[i])->size_byte,
458 size, &dummy); 458 size);
459 new_argv[i - 3][produced] = 0; 459 new_argv[i - 3][argument_coding.produced] = 0;
460 } 460 }
461 UNGCPRO; 461 UNGCPRO;
462 } 462 }
463 new_argv[nargs - 3] = 0; 463 new_argv[nargs - 3] = 0;
464 } 464 }
664 664
665 { 665 {
666 register int nread; 666 register int nread;
667 int first = 1; 667 int first = 1;
668 int total_read = 0; 668 int total_read = 0;
669 int carryover = 0;
669 670
670 while (1) 671 while (1)
671 { 672 {
672 /* Repeatedly read until we've filled as much as possible 673 /* Repeatedly read until we've filled as much as possible
673 of the buffer size we have. But don't read 674 of the buffer size we have. But don't read
674 less than 1024--save that for the next bufferful. */ 675 less than 1024--save that for the next bufferful. */
675 676
676 nread = process_coding.carryover_size; /* This value is initially 0. */ 677 nread = carryover;
677 while (nread < bufsize - 1024) 678 while (nread < bufsize - 1024)
678 { 679 {
679 int this_read 680 int this_read = read (fd[0], bufptr + nread, bufsize - nread);
680 = read (fd[0], bufptr + nread, bufsize - nread);
681 681
682 if (this_read < 0) 682 if (this_read < 0)
683 goto give_up; 683 goto give_up;
684 684
685 if (this_read == 0) 685 if (this_read == 0)
689 } 689 }
690 690
691 give_up_1: 691 give_up_1:
692 692
693 /* Now NREAD is the total amount of data in the buffer. */ 693 /* Now NREAD is the total amount of data in the buffer. */
694 if (nread == 0) 694 if (nread == carryover)
695 /* Here, just tell decode_coding that we are processing the 695 /* Here, just tell decode_coding that we are processing the
696 last block. We break the loop after decoding. */ 696 last block. We break the loop after decoding. */
697 process_coding.last_block = 1; 697 process_coding.mode |= CODING_MODE_LAST_BLOCK;
698 698
699 immediate_quit = 0; 699 immediate_quit = 0;
700 total_read += nread; 700 total_read += nread - carryover;
701 701
702 if (!NILP (buffer)) 702 if (!NILP (buffer))
703 { 703 {
704 if (process_coding.type == coding_type_no_conversion) 704 if (process_coding.type == coding_type_no_conversion)
705 insert (bufptr, nread); 705 insert (bufptr, nread);
706 else 706 else
707 { /* We have to decode the input. */ 707 { /* We have to decode the input. */
708 int size = decoding_buffer_size (&process_coding, bufsize); 708 int size = decoding_buffer_size (&process_coding, nread);
709 char *decoding_buf = get_conversion_buffer (size); 709 char *decoding_buf = get_conversion_buffer (size);
710 int dummy; 710
711 711 decode_coding (&process_coding, bufptr, decoding_buf,
712 nread = decode_coding (&process_coding, bufptr, decoding_buf, 712 nread, size);
713 nread, size, &dummy); 713 if (process_coding.produced > 0)
714 if (nread > 0) 714 insert (decoding_buf, process_coding.produced);
715 insert (decoding_buf, nread); 715 carryover = process_coding.produced - process_coding.consumed;
716 if (carryover > 0)
717 {
718 /* As CARRYOVER should not be that large, we had
719 better avoid overhead of bcopy. */
720 char *p = bufptr + process_coding.consumed;
721 char *pend = p + carryover;
722 char *dst = bufptr;
723
724 while (p < pend) *dst++ = *p++;
725 }
716 } 726 }
717 } 727 }
718 728 if (process_coding.mode & CODING_MODE_LAST_BLOCK)
719 if (process_coding.last_block) 729 {
720 break; 730 if (carryover > 0)
731 insert (bufptr, carryover);
732 break;
733 }
721 734
722 /* Make the buffer bigger as we continue to read more data, 735 /* Make the buffer bigger as we continue to read more data,
723 but not past 64k. */ 736 but not past 64k. */
724 if (bufsize < 64 * 1024 && total_read > 32 * bufsize) 737 if (bufsize < 64 * 1024 && total_read > 32 * bufsize)
725 { 738 {
726 bufsize *= 2; 739 bufsize *= 2;
727 bufptr = (char *) alloca (bufsize); 740 bufptr = (char *) alloca (bufsize);
728 } 741 }
729
730 if (!NILP (buffer) && process_coding.carryover_size > 0)
731 /* We have carryover in the last decoding. It should be
732 processed again after reading more data. */
733 bcopy (process_coding.carryover, bufptr,
734 process_coding.carryover_size);
735 742
736 if (!NILP (display) && INTERACTIVE) 743 if (!NILP (display) && INTERACTIVE)
737 { 744 {
738 if (first) 745 if (first)
739 prepare_menu_bars (); 746 prepare_menu_bars ();