mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-20 06:09:17 +02:00
Issue #340 - Fix u8 operations to work on integers
This commit is contained in:
parent
28c94c1e65
commit
17daa82bb9
2 changed files with 12 additions and 10 deletions
|
@ -5,6 +5,10 @@
|
||||||
TODO: mention cyclone-winds even though not part of this official release
|
TODO: mention cyclone-winds even though not part of this official release
|
||||||
https://github.com/cyclone-scheme/cyclone-winds
|
https://github.com/cyclone-scheme/cyclone-winds
|
||||||
|
|
||||||
|
Bug Fixes
|
||||||
|
|
||||||
|
- Fix `read-u8`, `peek-u8`, and `write-u8` to work with integers (bytes) instead of characters.
|
||||||
|
|
||||||
Deprecated
|
Deprecated
|
||||||
|
|
||||||
- `(scheme cyclone array-list)` is no longer going to be part of the official Cyclone release. It will be relocated to the `(cyclone array-list)` cyclone-winds package.
|
- `(scheme cyclone array-list)` is no longer going to be part of the official Cyclone release. It will be relocated to the `(cyclone array-list)` cyclone-winds package.
|
||||||
|
|
18
runtime.c
18
runtime.c
|
@ -1225,14 +1225,14 @@ object Cyc_write_char(void *data, object c, object port)
|
||||||
object Cyc_write_u8(void *data, object c, object port)
|
object Cyc_write_u8(void *data, object c, object port)
|
||||||
{
|
{
|
||||||
Cyc_check_port(data, port);
|
Cyc_check_port(data, port);
|
||||||
if (obj_is_char(c)) {
|
if (obj_is_int(c)) {
|
||||||
FILE *fp = ((port_type *) port)->fp;
|
FILE *fp = ((port_type *) port)->fp;
|
||||||
if (fp){
|
if (fp){
|
||||||
char unbox = (char) obj_obj2char(c);
|
int i = obj_obj2int(c);
|
||||||
fprintf(fp, "%c", unbox);
|
putc(i, fp);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Cyc_rt_raise2(data, "Argument is not a character", c);
|
Cyc_rt_raise2(data, "Argument is not an integer", c);
|
||||||
}
|
}
|
||||||
return quote_void;
|
return quote_void;
|
||||||
}
|
}
|
||||||
|
@ -7242,7 +7242,7 @@ object Cyc_io_peek_u8(void *data, object cont, object port)
|
||||||
{
|
{
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
port_type *p;
|
port_type *p;
|
||||||
int c;
|
uint8_t c;
|
||||||
|
|
||||||
Cyc_check_port(data, port);
|
Cyc_check_port(data, port);
|
||||||
{
|
{
|
||||||
|
@ -7256,7 +7256,7 @@ object Cyc_io_peek_u8(void *data, object cont, object port)
|
||||||
_read_next_char(data, cont, p);
|
_read_next_char(data, cont, p);
|
||||||
}
|
}
|
||||||
c = p->mem_buf[p->buf_idx];
|
c = p->mem_buf[p->buf_idx];
|
||||||
return_thread_runnable_with_obj(data, (c != EOF) ? obj_char2obj(c) : Cyc_EOF, p);
|
return_thread_runnable_with_obj(data, (c != EOF) ? obj_int2obj(c) : Cyc_EOF, p);
|
||||||
}
|
}
|
||||||
return Cyc_EOF;
|
return Cyc_EOF;
|
||||||
}
|
}
|
||||||
|
@ -7310,14 +7310,12 @@ object Cyc_io_read_u8(void *data, object cont, object port)
|
||||||
Cyc_rt_raise2(data, "Unable to read from closed port: ", port);
|
Cyc_rt_raise2(data, "Unable to read from closed port: ", port);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
char_type codepoint;
|
uint8_t c;
|
||||||
int c;
|
|
||||||
set_thread_blocked(data, cont);
|
set_thread_blocked(data, cont);
|
||||||
_read_next_char(data, cont, p);
|
_read_next_char(data, cont, p);
|
||||||
c = p->mem_buf[p->buf_idx++];
|
c = p->mem_buf[p->buf_idx++];
|
||||||
codepoint = (char_type) c;
|
|
||||||
p->col_num++;
|
p->col_num++;
|
||||||
return_thread_runnable_with_obj(data, (c != EOF) ? obj_char2obj(codepoint) : Cyc_EOF, p);
|
return_thread_runnable_with_obj(data, (c != EOF) ? obj_int2obj(c) : Cyc_EOF, p);
|
||||||
}
|
}
|
||||||
return Cyc_EOF;
|
return Cyc_EOF;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue