mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 05:27:35 +02:00
Fixing custom ports built without utf8 support.
This commit is contained in:
parent
a595badee5
commit
22e2a08563
2 changed files with 5 additions and 3 deletions
|
@ -880,6 +880,7 @@ SEXP_API sexp sexp_make_unsigned_integer(sexp ctx, sexp_luint_t x);
|
||||||
#define sexp_string_size(x) (sexp_field(x, string, SEXP_STRING, length))
|
#define sexp_string_size(x) (sexp_field(x, string, SEXP_STRING, length))
|
||||||
#if SEXP_USE_PACKED_STRINGS
|
#if SEXP_USE_PACKED_STRINGS
|
||||||
#define sexp_string_data(x) (sexp_field(x, string, SEXP_STRING, data))
|
#define sexp_string_data(x) (sexp_field(x, string, SEXP_STRING, data))
|
||||||
|
#define sexp_string_bytes(x) (x)
|
||||||
#else
|
#else
|
||||||
#define sexp_string_bytes(x) (sexp_field(x, string, SEXP_STRING, bytes))
|
#define sexp_string_bytes(x) (sexp_field(x, string, SEXP_STRING, bytes))
|
||||||
#define sexp_string_offset(x) (sexp_field(x, string, SEXP_STRING, offset))
|
#define sexp_string_offset(x) (sexp_field(x, string, SEXP_STRING, offset))
|
||||||
|
|
7
sexp.c
7
sexp.c
|
@ -1451,15 +1451,16 @@ int sexp_buffered_read_char (sexp ctx, sexp p) {
|
||||||
} else if (sexp_port_customp(p)) {
|
} else if (sexp_port_customp(p)) {
|
||||||
sexp_gc_preserve2(ctx, tmp, origbytes);
|
sexp_gc_preserve2(ctx, tmp, origbytes);
|
||||||
tmp = sexp_list2(ctx, SEXP_ZERO, sexp_make_fixnum(SEXP_PORT_BUFFER_SIZE));
|
tmp = sexp_list2(ctx, SEXP_ZERO, sexp_make_fixnum(SEXP_PORT_BUFFER_SIZE));
|
||||||
origbytes = sexp_port_binaryp(p) ? sexp_string_bytes(sexp_port_buffer(p)) : sexp_port_buffer(p);
|
origbytes = sexp_port_binaryp(p) && !SEXP_USE_PACKED_STRINGS ? sexp_string_bytes(sexp_port_buffer(p)) : sexp_port_buffer(p);
|
||||||
tmp = sexp_cons(ctx, origbytes, tmp);
|
tmp = sexp_cons(ctx, origbytes, tmp);
|
||||||
tmp = sexp_apply(ctx, sexp_port_reader(p), tmp);
|
tmp = sexp_apply(ctx, sexp_port_reader(p), tmp);
|
||||||
if (sexp_fixnump(tmp) && sexp_unbox_fixnum(tmp) > 0) {
|
if (sexp_fixnump(tmp) && sexp_unbox_fixnum(tmp) > 0) {
|
||||||
sexp_port_offset(p) = 0;
|
sexp_port_offset(p) = 0;
|
||||||
sexp_port_size(p) = sexp_unbox_fixnum(tmp);
|
sexp_port_size(p) = sexp_unbox_fixnum(tmp);
|
||||||
if (!sexp_port_binaryp(p) && origbytes != sexp_string_bytes(sexp_port_buffer(p))) {
|
if (!sexp_port_binaryp(p) && !SEXP_USE_PACKED_STRINGS
|
||||||
|
&& origbytes != sexp_string_bytes(sexp_port_buffer(p))) {
|
||||||
/* handle resize */
|
/* handle resize */
|
||||||
memcpy(sexp_port_buf(p), sexp_bytes_data(sexp_string_bytes(sexp_port_buffer(p))), sexp_port_size(p));
|
memcpy(sexp_port_buf(p), sexp_string_data(sexp_port_buffer(p)), sexp_port_size(p));
|
||||||
}
|
}
|
||||||
res = ((sexp_port_offset(p) < sexp_port_size(p))
|
res = ((sexp_port_offset(p) < sexp_port_size(p))
|
||||||
? ((unsigned char*)sexp_port_buf(p))[sexp_port_offset(p)++] : EOF);
|
? ((unsigned char*)sexp_port_buf(p))[sexp_port_offset(p)++] : EOF);
|
||||||
|
|
Loading…
Add table
Reference in a new issue