diff options
| author | Richard M. Stallman | 1994-08-07 17:23:44 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-08-07 17:23:44 +0000 |
| commit | 440c10f88247685c80bcc28beca94c197adeb912 (patch) | |
| tree | 2d7183504db2ea69a2ccf7b266816ad6da67e2ca | |
| parent | da6aae60a479603fbe762d14409492fba6a3e10a (diff) | |
| download | emacs-440c10f88247685c80bcc28beca94c197adeb912.tar.gz emacs-440c10f88247685c80bcc28beca94c197adeb912.zip | |
Doc fixes.
(c-macro-expansion): Capture and display CPP error messages.
| -rw-r--r-- | lisp/progmodes/cmacexp.el | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/lisp/progmodes/cmacexp.el b/lisp/progmodes/cmacexp.el index 6c615c4d996..daaa0109bb0 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.13 1994/04/21 18:40:14 rms Exp kwzh $ | 6 | ;; Version: $Id: cmacexp.el,v 1.14 1994/05/03 22:17:03 kwzh Exp rms $ |
| 7 | ;; Adapted-By: ESR | 7 | ;; Adapted-By: ESR |
| 8 | ;; Keywords: c | 8 | ;; Keywords: c |
| 9 | 9 | ||
| @@ -96,11 +96,11 @@ | |||
| 96 | (defvar c-macro-preprocessor "/lib/cpp -C" | 96 | (defvar c-macro-preprocessor "/lib/cpp -C" |
| 97 | "The preprocessor used by the cmacexp package. | 97 | "The preprocessor used by the cmacexp package. |
| 98 | 98 | ||
| 99 | If you change this, be sure to preserve the -C (don't strip comments) | 99 | If you change this, be sure to preserve the `-C' (don't strip comments) |
| 100 | option, or to set an equivalent one.") | 100 | option, or to set an equivalent one.") |
| 101 | 101 | ||
| 102 | (defvar c-macro-cppflags "" | 102 | (defvar c-macro-cppflags "" |
| 103 | "*Preprocessor flags used by c-macro-expand.") | 103 | "*Preprocessor flags used by `c-macro-expand'.") |
| 104 | 104 | ||
| 105 | (defconst c-macro-buffer-name "*Macroexpansion*") | 105 | (defconst c-macro-buffer-name "*Macroexpansion*") |
| 106 | 106 | ||
| @@ -239,7 +239,8 @@ Optional arg DISPLAY non-nil means show messages in the echo area." | |||
| 239 | (startlinenum 0) | 239 | (startlinenum 0) |
| 240 | (linenum 0) | 240 | (linenum 0) |
| 241 | (startstat ()) | 241 | (startstat ()) |
| 242 | (startmarker "")) | 242 | (startmarker "") |
| 243 | (tempname (make-temp-name "/tmp/"))) | ||
| 243 | (unwind-protect | 244 | (unwind-protect |
| 244 | (save-excursion | 245 | (save-excursion |
| 245 | (save-restriction | 246 | (save-restriction |
| @@ -300,10 +301,10 @@ Optional arg DISPLAY non-nil means show messages in the echo area." | |||
| 300 | 301 | ||
| 301 | ;; Call the preprocessor. | 302 | ;; Call the preprocessor. |
| 302 | (if display (message mymsg)) | 303 | (if display (message mymsg)) |
| 303 | (call-process-region 1 (point-max) "sh" t t nil "-c" | 304 | (setq exit-status |
| 304 | (concat cppcommand " 2>/dev/null")) | 305 | (call-process-region 1 (point-max) "sh" t t nil "-c" |
| 306 | (concat cppcommand " 2>" tempname))) | ||
| 305 | (if display (message (concat mymsg "done"))) | 307 | (if display (message (concat mymsg "done"))) |
| 306 | |||
| 307 | ;; Find and delete the mark of the start of the expansion. | 308 | ;; Find and delete the mark of the start of the expansion. |
| 308 | ;; Look for `# nn "file.c"' lines and delete them. | 309 | ;; Look for `# nn "file.c"' lines and delete them. |
| 309 | (goto-char (point-min)) | 310 | (goto-char (point-min)) |
| @@ -317,6 +318,16 @@ Optional arg DISPLAY non-nil means show messages in the echo area." | |||
| 317 | (forward-line 1) | 318 | (forward-line 1) |
| 318 | (delete-region beg (point)))) | 319 | (delete-region beg (point)))) |
| 319 | 320 | ||
| 321 | ;; If CPP got errors, show them at the beginning. | ||
| 322 | (or (eq exit-status 0) | ||
| 323 | (progn | ||
| 324 | (goto-char (point-min)) | ||
| 325 | (insert (format "Preprocessor terminated with status %s\n" | ||
| 326 | exit-status)) | ||
| 327 | (insert-file-contents tempname) | ||
| 328 | (insert "\n"))) | ||
| 329 | (delete-file tempname) | ||
| 330 | |||
| 320 | ;; Compute the return value, keeping in account the space | 331 | ;; Compute the return value, keeping in account the space |
| 321 | ;; inserted at the end of the buffer. | 332 | ;; inserted at the end of the buffer. |
| 322 | (buffer-substring 1 (max 1 (- (point-max) 1)))) | 333 | (buffer-substring 1 (max 1 (- (point-max) 1)))) |