runtime(cpp): Fix c++ float and integer literal syntax highlighting

Commit: 
https://github.com/vim/vim/commit/335aecd98f75a081ad34b99e34922f3e7e0b25ea
Author: Dominique Pelle <[email protected]>
Date:   Thu Jan 8 21:18:58 2026 +0000

    runtime(cpp): Fix c++ float and integer literal syntax highlighting
    
    closes: https://github.com/vim/vim/issues/8939
    
    Co-authored-by: Eisuke Kawashima <[email protected]>
    Signed-off-by: Dominique Pelle <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/syntax/cpp.vim b/runtime/syntax/cpp.vim
index 2bf5b1ffc..5ea52ec50 100644
--- a/runtime/syntax/cpp.vim
+++ b/runtime/syntax/cpp.vim
@@ -4,8 +4,9 @@
 " Previous Maintainer: vim-jp (https://github.com/vim-jp/vim-cpp)
 "                      Ken Shan <[email protected]>
 " Last Change: 2024 May 04
-"   2024 May 04 by Vim Project (fix digit separator in octals and floats)
-"   2026 Jan 06 by Vim Project (announce adoption)
+"   2024 May 04 by Vim Project fix digit separator in octals and floats
+"   2026 Jan 06 by Vim Project orphaning announcement
+"   2026 Jan 08 by Vim Project highlight capital letter prefixes for numbers
 
 " quit when a syntax file was already loaded
 if exists("b:current_syntax")
@@ -59,11 +60,11 @@ if !exists("cpp_no_cpp14")
   syn match cppNumber          display contained 
"\<0\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
   syn match cppNumber          display contained 
"\<[1-9]\('\=\d\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
   syn match cppNumber          display contained 
"\<0\('\=\o\+\)\+\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
-  syn match cppNumber          display contained 
"\<0b[01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
-  syn match cppNumber          display contained 
"\<0x\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
-  syn match cppFloat           display contained 
"\<\d\('\=\d\+\)*\.\(\d\('\=\d\+\)*\)\=\(e[-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
-  syn match cppFloat           display contained 
"\.\d\('\=\d\+\)*\(e[-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
-  syn match cppFloat           display contained 
"\<\d\+e[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+  syn match cppNumber          display contained 
"\<0[Bb][01]\('\=[01]\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+  syn match cppNumber          display contained 
"\<0[Xx]\x\('\=\x\+\)*\([Uu]\=\([Ll]\|LL\|ll\)\|\([Ll]\|LL\|ll\)\=[Uu]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+  syn match cppFloat           display contained 
"\<\d\('\=\d\+\)*\.\(\d\('\=\d\+\)*\)\=\([Ee][-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+  syn match cppFloat           display contained 
"\.\d\('\=\d\+\)*\([Ee][-+]\=\d\+\)\=\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+  syn match cppFloat           display contained 
"\<\d\+[Ee][-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
   syn region cppString         start=+\(L\|u\|u8\|U\)\="+ skip=+\\\|\"\|\$+ 
excludenl end=+"\(sv\|s\|_\i*\)\=+ end='$' contains=cSpecial,cFormat,@Spell
 endif
 
@@ -71,8 +72,8 @@ endif
 if !exists("cpp_no_cpp17")
   syn match cppCast            "\<reinterpret_pointer_cast\s*<"me=e-1
   syn match cppCast            "\<reinterpret_pointer_cast\s*$"
-  syn match cppFloat           display contained 
"\<0x\x*\.\x\+p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
-  syn match cppFloat           display contained 
"\<0x\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+  syn match cppFloat           display contained 
"\<0[Xx]\x*\.\x\+p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
+  syn match cppFloat           display contained 
"\<0[Xx]\x\+\.\=p[-+]\=\d\+\([FfLl]\|i[fl]\=\|h\|min\|s\|ms\|us\|ns\|_\i*\)\=\>"
 
   " TODO: push this up to c.vim if/when supported in C23
   syn match cppCharacter       "u8'[^\]'"
@@ -94,8 +95,8 @@ if !exists("cpp_no_cpp20")
   syn match cppNumber          display contained "\<0\(y\|d\)\>"
   syn match cppNumber          display contained 
"\<[1-9]\('\=\d\+\)*\(y\|d\)\>"
   syn match cppNumber          display contained "\<0\o\+\(y\|d\)\>"
-  syn match cppNumber          display contained 
"\<0b[01]\('\=[01]\+\)*\(y\|d\)\>"
-  syn match cppNumber          display contained "\<0x\x\('\=\x\+\)*\(y\|d\)\>"
+  syn match cppNumber          display contained 
"\<0[Bb][01]\('\=[01]\+\)*\(y\|d\)\>"
+  syn match cppNumber          display contained 
"\<0[Xx]\x\('\=\x\+\)*\(y\|d\)\>"
   syn keyword cppStatement     co_await co_return co_yield requires
   syn keyword cppStorageClass  consteval constinit
   syn keyword cppStructure     concept
diff --git a/runtime/syntax/testdir/dumps/cpp_numbers_00.dump 
b/runtime/syntax/testdir/dumps/cpp_numbers_00.dump
new file mode 100644
index 000000000..41a236a0e
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/cpp_numbers_00.dump
@@ -0,0 +1,20 @@
+>v+0#00e0003#ffffff0|o|i|d| +0#0000000&|f|o@1|(|)| @64
+|{| @73
+@4|{| @69
+@8|/+0#0000e05&@1| |S|e@1| 
|h|t@1|p|s|:|/@1|e|n|.|c|p@1|r|e|f|e|r|e|n|c|e|.|c|o|m|/|w|/|c|p@1|/|l|a|n|g|u|a|g|e|/|f|l|o|a|t|i|n|g|_|l|i|t|e|r|a|l|
 +0#0000000&
+@8|d+0#00e0003&|o|u|b|l|e| +0#0000000&|a| |=| 
|1+0#e000002&|.|0|E|2|;+0#0000000&| @49
+@8|d+0#00e0003&|o|u|b|l|e| +0#0000000&|b| |=| 
|1+0#e000002&|.|0|e|2|;+0#0000000&| @49
+@8|d+0#00e0003&|o|u|b|l|e| +0#0000000&|c| |=| |1+0#e000002&|E|2|;+0#0000000&| 
@51
+@8|d+0#00e0003&|o|u|b|l|e| +0#0000000&|d| |=| |1+0#e000002&|e|2|;+0#0000000&| 
@51
+@75
+@8|d+0#00e0003&|o|u|b|l|e| +0#0000000&|e| |=| 
|0+0#e000002&|X|1|f@1|p|1|0|;+0#0000000&| @46
+@8|d+0#00e0003&|o|u|b|l|e| +0#0000000&|f| |=| 
|0+0#e000002&|x|1|f@1|p|1|0|;+0#0000000&| @46
+@4|}| @69
+@75
+@4|/+0#0000e05&@1| |S|e@1|:| 
|h|t@1|p|s|:|/@1|e|n|.|c|p@1|r|e|f|e|r|e|n|c|e|.|c|o|m|/|w|/|c|p@1|/|l|a|n|g|u|a|g|e|/|i|n|t|e|g|e|r|_|l|i|t|e|r|a|l|
 +0#0000000&@4
+@4|i+0#00e0003&|n|t| +0#0000000&|a| |=| |0+0#e000002&|X|1|2|3|;+0#0000000&| @56
+@4|i+0#00e0003&|n|t| +0#0000000&|b| |=| |0+0#e000002&|x|1|2|3|;+0#0000000&| @56
+@75
+@4|i+0#00e0003&|n|t| +0#0000000&|c| |=| |0+0#e000002&|B|1|0|1|;+0#0000000&| @56
+@4|i+0#00e0003&|n|t| +0#0000000&|d| |=| |0+0#e000002&|b|1|0|1|;+0#0000000&| @56
+@57|1|,|1| @10|T|o|p| 
diff --git a/runtime/syntax/testdir/dumps/cpp_numbers_01.dump 
b/runtime/syntax/testdir/dumps/cpp_numbers_01.dump
new file mode 100644
index 000000000..85a85c1d8
--- /dev/null
+++ b/runtime/syntax/testdir/dumps/cpp_numbers_01.dump
@@ -0,0 +1,20 @@
+| +0&#ffffff0@3|/+0#0000e05&@1| |S|e@1|:| 
|h|t@1|p|s|:|/@1|e|n|.|c|p@1|r|e|f|e|r|e|n|c|e|.|c|o|m|/|w|/|c|p@1|/|l|a|n|g|u|a|g|e|/|i|n|t|e|g|e|r|_|l|i|t|e|r|a|l|
 +0#0000000&@4
+@4|i+0#00e0003&|n|t| +0#0000000&|a| |=| |0+0#e000002&|X|1|2|3|;+0#0000000&| @56
+@4|i+0#00e0003&|n|t| +0#0000000&|b| |=| |0+0#e000002&|x|1|2|3|;+0#0000000&| @56
+@75
+@4|i+0#00e0003&|n|t| +0#0000000&|c| |=| |0+0#e000002&|B|1|0|1|;+0#0000000&| @56
+@4>i+0#00e0003&|n|t| +0#0000000&|d| |=| |0+0#e000002&|b|1|0|1|;+0#0000000&| @56
+|}| @73
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|9|,|5| @9|B|o|t| 
diff --git a/runtime/syntax/testdir/input/cpp_numbers.cpp 
b/runtime/syntax/testdir/input/cpp_numbers.cpp
new file mode 100644
index 000000000..d6ef21b0a
--- /dev/null
+++ b/runtime/syntax/testdir/input/cpp_numbers.cpp
@@ -0,0 +1,20 @@
+void foo()
+{
+    {
+        // See https://en.cppreference.com/w/cpp/language/floating_literal
+        double a = 1.0E2;
+        double b = 1.0e2;
+        double c = 1E2;
+        double d = 1e2;
+
+        double e = 0X1ffp10;
+        double f = 0x1ffp10;
+    }
+
+    // See: https://en.cppreference.com/w/cpp/language/integer_literal
+    int a = 0X123;
+    int b = 0x123;
+
+    int c = 0B101;
+    int d = 0b101;
+}

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vdxa1-003Fm7-IO%40256bit.org.

Raspunde prin e-mail lui