From 12175a339e2a2214fdd0ab4e16d8d8b1e92a78d3 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 13 Oct 2020 06:51:06 +0200 Subject: Allow creating unibyte strings from Emacs modules * doc/lispref/internals.texi (Module Values): Document make_unibyte_string (bug#34873). * src/emacs-module.c (module_make_unibyte_string): New function. (initialize_environment): Export it. * src/module-env-25.h: Define it. * test/data/emacs-module/mod-test.c (Fmod_test_return_unibyte): Test it. * test/src/emacs-module-tests.el (module/unibyte): Test it. --- test/data/emacs-module/mod-test.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/data') diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c index da298d4e398..258a679b207 100644 --- a/test/data/emacs-module/mod-test.c +++ b/test/data/emacs-module/mod-test.c @@ -268,6 +268,16 @@ Fmod_test_string_a_to_b (emacs_env *env, ptrdiff_t nargs, emacs_value args[], } +/* Return a unibyte string. */ +static emacs_value +Fmod_test_return_unibyte (emacs_env *env, ptrdiff_t nargs, emacs_value args[], + void *data) +{ + const char *string = "foo\x00zot"; + return env->make_unibyte_string (env, string, 7); +} + + /* Embedded pointers in lisp objects. */ /* C struct (pointer to) that will be embedded. */ @@ -750,6 +760,7 @@ emacs_module_init (struct emacs_runtime *ert) DEFUN ("mod-test-globref-reordered", Fmod_test_globref_reordered, 0, 0, NULL, NULL); DEFUN ("mod-test-string-a-to-b", Fmod_test_string_a_to_b, 1, 1, NULL, NULL); + DEFUN ("mod-test-return-unibyte", Fmod_test_return_unibyte, 0, 0, NULL, NULL); DEFUN ("mod-test-userptr-make", Fmod_test_userptr_make, 1, 1, NULL, NULL); DEFUN ("mod-test-userptr-get", Fmod_test_userptr_get, 1, 1, NULL, NULL); DEFUN ("mod-test-vector-fill", Fmod_test_vector_fill, 2, 2, NULL, NULL); -- cgit v1.2.1