X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/6498c4b170e8a143f02913ec523e3b84ab11790c..c3702194809d8772afa226d5107ec3abb05e8d35:/src/callproc.c
diff --git a/src/callproc.c b/src/callproc.c
index a3b7b7afa4..5d94b05b60 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -5,10 +5,10 @@
This file is part of GNU Emacs.
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,9 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with GNU Emacs. If not, see . */
#include
@@ -92,13 +90,9 @@ extern int errno;
#include "msdos.h"
#endif
-#ifdef VMS
-extern noshare char **environ;
-#else
#ifndef USE_CRT_DLL
extern char **environ;
#endif
-#endif
#ifdef HAVE_SETPGID
#if !defined (USG) || defined (BSD_PGRPS)
@@ -144,8 +138,6 @@ static int call_process_exited;
EXFUN (Fgetenv_internal, 2);
-#ifndef VMS /* VMS version is in vmsproc.c. */
-
static Lisp_Object
call_process_kill (fdpid)
Lisp_Object fdpid;
@@ -234,8 +226,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
int bufsize = CALLPROC_BUFFER_SIZE_MIN;
int count = SPECPDL_INDEX ();
- register const unsigned char **new_argv
- = (const unsigned char **) alloca ((max (2, nargs - 2)) * sizeof (char *));
+ register const unsigned char **new_argv;
struct buffer *old = current_buffer;
/* File to use for stderr in the child.
t means use same as standard output. */
@@ -243,9 +234,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
#ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */
char *outf, *tempfile;
int outfilefd;
-#endif
-#if 0
- int mask;
#endif
struct coding_system process_coding; /* coding-system of process output */
struct coding_system argument_coding; /* coding-system of arguments */
@@ -376,9 +364,14 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
GCPRO4 (infile, buffer, current_dir, error_file);
- current_dir
- = expand_and_dir_to_file (Funhandled_file_name_directory (current_dir),
- Qnil);
+ current_dir = Funhandled_file_name_directory (current_dir);
+ if (NILP (current_dir))
+ /* If the file name handler says that current_dir is unreachable, use
+ a sensible default. */
+ current_dir = build_string ("~/");
+ current_dir = expand_and_dir_to_file (current_dir, Qnil);
+ current_dir = Ffile_name_as_directory (current_dir);
+
if (NILP (Ffile_accessible_directory_p (current_dir)))
report_file_error ("Setting current directory",
Fcons (current_buffer->directory, Qnil));
@@ -420,7 +413,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
&& SREF (path, 1) == ':')
path = Fsubstring (path, make_number (2), Qnil);
- new_argv[0] = SDATA (path);
+ new_argv = (const unsigned char **)
+ alloca (max (2, nargs - 2) * sizeof (char *));
if (nargs > 4)
{
register int i;
@@ -434,13 +428,15 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
if (CODING_REQUIRE_ENCODING (&argument_coding))
/* We must encode this argument. */
args[i] = encode_coding_string (&argument_coding, args[i], 1);
- new_argv[i - 3] = SDATA (args[i]);
}
UNGCPRO;
- new_argv[nargs - 3] = 0;
+ for (i = 4; i < nargs; i++)
+ new_argv[i - 3] = SDATA (args[i]);
+ new_argv[i - 3] = 0;
}
else
new_argv[1] = 0;
+ new_argv[0] = SDATA (path);
#ifdef MSDOS /* MW, July 1993 */
if ((outf = egetenv ("TMPDIR")))
@@ -478,10 +474,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
emacs_close (filefd);
report_file_error ("Creating process pipe", Qnil);
}
-#endif
-#if 0
- /* Replaced by close_process_descs */
- set_exclusive_use (fd[0]);
#endif
}
@@ -842,7 +834,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
Vlocale_coding_system, 0);
return make_number (synch_process_retcode);
}
-#endif
static Lisp_Object
delete_temp_file (name)
@@ -998,8 +989,6 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r
RETURN_UNGCPRO (unbind_to (count, Fcall_process (nargs, args)));
}
-#ifndef VMS /* VMS version is in vmsproc.c. */
-
static int relocate_fd ();
static char **
@@ -1447,7 +1436,6 @@ egetenv (var)
return 0;
}
-#endif /* not VMS */
/* This is run before init_cmdargs. */
@@ -1550,16 +1538,9 @@ init_callproc ()
dir_warning ("Warning: arch-independent data dir (%s) does not exist.\n",
Vdata_directory);
-#ifdef VMS
- Vshell_file_name = build_string ("*dcl*");
-#else
sh = (char *) getenv ("SHELL");
Vshell_file_name = build_string (sh ? sh : "/bin/sh");
-#endif
-#ifdef VMS
- Vtemp_file_name_pattern = build_string ("tmp:emacsXXXXXX.");
-#else
if (getenv ("TMPDIR"))
{
char *dir = getenv ("TMPDIR");
@@ -1569,7 +1550,6 @@ init_callproc ()
}
else
Vtemp_file_name_pattern = build_string ("/tmp/emacsXXXXXX");
-#endif
#ifdef DOS_NT
Vshared_game_score_directory = Qnil;
@@ -1586,8 +1566,11 @@ set_initial_environment ()
register char **envp;
#ifndef CANNOT_DUMP
if (initialized)
-#endif
{
+#else
+ {
+ Vprocess_environment = Qnil;
+#endif
for (envp = environ; *envp; envp++)
Vprocess_environment = Fcons (build_string (*envp),
Vprocess_environment);
@@ -1682,10 +1665,8 @@ use.
See `setenv' and `getenv'. */);
Vprocess_environment = Qnil;
-#ifndef VMS
defsubr (&Scall_process);
defsubr (&Sgetenv_internal);
-#endif
defsubr (&Scall_process_region);
}