diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-01-01 14:57:37 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-01-01 14:57:37 +0100 |
commit | 840cad2daa6294ff6d452c649ef8ba352414a9e4 (patch) | |
tree | 13022777d1e5536776a69830c006a99c234a4035 /io.c | |
parent | 587842835405e8debb220fd874e5b29e829a29f9 (diff) | |
download | uwu-nolambda-840cad2daa6294ff6d452c649ef8ba352414a9e4.tar.xz |
Use uwuutil functions for argument number checking
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -5,11 +5,11 @@ #include "common/err.h" #include "api/vm.h" #include "api/str.h" +#include "api/util.h" UwUVMValue uwu_print(UwUVMArgs *args) { - if (args->num != 1) - error("error: nolambda:io:print requires exactly one argument\n"); + uwuutil_require_exact("nolambda:io:print", args, 1); UwUVMValue value = uwuvm_get_arg(args, 0); @@ -22,14 +22,14 @@ UwUVMValue uwu_print(UwUVMArgs *args) UwUVMValue uwu_scan(UwUVMArgs *args) { + uwuutil_require_max("nolambda:io:scan", args, 1); + char *prompt = NULL; if (args->num == 0) prompt = strdup(""); - else if (args->num == 1) - prompt = uwustr_get(uwuvm_get_arg(args, 0)); else - error("error: nolambda:io:scan requires exactly one or zero arguments\n"); + prompt = uwustr_get(uwuvm_get_arg(args, 0)); char *return_string = linenoise(prompt); |