diff options
| author | Richard M. Stallman | 1996-01-29 05:26:21 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-01-29 05:26:21 +0000 |
| commit | 68dff3ca9ce655658060e3b2da2936c67effb79d (patch) | |
| tree | e2642c11c71c1b496c22b47b7771a44254e5d292 | |
| parent | b962d6c6ab44a0b911494aaea6d661401be3ed20 (diff) | |
| download | emacs-68dff3ca9ce655658060e3b2da2936c67effb79d.tar.gz emacs-68dff3ca9ce655658060e3b2da2936c67effb79d.zip | |
(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.
| -rw-r--r-- | lisp/progmodes/cmacexp.el | 37 |
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 @@ | |||
| 3 | ;; Copyright (C) 1992, 1994 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1992, 1994 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Francesco Potorti` <pot@cnuce.cnr.it> | 5 | ;; Author: Francesco Potorti` <pot@cnuce.cnr.it> |
| 6 | ;; Version: $Id: cmacexp.el,v 1.20 1995/10/26 03:14:40 rms Exp erik $ | 6 | ;; Version: $Id: cmacexp.el,v 1.21 1996/01/14 07:34:30 erik Exp rms $ |
| 7 | ;; Adapted-By: ESR | 7 | ;; Adapted-By: ESR |
| 8 | ;; Keywords: c | 8 | ;; Keywords: c |
| 9 | 9 | ||
| @@ -96,7 +96,9 @@ | |||
| 96 | (defvar c-macro-prompt-flag nil | 96 | (defvar c-macro-prompt-flag nil |
| 97 | "*Non-nil makes `c-macro-expand' prompt for preprocessor arguments.") | 97 | "*Non-nil makes `c-macro-expand' prompt for preprocessor arguments.") |
| 98 | 98 | ||
| 99 | (defvar c-macro-preprocessor "/lib/cpp -C" | 99 | (defvar c-macro-preprocessor |
| 100 | ;; Cannot rely on standard directory on MS-DOS to find CPP. | ||
| 101 | (if (eq system-type 'ms-dos) "cpp -C" "/lib/cpp -C") | ||
| 100 | "The preprocessor used by the cmacexp package. | 102 | "The preprocessor used by the cmacexp package. |
| 101 | 103 | ||
| 102 | If you change this, be sure to preserve the `-C' (don't strip comments) | 104 | 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." | |||
| 244 | (startstat ()) | 246 | (startstat ()) |
| 245 | (startmarker "") | 247 | (startmarker "") |
| 246 | (exit-status 0) | 248 | (exit-status 0) |
| 247 | (tempname (make-temp-name "/tmp/"))) | 249 | (tempname (make-temp-name (or (getenv "TMPDIR") (getenv "TEMP") |
| 250 | (getenv "TMP") "/tmp/")))) | ||
| 248 | (unwind-protect | 251 | (unwind-protect |
| 249 | (save-excursion | 252 | (save-excursion |
| 250 | (save-restriction | 253 | (save-restriction |
| @@ -306,8 +309,10 @@ Optional arg DISPLAY non-nil means show messages in the echo area." | |||
| 306 | ;; Call the preprocessor. | 309 | ;; Call the preprocessor. |
| 307 | (if display (message mymsg)) | 310 | (if display (message mymsg)) |
| 308 | (setq exit-status | 311 | (setq exit-status |
| 309 | (call-process-region 1 (point-max) "sh" t t nil "-c" | 312 | (call-process-region 1 (point-max) |
| 310 | (concat cppcommand " 2>" tempname))) | 313 | shell-file-name |
| 314 | t (list t tempname) nil "-c" | ||
| 315 | cppcommand)) | ||
| 311 | (if display (message (concat mymsg "done"))) | 316 | (if display (message (concat mymsg "done"))) |
| 312 | (if (= (buffer-size) 0) | 317 | (if (= (buffer-size) 0) |
| 313 | ;; Empty output is normal after a fatal error. | 318 | ;; Empty output is normal after a fatal error. |
| @@ -326,13 +331,25 @@ Optional arg DISPLAY non-nil means show messages in the echo area." | |||
| 326 | (delete-region beg (point)))) | 331 | (delete-region beg (point)))) |
| 327 | 332 | ||
| 328 | ;; If CPP got errors, show them at the beginning. | 333 | ;; If CPP got errors, show them at the beginning. |
| 329 | (or (eq exit-status 0) | 334 | ;; MS-DOS shells don't return the exit code of their children. |
| 335 | ;; Look at the size of the error message file instead, but | ||
| 336 | ;; don't punish those MS-DOS users who have a shell that does | ||
| 337 | ;; return an error code. | ||
| 338 | (or (and (or (not (boundp 'msdos-shells)) | ||
| 339 | (not (member (file-name-nondirectory shell-file-name) | ||
| 340 | msdos-shells))) | ||
| 341 | (eq exit-status 0)) | ||
| 342 | (zerop (nth 7 (file-attributes (expand-file-name tempname)))) | ||
| 330 | (progn | 343 | (progn |
| 331 | (goto-char (point-min)) | 344 | (goto-char (point-min)) |
| 332 | (insert (format "Preprocessor terminated with status %s\n" | 345 | ;; Put the messages inside a comment, so they won't get in |
| 333 | exit-status)) | 346 | ;; the way of font-lock, highlighting etc. |
| 334 | (insert-file-contents tempname) | 347 | (insert |
| 335 | (insert "\n"))) | 348 | (format "/* Preprocessor terminated with status %s\n\n Messages from `%s\':\n\n" |
| 349 | exit-status cppcommand)) | ||
| 350 | (goto-char (+ (point) | ||
| 351 | (nth 1 (insert-file-contents tempname)))) | ||
| 352 | (insert "\n\n*/\n"))) | ||
| 336 | (delete-file tempname) | 353 | (delete-file tempname) |
| 337 | 354 | ||
| 338 | ;; Compute the return value, keeping in account the space | 355 | ;; Compute the return value, keeping in account the space |