Add check for values passed to file:vsetbuf and file:seek.

This commit is contained in:
Enyby
2019-10-12 17:51:04 +03:00
parent 6985980572
commit 3613bc0862

View File

@@ -427,6 +427,12 @@ public class IoLib extends TwoArgFunction {
// file:setvbuf(mode,[size]) -> void // file:setvbuf(mode,[size]) -> void
public Varargs _file_setvbuf(LuaValue file, String mode, int size) { public Varargs _file_setvbuf(LuaValue file, String mode, int size) {
if ("no".equals(mode)) {
} else if ("full".equals(mode)) {
} else if ("line".equals(mode)) {
} else {
argerror(1, "invalid option '" + mode + "', must be one of 'no', 'full' or 'line'");
}
checkfile(file).setvbuf(mode,size); checkfile(file).setvbuf(mode,size);
return LuaValue.TRUE; return LuaValue.TRUE;
} }
@@ -443,6 +449,12 @@ public class IoLib extends TwoArgFunction {
// file:seek([whence][,offset]) -> pos | nil,error // file:seek([whence][,offset]) -> pos | nil,error
public Varargs _file_seek(LuaValue file, String whence, int offset) throws IOException { public Varargs _file_seek(LuaValue file, String whence, int offset) throws IOException {
if ("set".equals(whence)) {
} else if ("end".equals(whence)) {
} else if ("cur".equals(whence)) {
} else {
argerror(1, "invalid option '" + whence + "', must be one of 'set', 'cur' or 'end'");
}
return valueOf( checkfile(file).seek(whence,offset) ); return valueOf( checkfile(file).seek(whence,offset) );
} }