summaryrefslogtreecommitdiffhomepage
path: root/src/build/cmeta.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2023-07-29 14:32:06 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2023-08-02 21:02:31 +0100
commit9a0d8730fa977f666b5c12e4c5901e7d0391e245 (patch)
tree87eebcdcef04ae1e7348ef80e972c08aa4783649 /src/build/cmeta.c
parentd337b09936ecd90bad07b28b48b7103395d97ce5 (diff)
Make various preparations for upcoming features
A lot of this is random WIP from a while back, at least a month ago, and is being committed now to get it out of the way so that other patches can be brought in and integrated against it without causing headaches. Also rolled into this commit is a way to distinguish plugin_unload from exiting the game. This is required for another soon-to-be-integrated feature to avoid crashing on exit, and could in theory also be used to speed up unloading on exit in future. While we're at it, this also avoids the need to linearly scan through the plugin list to do the old branch unloading fix, because we can. Rough summary of the other smaller stuff I can remember doing: - Rework bitbuf a bit - Add some cryptographic nonsense in ac.c (not final at all) - Introduce the first couple of "chunklets" libraries as a sort-of subproject of this one - Tidy up random small bits and bobs - Add source for a small keypair generation tool - Rework democustom to be very marginally more useful
Diffstat (limited to 'src/build/cmeta.c')
-rw-r--r--src/build/cmeta.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/build/cmeta.c b/src/build/cmeta.c
index 7f314c7..40aba3a 100644
--- a/src/build/cmeta.c
+++ b/src/build/cmeta.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2022 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2023 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
@@ -111,15 +111,7 @@ static void die2(const char *s1, const char *s2) {
static char *readsource(const os_char *f) {
int fd = os_open(f, O_RDONLY);
-#ifndef _WIN32
- if (fd == -1) die2("couldn't open ", f);
-#else
- // XXX: this is dumb and bad
- if (fd == -1) {
- fprintf(stderr, "cmeta: fatal: couldn't open %S", f);
- exit(100);
- }
-#endif
+ if (fd == -1) return 0;
uint bufsz = 8192;
char *buf = malloc(bufsz);
if (!buf) die1("couldn't allocate memory");
@@ -146,6 +138,7 @@ struct cmeta;
const struct cmeta *cmeta_loadfile(const os_char *f) {
char *buf = readsource(f);
+ if (!buf) return 0;
#ifdef _WIN32
char *realname = malloc(wcslen(f) + 1);
if (!realname) die1("couldn't allocate memory");
@@ -163,7 +156,7 @@ const struct cmeta *cmeta_loadfile(const os_char *f) {
// NOTE: we don't care about conditional includes, nor do we expand macros. We
// just parse the minimum info to get what we need for SST. Also, there's not
// too much in the way of syntax checking; if an error gets ignored the compiler
-// picks it anyway, and gives far better diagnostics.
+// picks it up anyway, and gives far better diagnostics.
void cmeta_includes(const struct cmeta *cm,
void (*cb)(const char *f, bool issys, void *ctxt), void *ctxt) {
const Token *tp = (const Token *)cm;