Compare commits

..

15 Commits

Author SHA1 Message Date
d70888f9fb remove __attribute__((fallthrough)) from all that do not require it. Replace with // fall through in some places for readability 2025-07-24 16:32:41 +02:00
6dbf034ba1 add marker so I remember to add this back in 2025-07-24 16:29:03 +02:00
1ea37b6e86 fix: there is no need to let the compilation continue if it fails.
it actually makes it less easy to locate errors.
2025-07-24 16:29:03 +02:00
f3273ed5d0 fix: include my endian.h in nbt.h 2025-07-24 16:29:03 +02:00
6ccb55de8b remove unused function nbt_cmpstr, since we're performing this check directly now. 2025-07-24 16:29:03 +02:00
69dc174ff2 remove nbt_arrlen function 2025-07-24 16:29:03 +02:00
58d0dd01e2 move nbt_strlen to nbt.h, and rename to nbt_namelen 2025-07-24 16:29:03 +02:00
4005163d61 fix: use atrb_pure for functions reading global state 2025-07-24 16:29:03 +02:00
8964a1a563 fix: atrb for when _MSC_VER is defined did not have parameters 2025-07-24 16:29:03 +02:00
f0c5408c51 fix: error.h should exit with EXIT_FAILURE, rather than 1 2025-07-24 16:29:03 +02:00
1d5df8df0a apply new formatting rules to the whole project 2025-07-24 16:29:03 +02:00
cdf13b7529 change qualifier alignment to be left again 2025-07-24 16:28:25 +02:00
13e1ceddfc update nbt_proc function, still inoperable 2025-07-24 16:28:25 +02:00
333417dadd add funciton for data loading/processing 2025-07-24 16:28:25 +02:00
fd8db02e77 modify the array bytelength function to get the bytelength of a single tag. 2025-07-24 16:28:25 +02:00

View File

@@ -24,18 +24,18 @@ static const u8 *nbt_proctag(const u8 *restrict buf, u16 slen) {
// integral types
case NBT_I8: *dat = *ptr; return ptr;
case NBT_I16: *(u16 *)dat = be16toh(*(u16 *)ptr); return ptr + 2;
case NBT_I32: __attribute__((fallthrough));
case NBT_I32: // fall through
case NBT_F32: *(u32 *)dat = be16toh(*(u32 *)ptr); return ptr + 4;
case NBT_I64: __attribute__((fallthrough));
case NBT_I64: // fall through
case NBT_F64: *(u64 *)dat = be16toh(*(u64 *)ptr); return ptr + 8;
// arrays, handled differently
case NBT_LIST: __attribute__((fallthrough));
case NBT_ARR_I8: __attribute__((fallthrough));
case NBT_STR: __attribute__((fallthrough));
case NBT_ARR_I32: __attribute__((fallthrough));
case NBT_LIST:
case NBT_ARR_I8:
case NBT_STR:
case NBT_ARR_I32:
case NBT_ARR_I64:
// arrlen = nbt_arrbsize(ptr);
// TODO: arrlen = nbt_arrbsize(ptr);
break;
default: return NULL;
@@ -100,24 +100,26 @@ int nbt_primsize(u8 tag) {
switch (tag) {
case NBT_I8: return 1;
case NBT_I16: return 2;
case NBT_I32: __attribute__((fallthrough));
case NBT_I32: // fall through
case NBT_F32: return 4;
case NBT_I64: __attribute__((fallthrough));
case NBT_I64: // fall through
case NBT_F64: return 8;
default: return -1;
}
}
size_t nbt_tagdatlen(const u8 *restrict buf) {
i32 mems = 0;
size_t mems = 0;
switch (*buf) {
case NBT_I8: __attribute__((fallthrough));
case NBT_I16: __attribute__((fallthrough));
case NBT_I32: __attribute__((fallthrough));
case NBT_F32: __attribute__((fallthrough));
case NBT_I64: __attribute__((fallthrough));
case NBT_F64: __attribute__((fallthrough));
case NBT_I8:
case NBT_I16:
case NBT_I32:
case NBT_F32:
case NBT_I64:
case NBT_F64:
mems = nbt_primsize(*buf);
return -(mems >= 0) & mems;
case NBT_ARR_I64: mems += sizeof(i64) - sizeof(i32); __attribute__((fallthrough));
case NBT_ARR_I32: mems += sizeof(i32) - sizeof(i8); __attribute__((fallthrough));
@@ -135,11 +137,11 @@ size_t nbt_tagdatlen(const u8 *restrict buf) {
int nbt_isprim(u8 tag) {
switch (tag) {
case NBT_I8: __attribute__((fallthrough));
case NBT_I16: __attribute__((fallthrough));
case NBT_I32: __attribute__((fallthrough));
case NBT_F32: __attribute__((fallthrough));
case NBT_I64: __attribute__((fallthrough));
case NBT_I8:
case NBT_I16:
case NBT_I32:
case NBT_F32:
case NBT_I64:
case NBT_F64:
return 1;
default: