]> git.eshelyaron.com Git - emacs.git/commitdiff
CC Mode: Correct and simplify quoted number regexps
authorAlan Mackenzie <acm@muc.de>
Mon, 14 Oct 2024 21:27:04 +0000 (21:27 +0000)
committerEshel Yaron <me@eshelyaron.com>
Tue, 15 Oct 2024 19:43:16 +0000 (21:43 +0200)
C++ Mode now gives correct fontification when \' is inserted
between the adjacent apostrophes in the number 0xde'adb''eef.

* lisp/progmodes/cc-mode.el (c-maybe-quoted-number-head):
Simplify and correct.
(c-maybe-quoted-number-tail, c-maybe-quoted-number): Simplify.

(cherry picked from commit 2a6f1527f6b3080c3879e6159424b824c86801a7)

lisp/progmodes/cc-mode.el

index 71d343e1304cc1abbf366a0c0229cf3b312ff855..2fd1fb68fc06c545dfd6c49cc445a649e87aa65b 100644 (file)
@@ -1761,14 +1761,14 @@ position of `after-change-functions'.")
 (defconst c-maybe-quoted-number-head
   (concat
    "\\(0\\("
-       "\\([Xx]\\([[:xdigit:]]\\('[[:xdigit:]]\\|[[:xdigit:]]\\)*'?\\)?\\)"
+       "[Xx]\\([[:xdigit:]]\\('?[[:xdigit:]]\\)*\\)?"
        "\\|"
-       "\\([Bb]\\([01]\\('[01]\\|[01]\\)*'?\\)?\\)"
+       "[Bb]\\([01]\\('?[01]\\)*\\)?"
        "\\|"
-       "\\('[0-7]\\|[0-7]\\)*'?"
+       "\\('?[0-7]\\)*"
        "\\)"
    "\\|"
-       "[1-9]\\('[0-9]\\|[0-9]\\)*'?"
+       "[1-9]\\('?[0-9]\\)*"
    "\\)")
   "Regexp matching the head of a numeric literal, including with digit separators.")
 
@@ -1795,11 +1795,11 @@ position of `after-change-functions'.")
 (defconst c-maybe-quoted-number-tail
   (concat
    "\\("
-       "\\([xX']?[[:xdigit:]]\\('[[:xdigit:]]\\|[[:xdigit:]]\\)*\\)"
+       "\\([xX']?[[:xdigit:]]\\('?[[:xdigit:]]\\)*\\)"
    "\\|"
-       "\\([bB']?[01]\\('[01]\\|[01]\\)*\\)"
+       "\\([bB']?[01]\\('?[01]\\)*\\)"
    "\\|"
-       "\\('?[0-9]\\('[0-9]\\|[0-9]\\)*\\)"
+       "\\('?[0-9]\\)+"
    "\\)")
   "Regexp matching the tail of a numeric literal, including with digit separators.
 Note that this is a strict tail, so won't match, e.g. \"0x....\".")
@@ -1815,14 +1815,14 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
 (defconst c-maybe-quoted-number
   (concat
    "\\(0\\("
-       "\\([Xx][[:xdigit:]]\\('[[:xdigit:]]\\|[[:xdigit:]]\\)*\\)"
+       "\\([Xx][[:xdigit:]]\\('?[[:xdigit:]]\\)*\\)"
        "\\|"
-       "\\([Bb][01]\\('[01]\\|[01]\\)*\\)"
+       "\\([Bb][01]\\('?[01]\\)*\\)"
        "\\|"
-       "\\('[0-7]\\|[0-7]\\)*"
+       "\\('?[0-7]\\)*"
        "\\)"
    "\\|"
-       "[1-9]\\('[0-9]\\|[0-9]\\)*"
+       "[1-9]\\('?[0-9]\\)*"
    "\\)")
   "Regexp matching a numeric literal, including with digit separators.")