diff --git a/CHANGES.md b/CHANGES.md
index 6907413e8f..64f81406b2 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -15,6 +15,7 @@ Core Grammars:
- enh(erlang) OTP25/27 maybe statement [nixxquality][]
- enh(dart) Support digit-separators in number literals [Sam Rawlins][]
- enh(csharp) add Contextual keywords `file`, `args`, `dynamic`, `record`, `required` and `scoped` [Alvin Joy][]
+- fix(c) - Fixed hex numbers with decimals [Dxuian]
- fix(ruby) - fix `|=` operator false positives (as block arguments) [Aboobacker MK]
New Grammars:
@@ -42,6 +43,7 @@ CONTRIBUTORS
[nixxquality]: https://github.com/nixxquality
[srawlins]: https://github.com/srawlins
[Alvin Joy]: https://github.com/alvinsjoy
+[Dxuian]:https://github.com/Dxuian
[Aboobacker MK]: https://github.com/tachyons
[Imken]: https://github.com/immccn123
diff --git a/src/languages/c.js b/src/languages/c.js
index 350751f1ee..4c502d91c6 100644
--- a/src/languages/c.js
+++ b/src/languages/c.js
@@ -57,13 +57,14 @@ export default function(hljs) {
const NUMBERS = {
className: 'number',
variants: [
- { begin: '\\b(0b[01\']+)' },
- { begin: '(-?)\\b([\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)' },
- { begin: '(-?)(\\b0[xX][a-fA-F0-9\']+|(\\b[\\d\']+(\\.[\\d\']*)?|\\.[\\d\']+)([eE][-+]?[\\d\']+)?)' }
- ],
+ { match: /\b(0b[01']+)/ },
+ { match: /(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/ },
+ { match: /(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/ },
+ { match: /(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/ }
+ ],
relevance: 0
- };
-
+ };
+
const PREPROCESSOR = {
className: 'meta',
begin: /#\s*[a-z]+\b/,
diff --git a/test/markup/c/number-literals.expect.txt b/test/markup/c/number-literals.expect.txt
new file mode 100644
index 0000000000..3bc83a4bf6
--- /dev/null
+++ b/test/markup/c/number-literals.expect.txt
@@ -0,0 +1,46 @@
+
+
+1.
++12.
+1.2
+1234e56
+
+
+0x1p2
++0x1.p2
+-0X1A.P2
+0x1.Ap2
+
+
+1.F
+
+
+
++0b1
+0B01
+
+
++0x1
+0X1A
+
+
++01
+012
+
+
+0
++1
+12
+
+
+0X2L
+0x2l
+03LL
+03ll
+4UL 4Ul 4uL 4ul
+5LU 5Lu 5lU 5lu
+6ULL 6Ull 6uLL 6ull
+7LLU 7LLu 7llU 7llu
+
+
+char word[] = { '3', '\0' };
\ No newline at end of file
diff --git a/test/markup/c/number-literals.txt b/test/markup/c/number-literals.txt
new file mode 100644
index 0000000000..1d1972c4cc
--- /dev/null
+++ b/test/markup/c/number-literals.txt
@@ -0,0 +1,46 @@
+/* Floating-point literals. */
+// Decimal.
+1.
++12.
+1.2
+1234e56
+
+// Hexadecimal.
+0x1p2
++0x1.p2
+-0X1A.P2
+0x1.Ap2
+
+// Literal suffixes.
+1.F
+
+/* Integer literals. */
+// Binary.
++0b1 // Note: Not standard C, but valid in some compilers
+0B01 // Note: Not standard C, but valid in some compilers
+
+// Hexadecimal.
++0x1
+0X1A
+
+// Octal.
++01
+012
+
+// Decimal.
+0
++1
+12
+
+// Literal suffixes.
+0X2L
+0x2l
+03LL
+03ll
+4UL 4Ul 4uL 4ul
+5LU 5Lu 5lU 5lu
+6ULL 6Ull 6uLL 6ull
+7LLU 7LLu 7llU 7llu
+
+// Character array.
+char word[] = { '3', '\0' };
\ No newline at end of file