Use readline for repl

This commit is contained in:
2022-11-14 22:35:49 -05:00
parent 2af3c15785
commit fbc1055659

View File

@@ -1,5 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
#include "uclisp.h"
@@ -69,13 +71,12 @@ int main(int argc, const char **argv) {
if (argc < 2) {
while (1) {
printf("> ");
char *line = NULL;
size_t len = 0;
ssize_t lineSize = 0;
lineSize = getline(&line, &len, stdin);
if (lineSize == -1) {
return 0;
char *line = readline("> ");
if (line == NULL) {
break;
}
if (strlen(line) > 0) {
add_history(line);
}
struct ucl_object *sexp = ucl_parse(line);