Commit 9769d49f authored by Glenn Morris's avatar Glenn Morris

(check-declare-scan): Expand .c files relative to src/ directory.

(check-declare-verify): Handle .c files (without arg checking).
parent 3ab75cae
2007-11-22 Glenn Morris <rgm@gnu.org>
* dos-fns.el (int86):
* term/mac-win.el (mac-font-panel-mode): Fix declarations.
* calendar/cal-menu.el (cal-menu-holidays-menu): Fix holiday-list call.
* calendar/holidays.el (holiday-list): Add autoload cookie.
* emacs-lisp/check-declare.el (check-declare-scan): Expand .c
files relative to src/ directory.
(check-declare-verify): Handle .c files (without arg checking).
* emacs-lisp/byte-run.el (declare-function): Doc fix.
2007-11-22 Dan Nicolaescu <dann@ics.uci.edu> 2007-11-22 Dan Nicolaescu <dann@ics.uci.edu>
* replace.el (occur-mode-map): Add a major mode menu with entries * replace.el (occur-mode-map): Add a major mode menu with entries
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
;; 1. Handle defstructs (eg uniquify-item-base in desktop.el). ;; 1. Handle defstructs (eg uniquify-item-base in desktop.el).
;; 2. Check C files (look in src/)? ;; 2. Argument checking for functions defined in C.
;;; Code: ;;; Code:
...@@ -56,7 +56,15 @@ ARGLIST may be absent. This claims that FNFILE defines FN, with ARGLIST." ...@@ -56,7 +56,15 @@ ARGLIST may be absent. This claims that FNFILE defines FN, with ARGLIST."
(setq fn (match-string 1) (setq fn (match-string 1)
fnfile (match-string 2)) fnfile (match-string 2))
(or (file-name-absolute-p fnfile) (or (file-name-absolute-p fnfile)
(setq fnfile (expand-file-name fnfile (file-name-directory file)))) (setq fnfile
(expand-file-name fnfile
;; .c files are assumed to be
;; relative to the Emacs src/ directory.
(if (string-equal
"c" (file-name-extension fnfile))
(expand-file-name "src"
source-directory)
(file-name-directory file)))))
(setq alist (cons (setq alist (cons
(list fnfile fn (list fnfile fn
(progn (progn
...@@ -80,59 +88,64 @@ FNFILE with the specified ARGLIST. Returns nil if all claims are ...@@ -80,59 +88,64 @@ FNFILE with the specified ARGLIST. Returns nil if all claims are
found to be true, otherwise a list of errors with elements of the form found to be true, otherwise a list of errors with elements of the form
\(FILE FN TYPE), where TYPE is a string giving details of the error." \(FILE FN TYPE), where TYPE is a string giving details of the error."
(let ((m (format "Checking %s..." fnfile)) (let ((m (format "Checking %s..." fnfile))
(cflag (string-equal "c" (file-name-extension fnfile)))
re fn sig siglist arglist type errlist) re fn sig siglist arglist type errlist)
(message "%s" m) (message "%s" m)
(if (string-equal (file-name-extension fnfile) "c") (or cflag
(progn (file-exists-p fnfile)
(message "%sskipping C file" m) (setq fnfile (concat fnfile ".el")))
nil) (if (file-exists-p fnfile)
(or (file-exists-p fnfile) (with-temp-buffer
(setq fnfile (concat fnfile ".el"))) (insert-file-contents fnfile)
(if (file-exists-p fnfile) ;; defsubst's don't _have_ to be known at compile time.
(with-temp-buffer (setq re (format (if cflag
(insert-file-contents fnfile) "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\""
;; defsubst's don't _have_ to be known at compile time. "^[ \t]*(\\(def\\(?:un\\|subst\\|\
(setq re (format "^[ \t]*(\\(def\\(?:un\\|subst\\|\
ine-derived-mode\\|ine-minor-mode\\|alias[ \t]+'\\)\\)\ ine-derived-mode\\|ine-minor-mode\\|alias[ \t]+'\\)\\)\
\[ \t]*%s\\([ \t;]+\\|$\\)" \[ \t]*%s\\([ \t;]+\\|$\\)")
(regexp-opt (mapcar 'cadr fnlist) t))) (regexp-opt (mapcar 'cadr fnlist) t)))
(while (re-search-forward re nil t) (while (re-search-forward re nil t)
(skip-chars-forward " \t\n") (skip-chars-forward " \t\n")
(setq fn (match-string 2) (setq fn (match-string 2)
sig (cond ((string-equal (match-string 1) ;; (min . max) for a fixed number of arguments, or
"define-derived-mode") ;; arglists with optional elements.
'(0 . 0)) ;; (min) for arglists with &rest.
((string-equal (match-string 1) sig (cond ((string-equal (match-string 1)
"define-minor-mode") "define-derived-mode")
'(0 . 1)) '(0 . 0))
;; Can't easily check alias arguments. ((string-equal (match-string 1)
((string-equal (match-string 1) "define-minor-mode")
"defalias") '(0 . 1))
t) ;; Can't easily check alias arguments.
(t ((string-equal (match-string 1)
(if (looking-at "\\((\\|nil\\)") "defalias")
(byte-compile-arglist-signature t)
(read (current-buffer)))))) (t
;; alist of functions and arglist signatures. (if (looking-at "\\((\\|nil\\)")
siglist (cons (cons fn sig) siglist))))) (byte-compile-arglist-signature
(dolist (e fnlist) (read (current-buffer))))))
(setq arglist (nth 2 e) ;; alist of functions and arglist signatures.
type siglist (cons (cons fn sig) siglist)))))
(if re ; re non-nil means found a file (dolist (e fnlist)
(if (setq sig (assoc (cadr e) siglist)) (setq arglist (nth 2 e)
;; Recall we use t to mean no arglist specified, type
;; to distinguish from an empty arglist. (if re ; re non-nil means found a file
(unless (or (eq arglist t) (if (setq sig (assoc (cadr e) siglist))
(eq sig t)) ;; Recall we use t to mean no arglist specified,
(unless (equal (byte-compile-arglist-signature arglist) ;; to distinguish from an empty arglist.
(cdr sig)) ;; FIXME c arg checking not yet implemented.
"arglist mismatch")) (unless (or cflag
"function not found") (eq arglist t)
"file not found")) (eq sig t))
(when type (unless (equal (byte-compile-arglist-signature arglist)
(setq errlist (cons (list (car e) (cadr e) type) errlist)))) (cdr sig))
(message "%s%s" m (if errlist "problems found" "OK")) "arglist mismatch"))
errlist))) "function not found")
"file not found"))
(when type
(setq errlist (cons (list (car e) (cadr e) type) errlist))))
(message "%s%s" m (if errlist "problems found" "OK"))
errlist))
(defun check-declare-sort (alist) (defun check-declare-sort (alist)
"Sort a list with elements FILE (FNFILE ...). "Sort a list with elements FILE (FNFILE ...).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment