From 6c4dd4b740179932c81caa7949a927b5d7067a1c Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 24 Oct 2017 17:53:09 -0400 Subject: [PATCH] Compute number of code points and byte len --- scheme/base.sld | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scheme/base.sld b/scheme/base.sld index 75ecc2f1..1f864709 100644 --- a/scheme/base.sld +++ b/scheme/base.sld @@ -952,7 +952,8 @@ " object s = NULL; Cyc_check_int(data, count); char c = obj_obj2char(fill); - int len = obj_obj2int(count); + int num_cp = obj_obj2int(count); + int len = num_cp * uint32_num_bytes(c); if (len >= MAX_STACK_OBJ) { int heap_grown; s = gc_alloc(((gc_thread_data *)data)->heap, @@ -964,6 +965,7 @@ ((string_type *) s)->hdr.grayed = 0; ((string_type *) s)->tag = string_tag; ((string_type *) s)->len = len; + ((string_type *) s)->num_cp = num_cp; ((string_type *) s)->str = (((char *)s) + sizeof(string_type)); } else { s = alloca(sizeof(string_type)); @@ -971,6 +973,7 @@ ((string_type *)s)->hdr.grayed = 0; ((string_type *)s)->tag = string_tag; ((string_type *)s)->len = len; + ((string_type *)s)->num_cp = num_cp; ((string_type *)s)->str = alloca(sizeof(char) * (len + 1)); } memset(((string_type *)s)->str, c, len);