From 6b6a6f06b4df9d76ad50294d0b6e88978ffb27d0 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 28 Apr 2019 17:14:39 +0300 Subject: Fix names of functions in last commit * src/coding.h (build_string_from_utf8): Rename from build_utf8_string. All callers changed. * src/coding.c (make_string_from_utf8): Rename from make_utf8_string. All callers changed. --- src/coding.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/coding.c') diff --git a/src/coding.c b/src/coding.c index 71f687a14e3..9cba6494a8d 100644 --- a/src/coding.c +++ b/src/coding.c @@ -6353,22 +6353,26 @@ utf8_string_p (Lisp_Object string) return check_utf_8 (&coding) != -1; } +/* Like make_string, but always returns a multibyte Lisp string, and + avoids decoding if TEXT encoded in UTF-8. */ + Lisp_Object -make_utf8_string (const char *data, ptrdiff_t size) +make_string_from_utf8 (const char *text, ptrdiff_t nbytes) { ptrdiff_t chars, bytes; - parse_str_as_multibyte ((const unsigned char *) data, size, &chars, &bytes); - /* If DATA is a valid UTF-8 string, we can convert it to a Lisp + parse_str_as_multibyte ((const unsigned char *) text, nbytes, + &chars, &bytes); + /* If TEXT is a valid UTF-8 string, we can convert it to a Lisp string directly. Otherwise, we need to decode it. */ - if (chars == size || bytes == size) - return make_specified_string (data, chars, size, true); + if (chars == nbytes || bytes == nbytes) + return make_specified_string (text, chars, nbytes, true); else { struct coding_system coding; setup_coding_system (Qutf_8_unix, &coding); coding.mode |= CODING_MODE_LAST_BLOCK; - coding.source = (const unsigned char *) data; - decode_coding_object (&coding, Qnil, 0, 0, size, size, Qt); + coding.source = (const unsigned char *) text; + decode_coding_object (&coding, Qnil, 0, 0, nbytes, nbytes, Qt); return coding.dst_object; } } -- cgit v1.2.1