changeset 8476:1a837ee93535

Doc fixes. (c-macro-expansion): Capture and display CPP error messages.
author Richard M. Stallman <rms@gnu.org>
date Sun, 07 Aug 1994 17:23:44 +0000
parents 77d5e055dce1
children f4aa7a288cb6
files lisp/progmodes/cmacexp.el
diffstat 1 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/cmacexp.el	Sun Aug 07 07:58:18 1994 +0000
+++ b/lisp/progmodes/cmacexp.el	Sun Aug 07 17:23:44 1994 +0000
@@ -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.13 1994/04/21 18:40:14 rms Exp kwzh $
+;; Version: $Id: cmacexp.el,v 1.14 1994/05/03 22:17:03 kwzh Exp rms $
 ;; Adapted-By: ESR
 ;; Keywords: c
 
@@ -96,11 +96,11 @@
 (defvar c-macro-preprocessor "/lib/cpp -C"
   "The preprocessor used by the cmacexp package.
 
-If you change this, be sure to preserve the -C (don't strip comments)
+If you change this, be sure to preserve the `-C' (don't strip comments)
 option, or to set an equivalent one.")
 
 (defvar c-macro-cppflags ""
-  "*Preprocessor flags used by c-macro-expand.")
+  "*Preprocessor flags used by `c-macro-expand'.")
 
 (defconst c-macro-buffer-name "*Macroexpansion*")
 
@@ -239,7 +239,8 @@
 	(startlinenum 0)
 	(linenum 0)
 	(startstat ())
-	(startmarker ""))
+	(startmarker "")
+	(tempname (make-temp-name "/tmp/")))
     (unwind-protect
 	(save-excursion
 	  (save-restriction
@@ -300,10 +301,10 @@
 
 	  ;; Call the preprocessor.
 	  (if display (message mymsg))
-	  (call-process-region 1 (point-max) "sh" t t nil "-c"
-			       (concat cppcommand " 2>/dev/null"))
+	  (setq exit-status
+		(call-process-region 1 (point-max) "sh" t t nil "-c"
+				     (concat cppcommand " 2>" tempname)))
 	  (if display (message (concat mymsg "done")))
-
 	  ;; Find and delete the mark of the start of the expansion.
 	  ;; Look for `# nn "file.c"' lines and delete them.
 	  (goto-char (point-min))
@@ -317,6 +318,16 @@
 	      (forward-line 1)
 	      (delete-region beg (point))))
 
+	  ;; If CPP got errors, show them at the beginning.
+	  (or (eq exit-status 0)
+	      (progn
+		(goto-char (point-min))
+		(insert (format "Preprocessor terminated with status %s\n"
+				exit-status))
+		(insert-file-contents tempname)
+		(insert "\n")))
+	  (delete-file tempname)
+
 	  ;; Compute the return value, keeping in account the space
 	  ;; inserted at the end of the buffer.
 	  (buffer-substring 1 (max 1 (- (point-max) 1))))