mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-18 21:29:18 +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
|
||||
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
|
||||
|
||||
- `(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)
|
||||
{
|
||||
Cyc_check_port(data, port);
|
||||
if (obj_is_char(c)) {
|
||||
if (obj_is_int(c)) {
|
||||
FILE *fp = ((port_type *) port)->fp;
|
||||
if (fp){
|
||||
char unbox = (char) obj_obj2char(c);
|
||||
fprintf(fp, "%c", unbox);
|
||||
int i = obj_obj2int(c);
|
||||
putc(i, fp);
|
||||
}
|
||||
} else {
|
||||
Cyc_rt_raise2(data, "Argument is not a character", c);
|
||||
Cyc_rt_raise2(data, "Argument is not an integer", c);
|
||||
}
|
||||
return quote_void;
|
||||
}
|
||||
|
@ -7242,7 +7242,7 @@ object Cyc_io_peek_u8(void *data, object cont, object port)
|
|||
{
|
||||
FILE *stream;
|
||||
port_type *p;
|
||||
int c;
|
||||
uint8_t c;
|
||||
|
||||
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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
{
|
||||
char_type codepoint;
|
||||
int c;
|
||||
uint8_t c;
|
||||
set_thread_blocked(data, cont);
|
||||
_read_next_char(data, cont, p);
|
||||
c = p->mem_buf[p->buf_idx++];
|
||||
codepoint = (char_type) c;
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue