diff --git a/scheme/cyclone/cgen.sld b/scheme/cyclone/cgen.sld index 7cdd74f0..d3456d11 100644 --- a/scheme/cyclone/cgen.sld +++ b/scheme/cyclone/cgen.sld @@ -521,7 +521,15 @@ (string-append "&" cvar-name) ; Code is just the variable name (list ; Allocate integer on the C stack (string-append - "make_string(" cvar-name ", " (->cstr exp) ");"))))) + "make_utf8_string_with_len(" + cvar-name + ", " + (->cstr exp) + ", " + (number->string (string-byte-length exp)) + ", " + (number->string (string-length exp)) + ");"))))) ;TODO: not good enough, need to store new symbols in a table so they can ;be inserted into the C program ((symbol? exp) @@ -536,6 +544,10 @@ (define (->cstr str) (string-append "\"" (cstr:escape-chars str) "\"")) +(define-c string-byte-length + "(void *data, int argc, closure _, object k, object s)" + " return_closcall1(data, k, Cyc_string_byte_length(data, s)); ") + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Primitives