fix: replace strtol with strtoll for 64-bit hex literal parsing on 32-bit platforms

The previous implementation used strtol() for parsing hex literals, which only supports up to 32-bit values on 32-bit architectures. This caused hex literals larger than 0x7FFFFFFF to overflow or fail. Changed to strtoll() which guarantees 64-bit parsing regardless of platform word size.

Also updated the error message to include the actual sizeof(long int) for debugging, uncommented the previously disabled 64-bit hex literal examples in syntax.wren, and added a test case for 0xdeadbeef to verify the fix works correctly.
This commit is contained in:
Bob Nystrom
2017-01-13 05:53:21 +00:00
parent cd6b97d341
commit 1b635d029a
3 changed files with 16 additions and 9 deletions
+2 -3
View File
@@ -130,9 +130,8 @@ class Literals is SyntaxExample {
1.0
-12.34
0x1000000
// Literals larger than 0x1000000 are only valid in 64 bit builds
// 0xdeadbeef
// 0x1234567890ABCDEF
0xdeadbeef
0x1234567890ABCDEF
}
strings {