altos/scheme: Add ports. Split scheme code up.
[fw/altos] / src / scheme / tiny-test / ao_scheme_test.c
index 45068369e6faf49c7ceb8e6e02fd5b9240478c0e..89b8e5fa616bc3b3f2e37336db5f3ef418e930b8 100644 (file)
@@ -15,9 +15,6 @@
 #include "ao_scheme.h"
 #include <stdio.h>
 
-static FILE *ao_scheme_file;
-static int newline = 1;
-
 static char save_file[] = "scheme.image";
 
 int
@@ -69,43 +66,21 @@ ao_scheme_os_restore(void)
        return 1;
 }
 
-int
-ao_scheme_getc(void)
-{
-       int c;
-
-       if (ao_scheme_file)
-               return getc(ao_scheme_file);
-
-       if (newline) {
-               if (ao_scheme_read_list)
-                       printf("+ ");
-               else
-                       printf("> ");
-               newline = 0;
-       }
-       c = getchar();
-       if (c == '\n')
-               newline = 1;
-       return c;
-}
-
 int
 main (int argc, char **argv)
 {
        (void) argc;
 
        while (*++argv) {
-               ao_scheme_file = fopen(*argv, "r");
-               if (!ao_scheme_file) {
+               FILE *in = fopen(*argv, "r");
+               if (!in) {
                        perror(*argv);
                        exit(1);
                }
-               ao_scheme_read_eval_print();
-               fclose(ao_scheme_file);
-               ao_scheme_file = NULL;
+               ao_scheme_read_eval_print(in, stdout, false);
+               fclose(in);
        }
-       ao_scheme_read_eval_print();
+       ao_scheme_read_eval_print(stdin, stdout, true);
 
 #ifdef DBG_MEM_STATS
        printf ("collects: full: %lu incremental %lu\n",