Commit 6b6a6f06 authored by Eli Zaretskii's avatar Eli Zaretskii

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.
parent 75ee2036
Pipeline #1487 passed with stage
in 51 minutes and 25 seconds
......@@ -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. */
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);
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;
......@@ -695,7 +695,7 @@ extern Lisp_Object raw_text_coding_system (Lisp_Object);
extern bool raw_text_coding_system_p (struct coding_system *);
extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object);
extern Lisp_Object complement_process_encoding_system (Lisp_Object);
extern Lisp_Object make_utf8_string (const char *, ptrdiff_t);
extern Lisp_Object make_string_from_utf8 (const char *, ptrdiff_t);
extern void decode_coding_gap (struct coding_system *,
ptrdiff_t, ptrdiff_t);
......@@ -763,14 +763,13 @@ surrogates_to_codepoint (int low, int high)
return 0x10000 + (low - 0xDC00) + ((high - 0xD800) * 0x400);
/* Create a multibyte Lisp string from the NUL-terminated UTF-8 string
beginning at DATA. If the string is not a valid UTF-8 string, an
unspecified string is returned. */
/* Like build_string, but always returns a multibyte string, and is
optimized for speed when STR is a UTF-8 encoded text string. */
INLINE Lisp_Object
build_utf8_string (const char *data)
build_string_from_utf8 (const char *str)
return make_utf8_string (data, strlen (data));
return make_string_from_utf8 (str, strlen (str));
......@@ -530,7 +530,7 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity,
function->data = data;
if (documentation)
function->documentation = build_utf8_string (documentation);
function->documentation = build_string_from_utf8 (documentation);
Lisp_Object result;
XSET_MODULE_FUNCTION (result, function);
......@@ -663,7 +663,7 @@ module_make_string (emacs_env *env, const char *str, ptrdiff_t length)
if (! (0 <= length && length <= STRING_BYTES_BOUND))
overflow_error ();
Lisp_Object lstr = make_utf8_string (str, length);
Lisp_Object lstr = make_string_from_utf8 (str, length);
return lisp_to_value (env, lstr);
......@@ -215,7 +215,7 @@ json_has_suffix (const char *string, const char *suffix)
/* Note that all callers of make_utf8_string and build_utf8_string
/* Note that all callers of make_string_from_utf8 and build_string_from_utf8
below either pass only value UTF-8 strings or use the functionf for
formatting error messages; in the latter case correctness isn't
critical. */
......@@ -267,9 +267,11 @@ json_parse_error (const json_error_t *error)
symbol = Qjson_parse_error;
xsignal (symbol,
list5 (build_utf8_string (error->text),
build_utf8_string (error->source), INT_TO_INTEGER (error->line),
INT_TO_INTEGER (error->column), INT_TO_INTEGER (error->position)));
list5 (build_string_from_utf8 (error->text),
build_string_from_utf8 (error->source),
INT_TO_INTEGER (error->line),
INT_TO_INTEGER (error->column),
INT_TO_INTEGER (error->position)));
static void
......@@ -612,7 +614,7 @@ usage: (json-serialize OBJECT &rest ARGS) */)
json_out_of_memory ();
record_unwind_protect_ptr (json_free, string);
return unbind_to (count, build_utf8_string (string));
return unbind_to (count, build_string_from_utf8 (string));
struct json_buffer_and_size
......@@ -819,8 +821,8 @@ json_to_lisp (json_t *json, struct json_configuration *conf)
return make_float (json_real_value (json));
return make_utf8_string (json_string_value (json),
json_string_length (json));
return make_string_from_utf8 (json_string_value (json),
json_string_length (json));
if (++lisp_eval_depth > max_lisp_eval_depth)
......@@ -879,7 +881,7 @@ json_to_lisp (json_t *json, struct json_configuration *conf)
json_t *value;
json_object_foreach (json, key_str, value)
Lisp_Object key = build_utf8_string (key_str);
Lisp_Object key = build_string_from_utf8 (key_str);
ptrdiff_t i = hash_lookup (h, key, &hash);
/* Keys in JSON objects are unique, so the key can't
......@@ -896,7 +898,8 @@ json_to_lisp (json_t *json, struct json_configuration *conf)
json_t *value;
json_object_foreach (json, key_str, value)
Lisp_Object key = Fintern (build_utf8_string (key_str), Qnil);
Lisp_Object key
= Fintern (build_string_from_utf8 (key_str), Qnil);
= Fcons (Fcons (key, json_to_lisp (value, conf)),
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment