]> git.lizzy.rs Git - uwu-nolambda.git/blobdiff - io.c
Use uwuutil functions for argument number checking
[uwu-nolambda.git] / io.c
diff --git a/io.c b/io.c
index 0f178fa9207462653a2316cba35a39f92d4936cd..7896237521d6d46cde00ad4bef81b509b62f5578 100644 (file)
--- a/io.c
+++ b/io.c
@@ -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);