From 8ee04f3a4f72eb41f2c0ead6287185c829654b43 Mon Sep 17 00:00:00 2001 From: Alan Mackenzie Date: Tue, 19 Jan 2010 22:10:19 +0000 Subject: [PATCH] Fix bug#5395: typing '#' in an empty C buffer throws "args out of range". * progmodes/cc-defs.el: (c-set-cpp-delimiters, c-clear-cpp-delimiters): Check for EOB playing the role of delimiter. --- lisp/ChangeLog | 7 +++++++ lisp/progmodes/cc-defs.el | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index f9e55700c10..4b34373f2d3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2010-01-19 Alan Mackenzie + + * progmodes/cc-defs.el: Fix bug#5395: typing '#' in an empty + buffer throws "args out of range". + (c-set-cpp-delimiters, c-clear-cpp-delimiters): Check for EOB + playing the role of delimiter. + 2010-01-18 Stephen Leake * lisp/progmodes/ada-mode.el: Fix bug#5400. diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index de0cd896b8e..bb91dee6ce8 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el @@ -1217,12 +1217,14 @@ been put there by c-put-char-property. POINT remains unchanged." ;; This macro does a hidden buffer change. `(progn (c-put-char-property ,beg 'category 'c-cpp-delimiter) - (c-put-char-property ,end 'category 'c-cpp-delimiter))) + (if (< ,end (point-max)) + (c-put-char-property ,end 'category 'c-cpp-delimiter)))) (defmacro c-clear-cpp-delimiters (beg end) ;; This macro does a hidden buffer change. `(progn (c-clear-char-property ,beg 'category) - (c-clear-char-property ,end 'category))) + (if (< ,end (point-max)) + (c-clear-char-property ,end 'category)))) (defsubst c-comment-out-cpps () ;; Render all preprocessor constructs syntactically commented out. -- 2.39.5