comparison lisp/progmodes/compile.el @ 5605:fcf3556282dc

(compilation-error-regexp-alist): Add regexp for Lucid lcc. Element lists can now contain a 4th elt giving subexpr for the column. (next-error): Handle error records with column numbers. (compilation-parse-errors): Parse column numbers when the alist elt specifies it. Use string-to-int instead of read for numbers from buffer text.
author Roland McGrath <roland@gnu.org>
date Sun, 16 Jan 1994 09:10:58 +0000
parents e723f6be6239
children f600a46890d1
comparison
equal deleted inserted replaced
5604:32ac07bd58ef 5605:fcf3556282dc
151 ;; ****** Error number 140 in line 8 of file errors.c ****** 151 ;; ****** Error number 140 in line 8 of file errors.c ******
152 ("in line \\([0-9]+\\) of file \\([^ \n]+[^. \n]\\)\\.? " 2 1) 152 ("in line \\([0-9]+\\) of file \\([^ \n]+[^. \n]\\)\\.? " 2 1)
153 ;; IBM AIX lint is too painful to do right this way. File name 153 ;; IBM AIX lint is too painful to do right this way. File name
154 ;; prefixes entire sections rather than being on each line. 154 ;; prefixes entire sections rather than being on each line.
155 155
156 ;; Lucid Compiler, lcc 3.x
157 ;; E, file.cc(35,52) Illegal operation on pointers
158 ("[A-Z], \\([^(]*\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)" 1 2 3)
159
156 ) 160 )
157 "Alist that specifies how to match errors in compiler output. 161 "Alist that specifies how to match errors in compiler output.
158 Each element has the form (REGEXP FILE-IDX LINE-IDX). 162 Each element has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX]).
159 If REGEXP matches, the FILE-IDX'th subexpression gives the file 163 If REGEXP matches, the FILE-IDX'th subexpression gives the file name, and
160 name, and the LINE-IDX'th subexpression gives the line number.") 164 the LINE-IDX'th subexpression gives the line number. If COLUMN-IDX is
165 given, the COLUMN-IDX'th subexpression gives the column number on that line."
161 166
162 (defvar compilation-read-command t 167 (defvar compilation-read-command t
163 "If not nil, M-x compile reads the compilation command to use. 168 "If not nil, M-x compile reads the compilation command to use.
164 Otherwise, M-x compile just uses the value of `compile-command'.") 169 Otherwise, M-x compile just uses the value of `compile-command'.")
165 170
833 ;; We found the file. Get a marker for this error. 838 ;; We found the file. Get a marker for this error.
834 ;; compilation-old-error-list is a buffer-local 839 ;; compilation-old-error-list is a buffer-local
835 ;; variable, so we must be careful to extract its value 840 ;; variable, so we must be careful to extract its value
836 ;; before switching to the source file buffer. 841 ;; before switching to the source file buffer.
837 (let ((errors compilation-old-error-list) 842 (let ((errors compilation-old-error-list)
838 (last-line (cdr (cdr next-error)))) 843 (last-line (nth 1 (cdr next-error)))
844 (column (nth 2 (cdr next-error))))
839 (set-buffer buffer) 845 (set-buffer buffer)
840 (save-excursion 846 (save-excursion
841 (save-restriction 847 (save-restriction
842 (widen) 848 (widen)
843 (goto-line last-line) 849 (goto-line last-line)
844 (beginning-of-line) 850 (if column
851 (move-to-column column)
852 (beginning-of-line))
845 (setcdr next-error (point-marker)) 853 (setcdr next-error (point-marker))
846 ;; Make all the other error messages referring 854 ;; Make all the other error messages referring
847 ;; to the same file have markers into the buffer. 855 ;; to the same file have markers into the buffer.
848 (while errors 856 (while errors
849 (and (consp (cdr (car errors))) 857 (and (consp (cdr (car errors)))
850 (equal (car (cdr (car errors))) fileinfo) 858 (equal (car (cdr (car errors))) fileinfo)
851 (let ((this (cdr (cdr (car errors)))) 859 (let* ((this (nth 1 (cdr (car errors))))
852 (lines (- (cdr (cdr (car errors))) 860 (column (nth 2 (cdr (car errors))))
853 last-line))) 861 (lines (- this last-line)))
854 (if (eq selective-display t) 862 (if (eq selective-display t)
863 ;; When selective-display is t,
864 ;; each C-m is a line boundary,
865 ;; as well as each newline.
855 (if (< lines 0) 866 (if (< lines 0)
856 (re-search-backward "[\n\C-m]" 867 (re-search-backward "[\n\C-m]"
857 nil 'end 868 nil 'end
858 (- lines)) 869 (- lines))
859 (re-search-forward "[\n\C-m]" 870 (re-search-forward "[\n\C-m]"
860 nil 'end 871 nil 'end
861 lines)) 872 lines))
862 (forward-line lines)) 873 (forward-line lines))
874 (if column
875 (move-to-column column))
863 (setq last-line this) 876 (setq last-line this)
864 (setcdr (car errors) (point-marker)))) 877 (setcdr (car errors) (point-marker))))
865 (setq errors (cdr errors))))))))) 878 (setq errors (cdr errors)))))))))
866 ;; If we didn't get a marker for this error, 879 ;; If we didn't get a marker for this error,
867 ;; go on to the next one. 880 ;; go on to the next one.
1012 error-group (+ leave-group 1025 error-group (+ leave-group
1013 (count-regexp-groupings 1026 (count-regexp-groupings
1014 compilation-leave-directory-regexp) 1027 compilation-leave-directory-regexp)
1015 1)) 1028 1))
1016 1029
1017 ;; Compile an alist (IDX FILE LINE), where IDX is the number of the 1030 ;; Compile an alist (IDX FILE LINE [COL]), where IDX is the number of
1018 ;; subexpression for an entire error-regexp, and FILE and LINE are the 1031 ;; the subexpression for an entire error-regexp, and FILE and LINE (and
1019 ;; numbers for the subexpressions giving the file name and line number. 1032 ;; possibly COL) are the numbers for the subexpressions giving the file
1033 ;; name and line number (and possibly column number).
1020 (setq alist (or compilation-error-regexp-alist 1034 (setq alist (or compilation-error-regexp-alist
1021 (error "compilation-error-regexp-alist is empty!")) 1035 (error "compilation-error-regexp-alist is empty!"))
1022 subexpr (1+ error-group)) 1036 subexpr (1+ error-group))
1023 (while alist 1037 (while alist
1024 (setq error-regexp-groups (cons (list subexpr 1038 (setq error-regexp-groups
1025 (+ subexpr (nth 1 (car alist))) 1039 (cons (list subexpr
1026 (+ subexpr (nth 2 (car alist)))) 1040 (+ subexpr (nth 1 (car alist)))
1027 error-regexp-groups)) 1041 (+ subexpr (nth 2 (car alist)))
1042 (and (nth 2 (car alist))
1043 (+ subexpr (nth 2 (car alist)))))
1044 error-regexp-groups))
1028 (setq subexpr (+ subexpr 1 (count-regexp-groupings (car (car alist))))) 1045 (setq subexpr (+ subexpr 1 (count-regexp-groupings (car (car alist)))))
1029 (setq alist (cdr alist))) 1046 (setq alist (cdr alist)))
1030 1047
1031 (setq orig default-directory) 1048 (setq orig default-directory)
1032 (setq orig-expanded (file-truename orig)) 1049 (setq orig-expanded (file-truename orig))
1114 1131
1115 ;; Extract the file name and line number from the error message. 1132 ;; Extract the file name and line number from the error message.
1116 (let ((beginning-of-match (match-beginning 0)) ;looking-at nukes 1133 (let ((beginning-of-match (match-beginning 0)) ;looking-at nukes
1117 (filename (buffer-substring (match-beginning (nth 1 alist)) 1134 (filename (buffer-substring (match-beginning (nth 1 alist))
1118 (match-end (nth 1 alist)))) 1135 (match-end (nth 1 alist))))
1119 (linenum (save-restriction 1136 (linenum (string-to-int
1120 (narrow-to-region 1137 (buffer-substring
1121 (match-beginning (nth 2 alist)) 1138 (match-beginning (nth 2 alist))
1122 (match-end (nth 2 alist))) 1139 (match-end (nth 2 alist)))))
1123 (goto-char (point-min)) 1140 (column (and (nth 3 alist)
1124 (if (looking-at "[0-9]") 1141 (string-to-int
1125 (read (current-buffer)))))) 1142 (buffer-substring
1143 (match-beginning (nth 3 alist))
1144 (match-end (nth 3 alist)))))))
1145
1126 ;; Check for a comint-file-name-prefix and prepend it if 1146 ;; Check for a comint-file-name-prefix and prepend it if
1127 ;; appropriate. (This is very useful for 1147 ;; appropriate. (This is very useful for
1128 ;; compilation-minor-mode in an rlogin-mode buffer.) 1148 ;; compilation-minor-mode in an rlogin-mode buffer.)
1129 (and (boundp 'comint-file-name-prefix) 1149 (and (boundp 'comint-file-name-prefix)
1130 ;; If the file name is relative, default-directory will 1150 ;; If the file name is relative, default-directory will
1139 ;; giving a marker for the current compilation buffer 1159 ;; giving a marker for the current compilation buffer
1140 ;; location, and the file and line number of the error. 1160 ;; location, and the file and line number of the error.
1141 (save-excursion 1161 (save-excursion
1142 (beginning-of-line 1) 1162 (beginning-of-line 1)
1143 (let ((this (cons (point-marker) 1163 (let ((this (cons (point-marker)
1144 (cons filename linenum)))) 1164 (cons filename linenum column))))
1145 ;; Don't add the same source line more than once. 1165 ;; Don't add the same source line more than once.
1146 (if (equal (cdr this) (cdr (car compilation-error-list))) 1166 (if (equal (cdr this) (cdr (car compilation-error-list)))
1147 nil 1167 nil
1148 (setq compilation-error-list 1168 (setq compilation-error-list
1149 (cons this 1169 (cons this