diff options
| -rw-r--r-- | src/emacs-module.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/emacs-module.c b/src/emacs-module.c index 68bee70626e..8fd2a87cc23 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -211,6 +211,8 @@ static void module_out_of_memory (emacs_env *); | |||
| 211 | static void module_reset_handlerlist (struct handler **); | 211 | static void module_reset_handlerlist (struct handler **); |
| 212 | static bool value_storage_contains_p (const struct emacs_value_storage *, | 212 | static bool value_storage_contains_p (const struct emacs_value_storage *, |
| 213 | emacs_value, ptrdiff_t *); | 213 | emacs_value, ptrdiff_t *); |
| 214 | static Lisp_Object module_encode (Lisp_Object); | ||
| 215 | static Lisp_Object module_decode_copy (Lisp_Object); | ||
| 214 | 216 | ||
| 215 | static bool module_assertions = false; | 217 | static bool module_assertions = false; |
| 216 | 218 | ||
| @@ -496,8 +498,7 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, | |||
| 496 | if (documentation) | 498 | if (documentation) |
| 497 | { | 499 | { |
| 498 | AUTO_STRING (unibyte_doc, documentation); | 500 | AUTO_STRING (unibyte_doc, documentation); |
| 499 | function->documentation = | 501 | function->documentation = module_decode_copy (unibyte_doc); |
| 500 | code_convert_string_norecord (unibyte_doc, Qutf_8, false); | ||
| 501 | } | 502 | } |
| 502 | 503 | ||
| 503 | Lisp_Object result; | 504 | Lisp_Object result; |
| @@ -600,7 +601,7 @@ module_copy_string_contents (emacs_env *env, emacs_value value, char *buffer, | |||
| 600 | Lisp_Object lisp_str = value_to_lisp (value); | 601 | Lisp_Object lisp_str = value_to_lisp (value); |
| 601 | CHECK_STRING (lisp_str); | 602 | CHECK_STRING (lisp_str); |
| 602 | 603 | ||
| 603 | Lisp_Object lisp_str_utf8 = ENCODE_UTF_8 (lisp_str); | 604 | Lisp_Object lisp_str_utf8 = module_encode (lisp_str); |
| 604 | ptrdiff_t raw_size = SBYTES (lisp_str_utf8); | 605 | ptrdiff_t raw_size = SBYTES (lisp_str_utf8); |
| 605 | ptrdiff_t required_buf_size = raw_size + 1; | 606 | ptrdiff_t required_buf_size = raw_size + 1; |
| 606 | 607 | ||
| @@ -631,8 +632,7 @@ module_make_string (emacs_env *env, const char *str, ptrdiff_t length) | |||
| 631 | /* FIXME: AUTO_STRING_WITH_LEN requires STR to be NUL-terminated, | 632 | /* FIXME: AUTO_STRING_WITH_LEN requires STR to be NUL-terminated, |
| 632 | but we shouldn't require that. */ | 633 | but we shouldn't require that. */ |
| 633 | AUTO_STRING_WITH_LEN (lstr, str, length); | 634 | AUTO_STRING_WITH_LEN (lstr, str, length); |
| 634 | return lisp_to_value (env, | 635 | return lisp_to_value (env, module_decode_copy (lstr)); |
| 635 | code_convert_string_norecord (lstr, Qutf_8, false)); | ||
| 636 | } | 636 | } |
| 637 | 637 | ||
| 638 | static emacs_value | 638 | static emacs_value |
| @@ -940,6 +940,18 @@ module_out_of_memory (emacs_env *env) | |||
| 940 | XCDR (Vmemory_signal_data)); | 940 | XCDR (Vmemory_signal_data)); |
| 941 | } | 941 | } |
| 942 | 942 | ||
| 943 | static Lisp_Object | ||
| 944 | module_encode (Lisp_Object string) | ||
| 945 | { | ||
| 946 | return code_convert_string (string, Qutf_8_unix, Qt, true, true, true); | ||
| 947 | } | ||
| 948 | |||
| 949 | static Lisp_Object | ||
| 950 | module_decode_copy (Lisp_Object string) | ||
| 951 | { | ||
| 952 | return code_convert_string (string, Qutf_8_unix, Qt, false, false, true); | ||
| 953 | } | ||
| 954 | |||
| 943 | 955 | ||
| 944 | /* Value conversion. */ | 956 | /* Value conversion. */ |
| 945 | 957 | ||