changeset 80425:de6695693a29

(c-in-knr-argdecl): Limit number of paren/bracket pairs parsed, to solve performance problem.
author Alan Mackenzie <acm@muc.de>
date Tue, 01 Apr 2008 21:41:21 +0000
parents 417dccf4ec02
children 446857e94527
files lisp/progmodes/cc-engine.el
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/cc-engine.el	Tue Apr 01 20:18:44 2008 +0000
+++ b/lisp/progmodes/cc-engine.el	Tue Apr 01 21:41:21 2008 +0000
@@ -6333,7 +6333,8 @@
       ;; the searchable range.
       (let* ((macro-start (c-query-macro-start))
 	     (lim (max (or lim (point-min)) (or macro-start (point-min))))
-	     before-lparen after-rparen)
+	     before-lparen after-rparen
+	     (pp-count-out 20))	; Max number of paren/brace constructs before we give up
 	(narrow-to-region lim (c-point 'eol))
 
 	;; Search backwards for the defun's argument list.  We give up if we
@@ -6355,7 +6356,8 @@
 	;; {
 
 	(catch 'knr
-	  (while t ; go round one paren/bracket construct each time round.
+	  (while (> pp-count-out 0) ; go back one paren/bracket pair each time.
+	    (setq pp-count-out (1- pp-count-out))
 	    (c-syntactic-skip-backward "^)]}")
 	    (cond ((eq (char-before) ?\))
 		   (setq after-rparen (point)))