diff options
author | Eli Zaretskii <eliz@gnu.org> | 2019-04-28 17:14:39 +0300 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2019-04-28 17:14:39 +0300 |
commit | 6b6a6f06b4df9d76ad50294d0b6e88978ffb27d0 (patch) | |
tree | eb6d3c33d20a57caa9cb2430029249b88b1752fa /src/coding.c | |
parent | 75ee20364c5ed4c175b13debaa53a2ba14168999 (diff) | |
download | emacs-6b6a6f06b4df9d76ad50294d0b6e88978ffb27d0.tar.gz |
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.
Diffstat (limited to 'src/coding.c')
-rw-r--r-- | src/coding.c | 18 |
1 files changed, 11 insertions, 7 deletions
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; } } |