X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/b2ba4dcba149f845bf7fcf15b6cede6a6cbcc336..af6ea8ad8d62810d901561ae4a56d89f22ebacf0:/src/callproc.c diff --git a/src/callproc.c b/src/callproc.c index 128bf8825e..d8eebac08a 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -1,6 +1,6 @@ /* Synchronous subprocess invocation for GNU Emacs. Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 1999, 2000, 2001, - 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -203,6 +203,10 @@ t (mix it with ordinary output), or a file name string. Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted. Remaining arguments are strings passed as command arguments to PROGRAM. +If executable PROGRAM can't be found as an executable, `call-process' +signals a Lisp error. `call-process' reports errors in execution of +the program only through its return and output. + If BUFFER is 0, `call-process' returns immediately with value nil. Otherwise it waits for PROGRAM to terminate and returns a numeric exit status or a signal description string. @@ -269,6 +273,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) if (nargs >= 5) { int must_encode = 0; + Lisp_Object coding_attrs; for (i = 4; i < nargs; i++) CHECK_STRING (args[i]); @@ -294,7 +299,15 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) else val = Qnil; } + val = coding_inherit_eol_type (val, Qnil); setup_coding_system (Fcheck_coding_system (val), &argument_coding); + coding_attrs = CODING_ID_ATTRS (argument_coding.id); + if (NILP (CODING_ATTR_ASCII_COMPAT (coding_attrs))) + { + /* We should not use an ASCII incompatible coding system. */ + val = raw_text_coding_system (val); + setup_coding_system (val, &argument_coding); + } } } @@ -355,11 +368,11 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) protected by the caller, so all we really have to worry about is buffer. */ { - struct gcpro gcpro1, gcpro2, gcpro3; + struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; current_dir = current_buffer->directory; - GCPRO3 (infile, buffer, current_dir); + GCPRO4 (infile, buffer, current_dir, error_file); current_dir = expand_and_dir_to_file (Funhandled_file_name_directory (current_dir), @@ -368,6 +381,12 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) report_file_error ("Setting current directory", Fcons (current_buffer->directory, Qnil)); + if (STRING_MULTIBYTE (infile)) + infile = ENCODE_FILE (infile); + if (STRING_MULTIBYTE (current_dir)) + current_dir = ENCODE_FILE (current_dir); + if (STRINGP (error_file) && STRING_MULTIBYTE (error_file)) + error_file = ENCODE_FILE (error_file); UNGCPRO; } @@ -376,6 +395,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) filefd = emacs_open (SDATA (infile), O_RDONLY, 0); if (filefd < 0) { + infile = DECODE_FILE (infile); report_file_error ("Opening process input file", Fcons (infile, Qnil)); } /* Search for program; barf if not found. */ @@ -529,14 +549,13 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) #ifdef MSDOS unlink (tempfile); #endif - report_file_error ("Cannot redirect stderr", - Fcons ((NILP (error_file) - ? build_string (NULL_DEVICE) : error_file), - Qnil)); + if (NILP (error_file)) + error_file = build_string (NULL_DEVICE); + else if (STRINGP (error_file)) + error_file = DECODE_FILE (error_file); + report_file_error ("Cannot redirect stderr", Fcons (error_file, Qnil)); } - current_dir = ENCODE_FILE (current_dir); - #ifdef MAC_OS8 { /* Call run_mac_command in sysdep.c here directly instead of doing