mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-11-17 19:50:12 -08:00
base: fix data4 byte order in try_guid_from_string
The last two GUID groups were packed into a U64 and copied to data4 in host byte order, so on little endian data4 came out reversed and string_from_guid did not round trip (for example /RAD_GUID). Store the value big endian so data4[0] is the first byte of the fourth group.
This commit is contained in:
1 parent
2c226d8a4b
commit
1ac8fb5202
2 files changed
+12
-1
No files matched your search
@@ -2487,7 +2487,7 @@ try_guid_from_string(String8 string, Guid *guid_out)
|
||||
guid_out->data1 = (U32)data1;
|
||||
guid_out->data2 = (U16)data2;
|
||||
guid_out->data3 = (U16)data3;
|
||||
U64 data4 = (data4_hi << 48) | data4_lo;
|
||||
U64 data4 = from_be_u64((data4_hi << 48) | data4_lo);
|
||||
MemoryCopy(&guid_out->data4[0], &data4, sizeof(data4));
|
||||
is_parsed = 1;
|
||||
}
|
||||
|
||||
@@ -102,6 +102,17 @@ TEST(count_digits)
|
||||
T_Ok(count_digits_u64(999999, 10) == 6);
|
||||
}
|
||||
|
||||
TEST(guid_from_string)
|
||||
{
|
||||
String8 string = str8_lit("01234567-89AB-CDEF-0011-223344556677");
|
||||
U8 data4[8] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77 };
|
||||
Guid guid = {0};
|
||||
T_Ok(try_guid_from_string(string, &guid));
|
||||
T_Ok(guid.data1 == 0x01234567 && guid.data2 == 0x89AB && guid.data3 == 0xCDEF);
|
||||
T_Ok(MemoryMatch(guid.data4, data4, sizeof(data4)));
|
||||
T_Ok(str8_match(string_from_guid(arena, guid), string, 0));
|
||||
}
|
||||
|
||||
TEST(match_wildcard)
|
||||
{
|
||||
// empty strings
|
||||
|
||||
Reference in new issue
Block a user