Use readline for repl
This commit is contained in:
15
src/main.c
15
src/main.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user