diff --git a/src/CHANGELOG b/src/CHANGELOG index bf918f7ac..ca199ec9b 100644 --- a/src/CHANGELOG +++ b/src/CHANGELOG @@ -19,6 +19,9 @@ ECL 0.9g - DEF-FOREIGN-VAR rewritten to make variables visible from other files and to dereference also arrays and pointers. (M. Pasternacki) + - When creating a C-STRING, characters after the fill pointer are discarded, + according to people's expectations. + * Compiler changes: - Generated C functions now have readable names corresponding to appropriate diff --git a/src/lsp/ffi.lsp b/src/lsp/ffi.lsp index b9bcec7ad..b293e95f9 100644 --- a/src/lsp/ffi.lsp +++ b/src/lsp/ffi.lsp @@ -372,13 +372,16 @@ object) (defmacro convert-to-cstring (object) - object) + ;; This enforces that the string contains only as many characters as the + ;; fill-pointer determines Since ECL always sets a 0 character after the + ;; last element of a string, this way, the string is always zero-terminated + (copy-seq object)) (defmacro free-cstring (object) object) (defmacro with-cstring ((cstring string) &body body) - `(let ((,cstring ,string)) ,@body)) + `(let ((,cstring (copy-seq ,string))) ,@body)) (defmacro with-cstrings (bindings &rest body) (if bindings