summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-01-29 05:26:21 +0000
committerRichard M. Stallman <rms@gnu.org>1996-01-29 05:26:21 +0000
commitc6fb3394c30bb5b1cc9e7b8ea25b46c05052fb9b (patch)
tree5d4aaed8b13d83378a798ec7692edb5b0a676e94 /lisp
parent37a3133f34a251bb345f67983c9e0a5fca021183 (diff)
downloademacs-c6fb3394c30bb5b1cc9e7b8ea25b46c05052fb9b.tar.gz
(c-macro-preprocessor): Define a preprocessor name
which is valid on MS-DOS. (c-macro-expansion): Do not rely on ``/tmp/'' being present; use environment variables as alternatives (MSDOS). Use `shell-file-name' rather than ``sh''. Redirect `stderr' with `call-process-region' option, not from the shell. Handle shells which don't return exit code from `cpp' (MSDOS). Put messages from `cpp' inside a comment, to avoid messing up syntax highlighting.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/cmacexp.el37
1 files changed, 27 insertions, 10 deletions
diff --git a/lisp/progmodes/cmacexp.el b/lisp/progmodes/cmacexp.el
index 0eaac943382..0a773404186 100644
--- a/lisp/progmodes/cmacexp.el
+++ b/lisp/progmodes/cmacexp.el
@@ -3,7 +3,7 @@
;; Copyright (C) 1992, 1994 Free Software Foundation, Inc.
;; Author: Francesco Potorti` <pot@cnuce.cnr.it>
-;; Version: $Id: cmacexp.el,v 1.20 1995/10/26 03:14:40 rms Exp erik $
+;; Version: $Id: cmacexp.el,v 1.21 1996/01/14 07:34:30 erik Exp rms $
;; Adapted-By: ESR
;; Keywords: c
@@ -96,7 +96,9 @@
(defvar c-macro-prompt-flag nil
"*Non-nil makes `c-macro-expand' prompt for preprocessor arguments.")
-(defvar c-macro-preprocessor "/lib/cpp -C"
+(defvar c-macro-preprocessor
+ ;; Cannot rely on standard directory on MS-DOS to find CPP.
+ (if (eq system-type 'ms-dos) "cpp -C" "/lib/cpp -C")
"The preprocessor used by the cmacexp package.
If you change this, be sure to preserve the `-C' (don't strip comments)
@@ -244,7 +246,8 @@ Optional arg DISPLAY non-nil means show messages in the echo area."
(startstat ())
(startmarker "")
(exit-status 0)
- (tempname (make-temp-name "/tmp/")))
+ (tempname (make-temp-name (or (getenv "TMPDIR") (getenv "TEMP")
+ (getenv "TMP") "/tmp/"))))
(unwind-protect
(save-excursion
(save-restriction
@@ -306,8 +309,10 @@ Optional arg DISPLAY non-nil means show messages in the echo area."
;; Call the preprocessor.
(if display (message mymsg))
(setq exit-status
- (call-process-region 1 (point-max) "sh" t t nil "-c"
- (concat cppcommand " 2>" tempname)))
+ (call-process-region 1 (point-max)
+ shell-file-name
+ t (list t tempname) nil "-c"
+ cppcommand))
(if display (message (concat mymsg "done")))
(if (= (buffer-size) 0)
;; Empty output is normal after a fatal error.
@@ -326,13 +331,25 @@ Optional arg DISPLAY non-nil means show messages in the echo area."
(delete-region beg (point))))
;; If CPP got errors, show them at the beginning.
- (or (eq exit-status 0)
+ ;; MS-DOS shells don't return the exit code of their children.
+ ;; Look at the size of the error message file instead, but
+ ;; don't punish those MS-DOS users who have a shell that does
+ ;; return an error code.
+ (or (and (or (not (boundp 'msdos-shells))
+ (not (member (file-name-nondirectory shell-file-name)
+ msdos-shells)))
+ (eq exit-status 0))
+ (zerop (nth 7 (file-attributes (expand-file-name tempname))))
(progn
(goto-char (point-min))
- (insert (format "Preprocessor terminated with status %s\n"
- exit-status))
- (insert-file-contents tempname)
- (insert "\n")))
+ ;; Put the messages inside a comment, so they won't get in
+ ;; the way of font-lock, highlighting etc.
+ (insert
+ (format "/* Preprocessor terminated with status %s\n\n Messages from `%s\':\n\n"
+ exit-status cppcommand))
+ (goto-char (+ (point)
+ (nth 1 (insert-file-contents tempname))))
+ (insert "\n\n*/\n")))
(delete-file tempname)
;; Compute the return value, keeping in account the space