diff --git a/makefile b/makefile index 13c10d3..c975e7f 100644 --- a/makefile +++ b/makefile @@ -20,7 +20,7 @@ SRC=./src/mumble.c MPC=./src/mpc/mpc.c ## Dependencies -DEPS_PC=libedit +DEPS_PC=libeditline #libedit: an older version # ^ libm, which doesn't have files which pkg-config can find, grr. DEBUG= #'-g' @@ -41,6 +41,6 @@ format: $(SRC) $(FORMATTER) $(SRC) debug: - gcc -I/usr/include/editline ./src/mumble.c ./src/mpc/mpc.c -o mumble -lm -ledit -g - # valgrind --tool=memcheck --leak-check=yes --show-leak-kinds=all ./mumble - valgrind --tool=memcheck --leak-check=yes ./mumble + gcc -I/usr/include/editline ./src/mumble.c ./src/mpc/mpc.c -o mumble -lm -leditline -g + valgrind --tool=memcheck --leak-check=yes --show-leak-kinds=all ./mumble + # valgrind --tool=memcheck --leak-check=yes ./mumble diff --git a/mumble b/mumble index aaf1f5b..4f5f2f8 100755 Binary files a/mumble and b/mumble differ diff --git a/src/mumble.c b/src/mumble.c index 73f3723..2464750 100644 --- a/src/mumble.c +++ b/src/mumble.c @@ -1,5 +1,6 @@ -#include -#include +// #include +// #include +#include #include #include #include @@ -16,7 +17,7 @@ int VERBOSE = 2; printf("\n@ %s (%d): ", __FILE__, __LINE__); \ printf(__VA_ARGS__); \ } else { \ - printf("\n"); \ + printf("%s", "\n"); \ printf(__VA_ARGS__); \ } \ } while (0) @@ -807,7 +808,7 @@ lispval* evaluate_lispval(lispval* l, lispenv* env) printfln("Evaluating lispval"); // Check if this is neither an s-expression nor a symbol; otherwise return as is. if (VERBOSE) - printfln(""); + printfln("%s", ""); if (l->type != LISPVAL_SEXPR && l->type != LISPVAL_SYM) return l; @@ -825,18 +826,18 @@ lispval* evaluate_lispval(lispval* l, lispenv* env) // Evaluate the children if needed if (VERBOSE) - printfln("Evaluating children"); + printfln("%s", "Evaluating children"); for (int i = 0; i < l->count; i++) { if (l->cell[i]->type == LISPVAL_SEXPR || l->cell[i]->type == LISPVAL_SYM) { // l->cell[i] = if (VERBOSE) - printfln(""); + printfln("%s", ""); lispval* new = evaluate_lispval(l->cell[i], env); // delete_lispval(l->cell[i]); // ^ gave me a "double free" error. l->cell[i] = new; if (VERBOSE) - printfln(""); + printfln("%s", ""); } } // Check if any are errors. @@ -918,8 +919,8 @@ void modify_verbosity(char* command) int main(int argc, char** argv) { // Info - puts("Mumble version 0.0.2\n"); - puts("Press Ctrl+C to exit\n"); + printfln("%s", "Mumble version 0.0.2\n"); + printfln("%s", "Press Ctrl+C to exit\n"); /* Create Some Parsers */ mpc_parser_t* Number = mpc_new("number"); @@ -967,6 +968,7 @@ int main(int argc, char** argv) if (input == NULL) { // ^ catches Ctrl+D loop = 0; + } else { /* Attempt to Parse the user Input */ mpc_result_t result; @@ -1022,11 +1024,14 @@ int main(int argc, char** argv) add_history(input); // can't add if input is NULL } - puts(""); + printf("%s", ""); free(input); input = NULL; } + // Clear the history + rl_uninitialize(); + // rl_free_line_state(); // Clean up environment destroy_lispenv(env);