|
Packit |
fd8b60 |
;;; -*- mode: emacs-lisp; indent-tabs-mode: nil -*-
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
;; emacs-23.x has a bug in cc-mode that that incorrectly deals with
|
|
Packit |
fd8b60 |
;; case labels with character constants.
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
(require 'cl)
|
|
Packit |
fd8b60 |
(require 'cc-defs)
|
|
Packit |
fd8b60 |
(require 'cc-vars)
|
|
Packit |
fd8b60 |
(require 'cc-langs)
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
;; Hack load-in-progress to silence the c-lang-defconst error. For
|
|
Packit |
fd8b60 |
;; some reason, load-in-progress is nil at some times when it
|
|
Packit |
fd8b60 |
;; shouldn't be, at least on released emacs-23.1.1.
|
|
Packit |
fd8b60 |
(let ((load-in-progress t))
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
;; Updated c-nonlabel-token-key based on cc-langs.el 5.267.2.22, to
|
|
Packit |
fd8b60 |
;; allow character constants in case labels.
|
|
Packit |
fd8b60 |
(c-lang-defconst c-nonlabel-token-key
|
|
Packit |
fd8b60 |
"Regexp matching things that can't occur in generic colon labels,
|
|
Packit |
fd8b60 |
neither in a statement nor in a declaration context. The regexp is
|
|
Packit |
fd8b60 |
tested at the beginning of every sexp in a suspected label,
|
|
Packit |
fd8b60 |
i.e. before \":\". Only used if `c-recognize-colon-labels' is set."
|
|
Packit |
fd8b60 |
t (concat
|
|
Packit |
fd8b60 |
;; Don't allow string literals.
|
|
Packit |
fd8b60 |
"\"\\|"
|
|
Packit |
fd8b60 |
;; All keywords except `c-label-kwds' and `c-protection-kwds'.
|
|
Packit |
fd8b60 |
(c-make-keywords-re t
|
|
Packit |
fd8b60 |
(set-difference (c-lang-const c-keywords)
|
|
Packit |
fd8b60 |
(append (c-lang-const c-label-kwds)
|
|
Packit |
fd8b60 |
(c-lang-const c-protection-kwds))
|
|
Packit |
fd8b60 |
:test 'string-equal)))
|
|
Packit |
fd8b60 |
;; Also check for open parens in C++, to catch member init lists in
|
|
Packit |
fd8b60 |
;; constructors. We normally allow it so that macros with arguments
|
|
Packit |
fd8b60 |
;; work in labels.
|
|
Packit |
fd8b60 |
c++ (concat "\\s\(\\|" (c-lang-const c-nonlabel-token-key)))
|
|
Packit |
fd8b60 |
(c-lang-defvar c-nonlabel-token-key (c-lang-const c-nonlabel-token-key))
|
|
Packit |
fd8b60 |
|
|
Packit |
fd8b60 |
;; Monkey-patch by way of c-mode-common-hook, as the byte-compiled
|
|
Packit |
fd8b60 |
;; version of c-init-language-vars will have the old value. This
|
|
Packit |
fd8b60 |
;; avoids finding some way to re-evaluate the defun for
|
|
Packit |
fd8b60 |
;; c-init-language-vars.
|
|
Packit |
fd8b60 |
(defun krb5-c-monkey-patch-caselabel ()
|
|
Packit |
fd8b60 |
(setq c-nonlabel-token-key (c-lang-const c-nonlabel-token-key)))
|
|
Packit |
fd8b60 |
(add-hook 'c-mode-common-hook 'krb5-c-monkey-patch-caselabel))
|