mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-24 00:00:17 +00:00
cbaselib.c:fileB_read() fix MSVC warnings
This commit is contained in:
parent
39060a67e9
commit
e7b2d7d833
@ -295,14 +295,14 @@ int fileB_read(CState *state, int nargs, CValue *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// allocate a buffer for the read data
|
// allocate a buffer for the read data
|
||||||
buffer = cosmoM_xmalloc(state, length + 1);
|
buffer = cosmoM_xmalloc(state, (size_t)length + 1);
|
||||||
|
|
||||||
// read the data
|
// read the data
|
||||||
fread(buffer, sizeof(char), length, file);
|
fread(buffer, sizeof(char), (size_t)length, file);
|
||||||
buffer[(int)length] = '\0'; // write the NULL terminator
|
buffer[(int)length] = '\0'; // write the NULL terminator
|
||||||
|
|
||||||
// push the read data
|
// push the read data
|
||||||
temp = cosmoV_newRef(cosmoO_takeString(state, buffer, length));
|
temp = cosmoV_newRef(cosmoO_takeString(state, buffer, (size_t)length));
|
||||||
cosmoV_pushValue(state, temp);
|
cosmoV_pushValue(state, temp);
|
||||||
} else if (IS_STRING(args[1])) {
|
} else if (IS_STRING(args[1])) {
|
||||||
if (strcmp(cosmoV_readCString(args[1]), "a") == 0) {
|
if (strcmp(cosmoV_readCString(args[1]), "a") == 0) {
|
||||||
@ -316,17 +316,17 @@ int fileB_read(CState *state, int nargs, CValue *args)
|
|||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
|
|
||||||
// allocate a buffer for the read data
|
// allocate a buffer for the read data
|
||||||
buffer = cosmoM_xmalloc(state, length + 1);
|
buffer = cosmoM_xmalloc(state, (size_t)length + 1);
|
||||||
|
|
||||||
// read the data
|
// read the data
|
||||||
fread(buffer, sizeof(char), length, file);
|
fread(buffer, sizeof(char), (size_t)length, file);
|
||||||
buffer[length] = '\0'; // write the NULL terminator
|
buffer[length] = '\0'; // write the NULL terminator
|
||||||
|
|
||||||
// push the read data
|
// push the read data
|
||||||
temp = cosmoV_newRef(cosmoO_takeString(state, buffer, length));
|
temp = cosmoV_newRef(cosmoO_takeString(state, buffer, (size_t)length));
|
||||||
cosmoV_pushValue(state, temp);
|
cosmoV_pushValue(state, temp);
|
||||||
} else {
|
} else {
|
||||||
cosmoV_error(state, "file:read() expected \"a\" or <number>, got %s!",
|
cosmoV_error(state, "file:read() expected \"a\" or <number>, got \"%s\"!",
|
||||||
cosmoV_readCString(args[1]));
|
cosmoV_readCString(args[1]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user