Compare commits

..

5 Commits

Author SHA1 Message Date
2cafddc2b3 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:06:56 +02:00
96817cd061 fix: include my endian.h in nbt.h 2025-07-24 16:05:18 +02:00
d561588490 remove unused function nbt_cmpstr, since we're performing this check directly now. 2025-07-24 16:05:18 +02:00
3078a9fb5c remove nbt_arrlen function 2025-07-24 16:05:18 +02:00
16f74a91c1 move nbt_strlen to nbt.h, and rename to nbt_namelen 2025-07-24 16:05:18 +02:00
3 changed files with 6 additions and 22 deletions

View File

@@ -43,11 +43,7 @@ jobs:
git clone https://github.com/microsoft/vcpkg.git "$VCPKG_ROOT"
"$VCPKG_ROOT/bootstrap-vcpkg.sh"
"$VCPKG_ROOT/vcpkg" install $DEPS_VCPKG
# compilation (using bulk compilation)
- run: make all CALL=compile -j || echo "JOB_FAILED=1" >>"$GITHUB_ENV"
# executing unit tests (using bulk flags)
- run: make all CALL=run DEBUG=test -j || echo "JOB_FAILED=1" >>"$GITHUB_ENV"
# exit if any errors occurred
- name: exit on errors
run: |
[ "$JOB_FAILED" != "1" ]
- name: compilation (using bulk compilation)
run: make all CALL=compile -j
- name: unit tests (using bulk flags)
run: make all CALL=run DEBUG=test -j

View File

@@ -13,19 +13,6 @@ const u8 *nbt_nexttag(const u8 *restrict buf, u16 naml) {
return buf + naml + len + 3;
}
/* compares the string in `buf` to `matstr`.
* returns `=0` if equal, `>0` if buf is greater, `<0` if matstr is greater. */
static int nbt_cmpstr(const char *restrict matstr, const u8 *restrict buf) {
u16 len = be16toh(*(u16 *)buf);
// allocate and copy bytes
char str[len + 1];
memcpy(str, buf + 2, len);
str[len] = '\0';
return strncmp(str, matstr, len);
}
// TODO: not actually doing anything
/* readies the output data for export, returns the new buffer position, or `NULL` upon an error (may be out of bounds) */
static const u8 *nbt_proctag(const u8 *restrict buf, u16 slen) {

View File

@@ -7,6 +7,7 @@
#include <stdlib.h>
#include "../util/atrb.h"
#include "../util/compat/endian.h"
#include "../util/types.h"
/* NBT (named binary tag) is a tree data structure. Tags have a numeric type ID, name and a payload.
@@ -48,7 +49,7 @@ atrb_pure atrb_nonnull(1) static inline u16 nbt_namelen(const u8 *restrict buf)
/* returns the (expected) pointer of the tag following this one.
* `NULL` is returned if anything went wrong. */
atrb_pure atrb((nonnull(1))) const u8 *nbt_nexttag(const u8 *restrict buf, u16 naml);
atrb_pure atrb_nonnull(1) const u8 *nbt_nexttag(const u8 *restrict buf, u16 naml);
/* checks whether the tag is a primitive data tag. (not recommended for filtering tags, use a `switch`)
* returns a boolean value. */