comparison lisp/emacs-lisp/check-declare.el @ 86302:9525bd421fdb

(check-declare-verify): Fix previous change. Warn if could not find an arglist to check.
author Glenn Morris <rgm@gnu.org>
date Thu, 22 Nov 2007 06:53:24 +0000
parents 96fee69c65a2
children 79a4d6e44352
comparison
equal deleted inserted replaced
86301:447a37803114 86302:9525bd421fdb
106 (skip-chars-forward " \t\n") 106 (skip-chars-forward " \t\n")
107 (setq fn (match-string 2) 107 (setq fn (match-string 2)
108 ;; (min . max) for a fixed number of arguments, or 108 ;; (min . max) for a fixed number of arguments, or
109 ;; arglists with optional elements. 109 ;; arglists with optional elements.
110 ;; (min) for arglists with &rest. 110 ;; (min) for arglists with &rest.
111 ;; sig = 'err means we could not find an arglist.
111 sig (cond (cflag 112 sig (cond (cflag
112 (re-search-forward "," nil t 3) 113 (or
113 (skip-chars-forward " \t\n") 114 (when (re-search-forward "," nil t 3)
114 ;; Assuming minargs and maxargs on same line. 115 (skip-chars-forward " \t\n")
115 (when (looking-at "\\([0-9]+\\)[ \t]*,[ \t]*\ 116 ;; Assuming minargs and maxargs on same line.
117 (when (looking-at "\\([0-9]+\\)[ \t]*,[ \t]*\
116 \\([0-9]+\\|MANY\\|UNEVALLED\\)") 118 \\([0-9]+\\|MANY\\|UNEVALLED\\)")
117 (setq minargs (string-to-number (match-string 1)) 119 (setq minargs (string-to-number
118 maxargs (match-string 2)) 120 (match-string 1))
119 (cons minargs (unless (string-match "[^0-9]" 121 maxargs (match-string 2))
120 maxargs) 122 (cons minargs (unless (string-match "[^0-9]"
121 (string-to-number maxargs))))) 123 maxargs)
124 (string-to-number
125 maxargs)))))
126 'err))
122 ((string-equal (match-string 1) 127 ((string-equal (match-string 1)
123 "define-derived-mode") 128 "define-derived-mode")
124 '(0 . 0)) 129 '(0 . 0))
125 ((string-equal (match-string 1) 130 ((string-equal (match-string 1)
126 "define-minor-mode") 131 "define-minor-mode")
127 '(0 . 1)) 132 '(0 . 1))
128 ;; Can't easily check alias arguments. 133 ;; Can't easily check alias arguments.
129 ((string-equal (match-string 1) 134 ((string-equal (match-string 1)
130 "defalias") 135 "defalias")
131 t) 136 t)
137 ((looking-at "\\((\\|nil\\)")
138 (byte-compile-arglist-signature
139 (read (current-buffer))))
132 (t 140 (t
133 (if (looking-at "\\((\\|nil\\)") 141 'err))
134 (byte-compile-arglist-signature
135 (read (current-buffer))))))
136 ;; alist of functions and arglist signatures. 142 ;; alist of functions and arglist signatures.
137 siglist (cons (cons fn sig) siglist))))) 143 siglist (cons (cons fn sig) siglist)))))
138 (dolist (e fnlist) 144 (dolist (e fnlist)
139 (setq arglist (nth 2 e) 145 (setq arglist (nth 2 e)
140 type 146 type
141 (if re ; re non-nil means found a file 147 (if re ; re non-nil means found a file
142 (if (setq sig (assoc (cadr e) siglist)) 148 (if (setq sig (assoc (cadr e) siglist)) ; found function
143 ;; Recall we use t to mean no arglist specified, 149 ;; Recall we use t to mean no arglist specified,
144 ;; to distinguish from an empty arglist. 150 ;; to distinguish from an empty arglist.
145 (unless (or (eq arglist t) 151 (unless (eq arglist t)
146 (eq sig t)) 152 (setq sig (cdr-safe sig))
147 (unless (equal (byte-compile-arglist-signature arglist) 153 (cond ((eq sig t)) ; defalias, can't check
148 (cdr sig)) 154 ((eq sig 'err)
149 "arglist mismatch")) 155 "arglist not found") ; internal error
156 ((not (equal (byte-compile-arglist-signature
157 arglist)
158 sig))
159 "arglist mismatch")))
150 "function not found") 160 "function not found")
151 "file not found")) 161 "file not found"))
152 (when type 162 (when type
153 (setq errlist (cons (list (car e) (cadr e) type) errlist)))) 163 (setq errlist (cons (list (car e) (cadr e) type) errlist))))
154 (message "%s%s" m (if errlist "problems found" "OK")) 164 (message "%s%s" m (if errlist "problems found" "OK"))