svn rev #23122: trunk/src/util/

tlyu@MIT.EDU tlyu at MIT.EDU
Mon Nov 2 22:14:41 EST 2009


http://src.mit.edu/fisheye/changelog/krb5/?cs=23122
Commit By: tlyu
Log Message:
Monkey patch for the cc-mode that comes with emacs-23.x; that version
of cc-mode has a bug that causes incorrect indentation of case labels
containing character constants.  Already fixed upstream in unreleased
cc-mode sources.


Changed Files:
U   trunk/src/util/krb5-c-style.el
A   trunk/src/util/krb5-hack-cc-mode-caselabel.el
Modified: trunk/src/util/krb5-c-style.el
===================================================================
--- trunk/src/util/krb5-c-style.el	2009-11-02 19:19:02 UTC (rev 23121)
+++ trunk/src/util/krb5-c-style.el	2009-11-03 03:14:41 UTC (rev 23122)
@@ -45,3 +45,11 @@
 ;; Use hack-local-variables-hook because the c-mode hooks run before
 ;; hack-local-variables runs.
 (add-hook 'hack-local-variables-hook 'krb5-c-mode-hook)
+
+;; emacs-23.x has a buggy cc-mode that incorrectly deals with case
+;; labels with character constants.
+(if (and (string-match "^23\." emacs-version)
+         (require 'cc-defs)
+         (string-match "5.31.[0-7]" c-version))
+    (let ((load-path (cons (file-name-directory load-file-name) load-path)))
+      (load "krb5-hack-cc-mode-caselabel")))

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




More information about the cvs-krb5 mailing list