Mercurial > emacs
comparison lisp/progmodes/cc-engine.el @ 92572:897b09fb6e10
(c-in-knr-argdecl): Limit number of paren/bracket pairs parsed, to solve
performance problem.
author | Alan Mackenzie <acm@muc.de> |
---|---|
date | Fri, 07 Mar 2008 22:34:09 +0000 |
parents | f991f10f15ec |
children | 1e3a407766b9 |
comparison
equal
deleted
inserted
replaced
92571:35628f10d78a | 92572:897b09fb6e10 |
---|---|
6334 (save-restriction | 6334 (save-restriction |
6335 ;; If we're in a macro, our search range is restricted to it. Narrow to | 6335 ;; If we're in a macro, our search range is restricted to it. Narrow to |
6336 ;; the searchable range. | 6336 ;; the searchable range. |
6337 (let* ((macro-start (c-query-macro-start)) | 6337 (let* ((macro-start (c-query-macro-start)) |
6338 (lim (max (or lim (point-min)) (or macro-start (point-min)))) | 6338 (lim (max (or lim (point-min)) (or macro-start (point-min)))) |
6339 before-lparen after-rparen) | 6339 before-lparen after-rparen |
6340 (pp-count-out 20)) ; Max number of paren/brace constructs before we give up | |
6340 (narrow-to-region lim (c-point 'eol)) | 6341 (narrow-to-region lim (c-point 'eol)) |
6341 | 6342 |
6342 ;; Search backwards for the defun's argument list. We give up if we | 6343 ;; Search backwards for the defun's argument list. We give up if we |
6343 ;; encounter a "}" (end of a previous defun) or BOB. | 6344 ;; encounter a "}" (end of a previous defun) or BOB. |
6344 ;; | 6345 ;; |
6356 ;; int (*baz) (my_type) ; | 6357 ;; int (*baz) (my_type) ; |
6357 ;; int (*) (void) (*yuk) (void) ; | 6358 ;; int (*) (void) (*yuk) (void) ; |
6358 ;; { | 6359 ;; { |
6359 | 6360 |
6360 (catch 'knr | 6361 (catch 'knr |
6361 (while t ; go round one paren/bracket construct each time round. | 6362 (while (> pp-count-out 0) ; go back one paren/bracket pair each time. |
6363 (setq pp-count-out (1- pp-count-out)) | |
6362 (c-syntactic-skip-backward "^)]}") | 6364 (c-syntactic-skip-backward "^)]}") |
6363 (cond ((eq (char-before) ?\)) | 6365 (cond ((eq (char-before) ?\)) |
6364 (setq after-rparen (point))) | 6366 (setq after-rparen (point))) |
6365 ((eq (char-before) ?\]) | 6367 ((eq (char-before) ?\]) |
6366 (setq after-rparen nil)) | 6368 (setq after-rparen nil)) |