add validation for split/index args
This commit is contained in:
parent
7543ecafaa
commit
8ce844ceed
1 changed files with 22 additions and 5 deletions
27
src/lang.zig
27
src/lang.zig
|
@ -362,9 +362,14 @@ pub const Command = struct {
|
||||||
t4d: f32,
|
t4d: f32,
|
||||||
t4a_db: f32,
|
t4a_db: f32,
|
||||||
});
|
});
|
||||||
pub const Moddelay = LV2Command(.moddelay, "http://plugin.org.uk/swh-plugins/modDelay", struct {
|
|
||||||
base: f32,
|
pub const Moddelay = LV2Command(
|
||||||
});
|
.moddelay,
|
||||||
|
"http://plugin.org.uk/swh-plugins/modDelay",
|
||||||
|
struct {
|
||||||
|
base: f32,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
pub const Multichorus = LV2Command(.multichorus, "http://calf.sourceforge.net/plugins/MultiChorus", struct {
|
pub const Multichorus = LV2Command(.multichorus, "http://calf.sourceforge.net/plugins/MultiChorus", struct {
|
||||||
min_delay: f32,
|
min_delay: f32,
|
||||||
|
@ -471,8 +476,20 @@ pub const Lang = struct {
|
||||||
// arguments...
|
// arguments...
|
||||||
|
|
||||||
if (is_lv2_command) {
|
if (is_lv2_command) {
|
||||||
cmd.split = try std.fmt.parseInt(usize, tok_it.next().?, 10);
|
const split = tok_it.next();
|
||||||
cmd.index = try std.fmt.parseInt(usize, tok_it.next().?, 10);
|
if (split == null) {
|
||||||
|
self.doError("Expected split parameter, got EOL", .{});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const index = tok_it.next();
|
||||||
|
if (index == null) {
|
||||||
|
self.doError("Expected index parameter, got EOL", .{});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.split = try std.fmt.parseInt(usize, split.?, 10);
|
||||||
|
cmd.index = try std.fmt.parseInt(usize, index.?, 10);
|
||||||
|
|
||||||
inline for (@typeInfo(@TypeOf(cmd.parameters)).Struct.fields) |cmd_field| {
|
inline for (@typeInfo(@TypeOf(cmd.parameters)).Struct.fields) |cmd_field| {
|
||||||
const arg = tok_it.next().?;
|
const arg = tok_it.next().?;
|
||||||
|
|
Loading…
Reference in a new issue