aboutsummaryrefslogtreecommitdiffstats
path: root/src/callproc.c
diff options
context:
space:
mode:
authorChong Yidong2009-01-30 05:17:33 +0000
committerChong Yidong2009-01-30 05:17:33 +0000
commitf92d51d84e3d79798ef23bb59934e08aa29fd60a (patch)
tree75ddebea6275ef997035c5637a34e7bdf2a30092 /src/callproc.c
parenta8b11cc93bf96152c2723d89c2a57222366bd39b (diff)
downloademacs-f92d51d84e3d79798ef23bb59934e08aa29fd60a.tar.gz
emacs-f92d51d84e3d79798ef23bb59934e08aa29fd60a.zip
(Vtemp_file_name_pattern): Remove DEFVAR_LISP.
Initialize it as a relative filename pattern. (init_callproc): Don't initialize Vtemp_file_name_pattern here. (Fcall_process_region): Simplify temp file creation using temporary-file-directory.
Diffstat (limited to 'src/callproc.c')
-rw-r--r--src/callproc.c74
1 files changed, 34 insertions, 40 deletions
diff --git a/src/callproc.c b/src/callproc.c
index e84c0c64148..316740391ed 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -104,7 +104,11 @@ extern char **environ;
104Lisp_Object Vexec_path, Vexec_directory, Vexec_suffixes; 104Lisp_Object Vexec_path, Vexec_directory, Vexec_suffixes;
105Lisp_Object Vdata_directory, Vdoc_directory; 105Lisp_Object Vdata_directory, Vdoc_directory;
106Lisp_Object Vconfigure_info_directory, Vshared_game_score_directory; 106Lisp_Object Vconfigure_info_directory, Vshared_game_score_directory;
107Lisp_Object Vtemp_file_name_pattern; 107
108/* Pattern used by call-process-region to make temp files. */
109static Lisp_Object Vtemp_file_name_pattern;
110
111extern Lisp_Object Vtemporary_file_directory;
108 112
109Lisp_Object Vshell_file_name; 113Lisp_Object Vshell_file_name;
110 114
@@ -882,36 +886,32 @@ usage: (call-process-region START END PROGRAM &optional DELETE BUFFER DISPLAY &r
882 Lisp_Object coding_systems; 886 Lisp_Object coding_systems;
883 Lisp_Object val, *args2; 887 Lisp_Object val, *args2;
884 int i; 888 int i;
885#ifdef DOS_NT
886 char *tempfile; 889 char *tempfile;
887 char *outf = '\0'; 890 Lisp_Object tmpdir, pattern;
888 891
889 if ((outf = egetenv ("TMPDIR")) 892 if (STRINGP (Vtemporary_file_directory))
890 || (outf = egetenv ("TMP")) 893 tmpdir = Vtemporary_file_directory;
891 || (outf = egetenv ("TEMP")))
892 strcpy (tempfile = alloca (strlen (outf) + 20), outf);
893 else 894 else
894 { 895 {
895 tempfile = alloca (20); 896#ifndef DOS_NT
896 *tempfile = '\0'; 897 if (getenv ("TMPDIR"))
897 } 898 tmpdir = build_string (getenv ("TMPDIR"));
898 if (!IS_DIRECTORY_SEP (tempfile[strlen (tempfile) - 1])) 899 else
899 strcat (tempfile, "/"); 900 tmpdir = build_string ("/tmp/");
900 if ('/' == DIRECTORY_SEP) 901#else /* DOS_NT */
901 dostounix_filename (tempfile); 902 char *outf;
902 else 903 if ((outf = egetenv ("TMPDIR"))
903 unixtodos_filename (tempfile); 904 || (outf = egetenv ("TMP"))
904#ifdef WINDOWSNT 905 || (outf = egetenv ("TEMP")))
905 strcat (tempfile, "emXXXXXX"); 906 tmpdir = build_string (outf);
906#else 907 else
907 strcat (tempfile, "detmp.XXX"); 908 tmpdir = Ffile_name_as_directory (build_string ("c:/temp"));
908#endif 909#endif
909#else /* not DOS_NT */ 910 }
910 char *tempfile = (char *) alloca (SBYTES (Vtemp_file_name_pattern) + 1);
911 bcopy (SDATA (Vtemp_file_name_pattern), tempfile,
912 SBYTES (Vtemp_file_name_pattern) + 1);
913#endif /* not DOS_NT */
914 911
912 pattern = Fexpand_file_name (Vtemp_file_name_pattern, tmpdir);
913 tempfile = (char *) alloca (SBYTES (pattern) + 1);
914 bcopy (SDATA (pattern), tempfile, SBYTES (pattern) + 1);
915 coding_systems = Qt; 915 coding_systems = Qt;
916 916
917#ifdef HAVE_MKSTEMP 917#ifdef HAVE_MKSTEMP
@@ -1537,16 +1537,6 @@ init_callproc ()
1537 sh = (char *) getenv ("SHELL"); 1537 sh = (char *) getenv ("SHELL");
1538 Vshell_file_name = build_string (sh ? sh : "/bin/sh"); 1538 Vshell_file_name = build_string (sh ? sh : "/bin/sh");
1539 1539
1540 if (getenv ("TMPDIR"))
1541 {
1542 char *dir = getenv ("TMPDIR");
1543 Vtemp_file_name_pattern
1544 = Fexpand_file_name (build_string ("emacsXXXXXX"),
1545 build_string (dir));
1546 }
1547 else
1548 Vtemp_file_name_pattern = build_string ("/tmp/emacsXXXXXX");
1549
1550#ifdef DOS_NT 1540#ifdef DOS_NT
1551 Vshared_game_score_directory = Qnil; 1541 Vshared_game_score_directory = Qnil;
1552#else 1542#else
@@ -1584,6 +1574,15 @@ syms_of_callproc ()
1584 staticpro (&Qbuffer_file_type); 1574 staticpro (&Qbuffer_file_type);
1585#endif /* DOS_NT */ 1575#endif /* DOS_NT */
1586 1576
1577#ifndef DOS_NT
1578 Vtemp_file_name_pattern = build_string ("emacsXXXXXX");
1579#elif defined (WINDOWSNT)
1580 Vtemp_file_name_pattern = build_string ("emXXXXXX");
1581#else
1582 Vtemp_file_name_pattern = build_string ("detmp.XXX");
1583#endif
1584 staticpro (&Vtemp_file_name_pattern);
1585
1587 DEFVAR_LISP ("shell-file-name", &Vshell_file_name, 1586 DEFVAR_LISP ("shell-file-name", &Vshell_file_name,
1588 doc: /* *File name to load inferior shells from. 1587 doc: /* *File name to load inferior shells from.
1589Initialized from the SHELL environment variable, or to a system-dependent 1588Initialized from the SHELL environment variable, or to a system-dependent
@@ -1627,11 +1626,6 @@ If this variable is nil, then Emacs is unable to use a shared directory. */);
1627 Vshared_game_score_directory = build_string (PATH_GAME); 1626 Vshared_game_score_directory = build_string (PATH_GAME);
1628#endif 1627#endif
1629 1628
1630 DEFVAR_LISP ("temp-file-name-pattern", &Vtemp_file_name_pattern,
1631 doc: /* Pattern for making names for temporary files.
1632This is used by `call-process-region'. */);
1633 /* This variable is initialized in init_callproc. */
1634
1635 DEFVAR_LISP ("initial-environment", &Vinitial_environment, 1629 DEFVAR_LISP ("initial-environment", &Vinitial_environment,
1636 doc: /* List of environment variables inherited from the parent process. 1630 doc: /* List of environment variables inherited from the parent process.
1637Each element should be a string of the form ENVVARNAME=VALUE. 1631Each element should be a string of the form ENVVARNAME=VALUE.