aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2009-10-01 02:02:39 +0000
committerGlenn Morris2009-10-01 02:02:39 +0000
commit787cc821c04a8c0f6a58461a17df3565d2b893c5 (patch)
tree1994c265d6a78cd515360c4bc202cf478248729c
parent8aed8fa983231d1cc69ae4d765fbf362d5580b9f (diff)
downloademacs-787cc821c04a8c0f6a58461a17df3565d2b893c5.tar.gz
emacs-787cc821c04a8c0f6a58461a17df3565d2b893c5.zip
(check-declare-scan): Read the declaration rather than parsing it as a
regexp. This relaxes the layout requirements and makes errors easier to detect. (check-declare-verify): Check file is regular. (check-declare-directory): Doc fix.
-rw-r--r--lisp/emacs-lisp/check-declare.el46
1 files changed, 23 insertions, 23 deletions
diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-declare.el
index 9e1f8b4f089..38a3a880f16 100644
--- a/lisp/emacs-lisp/check-declare.el
+++ b/lisp/emacs-lisp/check-declare.el
@@ -81,28 +81,30 @@ defines FN, with ARGLIST. FILEONLY non-nil means only check that FNFILE
81exists, not that it defines FN. This is for function definitions that we 81exists, not that it defines FN. This is for function definitions that we
82don't know how to recognize (e.g. some macros)." 82don't know how to recognize (e.g. some macros)."
83 (let ((m (format "Scanning %s..." file)) 83 (let ((m (format "Scanning %s..." file))
84 alist fnfile fn arglist fileonly) 84 alist form len fn fnfile arglist fileonly)
85 (message "%s" m) 85 (message "%s" m)
86 (with-temp-buffer 86 (with-temp-buffer
87 (insert-file-contents file) 87 (insert-file-contents file)
88 (while (re-search-forward 88 ;; FIXME we could theoretically be inside a string.
89 "^[ \t]*(declare-function[ \t]+\\(\\S-+\\)[ \t]+\ 89 (while (re-search-forward "^[ \t]*\\((declare-function\\)[ \t\n]" nil t)
90\"\\(\\S-+\\)\"" nil t) 90 (goto-char (match-beginning 1))
91 (setq fn (match-string 1) 91 (if (and (setq form (ignore-errors (read (current-buffer)))
92 fnfile (match-string 2) 92 len (length form))
93 fnfile (check-declare-locate fnfile (expand-file-name file)) 93 (> len 2) (< len 6)
94 arglist (progn 94 (symbolp (setq fn (cadr form)))
95 (skip-chars-forward " \t\n") 95 (setq fn (symbol-name fn)) ; later we use as a search string
96 ;; Use `t' to distinguish no arglist 96 (stringp (setq fnfile (nth 2 form)))
97 ;; specified from an empty one. 97 (setq fnfile (check-declare-locate fnfile
98 (if (looking-at "\\((\\|nil\\|t\\)") 98 (expand-file-name file)))
99 (read (current-buffer)) 99 ;; Use `t' to distinguish unspecified arglist from empty one.
100 t)) 100 (or (eq t (setq arglist (if (> len 3)
101 fileonly (progn 101 (nth 3 form)
102 (skip-chars-forward " \t\n") 102 t)))
103 (if (looking-at "\\(t\\|'\\sw+\\)") 103 (listp arglist))
104 (match-string 1))) 104 (symbolp (setq fileonly (nth 4 form))))
105 alist (cons (list fnfile fn arglist fileonly) alist)))) 105 (setq alist (cons (list fnfile fn arglist fileonly) alist))
106 ;; FIXME make this more noticeable.
107 (message "Malformed declaration for `%s'" (cadr form)))))
106 (message "%sdone" m) 108 (message "%sdone" m)
107 alist)) 109 alist))
108 110
@@ -138,7 +140,7 @@ is a string giving details of the error."
138 (message "%s" m) 140 (message "%s" m)
139 (if ext 141 (if ext
140 (setq fnfile (substring fnfile 4))) 142 (setq fnfile (substring fnfile 4)))
141 (if (file-exists-p fnfile) 143 (if (file-regular-p fnfile)
142 (with-temp-buffer 144 (with-temp-buffer
143 (insert-file-contents fnfile) 145 (insert-file-contents fnfile)
144 ;; defsubst's don't _have_ to be known at compile time. 146 ;; defsubst's don't _have_ to be known at compile time.
@@ -291,9 +293,7 @@ See `check-declare-directory' for more information."
291;;;###autoload 293;;;###autoload
292(defun check-declare-directory (root) 294(defun check-declare-directory (root)
293 "Check veracity of all `declare-function' statements under directory ROOT. 295 "Check veracity of all `declare-function' statements under directory ROOT.
294Returns non-nil if any false statements are found. For this to 296Returns non-nil if any false statements are found."
295work correctly, the statements must adhere to the format
296described in the documentation of `declare-function'."
297 (interactive "DDirectory to check: ") 297 (interactive "DDirectory to check: ")
298 (or (file-directory-p (setq root (expand-file-name root))) 298 (or (file-directory-p (setq root (expand-file-name root)))
299 (error "Directory `%s' not found" root)) 299 (error "Directory `%s' not found" root))