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