diff options
| author | Eli Zaretskii | 2011-05-07 14:28:55 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2011-05-07 14:28:55 +0300 |
| commit | 0966ef96e7b63f3f85244f28b8c36c846c420e3b (patch) | |
| tree | 6c1813798603eec60283fd9ed209f82f448ebc5a /src | |
| parent | 7ef1d634067b0edbc126fa25afdf600d5482e403 (diff) | |
| parent | 888c9e865f8c9faea62621519da7e42ba1b7adbf (diff) | |
| download | emacs-0966ef96e7b63f3f85244f28b8c36c846c420e3b.tar.gz emacs-0966ef96e7b63f3f85244f28b8c36c846c420e3b.zip | |
Adapt the MS-DOS build to latest changes.
src/callproc.c (call_process_cleanup): Don't close and unlink the
temporary file if Fcall_process didn't create it in the first
place.
(Fcall_process): Don't create tempfile if stdout of the child
process will be redirected to a file specified with `:file'.
Don't try to re-open tempfile in that case, and set fd[0] to -1 as
cue to call_process_cleanup not to close that handle.
msdos/inttypes.h: Include stdint.h.
(uintmax_t): Don't define, it is defined in stdint.h.
msdos/sedlibmk.inp (am__append_1): Edit to comment out.
(am__append_2): Edit to expose.
(NEXT_AS_FIRST_DIRECTIVE_STDARG_H, NEXT_STDARG_H, STDARG_H): Edit
to empty.
(@GL_GENERATE_STDARG_H_TRUE@, @GL_GENERATE_STDARG_H_FALSE@): Edit
to comment out corresponding lines.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/callproc.c | 60 |
2 files changed, 46 insertions, 24 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 199c270a018..394b7a172f5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2011-05-07 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * callproc.c (call_process_cleanup): Don't close and unlink the | ||
| 4 | temporary file if Fcall_process didn't create it in the first | ||
| 5 | place. | ||
| 6 | (Fcall_process): Don't create tempfile if stdout of the child | ||
| 7 | process will be redirected to a file specified with `:file'. | ||
| 8 | Don't try to re-open tempfile in that case, and set fd[0] to -1 as | ||
| 9 | cue to call_process_cleanup not to close that handle. | ||
| 10 | |||
| 1 | 2011-05-07 Ben Key <bkey76@gmail.com> | 11 | 2011-05-07 Ben Key <bkey76@gmail.com> |
| 2 | 12 | ||
| 3 | * makefile.w32-in: The bootstrap-temacs rule now makes use of | 13 | * makefile.w32-in: The bootstrap-temacs rule now makes use of |
diff --git a/src/callproc.c b/src/callproc.c index 946670320ca..a966a26b938 100644 --- a/src/callproc.c +++ b/src/callproc.c | |||
| @@ -114,6 +114,7 @@ call_process_cleanup (Lisp_Object arg) | |||
| 114 | Lisp_Object fdpid = Fcdr (arg); | 114 | Lisp_Object fdpid = Fcdr (arg); |
| 115 | #if defined (MSDOS) | 115 | #if defined (MSDOS) |
| 116 | Lisp_Object file; | 116 | Lisp_Object file; |
| 117 | int fd; | ||
| 117 | #else | 118 | #else |
| 118 | int pid; | 119 | int pid; |
| 119 | #endif | 120 | #endif |
| @@ -122,9 +123,13 @@ call_process_cleanup (Lisp_Object arg) | |||
| 122 | 123 | ||
| 123 | #if defined (MSDOS) | 124 | #if defined (MSDOS) |
| 124 | /* for MSDOS fdpid is really (fd . tempfile) */ | 125 | /* for MSDOS fdpid is really (fd . tempfile) */ |
| 126 | fd = XFASTINT (Fcar (fdpid)); | ||
| 125 | file = Fcdr (fdpid); | 127 | file = Fcdr (fdpid); |
| 126 | emacs_close (XFASTINT (Fcar (fdpid))); | 128 | /* FD is -1 and FILE is "" when we didn't actually create a |
| 127 | if (strcmp (SDATA (file), NULL_DEVICE) != 0) | 129 | temporary file in call-process. */ |
| 130 | if (fd >= 0) | ||
| 131 | emacs_close (fd); | ||
| 132 | if (!(strcmp (SDATA (file), NULL_DEVICE) == 0 || SREF (file, 0) == '\0')) | ||
| 128 | unlink (SDATA (file)); | 133 | unlink (SDATA (file)); |
| 129 | #else /* not MSDOS */ | 134 | #else /* not MSDOS */ |
| 130 | pid = XFASTINT (Fcdr (fdpid)); | 135 | pid = XFASTINT (Fcdr (fdpid)); |
| @@ -199,7 +204,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 199 | Lisp_Object error_file; | 204 | Lisp_Object error_file; |
| 200 | Lisp_Object output_file = Qnil; | 205 | Lisp_Object output_file = Qnil; |
| 201 | #ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */ | 206 | #ifdef MSDOS /* Demacs 1.1.1 91/10/16 HIRANO Satoshi */ |
| 202 | char *outf, *tempfile; | 207 | char *outf, *tempfile = NULL; |
| 203 | int outfilefd; | 208 | int outfilefd; |
| 204 | #endif | 209 | #endif |
| 205 | int fd_output = -1; | 210 | int fd_output = -1; |
| @@ -439,22 +444,23 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 439 | new_argv[0] = SDATA (path); | 444 | new_argv[0] = SDATA (path); |
| 440 | 445 | ||
| 441 | #ifdef MSDOS /* MW, July 1993 */ | 446 | #ifdef MSDOS /* MW, July 1993 */ |
| 442 | if ((outf = egetenv ("TMPDIR"))) | ||
| 443 | strcpy (tempfile = alloca (strlen (outf) + 20), outf); | ||
| 444 | else | ||
| 445 | { | ||
| 446 | tempfile = alloca (20); | ||
| 447 | *tempfile = '\0'; | ||
| 448 | } | ||
| 449 | dostounix_filename (tempfile); | ||
| 450 | if (*tempfile == '\0' || tempfile[strlen (tempfile) - 1] != '/') | ||
| 451 | strcat (tempfile, "/"); | ||
| 452 | strcat (tempfile, "detmp.XXX"); | ||
| 453 | mktemp (tempfile); | ||
| 454 | 447 | ||
| 455 | /* If we're redirecting STDOUT to a file, this is already opened. */ | 448 | /* If we're redirecting STDOUT to a file, that file is already open |
| 449 | on fd_output. */ | ||
| 456 | if (fd_output < 0) | 450 | if (fd_output < 0) |
| 457 | { | 451 | { |
| 452 | if ((outf = egetenv ("TMPDIR"))) | ||
| 453 | strcpy (tempfile = alloca (strlen (outf) + 20), outf); | ||
| 454 | else | ||
| 455 | { | ||
| 456 | tempfile = alloca (20); | ||
| 457 | *tempfile = '\0'; | ||
| 458 | } | ||
| 459 | dostounix_filename (tempfile); | ||
| 460 | if (*tempfile == '\0' || tempfile[strlen (tempfile) - 1] != '/') | ||
| 461 | strcat (tempfile, "/"); | ||
| 462 | strcat (tempfile, "detmp.XXX"); | ||
| 463 | mktemp (tempfile); | ||
| 458 | outfilefd = creat (tempfile, S_IREAD | S_IWRITE); | 464 | outfilefd = creat (tempfile, S_IREAD | S_IWRITE); |
| 459 | if (outfilefd < 0) { | 465 | if (outfilefd < 0) { |
| 460 | emacs_close (filefd); | 466 | emacs_close (filefd); |
| @@ -561,15 +567,21 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 561 | if (fd_error != outfilefd) | 567 | if (fd_error != outfilefd) |
| 562 | emacs_close (fd_error); | 568 | emacs_close (fd_error); |
| 563 | fd1 = -1; /* No harm in closing that one! */ | 569 | fd1 = -1; /* No harm in closing that one! */ |
| 564 | /* Since CRLF is converted to LF within `decode_coding', we can | 570 | if (tempfile) |
| 565 | always open a file with binary mode. */ | ||
| 566 | fd[0] = emacs_open (tempfile, O_RDONLY | O_BINARY, 0); | ||
| 567 | if (fd[0] < 0) | ||
| 568 | { | 571 | { |
| 569 | unlink (tempfile); | 572 | /* Since CRLF is converted to LF within `decode_coding', we |
| 570 | emacs_close (filefd); | 573 | can always open a file with binary mode. */ |
| 571 | report_file_error ("Cannot re-open temporary file", Qnil); | 574 | fd[0] = emacs_open (tempfile, O_RDONLY | O_BINARY, 0); |
| 575 | if (fd[0] < 0) | ||
| 576 | { | ||
| 577 | unlink (tempfile); | ||
| 578 | emacs_close (filefd); | ||
| 579 | report_file_error ("Cannot re-open temporary file", | ||
| 580 | Fcons (tempfile, Qnil)); | ||
| 581 | } | ||
| 572 | } | 582 | } |
| 583 | else | ||
| 584 | fd[0] = -1; /* We are not going to read from tempfile. */ | ||
| 573 | #else /* not MSDOS */ | 585 | #else /* not MSDOS */ |
| 574 | #ifdef WINDOWSNT | 586 | #ifdef WINDOWSNT |
| 575 | pid = child_setup (filefd, fd1, fd_error, (char **) new_argv, | 587 | pid = child_setup (filefd, fd1, fd_error, (char **) new_argv, |
| @@ -676,7 +688,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) | |||
| 676 | record_unwind_protect (call_process_cleanup, | 688 | record_unwind_protect (call_process_cleanup, |
| 677 | Fcons (Fcurrent_buffer (), | 689 | Fcons (Fcurrent_buffer (), |
| 678 | Fcons (make_number (fd[0]), | 690 | Fcons (make_number (fd[0]), |
| 679 | build_string (tempfile)))); | 691 | build_string (tempfile ? tempfile : "")))); |
| 680 | #else | 692 | #else |
| 681 | record_unwind_protect (call_process_cleanup, | 693 | record_unwind_protect (call_process_cleanup, |
| 682 | Fcons (Fcurrent_buffer (), | 694 | Fcons (Fcurrent_buffer (), |