Fixed a couple Windows errors.
This commit is contained in:
parent
f7a10cc921
commit
d9480da470
3 changed files with 12 additions and 1 deletions
|
@ -2219,7 +2219,7 @@ void singe(SDL_Window *window, SDL_Renderer *renderer) {
|
||||||
free(temp);
|
free(temp);
|
||||||
// Load mappings in game script dir
|
// Load mappings in game script dir
|
||||||
temp = strdup(_confScriptFile);
|
temp = strdup(_confScriptFile);
|
||||||
temp2 = strndup(temp, strlen(temp) - strlen(utilGetLastPathComponent(temp)));
|
temp2 = utilStrndup(temp, strlen(temp) - strlen(utilGetLastPathComponent(temp)));
|
||||||
free(temp);
|
free(temp);
|
||||||
temp = utilCreateString("%scontrols.cfg", temp2);
|
temp = utilCreateString("%scontrols.cfg", temp2);
|
||||||
if (utilFileExists(temp) && luaL_dofile(_luaContext, temp)) utilDie("%s", lua_tostring(_luaContext, -1));
|
if (utilFileExists(temp) && luaL_dofile(_luaContext, temp)) utilDie("%s", lua_tostring(_luaContext, -1));
|
||||||
|
|
10
singe/util.c
10
singe/util.c
|
@ -376,6 +376,16 @@ void utilSay(char *fmt, ...) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Windows does not have strndup() so we implement our own.
|
||||||
|
char *utilStrndup( const char *s1, size_t n) {
|
||||||
|
char *copy = (char *)malloc(n + 1);
|
||||||
|
memcpy(copy, s1, n);
|
||||||
|
copy[n] = 0;
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void utilTrace(char *fmt, ...) {
|
void utilTrace(char *fmt, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
if (utilTraceFile) {
|
if (utilTraceFile) {
|
||||||
|
|
|
@ -52,6 +52,7 @@ char *utilReadFile(char *filename, size_t *bytes);
|
||||||
char *utilReadLine(char *haystack, size_t length, char **offset);
|
char *utilReadLine(char *haystack, size_t length, char **offset);
|
||||||
void utilRedirectConsole(void);
|
void utilRedirectConsole(void);
|
||||||
void utilSay(char *fmt, ...);
|
void utilSay(char *fmt, ...);
|
||||||
|
char *utilStrndup( const char *s1, size_t n);
|
||||||
void utilTrace(char *fmt, ...);
|
void utilTrace(char *fmt, ...);
|
||||||
void utilTraceEnd(void);
|
void utilTraceEnd(void);
|
||||||
void utilTraceStart(char *filename);
|
void utilTraceStart(char *filename);
|
||||||
|
|
Loading…
Add table
Reference in a new issue