Subject: Re: bug#10463: 24.0.92; c-literal-limits out of range

From: Alan Mackenzie <[email-masked]>
Date: Mon, 9 Jan 2012 21:17:21 +0000

On Mon, Jan 09, 2012 at 07:19:25PM +0100, martin rudalics wrote a bug
report:

Hi, Martin.

Please apply this patch, use C Mode for an infinite amount of time, then
report back and tell me the bug has disappeared.

Thanks!

*** orig/cc-engine.el	2012-01-09 20:27:51.000000000 +0000
--- cc-engine.el	2012-01-09 20:53:42.000000000 +0000
***************
*** 4225,4236 ****
  
  Note that this function might do hidden buffer changes.	 See the
  comment at the start of cc-engine.el for more info."
!   (let* ((safe-place (c-state-safe-place (point)))
! 	 (lit (c-state-pp-to-literal safe-place (point))))
!     (or (cadr lit)
! 	(and detect-cpp
! 	     (save-excursion (c-beginning-of-macro))
! 	     'pound))))
  
  (defun c-literal-limits (&optional lim near not-in-delimiter)
    "Return a cons of the beginning and end positions of the comment or
--- 4225,4238 ----
  
  Note that this function might do hidden buffer changes.	 See the
  comment at the start of cc-engine.el for more info."
!   (save-restriction
!     (widen
!      (let* ((safe-place (c-state-safe-place (point)))
! 	    (lit (c-state-pp-to-literal safe-place (point))))
!        (or (cadr lit)
! 	   (and detect-cpp
! 		(save-excursion (c-beginning-of-macro))
! 		'pound))))))
  
  (defun c-literal-limits (&optional lim near not-in-delimiter)
    "Return a cons of the beginning and end positions of the comment or
***************
*** 4250,4258 ****
    (save-excursion
      (let* ((pos (point))
  	   (lim (or lim (c-state-safe-place pos)))
! 	   (pp-to-lit (c-state-pp-to-literal lim pos))
  	   (state (car pp-to-lit))
- 	   (lit-type (cadr pp-to-lit))
  	   (lit-limits (car (cddr pp-to-lit))))
  
        (cond
--- 4252,4261 ----
    (save-excursion
      (let* ((pos (point))
  	   (lim (or lim (c-state-safe-place pos)))
! 	   (pp-to-lit (save-restriction
! 			(widen)
! 			(c-state-pp-to-literal lim pos)))
  	   (state (car pp-to-lit))
  	   (lit-limits (car (cddr pp-to-lit))))
  
        (cond

> martin

-- 
Alan Mackenzie (Nuremberg, Germany).