summaryrefslogtreecommitdiffhomepage
path: root/src/build
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2024-08-03 23:40:31 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2024-08-23 20:37:37 +0100
commit83da606072ce272eb053d4e1497d77e647cfecae (patch)
tree71d0110881ff8685184c5f4ab720cc8d49c24678 /src/build
parentacbd30e0427b16f885f96aed59881ec04eff25bc (diff)
Revise syntax macros and add a ton of branch hints
My new programming style is branch hints. All non-confusing branches must be hinted when I can be bothered. It's faster, sometimes, maybe. Also, start trying to use more signed sizes in at least some of the places where it makes sense. Unsigned sizes are surprisingly error-prone!
Diffstat (limited to 'src/build')
-rw-r--r--src/build/codegen.c9
-rw-r--r--src/build/mkentprops.c4
-rw-r--r--src/build/mkgamedata.c2
3 files changed, 8 insertions, 7 deletions
diff --git a/src/build/codegen.c b/src/build/codegen.c
index 3cf4d8b..70b5e12 100644
--- a/src/build/codegen.c
+++ b/src/build/codegen.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2023 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2024 Michael Smith <mikesmiffy128@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -20,6 +20,7 @@
#include <string.h>
#include "../intdefs.h"
+#include "../langext.h"
#include "../os.h"
#include "cmeta.h"
#include "skiplist.h"
@@ -45,8 +46,8 @@ static struct conent {
static int nconents;
#define PUT(name_, isvar_, unreg_) do { \
- if (nconents == sizeof(conents) / sizeof(*conents)) { \
- fprintf(stderr, "codegen: out of space; make ents bigger!\n"); \
+ if (nconents == countof(conents)) { \
+ fprintf(stderr, "codegen: out of space; make conents bigger!\n"); \
exit(1); \
} \
conents[nconents].name = name_; \
@@ -116,7 +117,7 @@ static struct skiplist_hdr_feature_bydesc features_bydesc = {0};
static void onfeatinfo(enum cmeta_featmacro type, const char *param,
void *ctxt) {
struct feature *f = ctxt;
- switch (type) {
+ switch_exhaust_enum (cmeta_featmacro, type) {
case CMETA_FEAT_REQUIRE:; bool optional = false; goto dep;
case CMETA_FEAT_REQUEST: optional = true;
dep:; struct feature *dep = skiplist_get_feature(&features, param);
diff --git a/src/build/mkentprops.c b/src/build/mkentprops.c
index 2043a9b..fdbb8af 100644
--- a/src/build/mkentprops.c
+++ b/src/build/mkentprops.c
@@ -20,7 +20,7 @@
#include "../intdefs.h"
#include "../kv.h"
-#include "../noreturn.h"
+#include "../langext.h"
#include "../os.h"
#include "skiplist.h"
#include "vec.h"
@@ -73,7 +73,7 @@ static noreturn badparse(struct parsestate *state, const char *e) {
static void kv_cb(enum kv_token type, const char *p, uint len, void *ctxt) {
struct parsestate *state = ctxt;
- switch (type) {
+ switch_exhaust_enum (kv_token, type) {
case KV_IDENT: case KV_IDENT_QUOTED:
state->lastvar = malloc(len + 1);
if (!state->lastvar) die("couldn't allocate memory");
diff --git a/src/build/mkgamedata.c b/src/build/mkgamedata.c
index bf359b2..266a411 100644
--- a/src/build/mkgamedata.c
+++ b/src/build/mkgamedata.c
@@ -20,7 +20,7 @@
#include "../intdefs.h"
#include "../kv.h"
-#include "../noreturn.h"
+#include "../langext.h"
#include "../os.h"
#include "vec.h"