changeset 106911:497e3aa2f614

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.
author Alan Mackenzie <acm@muc.de>
date Tue, 19 Jan 2010 22:10:19 +0000
parents a38986b4badb
children 6881eb43ae95
files lisp/ChangeLog lisp/progmodes/cc-defs.el
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Tue Jan 19 15:56:35 2010 +0100
+++ b/lisp/ChangeLog	Tue Jan 19 22:10:19 2010 +0000
@@ -1,3 +1,10 @@
+2010-01-19  Alan Mackenzie  <acm@muc.de>
+
+	* 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  <stephen_leake@member.fsf.org>
 
 	* lisp/progmodes/ada-mode.el: Fix bug#5400.
--- a/lisp/progmodes/cc-defs.el	Tue Jan 19 15:56:35 2010 +0100
+++ b/lisp/progmodes/cc-defs.el	Tue Jan 19 22:10:19 2010 +0000
@@ -1217,12 +1217,14 @@
   ;; 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.