diff options
| author | Glenn Morris | 2007-11-22 04:19:48 +0000 |
|---|---|---|
| committer | Glenn Morris | 2007-11-22 04:19:48 +0000 |
| commit | 9769d49f91e944dfe1b7a44684df4382c8a19411 (patch) | |
| tree | 7326835e400fa43926f2ec94251dc0ff46799f60 | |
| parent | 3ab75caec0317d22b5ecf301d55467eb8a685f61 (diff) | |
| download | emacs-9769d49f91e944dfe1b7a44684df4382c8a19411.tar.gz emacs-9769d49f91e944dfe1b7a44684df4382c8a19411.zip | |
(check-declare-scan): Expand .c files relative to src/ directory.
(check-declare-verify): Handle .c files (without arg checking).
| -rw-r--r-- | lisp/ChangeLog | 15 | ||||
| -rw-r--r-- | lisp/emacs-lisp/check-declare.el | 117 |
2 files changed, 80 insertions, 52 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2280c706bd5..08cfd22f581 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | 2007-11-22 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * dos-fns.el (int86): | ||
| 4 | * term/mac-win.el (mac-font-panel-mode): Fix declarations. | ||
| 5 | |||
| 6 | * calendar/cal-menu.el (cal-menu-holidays-menu): Fix holiday-list call. | ||
| 7 | |||
| 8 | * calendar/holidays.el (holiday-list): Add autoload cookie. | ||
| 9 | |||
| 10 | * emacs-lisp/check-declare.el (check-declare-scan): Expand .c | ||
| 11 | files relative to src/ directory. | ||
| 12 | (check-declare-verify): Handle .c files (without arg checking). | ||
| 13 | |||
| 14 | * emacs-lisp/byte-run.el (declare-function): Doc fix. | ||
| 15 | |||
| 1 | 2007-11-22 Dan Nicolaescu <dann@ics.uci.edu> | 16 | 2007-11-22 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 17 | ||
| 3 | * replace.el (occur-mode-map): Add a major mode menu with entries | 18 | * replace.el (occur-mode-map): Add a major mode menu with entries |
diff --git a/lisp/emacs-lisp/check-declare.el b/lisp/emacs-lisp/check-declare.el index 76719f1b876..5da8691beed 100644 --- a/lisp/emacs-lisp/check-declare.el +++ b/lisp/emacs-lisp/check-declare.el | |||
| @@ -34,7 +34,7 @@ | |||
| 34 | 34 | ||
| 35 | ;; 1. Handle defstructs (eg uniquify-item-base in desktop.el). | 35 | ;; 1. Handle defstructs (eg uniquify-item-base in desktop.el). |
| 36 | 36 | ||
| 37 | ;; 2. Check C files (look in src/)? | 37 | ;; 2. Argument checking for functions defined in C. |
| 38 | 38 | ||
| 39 | ;;; Code: | 39 | ;;; Code: |
| 40 | 40 | ||
| @@ -56,7 +56,15 @@ ARGLIST may be absent. This claims that FNFILE defines FN, with ARGLIST." | |||
| 56 | (setq fn (match-string 1) | 56 | (setq fn (match-string 1) |
| 57 | fnfile (match-string 2)) | 57 | fnfile (match-string 2)) |
| 58 | (or (file-name-absolute-p fnfile) | 58 | (or (file-name-absolute-p fnfile) |
| 59 | (setq fnfile (expand-file-name fnfile (file-name-directory file)))) | 59 | (setq fnfile |
| 60 | (expand-file-name fnfile | ||
| 61 | ;; .c files are assumed to be | ||
| 62 | ;; relative to the Emacs src/ directory. | ||
| 63 | (if (string-equal | ||
| 64 | "c" (file-name-extension fnfile)) | ||
| 65 | (expand-file-name "src" | ||
| 66 | source-directory) | ||
| 67 | (file-name-directory file))))) | ||
| 60 | (setq alist (cons | 68 | (setq alist (cons |
| 61 | (list fnfile fn | 69 | (list fnfile fn |
| 62 | (progn | 70 | (progn |
| @@ -80,59 +88,64 @@ FNFILE with the specified ARGLIST. Returns nil if all claims are | |||
| 80 | found to be true, otherwise a list of errors with elements of the form | 88 | found to be true, otherwise a list of errors with elements of the form |
| 81 | \(FILE FN TYPE), where TYPE is a string giving details of the error." | 89 | \(FILE FN TYPE), where TYPE is a string giving details of the error." |
| 82 | (let ((m (format "Checking %s..." fnfile)) | 90 | (let ((m (format "Checking %s..." fnfile)) |
| 91 | (cflag (string-equal "c" (file-name-extension fnfile))) | ||
| 83 | re fn sig siglist arglist type errlist) | 92 | re fn sig siglist arglist type errlist) |
| 84 | (message "%s" m) | 93 | (message "%s" m) |
| 85 | (if (string-equal (file-name-extension fnfile) "c") | 94 | (or cflag |
| 86 | (progn | 95 | (file-exists-p fnfile) |
| 87 | (message "%sskipping C file" m) | 96 | (setq fnfile (concat fnfile ".el"))) |
| 88 | nil) | 97 | (if (file-exists-p fnfile) |
| 89 | (or (file-exists-p fnfile) | 98 | (with-temp-buffer |
| 90 | (setq fnfile (concat fnfile ".el"))) | 99 | (insert-file-contents fnfile) |
| 91 | (if (file-exists-p fnfile) | 100 | ;; defsubst's don't _have_ to be known at compile time. |
| 92 | (with-temp-buffer | 101 | (setq re (format (if cflag |
| 93 | (insert-file-contents fnfile) | 102 | "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\"" |
| 94 | ;; defsubst's don't _have_ to be known at compile time. | 103 | "^[ \t]*(\\(def\\(?:un\\|subst\\|\ |
| 95 | (setq re (format "^[ \t]*(\\(def\\(?:un\\|subst\\|\ | ||
| 96 | ine-derived-mode\\|ine-minor-mode\\|alias[ \t]+'\\)\\)\ | 104 | ine-derived-mode\\|ine-minor-mode\\|alias[ \t]+'\\)\\)\ |
| 97 | \[ \t]*%s\\([ \t;]+\\|$\\)" | 105 | \[ \t]*%s\\([ \t;]+\\|$\\)") |
| 98 | (regexp-opt (mapcar 'cadr fnlist) t))) | 106 | (regexp-opt (mapcar 'cadr fnlist) t))) |
| 99 | (while (re-search-forward re nil t) | 107 | (while (re-search-forward re nil t) |
| 100 | (skip-chars-forward " \t\n") | 108 | (skip-chars-forward " \t\n") |
| 101 | (setq fn (match-string 2) | 109 | (setq fn (match-string 2) |
| 102 | sig (cond ((string-equal (match-string 1) | 110 | ;; (min . max) for a fixed number of arguments, or |
| 103 | "define-derived-mode") | 111 | ;; arglists with optional elements. |
| 104 | '(0 . 0)) | 112 | ;; (min) for arglists with &rest. |
| 105 | ((string-equal (match-string 1) | 113 | sig (cond ((string-equal (match-string 1) |
| 106 | "define-minor-mode") | 114 | "define-derived-mode") |
| 107 | '(0 . 1)) | 115 | '(0 . 0)) |
| 108 | ;; Can't easily check alias arguments. | 116 | ((string-equal (match-string 1) |
| 109 | ((string-equal (match-string 1) | 117 | "define-minor-mode") |
| 110 | "defalias") | 118 | '(0 . 1)) |
| 111 | t) | 119 | ;; Can't easily check alias arguments. |
| 112 | (t | 120 | ((string-equal (match-string 1) |
| 113 | (if (looking-at "\\((\\|nil\\)") | 121 | "defalias") |
| 114 | (byte-compile-arglist-signature | 122 | t) |
| 115 | (read (current-buffer)))))) | 123 | (t |
| 116 | ;; alist of functions and arglist signatures. | 124 | (if (looking-at "\\((\\|nil\\)") |
| 117 | siglist (cons (cons fn sig) siglist))))) | 125 | (byte-compile-arglist-signature |
| 118 | (dolist (e fnlist) | 126 | (read (current-buffer)))))) |
| 119 | (setq arglist (nth 2 e) | 127 | ;; alist of functions and arglist signatures. |
| 120 | type | 128 | siglist (cons (cons fn sig) siglist))))) |
| 121 | (if re ; re non-nil means found a file | 129 | (dolist (e fnlist) |
| 122 | (if (setq sig (assoc (cadr e) siglist)) | 130 | (setq arglist (nth 2 e) |
| 123 | ;; Recall we use t to mean no arglist specified, | 131 | type |
| 124 | ;; to distinguish from an empty arglist. | 132 | (if re ; re non-nil means found a file |
| 125 | (unless (or (eq arglist t) | 133 | (if (setq sig (assoc (cadr e) siglist)) |
| 126 | (eq sig t)) | 134 | ;; Recall we use t to mean no arglist specified, |
| 127 | (unless (equal (byte-compile-arglist-signature arglist) | 135 | ;; to distinguish from an empty arglist. |
| 128 | (cdr sig)) | 136 | ;; FIXME c arg checking not yet implemented. |
| 129 | "arglist mismatch")) | 137 | (unless (or cflag |
| 130 | "function not found") | 138 | (eq arglist t) |
| 131 | "file not found")) | 139 | (eq sig t)) |
| 132 | (when type | 140 | (unless (equal (byte-compile-arglist-signature arglist) |
| 133 | (setq errlist (cons (list (car e) (cadr e) type) errlist)))) | 141 | (cdr sig)) |
| 134 | (message "%s%s" m (if errlist "problems found" "OK")) | 142 | "arglist mismatch")) |
| 135 | errlist))) | 143 | "function not found") |
| 144 | "file not found")) | ||
| 145 | (when type | ||
| 146 | (setq errlist (cons (list (car e) (cadr e) type) errlist)))) | ||
| 147 | (message "%s%s" m (if errlist "problems found" "OK")) | ||
| 148 | errlist)) | ||
| 136 | 149 | ||
| 137 | (defun check-declare-sort (alist) | 150 | (defun check-declare-sort (alist) |
| 138 | "Sort a list with elements FILE (FNFILE ...). | 151 | "Sort a list with elements FILE (FNFILE ...). |