aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-06-25 11:18:47 +0200
committerThomas Voss <mail@thomasvoss.com> 2024-06-25 11:18:47 +0200
commitf92ebd28b4b5c6451c4bf1deb96e8b141dc579f3 (patch)
tree755f08d5e058bbbe033b54921024fba98ac50701
parent02c0f565c4003ffee16f6d99819ecedfb042c875 (diff)
Fix build on Darwin
-rw-r--r--make.c3
-rw-r--r--src/codegen.c6
-rw-r--r--src/lexer.c11
3 files changed, 11 insertions, 9 deletions
diff --git a/make.c b/make.c
index 598db1d..d5f7da4 100644
--- a/make.c
+++ b/make.c
@@ -207,8 +207,7 @@ cc(void *arg)
strspushl(&cmd, "-fsanitize=address,undefined");
if (simd_flags != 0)
strspushl(&cmd, "-DORYX_SIMD=1");
- if (strcmp(arg, "src/codegen.c") == 0)
- llvmquery(&cmd, LLVM_CFLAGS);
+ llvmquery(&cmd, LLVM_CFLAGS);
strspushl(&cmd, "-o", dst, "-c", src);
cmdput(cmd);
diff --git a/src/codegen.c b/src/codegen.c
index 4d331e2..1567adf 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -268,8 +268,10 @@ codegenfunc(struct cgctx ctx, idx_t i, strview_t sv)
if (ctx.namespace.len == 0) {
svtocstr(name, sv);
namesz--;
- } else
- sprintf(name, "%.*s.%.*s", SV_PRI_ARGS(ctx.namespace), SV_PRI_ARGS(sv));
+ } else {
+ snprintf(name, namesz + 1, "%.*s.%.*s", SV_PRI_ARGS(ctx.namespace),
+ SV_PRI_ARGS(sv));
+ }
ctx.namespace.p = name;
ctx.namespace.len = namesz;
diff --git a/src/lexer.c b/src/lexer.c
index 0ed057d..7938b28 100644
--- a/src/lexer.c
+++ b/src/lexer.c
@@ -116,8 +116,9 @@ lexstring(const uchar *code, size_t codesz)
break;
case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9': {
+ case '5': case '6': case '7': case '8': case '9':
number:
+ {
bool saw_dot = false;
data.kinds[data.len] = LEXNUM;
data.strs[data.len].p = spnbeg;
@@ -179,7 +180,7 @@ mklexemes(void)
static_assert(offsetof(lexemes_t, kinds) < offsetof(lexemes_t, strs),
"KINDS is not the first field before STRS");
- static_assert(LEXEMES_DFLT_CAP * sizeof(*soa.kinds) % alignof(*soa.strs)
+ static_assert(LEXEMES_DFLT_CAP * sizeof(*soa.kinds) % alignof(strview_t)
== 0,
"Additional padding is required to properly align STRS");
@@ -209,9 +210,9 @@ lexemesresz(lexemes_t *soa)
ncap = soa->cap << 1;
/* Ensure that soa->strs is properly aligned */
- pad = alignof(*soa->strs)
- - ncap * sizeof(*soa->kinds) % alignof(*soa->strs);
- if (pad == alignof(*soa->strs))
+ pad = alignof(strview_t)
+ - ncap * sizeof(*soa->kinds) % alignof(strview_t);
+ if (pad == alignof(strview_t))
pad = 0;
newsz = ncap * LEXEMES_BLKSZ + pad;