Initial import

This commit is contained in:
Jeremy Baxter 2023-06-25 16:47:09 +12:00
commit b124d99c36
155 changed files with 49639 additions and 0 deletions

28
util.h Normal file
View file

@ -0,0 +1,28 @@
#include <lua.h>
#define LFAIL_RET 2
#define newoverride(L, lib, libname) \
lua_getglobal(L, libname); \
for (int i = 0; lib[i].name != NULL; i++) { \
lua_pushcfunction(L, lib[i].func); \
lua_setfield(L, -2, lib[i].name); \
}
/*
* Pushes the fail value and the string mesg
* onto the stack, then returns 2.
*/
int lfail(lua_State *L, const char* mesg);
/*
* Prepends t onto s.
* Assumes s has enough space allocated
* for the combined string.
*/
void strprepend(char* s, const char* t);
/*
* Slices the string s into buf.
* The sliced string has the range [start .. end].
*/
void strslice(const char *s, char *buf, size_t start, size_t end);