From: Richard M. Stallman Date: Mon, 29 Jan 1996 05:26:21 +0000 (+0000) Subject: (c-macro-preprocessor): Define a preprocessor name X-Git-Tag: emacs-19.34~1452 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=68dff3ca9ce655658060e3b2da2936c67effb79d;p=emacs.git (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. --- 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` -;; 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