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>

Johannes Sixt committed Oct 10, 2021 at 17:03 UTC 637b80cd6a2a73eb6723aec2f52aed1135d99de4
2 files changed +7 -7
t/t4034/cpp/expect
+4 -4
@@ -7,15 +7,15 @@ Foo() : x(0<RED>&&1<RESET><GREEN>&42<RESET>) { <RED>foo0<RESET><GREEN>bar<RESET>
7 cout<<"Hello World<RED>!<RESET><GREEN>?<RESET>\n"<<endl;
8 <GREEN>(<RESET>1 <RED>-<RESET><GREEN>+<RESET>1e10 0xabcdef<GREEN>)<RESET> '<RED>x<RESET><GREEN>.<RESET>'
9 // long double<RESET>
10 -3.141'592'<RED>653e-10l<RESET><GREEN>654e+10l<RESET>
10 +<RED>3.141'592'653e-10l<RESET><GREEN>3.141'592'654e+10l<RESET>
11 // float<RESET>
12 <RED>120E5f<RESET><GREEN>120E6f<RESET>
13 // hex<RESET>
14 -0xdead'<RED>beaf<RESET><GREEN>Beaf<RESET>+<RED>8ULL<RESET><GREEN>7ULL<RESET>
14 +<RED>0xdead'beaf<RESET><GREEN>0xdead'Beaf<RESET>+<RED>8ULL<RESET><GREEN>7ULL<RESET>
15 // octal<RESET>
16 -0123'<RED>4567<RESET><GREEN>4560<RESET>
16 +<RED>0123'4567<RESET><GREEN>0123'4560<RESET>
17 // binary<RESET>
18 -<RED>0b10<RESET><GREEN>0b11<RESET>'00+e1
18 +<RED>0b10'00<RESET><GREEN>0b11'00<RESET>+e1
19 // expression<RESET>
20 1.5-e+<RED>2<RESET><GREEN>3<RESET>+f
21 // another one<RESET>
userdiff.c
+3 -3
@@ -67,11 +67,11 @@ PATTERNS("cpp",
67 /* identifiers and keywords */
68 "[a-zA-Z_][a-zA-Z0-9_]*"
69 /* decimal and octal integers as well as floatingpoint numbers */
70 - "|[0-9][0-9.]*([Ee][-+]?[0-9]+)?[fFlLuU]*"
70 + "|[0-9][0-9.']*([Ee][-+]?[0-9]+)?[fFlLuU]*"
71 /* hexadecimal and binary integers */
72 - "|0[xXbB][0-9a-fA-F]+[lLuU]*"
72 + "|0[xXbB][0-9a-fA-F']+[lLuU]*"
73 /* floatingpoint numbers that begin with a decimal point */
74 - "|\\.[0-9]+([Ee][-+]?[0-9]+)?[fFlL]?"
74 + "|\\.[0-9][0-9']*([Ee][-+]?[0-9]+)?[fFlL]?"
75 "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*"),
76 PATTERNS("csharp",
77 /* Keywords */