emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 607cc29: Fix C++ Mode dynamic error with string del


From: Alan Mackenzie
Subject: [Emacs-diffs] master 607cc29: Fix C++ Mode dynamic error with string delimiters.
Date: Tue, 30 Oct 2018 07:46:01 -0400 (EDT)

branch: master
commit 607cc2901bab0be64d08aff0394a4676a81da40b
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    Fix C++ Mode dynamic error with string delimiters.
    
    Fixes bug #33163
    
    * lisp/progmodes/cc-mode.el (c-before-change-check-unbalanced-strings):
    Use the correct variable `end' in place of the wrong `c-new-END'.
    (c-after-change-re-mark-unbalanced-strings): Correct a logic error whilst
    skipping over comments.
---
 lisp/progmodes/cc-mode.el | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 09c30e2..d019cf2 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -1232,21 +1232,21 @@ Note that the style variables are always made local to 
the buffer."
       (if (eq beg-literal-type 'string)
          (setq c-new-BEG (min (car beg-limits) c-new-BEG))))
 
-     ((< c-new-END (point-max))
-      (goto-char (1+ c-new-END))       ; might be a newline.
+     ((< end (point-max))
+      (goto-char (1+ end))     ; might be a newline.
       ;; In the following regexp, the initial \n caters for a newline getting
       ;; joined to a preceding \ by the removal of what comes between.
       (re-search-forward "[\n\r]?\\(\\\\\\(.\\|\n\\|\r\\)\\|[^\\\n\r]\\)*"
                         nil t)
       ;; We're at an EOLL or point-max.
-      (setq c-new-END (min (1+ (point)) (point-max)))
-      (goto-char c-new-END)
-      (if (equal (c-get-char-property (1- (point)) 'syntax-table) '(15))
-         (if (memq (char-before) '(?\n ?\r))
+      (setq c-new-END (max c-new-END (min (1+ (point)) (point-max))))
+      (if (equal (c-get-char-property (point) 'syntax-table) '(15))
+         (if (memq (char-after) '(?\n ?\r))
              ;; Normally terminated invalid string.
-             (progn
+             (let ((eoll-1 (point)))
+               (forward-char)
                (backward-sexp)
-               (c-clear-char-property (1- c-new-END) 'syntax-table)
+               (c-clear-char-property eoll-1 'syntax-table)
                (c-clear-char-property (point) 'syntax-table))
            ;; Opening " at EOB.
            (c-clear-char-property (1- (point)) 'syntax-table))
@@ -1254,7 +1254,7 @@ Note that the style variables are always made local to 
the buffer."
            ;; Opening " on last line of text (without EOL).
            (c-clear-char-property (point) 'syntax-table))))
 
-     (t (goto-char c-new-END)
+     (t (goto-char end)                        ; point-max
        (if (c-search-backward-char-property 'syntax-table '(15) c-new-BEG)
            (c-clear-char-property (point) 'syntax-table))))
 
@@ -1343,9 +1343,9 @@ Note that the style variables are always made local to 
the buffer."
             (while (progn
                      (setq s (parse-partial-sexp (point) c-new-END nil
                                                  nil s 'syntax-table))
-                     (and (not (nth 3 s))
-                          (< (point) c-new-END)
-                          (not (memq (char-before) c-string-delims)))))
+                      (and (< (point) c-new-END)
+                           (or (not (nth 3 s))
+                               (not (memq (char-before) c-string-delims))))))
             ;; We're at the start of a string.
             (memq (char-before) c-string-delims)))
        (if (c-unescaped-nls-in-string-p (1- (point)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]