aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2000-05-19 23:51:10 +0000
committerKenichi Handa2000-05-19 23:51:10 +0000
commitc5bfa12badc7931b125ababe902697e3d880b6d0 (patch)
tree83b4e2de7092a4a978c780ad010e86c9f521c385 /src
parent089b985ff9f2d34e99b4c62c928c461ffc0bf2a9 (diff)
downloademacs-c5bfa12badc7931b125ababe902697e3d880b6d0.tar.gz
emacs-c5bfa12badc7931b125ababe902697e3d880b6d0.zip
(Fcall_process): Always encode an argument string if
it is multibyte. Setup src_multibyte and dst_multibyte members of process_coding properly.
Diffstat (limited to 'src')
-rw-r--r--src/callproc.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/src/callproc.c b/src/callproc.c
index 20a260daa09..eb7ca1b232f 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -379,22 +379,23 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
379 if (nargs > 4) 379 if (nargs > 4)
380 { 380 {
381 register int i; 381 register int i;
382 struct gcpro gcpro1, gcpro2, gcpro3;
382 383
383 if (CODING_REQUIRE_ENCODING (&argument_coding)) 384 GCPRO3 (infile, buffer, current_dir);
385 argument_coding.dst_multibyte = 0;
386 for (i = 4; i < nargs; i++)
384 { 387 {
385 /* We must encode the arguments. */ 388 argument_coding.src_multibyte = STRING_MULTIBYTE (args[i]);
386 struct gcpro gcpro1, gcpro2, gcpro3; 389 if (CODING_REQUIRE_ENCODING (&argument_coding))
387
388 GCPRO3 (infile, buffer, current_dir);
389 for (i = 4; i < nargs; i++)
390 { 390 {
391 args[i] = code_convert_string (args[i], &argument_coding, 1, 0); 391 /* We must encode this argument. */
392 setup_ccl_program (&(argument_coding.spec.ccl.encoder), Qnil); 392 args[i] = encode_coding_string (args[i], &argument_coding, 1);
393 if (argument_coding.type == coding_type_ccl)
394 setup_ccl_program (&(argument_coding.spec.ccl.encoder), Qnil);
393 } 395 }
394 UNGCPRO; 396 new_argv[i - 3] = XSTRING (args[i])->data;
395 } 397 }
396 for (i = 4; i < nargs; i++) 398 UNGCPRO;
397 new_argv[i - 3] = XSTRING (args[i])->data;
398 new_argv[nargs - 3] = 0; 399 new_argv[nargs - 3] = 0;
399 } 400 }
400 else 401 else
@@ -702,6 +703,11 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
702 && !NILP (val)) 703 && !NILP (val))
703 setup_raw_text_coding_system (&process_coding); 704 setup_raw_text_coding_system (&process_coding);
704 } 705 }
706 process_coding.src_multibyte = 0;
707 process_coding.dst_multibyte
708 = (BUFFERP (buffer)
709 ? ! NILP (XBUFFER (buffer)->enable_multibyte_characters)
710 : ! NILP (current_buffer->enable_multibyte_characters));
705 711
706 immediate_quit = 1; 712 immediate_quit = 1;
707 QUIT; 713 QUIT;
@@ -748,8 +754,8 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
748 754
749 if (!NILP (buffer)) 755 if (!NILP (buffer))
750 { 756 {
751 if (! CODING_REQUIRE_DECODING (&process_coding)) 757 if (! CODING_MAY_REQUIRE_DECODING (&process_coding))
752 insert (bufptr, nread); 758 insert_1_both (bufptr, nread, nread, 0, 1, 0);
753 else 759 else
754 { /* We have to decode the input. */ 760 { /* We have to decode the input. */
755 int size = decoding_buffer_size (&process_coding, nread); 761 int size = decoding_buffer_size (&process_coding, nread);
@@ -772,27 +778,20 @@ If you quit, the process is killed with SIGINT, or SIGKILL if you quit again.")
772 continue; 778 continue;
773 } 779 }
774 if (process_coding.produced > 0) 780 if (process_coding.produced > 0)
775 insert (decoding_buf, process_coding.produced); 781 insert_1_both (decoding_buf, process_coding.produced_char,
782 process_coding.produced, 0, 1, 0);
776 xfree (decoding_buf); 783 xfree (decoding_buf);
777 carryover = nread - process_coding.consumed; 784 carryover = nread - process_coding.consumed;
778 if (carryover > 0) 785 if (carryover > 0)
779 { 786 /* As CARRYOVER should not be that large, we had
780 /* As CARRYOVER should not be that large, we had 787 better avoid overhead of bcopy. */
781 better avoid overhead of bcopy. */ 788 BCOPY_SHORT (bufptr + process_coding.consumed, bufptr,
782 char *p = bufptr + process_coding.consumed; 789 carryover);
783 char *pend = p + carryover;
784 char *dst = bufptr;
785
786 while (p < pend) *dst++ = *p++;
787 }
788 } 790 }
789 } 791 }
792
790 if (process_coding.mode & CODING_MODE_LAST_BLOCK) 793 if (process_coding.mode & CODING_MODE_LAST_BLOCK)
791 { 794 break;
792 if (carryover > 0)
793 insert (bufptr, carryover);
794 break;
795 }
796 795
797 /* Make the buffer bigger as we continue to read more data, 796 /* Make the buffer bigger as we continue to read more data,
798 but not past 64k. */ 797 but not past 64k. */