Initial import
This commit is contained in:
commit
b124d99c36
155 changed files with 49639 additions and 0 deletions
37
util.c
Normal file
37
util.c
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* util.c
|
||||
*
|
||||
* Utility functions.
|
||||
* See util.h for a description
|
||||
* of these functions.
|
||||
*/
|
||||
|
||||
#include <util.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
|
||||
int lfail(lua_State *L, const char* mesg)
|
||||
{
|
||||
luaL_pushfail(L);
|
||||
lua_pushstring(L, mesg);
|
||||
return LFAIL_RET;
|
||||
}
|
||||
|
||||
void strprepend(char *s, const char *t)
|
||||
{
|
||||
size_t len = strlen(t);
|
||||
memmove(s + len, s, strlen(s) + 1);
|
||||
memcpy(s, t, len);
|
||||
}
|
||||
|
||||
void strslice(const char *s, char *buf, size_t start, size_t end)
|
||||
{
|
||||
size_t j = 0;
|
||||
for (size_t i = start; i <= end; ++i) {
|
||||
buf[j++] = s[i];
|
||||
}
|
||||
buf[j] = 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue