summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Johannes Sixt <j6t@kdbg.org>2021-10-10 17:03:03 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-10-10 15:24:21 -0700
commit637b80cd6a2a73eb6723aec2f52aed1135d99de4 (patch)
tree523f84e2e59077c69d6eec3fd516df830459feb4
parentuserdiff-cpp: prepare test cases with yet unsupported features (diff)
downloadtgif-637b80cd6a2a73eb6723aec2f52aed1135d99de4.tar.xz
userdiff-cpp: permit the digit-separating single-quote in numbers
Since C++17, the single-quote can be used as digit separator: 3.141'592'654 1'000'000 0xdead'beaf Make it known to the word regex of the cpp driver, so that numbers are not split into separate tokens at the single-quotes. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--t/t4034/cpp/expect8
-rw-r--r--userdiff.c6
2 files changed, 7 insertions, 7 deletions
diff --git a/t/t4034/cpp/expect b/t/t4034/cpp/expect
index 3d37ddac42..b90b3f207b 100644
--- a/t/t4034/cpp/expect
+++ b/t/t4034/cpp/expect
@@ -7,15 +7,15 @@ Foo() : x(0<RED>&&1<RESET><GREEN>&42<RESET>) { <RED>foo0<RESET><GREEN>bar<RESET>
cout<<"Hello World<RED>!<RESET><GREEN>?<RESET>\n"<<endl;
<GREEN>(<RESET>1 <RED>-<RESET><GREEN>+<RESET>1e10 0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>.<RESET>'
// long double<RESET>
-3.141'592'<RED>653e-10l<RESET><GREEN>654e+10l<RESET>
+<RED>3.141'592'653e-10l<RESET><GREEN>3.141'592'654e+10l<RESET>
// float<RESET>
<RED>120E5f<RESET><GREEN>120E6f<RESET>
// hex<RESET>
-0xdead'<RED>beaf<RESET><GREEN>Beaf<RESET>+<RED>8ULL<RESET><GREEN>7ULL<RESET>
+<RED>0xdead'beaf<RESET><GREEN>0xdead'Beaf<RESET>+<RED>8ULL<RESET><GREEN>7ULL<RESET>
// octal<RESET>
-0123'<RED>4567<RESET><GREEN>4560<RESET>
+<RED>0123'4567<RESET><GREEN>0123'4560<RESET>
// binary<RESET>
-<RED>0b10<RESET><GREEN>0b11<RESET>'00+e1
+<RED>0b10'00<RESET><GREEN>0b11'00<RESET>+e1
// expression<RESET>
1.5-e+<RED>2<RESET><GREEN>3<RESET>+f
// another one<RESET>
diff --git a/userdiff.c b/userdiff.c
index 8b49194f56..c1084650dd 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -67,11 +67,11 @@ PATTERNS("cpp",
/* identifiers and keywords */
"[a-zA-Z_][a-zA-Z0-9_]*"
/* decimal and octal integers as well as floatingpoint numbers */
- "|[0-9][0-9.]*([Ee][-+]?[0-9]+)?[fFlLuU]*"
+ "|[0-9][0-9.']*([Ee][-+]?[0-9]+)?[fFlLuU]*"
/* hexadecimal and binary integers */
- "|0[xXbB][0-9a-fA-F]+[lLuU]*"
+ "|0[xXbB][0-9a-fA-F']+[lLuU]*"
/* floatingpoint numbers that begin with a decimal point */
- "|\\.[0-9]+([Ee][-+]?[0-9]+)?[fFlL]?"
+ "|\\.[0-9][0-9']*([Ee][-+]?[0-9]+)?[fFlL]?"
"|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*"),
PATTERNS("csharp",
/* Keywords */