mumble

A Lisp written in C, following the *Build Your Own Lisp* book
Log | Files | Refs | README

commit aafc697a5920c7c825c7f8f4460514396004bc12
parent b43f74cdc6dc42615104c8e10dc3c35a00cdafc5
Author: NunoSempere <nuno.sempere@protonmail.com>
Date:   Tue,  2 May 2023 14:41:25 -0400

step: increase/decrease verbosity from within the program

Diffstat:
Mmumble | 0
Msrc/mumble.c | 17++++++++++++++++-
2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/mumble b/mumble Binary files differ. diff --git a/src/mumble.c b/src/mumble.c @@ -5,11 +5,11 @@ #include <string.h> #include "mpc/mpc.h" -#define VERBOSE 2 #define LISPVAL_ASSERT(cond, err) \ if (!(cond)) { \ return lispval_err(err); \ } +int VERBOSE = 0; #define printfln(...) do { \ if(VERBOSE == 2) { \ printf ("\n@ %s (%d): ", __FILE__, __LINE__); \ @@ -790,6 +790,20 @@ lispval* evaluate_lispval(lispval* l, lispenv* env) } return l; } +// Increase or decrease verbosity level manually +void modify_verbosity(char* command){ + if(strcmp("VERBOSE=0", command) == 0){ + VERBOSE=0; + } + if(strcmp("VERBOSE=1", command) == 0){ + VERBOSE=1; + printfln("VERBOSE=1"); + } + if(strcmp("VERBOSE=2", command) == 0){ + VERBOSE=2; + } +} + // Main int main(int argc, char** argv) { @@ -831,6 +845,7 @@ int main(int argc, char** argv) int loop = 1; while (loop) { char* input = readline("mumble> "); + modify_verbosity(input); if (input == NULL) { // ^ catches Ctrl+D loop = 0;