core: Support switching of input stream.
* mes.c (g_stdin): New global. (getchar): New function, use g_stdin. (ungetchar): Use g_stdin. (main): Initialize g_stdin to stdin.
This commit is contained in:
parent
0e13b7e8dd
commit
1e2e2f2a4a
10
mes.c
10
mes.c
|
@ -893,10 +893,17 @@ display_helper (FILE* f, scm *x, bool cont, char const *sep, bool quote)
|
|||
|
||||
// READ
|
||||
|
||||
FILE *g_stdin;
|
||||
int
|
||||
getchar ()
|
||||
{
|
||||
return getc (g_stdin);
|
||||
}
|
||||
|
||||
int
|
||||
ungetchar (int c)
|
||||
{
|
||||
return ungetc (c, stdin);
|
||||
return ungetc (c, g_stdin);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1179,6 +1186,7 @@ main (int argc, char *argv[])
|
|||
{
|
||||
if (argc > 1 && !strcmp (argv[1], "--help")) return puts ("Usage: mes < FILE\n");
|
||||
if (argc > 1 && !strcmp (argv[1], "--version")) return puts ("Mes 0.1\n");
|
||||
g_stdin = stdin;
|
||||
scm *a = mes_environment ();
|
||||
display_ (stderr, load_file_env (a));
|
||||
fputs ("", stderr);
|
||||
|
|
Loading…
Reference in New Issue