[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-25 345bc61: Improve how non-ASCII strings are accept
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] emacs-25 345bc61: Improve how non-ASCII strings are accepted from modules |
Date: |
Mon, 23 Nov 2015 18:09:30 +0000 |
branch: emacs-25
commit 345bc61796b4f0712fa45d47ed14692c0de628ea
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>
Improve how non-ASCII strings are accepted from modules
* src/emacs-module.c (module_make_function, module_make_string):
Build a unibyte Lisp string and then decode it by UTF-8, instead
of building a multibyte string without decoding. This is more
tolerant to deviations from UTF-8.
---
src/emacs-module.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/src/emacs-module.c b/src/emacs-module.c
index 6436339..a24d855 100644
--- a/src/emacs-module.c
+++ b/src/emacs-module.c
@@ -393,10 +393,8 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity,
ptrdiff_t max_arity,
else
{
ptrdiff_t nbytes = strlen (documentation);
- ptrdiff_t nchars, ignored_nbytes;
- parse_str_as_multibyte ((unsigned char const *) documentation, nbytes,
- &nchars, &ignored_nbytes);
- doc = make_multibyte_string (documentation, nchars, nbytes);
+ doc = make_unibyte_string (documentation, nbytes);
+ doc = code_convert_string_norecord (doc, Qutf_8, false);
}
Lisp_Object ret = list4 (Qlambda,
@@ -555,8 +553,7 @@ module_copy_string_contents (emacs_env *env, emacs_value
value, char *buffer,
}
*length = required_buf_size;
- memcpy (buffer, SDATA (lisp_str_utf8), raw_size);
- buffer[raw_size] = 0;
+ memcpy (buffer, SDATA (lisp_str_utf8), raw_size + 1);
return true;
}
@@ -572,10 +569,9 @@ module_make_string (emacs_env *env, const char *str,
ptrdiff_t length)
module_non_local_exit_signal_1 (env, Qoverflow_error, Qnil);
return NULL;
}
- ptrdiff_t nchars, ignored_nbytes;
- parse_str_as_multibyte ((unsigned char const *) str, length,
- &nchars, &ignored_nbytes);
- return lisp_to_value (env, make_multibyte_string (str, nchars, length));
+ Lisp_Object lstr = make_unibyte_string (str, length);
+ return lisp_to_value (env,
+ code_convert_string_norecord (lstr, Qutf_8, false));
}
static emacs_value
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-25 345bc61: Improve how non-ASCII strings are accepted from modules,
Eli Zaretskii <=