Add read-u8 built-in (R7RS)
io.getc gets UTF-8 characters
This commit is contained in:
parent
c2da0753af
commit
2e8153019c
12
c/iostream.c
12
c/iostream.c
|
@ -153,6 +153,17 @@ value_t fl_read(value_t *args, uint32_t nargs)
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value_t builtin_read_u8(value_t *args, uint32_t nargs)
|
||||||
|
{
|
||||||
|
argcount("read-u8", nargs, 1);
|
||||||
|
struct ios *s = toiostream(args[0], "read-u8");
|
||||||
|
int c;
|
||||||
|
if ((c = ios_getc(s)) == IOS_EOF)
|
||||||
|
// lerror(IOError, "io.getc: end of file reached");
|
||||||
|
return FL_EOF;
|
||||||
|
return fixnum(c);
|
||||||
|
}
|
||||||
|
|
||||||
value_t fl_iogetc(value_t *args, uint32_t nargs)
|
value_t fl_iogetc(value_t *args, uint32_t nargs)
|
||||||
{
|
{
|
||||||
argcount("io.getc", nargs, 1);
|
argcount("io.getc", nargs, 1);
|
||||||
|
@ -447,6 +458,7 @@ static struct builtinspec iostreamfunc_info[] = {
|
||||||
{ "file", fl_file },
|
{ "file", fl_file },
|
||||||
{ "buffer", fl_buffer },
|
{ "buffer", fl_buffer },
|
||||||
{ "read", fl_read },
|
{ "read", fl_read },
|
||||||
|
{ "read-u8", builtin_read_u8 },
|
||||||
{ "write", fl_write },
|
{ "write", fl_write },
|
||||||
{ "io.flush", fl_ioflush },
|
{ "io.flush", fl_ioflush },
|
||||||
{ "io.close", fl_ioclose },
|
{ "io.close", fl_ioclose },
|
||||||
|
|
Loading…
Reference in New Issue