105 |
|
|
106 |
;;; Variables also used at compile time. |
;;; Variables also used at compile time. |
107 |
|
|
108 |
(defconst c-version "5.30.7" |
(defconst c-version "5.30.8" |
109 |
"CC Mode version number.") |
"CC Mode version number.") |
110 |
|
|
111 |
(defconst c-version-sym (intern c-version)) |
(defconst c-version-sym (intern c-version)) |
1001 |
|
|
1002 |
(defun c-make-keywords-re (adorn list &optional mode) |
(defun c-make-keywords-re (adorn list &optional mode) |
1003 |
"Make a regexp that matches all the strings the list. |
"Make a regexp that matches all the strings the list. |
1004 |
Duplicates in the list are removed. The regexp may contain zero or |
Duplicates in the list are removed. The resulting regexp may contain |
1005 |
more submatch expressions. |
zero or more submatch expressions. |
1006 |
|
|
1007 |
If ADORN is non-nil there will be at least one submatch and the first |
If ADORN is non-nil there will be at least one submatch and the first |
1008 |
matches the whole keyword, and the regexp will also not match a prefix |
matches the whole keyword, and the regexp will also not match a prefix |
1010 |
variable `c-nonsymbol-key' is used to make the adornment. The |
variable `c-nonsymbol-key' is used to make the adornment. The |
1011 |
optional MODE specifies the language to get it in. The default is the |
optional MODE specifies the language to get it in. The default is the |
1012 |
current language (taken from `c-buffer-is-cc-mode')." |
current language (taken from `c-buffer-is-cc-mode')." |
1013 |
|
|
1014 |
(let (unique) |
(let (unique) |
1015 |
(dolist (elt list) |
(dolist (elt list) |
1016 |
(unless (member elt unique) |
(unless (member elt unique) |
1018 |
(setq list unique)) |
(setq list unique)) |
1019 |
(if list |
(if list |
1020 |
(let ((re (c-regexp-opt list))) |
(let ((re (c-regexp-opt list))) |
1021 |
|
|
1022 |
|
;; Emacs < 21 and XEmacs (all versions so far) has a buggy |
1023 |
|
;; regexp-opt that doesn't always cope with strings containing |
1024 |
|
;; newlines. This kludge doesn't handle shy parens correctly |
1025 |
|
;; so we can't advice regexp-opt directly with it. |
1026 |
|
(let (fail-list) |
1027 |
|
(while list |
1028 |
|
(and (string-match "\n" (car list)) ; To speed it up a little. |
1029 |
|
(not (string-match (concat "\\`\\(" re "\\)\\'") |
1030 |
|
(car list))) |
1031 |
|
(setq fail-list (cons (car list) fail-list))) |
1032 |
|
(setq list (cdr list))) |
1033 |
|
(when fail-list |
1034 |
|
(setq re (concat re |
1035 |
|
"\\|" |
1036 |
|
(mapconcat 'regexp-quote |
1037 |
|
(sort fail-list |
1038 |
|
(lambda (a b) |
1039 |
|
(> (length a) (length b)))) |
1040 |
|
"\\|"))))) |
1041 |
|
|
1042 |
;; Add our own grouping parenthesis around re instead of |
;; Add our own grouping parenthesis around re instead of |
1043 |
;; passing adorn to `regexp-opt', since in XEmacs it makes the |
;; passing adorn to `regexp-opt', since in XEmacs it makes the |
1044 |
;; top level grouping "shy". |
;; top level grouping "shy". |
1048 |
(c-get-lang-constant 'c-nonsymbol-key nil mode) |
(c-get-lang-constant 'c-nonsymbol-key nil mode) |
1049 |
"\\|$\\)") |
"\\|$\\)") |
1050 |
re)) |
re)) |
1051 |
|
|
1052 |
;; Produce a regexp that matches nothing. |
;; Produce a regexp that matches nothing. |
1053 |
(if adorn |
(if adorn |
1054 |
"\\(\\<\\>\\)" |
"\\(\\<\\>\\)" |
1055 |
"\\<\\>"))) |
"\\<\\>"))) |
1056 |
|
|
1057 |
(put 'c-make-keywords-re 'lisp-indent-function 1) |
(put 'c-make-keywords-re 'lisp-indent-function 1) |
1058 |
|
|
1059 |
|
|