[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 18331d0: Fix "Args out of range" error in c-deter
From: |
Alan Mackenzie |
Subject: |
[Emacs-diffs] emacs-26 18331d0: Fix "Args out of range" error in c-determine-limit. Fixes bug #28598. |
Date: |
Mon, 30 Oct 2017 13:41:36 -0400 (EDT) |
branch: emacs-26
commit 18331d00da7394f169b842f9e701568fede9b402
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>
Fix "Args out of range" error in c-determine-limit. Fixes bug #28598.
* lisp/progmodes/cc-engine.el (c-determine-limit-get-base): If the candidate
position for BASE is below point-min, scan forward to the end of the current
literal.
(c-determine-limit): Add an extra arm to the final cond form, testing for
BASE
being at point-min.
---
lisp/progmodes/cc-engine.el | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index db201a6..6f39cc6 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -5189,16 +5189,25 @@ comment at the start of cc-engine.el for more info."
;; Get a "safe place" approximately TRY-SIZE characters before START.
;; This defsubst doesn't preserve point.
(let* ((pos (max (- start try-size) (point-min)))
- (s (c-state-semi-pp-to-literal pos)))
- (or (car (cddr s)) pos)))
+ (s (c-state-semi-pp-to-literal pos))
+ (cand (or (car (cddr s)) pos)))
+ (if (>= cand (point-min))
+ cand
+ (parse-partial-sexp pos start nil nil (car s) 'syntax-table)
+ (point))))
(defun c-determine-limit (how-far-back &optional start try-size)
- ;; Return a buffer position HOW-FAR-BACK non-literal characters from START
- ;; (default point). This is done by going back further in the buffer then
- ;; searching forward for literals. The position found won't be in a
- ;; literal. We start searching for the sought position TRY-SIZE (default
- ;; twice HOW-FAR-BACK) bytes back from START. This function must be fast.
- ;; :-)
+ ;; Return a buffer position HOW-FAR-BACK non-literal characters from
+ ;; START (default point). The starting position, either point or
+ ;; START may not be in a comment or string.
+ ;;
+ ;; The position found will not be before POINT-MIN and won't be in a
+ ;; literal.
+ ;;
+ ;; We start searching for the sought position TRY-SIZE (default
+ ;; twice HOW-FAR-BACK) bytes back from START.
+ ;;
+ ;; This function must be fast. :-)
(save-excursion
(let* ((start (or start (point)))
(try-size (or try-size (* 2 how-far-back)))
@@ -5254,6 +5263,8 @@ comment at the start of cc-engine.el for more info."
(+ (car elt) (- count how-far-back)))
((eq base (point-min))
(point-min))
+ ((> base (- start try-size)) ; Can only happen if we hit point-min.
+ (car elt))
(t
(c-determine-limit (- how-far-back count) base try-size))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-26 18331d0: Fix "Args out of range" error in c-determine-limit. Fixes bug #28598.,
Alan Mackenzie <=