diff --git a/implementations/c/src/lisp.c b/implementations/c/src/lisp.c index e0349c5..a11a3dc 100644 --- a/implementations/c/src/lisp.c +++ b/implementations/c/src/lisp.c @@ -324,14 +324,7 @@ void init(void) { void repl(void) { while(true) { printf(">>> "); - Pointer reader = read_fn(NIL, NIL); - char c; - while((c = getc(stdin)) && isspace(c) && c != '\n'); - if (c != '\n') ungetc(c, stdin); - /* read_char_fn(NIL, NIL); */ - /* read_char_fn(NIL, NIL); */ - /* printf("eof?: %d", feof(stdin)); */ - print(eval(reader, NIL), stdout); + print(eval(read_fn(NIL, NIL), NIL), stdout); printf("\n"); } } diff --git a/implementations/c/src/reader.c b/implementations/c/src/reader.c index b3c821f..0256f41 100644 --- a/implementations/c/src/reader.c +++ b/implementations/c/src/reader.c @@ -143,14 +143,11 @@ Pointer read1(Pointer streamPtr, Pointer env) { Pointer read_fn(Pointer args, Pointer env) { Pointer streamPtr = CAR(args); streamPtr = streamPtr == NIL ? environment_get(env, STANDARD_INPUT) : streamPtr; - /* Stream stream = STREAM(streamPtr); */ + Stream stream = STREAM(streamPtr); Pointer result = read1(streamPtr, env); - /* peek_char(T, stream); */ - /* getc(stream); */ - /* char c; */ - /* getc(stream); */ - /* while((c = getc(stream)) >= 0 && c == ' ') ungetc(c, stream); */ - /* if (c != EOF) ungetc(c, stream); */ + char c; + while((c = getc(stream)) && isspace(c) && c != '\n'); + if (c != '\n') ungetc(c, stream); return result; }