mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-03 19:26:36 +02:00
use unsigned char* in sexp_update_string_index_lookup (fixes issue #804)
This commit is contained in:
parent
ab29a2b973
commit
b769a318ef
3 changed files with 5 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
(define-library (chibi io)
|
(define-library (chibi io)
|
||||||
(export read-string read-string! read-line write-line
|
(export read-string read-string! read-line write-line %%read-line
|
||||||
port-fold port-fold-right port-map
|
port-fold port-fold-right port-map
|
||||||
port->list port->string-list port->sexp-list
|
port->list port->string-list port->sexp-list
|
||||||
port->string port->bytevector
|
port->string port->bytevector
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
(define-c non-null-string (%%read-line "fgets")
|
(define-c non-null-string (%%read-line "fgets_unlocked")
|
||||||
((result (array char arg1)) int (default (current-input-port) input-port)))
|
((result (array char arg1)) int (default (current-input-port) input-port)))
|
||||||
|
|
||||||
;;(define-c size_t (%%read-string "fread")
|
;;(define-c size_t (%%read-string "fread")
|
||||||
|
|
6
sexp.c
6
sexp.c
|
@ -1298,7 +1298,7 @@ sexp sexp_string_cursor_offset (sexp ctx, sexp self, sexp_sint_t n, sexp cur) {
|
||||||
|
|
||||||
#if SEXP_USE_STRING_INDEX_TABLE
|
#if SEXP_USE_STRING_INDEX_TABLE
|
||||||
void sexp_update_string_index_lookup(sexp ctx, sexp s) {
|
void sexp_update_string_index_lookup(sexp ctx, sexp s) {
|
||||||
char *p;
|
unsigned char *p;
|
||||||
sexp_sint_t numchunks, len, i, *chunks;
|
sexp_sint_t numchunks, len, i, *chunks;
|
||||||
sexp_gc_var1(tmp);
|
sexp_gc_var1(tmp);
|
||||||
if (sexp_string_size(s) < SEXP_STRING_INDEX_TABLE_CHUNK_SIZE*1.2) {
|
if (sexp_string_size(s) < SEXP_STRING_INDEX_TABLE_CHUNK_SIZE*1.2) {
|
||||||
|
@ -1312,12 +1312,12 @@ void sexp_update_string_index_lookup(sexp ctx, sexp s) {
|
||||||
sexp_string_charlens(s) =
|
sexp_string_charlens(s) =
|
||||||
sexp_make_bytes_op(ctx, NULL, 2, sexp_make_fixnum(numchunks * sizeof(sexp_sint_t)), SEXP_VOID);
|
sexp_make_bytes_op(ctx, NULL, 2, sexp_make_fixnum(numchunks * sizeof(sexp_sint_t)), SEXP_VOID);
|
||||||
chunks = (sexp_sint_t*)sexp_bytes_data(sexp_string_charlens(s));
|
chunks = (sexp_sint_t*)sexp_bytes_data(sexp_string_charlens(s));
|
||||||
p = sexp_string_data(s);
|
p = (unsigned char*) sexp_string_data(s);
|
||||||
i = 0;
|
i = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
p += sexp_utf8_initial_byte_count(*p);
|
p += sexp_utf8_initial_byte_count(*p);
|
||||||
if (++i % SEXP_STRING_INDEX_TABLE_CHUNK_SIZE == 0) {
|
if (++i % SEXP_STRING_INDEX_TABLE_CHUNK_SIZE == 0) {
|
||||||
chunks[i/SEXP_STRING_INDEX_TABLE_CHUNK_SIZE - 1] = p - sexp_string_data(s);
|
chunks[i/SEXP_STRING_INDEX_TABLE_CHUNK_SIZE - 1] = p - (unsigned char*) sexp_string_data(s);
|
||||||
if (i / SEXP_STRING_INDEX_TABLE_CHUNK_SIZE >= numchunks-1)
|
if (i / SEXP_STRING_INDEX_TABLE_CHUNK_SIZE >= numchunks-1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue