aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorAlan Mackenzie2017-10-26 18:29:39 +0000
committerAlan Mackenzie2017-10-26 18:29:39 +0000
commitad68bbd0da4ed90117f09dc2344c0c3d9d728851 (patch)
tree41327ffea2ac778e885d931a31249948fa7fb2bf /lisp
parent646e56e150ca08978d6ce736b12867b4958a0cd8 (diff)
downloademacs-ad68bbd0da4ed90117f09dc2344c0c3d9d728851.tar.gz
emacs-ad68bbd0da4ed90117f09dc2344c0c3d9d728851.zip
Fix another "wrong side of point" error in CC Mode.
This fixes (a follow-up to) bug #28850. A internal generated form for scanning text to fontify had a LIMIT parameter. It also locally bound LIMIT to a value possibly beyond the original LIMIT, allowing point to move beyond the original LIMIT, and to create the wrong side error. Fix it by checking point is not beyond LIMIT in the outer context before using it. * lisp/progmodes/cc-fonts.el (c-make-font-lock-search-form): Add a new parameter CHECK-POINT which, when non-nil, directs the function to generate a check on point. (c-make-font-lock-context-search-function): Invoke the above function with new argument value t.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/cc-fonts.el15
1 files changed, 11 insertions, 4 deletions
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index a2ac2a32535..d352e5b08c9 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -292,12 +292,17 @@
292 nil))))) 292 nil)))))
293 res)))) 293 res))))
294 294
295 (defun c-make-font-lock-search-form (regexp highlights) 295 (defun c-make-font-lock-search-form (regexp highlights &optional check-point)
296 ;; Return a lisp form which will fontify every occurrence of REGEXP 296 ;; Return a lisp form which will fontify every occurrence of REGEXP
297 ;; (a regular expression, NOT a function) between POINT and `limit' 297 ;; (a regular expression, NOT a function) between POINT and `limit'
298 ;; with HIGHLIGHTS, a list of highlighters as specified on page 298 ;; with HIGHLIGHTS, a list of highlighters as specified on page
299 ;; "Search-based Fontification" in the elisp manual. 299 ;; "Search-based Fontification" in the elisp manual. If CHECK-POINT
300 `(while (re-search-forward ,regexp limit t) 300 ;; is non-nil, we will check (< (point) limit) in the main loop.
301 `(while
302 ,(if check-point
303 `(and (< (point) limit)
304 (re-search-forward ,regexp limit t))
305 `(re-search-forward ,regexp limit t))
301 (unless (progn 306 (unless (progn
302 (goto-char (match-beginning 0)) 307 (goto-char (match-beginning 0))
303 (c-skip-comments-and-strings limit)) 308 (c-skip-comments-and-strings limit))
@@ -476,7 +481,9 @@
476 ,(c-make-font-lock-search-form 481 ,(c-make-font-lock-search-form
477 regexp highlights))))) 482 regexp highlights)))))
478 state-stanzas) 483 state-stanzas)
479 ,(c-make-font-lock-search-form (car normal) (cdr normal)) 484 ;; In the next form, check that point hasn't been moved beyond
485 ;; `limit' in any of the above stanzas.
486 ,(c-make-font-lock-search-form (car normal) (cdr normal) t)
480 nil)))) 487 nil))))
481 488
482; (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el. 489; (eval-after-load "edebug" ; 2006-07-09: def-edebug-spec is now in subr.el.