Fix warning and formatting
This commit is contained in:
parent
76bda716cd
commit
7ba93c184f
|
@ -34,7 +34,8 @@
|
||||||
#define FMT_FILECALLBACKID "file_callback_%d"
|
#define FMT_FILECALLBACKID "file_callback_%d"
|
||||||
|
|
||||||
|
|
||||||
static const char *whitelist[] = { // Allow scripters to write files of these types to SRB2's folder
|
// Allow scripters to write files of these types to SRB2's folder
|
||||||
|
static const char *whitelist[] = {
|
||||||
".bmp",
|
".bmp",
|
||||||
".cfg",
|
".cfg",
|
||||||
".csv",
|
".csv",
|
||||||
|
@ -508,7 +509,6 @@ static int io_readline (lua_State *L) {
|
||||||
static int g_write (lua_State *L, FILE *f, int arg) {
|
static int g_write (lua_State *L, FILE *f, int arg) {
|
||||||
int nargs = lua_gettop(L) - 1;
|
int nargs = lua_gettop(L) - 1;
|
||||||
int status = 1;
|
int status = 1;
|
||||||
size_t count;
|
|
||||||
for (; nargs--; arg++) {
|
for (; nargs--; arg++) {
|
||||||
if (lua_type(L, arg) == LUA_TNUMBER) {
|
if (lua_type(L, arg) == LUA_TNUMBER) {
|
||||||
/* optimization: could be done exactly as for strings */
|
/* optimization: could be done exactly as for strings */
|
||||||
|
@ -518,12 +518,10 @@ static int g_write (lua_State *L, FILE *f, int arg) {
|
||||||
else {
|
else {
|
||||||
size_t l;
|
size_t l;
|
||||||
const char *s = luaL_checklstring(L, arg, &l);
|
const char *s = luaL_checklstring(L, arg, &l);
|
||||||
count += l;
|
if (ftell(f) + l > FILELIMIT) {
|
||||||
if (ftell(f) + l > FILELIMIT)
|
luaL_error(L,"write limit bypassed in file. Changes have been discarded.");
|
||||||
{
|
break;
|
||||||
luaL_error(L,"write limit bypassed in file. Changes have been discarded.");
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
status = status && (fwrite(s, sizeof(char), l, f) == l);
|
status = status && (fwrite(s, sizeof(char), l, f) == l);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue