]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug in yesterday's CC Mode commit.
authorAlan Mackenzie <acm@muc.de>
Sun, 2 Jul 2017 12:58:27 +0000 (12:58 +0000)
committerAlan Mackenzie <acm@muc.de>
Sun, 2 Jul 2017 12:58:27 +0000 (12:58 +0000)
* lisp/progmodes/cc-mode.el (c-quoted-number-head-before-point): Check a
search has succeded before using the match data.
(c-quoted-number-head-before-point, c-quoted-number-head-after-point):
Specify that the position of the extremity of the head or tail is in the
match data.

lisp/progmodes/cc-mode.el

index c5ee60f7d799e1e231111fdbbad009807c668687..ef93f75c5f3cd9db4d88b6f8cd9e5f79dce6e0db 100644 (file)
@@ -1113,18 +1113,22 @@ Note that the style variables are always made local to the buffer."
 (defun c-quoted-number-head-before-point ()
   ;; Return non-nil when the head of a possibly quoted number is found
   ;; immediately before point.  The value returned in this case is the buffer
-  ;; position of the start of the head.
+  ;; position of the start of the head.  That position is also in
+  ;; (match-beginning 0).
   (when c-has-quoted-numbers
     (save-excursion
       (let ((here (point))
-           )
+           found)
        (skip-chars-backward "0-9a-fA-F'")
        (if (and (memq (char-before) '(?x ?X))
                 (eq (char-before (1- (point))) ?0))
            (backward-char 2))
-       (while (and (search-forward-regexp c-maybe-quoted-number-head here t)
-                   (< (match-end 0) here)))
-       (and (eq (match-end 0) here) (match-beginning 0))))))
+       (while
+           (and
+            (setq found
+                  (search-forward-regexp c-maybe-quoted-number-head here t))
+            (< found here)))
+       (and (eq found here) (match-beginning 0))))))
 
 (defconst c-maybe-quoted-number-tail
   (concat
@@ -1141,7 +1145,7 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
 (defun c-quoted-number-tail-after-point ()
   ;; Return non-nil when a proper tail of a possibly quoted number is found
   ;; immediately after point.  The value returned in this case is the buffer
-  ;; position of the end of the tail.
+  ;; position of the end of the tail.  That position is also in (match-end 0).
   (when c-has-quoted-numbers
     (and (looking-at c-maybe-quoted-number-tail)
         (match-end 0))))