1;;; -*- mode: emacs-lisp; indent-tabs-mode: nil -*- 2 3;; emacs-23.x has a bug in cc-mode that that incorrectly deals with 4;; case labels with character constants. 5 6(require 'cl) 7(require 'cc-defs) 8(require 'cc-vars) 9(require 'cc-langs) 10 11;; Hack load-in-progress to silence the c-lang-defconst error. For 12;; some reason, load-in-progress is nil at some times when it 13;; shouldn't be, at least on released emacs-23.1.1. 14(let ((load-in-progress t)) 15 16 ;; Updated c-nonlabel-token-key based on cc-langs.el 5.267.2.22, to 17 ;; allow character constants in case labels. 18 (c-lang-defconst c-nonlabel-token-key 19 "Regexp matching things that can't occur in generic colon labels, 20neither in a statement nor in a declaration context. The regexp is 21tested at the beginning of every sexp in a suspected label, 22i.e. before \":\". Only used if `c-recognize-colon-labels' is set." 23 t (concat 24 ;; Don't allow string literals. 25 "\"\\|" 26 ;; All keywords except `c-label-kwds' and `c-protection-kwds'. 27 (c-make-keywords-re t 28 (set-difference (c-lang-const c-keywords) 29 (append (c-lang-const c-label-kwds) 30 (c-lang-const c-protection-kwds)) 31 :test 'string-equal))) 32 ;; Also check for open parens in C++, to catch member init lists in 33 ;; constructors. We normally allow it so that macros with arguments 34 ;; work in labels. 35 c++ (concat "\\s\(\\|" (c-lang-const c-nonlabel-token-key))) 36 (c-lang-defvar c-nonlabel-token-key (c-lang-const c-nonlabel-token-key)) 37 38 ;; Monkey-patch by way of c-mode-common-hook, as the byte-compiled 39 ;; version of c-init-language-vars will have the old value. This 40 ;; avoids finding some way to re-evaluate the defun for 41 ;; c-init-language-vars. 42 (defun krb5-c-monkey-patch-caselabel () 43 (setq c-nonlabel-token-key (c-lang-const c-nonlabel-token-key))) 44 (add-hook 'c-mode-common-hook 'krb5-c-monkey-patch-caselabel)) 45