diff options
| author | Eli Zaretskii | 2019-04-28 17:14:39 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2019-04-28 17:14:39 +0300 |
| commit | 6b6a6f06b4df9d76ad50294d0b6e88978ffb27d0 (patch) | |
| tree | eb6d3c33d20a57caa9cb2430029249b88b1752fa /src | |
| parent | 75ee20364c5ed4c175b13debaa53a2ba14168999 (diff) | |
| download | emacs-6b6a6f06b4df9d76ad50294d0b6e88978ffb27d0.tar.gz emacs-6b6a6f06b4df9d76ad50294d0b6e88978ffb27d0.zip | |
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')
| -rw-r--r-- | src/coding.c | 18 | ||||
| -rw-r--r-- | src/coding.h | 11 | ||||
| -rw-r--r-- | src/emacs-module.c | 4 | ||||
| -rw-r--r-- | src/json.c | 21 |
4 files changed, 30 insertions, 24 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) | |||
| 6353 | return check_utf_8 (&coding) != -1; | 6353 | return check_utf_8 (&coding) != -1; |
| 6354 | } | 6354 | } |
| 6355 | 6355 | ||
| 6356 | /* Like make_string, but always returns a multibyte Lisp string, and | ||
| 6357 | avoids decoding if TEXT encoded in UTF-8. */ | ||
| 6358 | |||
| 6356 | Lisp_Object | 6359 | Lisp_Object |
| 6357 | make_utf8_string (const char *data, ptrdiff_t size) | 6360 | make_string_from_utf8 (const char *text, ptrdiff_t nbytes) |
| 6358 | { | 6361 | { |
| 6359 | ptrdiff_t chars, bytes; | 6362 | ptrdiff_t chars, bytes; |
| 6360 | parse_str_as_multibyte ((const unsigned char *) data, size, &chars, &bytes); | 6363 | parse_str_as_multibyte ((const unsigned char *) text, nbytes, |
| 6361 | /* If DATA is a valid UTF-8 string, we can convert it to a Lisp | 6364 | &chars, &bytes); |
| 6365 | /* If TEXT is a valid UTF-8 string, we can convert it to a Lisp | ||
| 6362 | string directly. Otherwise, we need to decode it. */ | 6366 | string directly. Otherwise, we need to decode it. */ |
| 6363 | if (chars == size || bytes == size) | 6367 | if (chars == nbytes || bytes == nbytes) |
| 6364 | return make_specified_string (data, chars, size, true); | 6368 | return make_specified_string (text, chars, nbytes, true); |
| 6365 | else | 6369 | else |
| 6366 | { | 6370 | { |
| 6367 | struct coding_system coding; | 6371 | struct coding_system coding; |
| 6368 | setup_coding_system (Qutf_8_unix, &coding); | 6372 | setup_coding_system (Qutf_8_unix, &coding); |
| 6369 | coding.mode |= CODING_MODE_LAST_BLOCK; | 6373 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 6370 | coding.source = (const unsigned char *) data; | 6374 | coding.source = (const unsigned char *) text; |
| 6371 | decode_coding_object (&coding, Qnil, 0, 0, size, size, Qt); | 6375 | decode_coding_object (&coding, Qnil, 0, 0, nbytes, nbytes, Qt); |
| 6372 | return coding.dst_object; | 6376 | return coding.dst_object; |
| 6373 | } | 6377 | } |
| 6374 | } | 6378 | } |
diff --git a/src/coding.h b/src/coding.h index 773df9abb90..619ca29c8e4 100644 --- a/src/coding.h +++ b/src/coding.h | |||
| @@ -695,7 +695,7 @@ extern Lisp_Object raw_text_coding_system (Lisp_Object); | |||
| 695 | extern bool raw_text_coding_system_p (struct coding_system *); | 695 | extern bool raw_text_coding_system_p (struct coding_system *); |
| 696 | extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); | 696 | extern Lisp_Object coding_inherit_eol_type (Lisp_Object, Lisp_Object); |
| 697 | extern Lisp_Object complement_process_encoding_system (Lisp_Object); | 697 | extern Lisp_Object complement_process_encoding_system (Lisp_Object); |
| 698 | extern Lisp_Object make_utf8_string (const char *, ptrdiff_t); | 698 | extern Lisp_Object make_string_from_utf8 (const char *, ptrdiff_t); |
| 699 | 699 | ||
| 700 | extern void decode_coding_gap (struct coding_system *, | 700 | extern void decode_coding_gap (struct coding_system *, |
| 701 | ptrdiff_t, ptrdiff_t); | 701 | ptrdiff_t, ptrdiff_t); |
| @@ -763,14 +763,13 @@ surrogates_to_codepoint (int low, int high) | |||
| 763 | return 0x10000 + (low - 0xDC00) + ((high - 0xD800) * 0x400); | 763 | return 0x10000 + (low - 0xDC00) + ((high - 0xD800) * 0x400); |
| 764 | } | 764 | } |
| 765 | 765 | ||
| 766 | /* Create a multibyte Lisp string from the NUL-terminated UTF-8 string | 766 | /* Like build_string, but always returns a multibyte string, and is |
| 767 | beginning at DATA. If the string is not a valid UTF-8 string, an | 767 | optimized for speed when STR is a UTF-8 encoded text string. */ |
| 768 | unspecified string is returned. */ | ||
| 769 | 768 | ||
| 770 | INLINE Lisp_Object | 769 | INLINE Lisp_Object |
| 771 | build_utf8_string (const char *data) | 770 | build_string_from_utf8 (const char *str) |
| 772 | { | 771 | { |
| 773 | return make_utf8_string (data, strlen (data)); | 772 | return make_string_from_utf8 (str, strlen (str)); |
| 774 | } | 773 | } |
| 775 | 774 | ||
| 776 | 775 | ||
diff --git a/src/emacs-module.c b/src/emacs-module.c index b9050942559..685bdb8bb4c 100644 --- a/src/emacs-module.c +++ b/src/emacs-module.c | |||
| @@ -530,7 +530,7 @@ module_make_function (emacs_env *env, ptrdiff_t min_arity, ptrdiff_t max_arity, | |||
| 530 | function->data = data; | 530 | function->data = data; |
| 531 | 531 | ||
| 532 | if (documentation) | 532 | if (documentation) |
| 533 | function->documentation = build_utf8_string (documentation); | 533 | function->documentation = build_string_from_utf8 (documentation); |
| 534 | 534 | ||
| 535 | Lisp_Object result; | 535 | Lisp_Object result; |
| 536 | XSET_MODULE_FUNCTION (result, function); | 536 | XSET_MODULE_FUNCTION (result, function); |
| @@ -663,7 +663,7 @@ module_make_string (emacs_env *env, const char *str, ptrdiff_t length) | |||
| 663 | MODULE_FUNCTION_BEGIN (NULL); | 663 | MODULE_FUNCTION_BEGIN (NULL); |
| 664 | if (! (0 <= length && length <= STRING_BYTES_BOUND)) | 664 | if (! (0 <= length && length <= STRING_BYTES_BOUND)) |
| 665 | overflow_error (); | 665 | overflow_error (); |
| 666 | Lisp_Object lstr = make_utf8_string (str, length); | 666 | Lisp_Object lstr = make_string_from_utf8 (str, length); |
| 667 | return lisp_to_value (env, lstr); | 667 | return lisp_to_value (env, lstr); |
| 668 | } | 668 | } |
| 669 | 669 | ||
diff --git a/src/json.c b/src/json.c index cc98914423b..e2a4424463b 100644 --- a/src/json.c +++ b/src/json.c | |||
| @@ -215,7 +215,7 @@ json_has_suffix (const char *string, const char *suffix) | |||
| 215 | 215 | ||
| 216 | #endif | 216 | #endif |
| 217 | 217 | ||
| 218 | /* Note that all callers of make_utf8_string and build_utf8_string | 218 | /* Note that all callers of make_string_from_utf8 and build_string_from_utf8 |
| 219 | below either pass only value UTF-8 strings or use the functionf for | 219 | below either pass only value UTF-8 strings or use the functionf for |
| 220 | formatting error messages; in the latter case correctness isn't | 220 | formatting error messages; in the latter case correctness isn't |
| 221 | critical. */ | 221 | critical. */ |
| @@ -267,9 +267,11 @@ json_parse_error (const json_error_t *error) | |||
| 267 | symbol = Qjson_parse_error; | 267 | symbol = Qjson_parse_error; |
| 268 | #endif | 268 | #endif |
| 269 | xsignal (symbol, | 269 | xsignal (symbol, |
| 270 | list5 (build_utf8_string (error->text), | 270 | list5 (build_string_from_utf8 (error->text), |
| 271 | build_utf8_string (error->source), INT_TO_INTEGER (error->line), | 271 | build_string_from_utf8 (error->source), |
| 272 | INT_TO_INTEGER (error->column), INT_TO_INTEGER (error->position))); | 272 | INT_TO_INTEGER (error->line), |
| 273 | INT_TO_INTEGER (error->column), | ||
| 274 | INT_TO_INTEGER (error->position))); | ||
| 273 | } | 275 | } |
| 274 | 276 | ||
| 275 | static void | 277 | static void |
| @@ -612,7 +614,7 @@ usage: (json-serialize OBJECT &rest ARGS) */) | |||
| 612 | json_out_of_memory (); | 614 | json_out_of_memory (); |
| 613 | record_unwind_protect_ptr (json_free, string); | 615 | record_unwind_protect_ptr (json_free, string); |
| 614 | 616 | ||
| 615 | return unbind_to (count, build_utf8_string (string)); | 617 | return unbind_to (count, build_string_from_utf8 (string)); |
| 616 | } | 618 | } |
| 617 | 619 | ||
| 618 | struct json_buffer_and_size | 620 | struct json_buffer_and_size |
| @@ -819,8 +821,8 @@ json_to_lisp (json_t *json, struct json_configuration *conf) | |||
| 819 | case JSON_REAL: | 821 | case JSON_REAL: |
| 820 | return make_float (json_real_value (json)); | 822 | return make_float (json_real_value (json)); |
| 821 | case JSON_STRING: | 823 | case JSON_STRING: |
| 822 | return make_utf8_string (json_string_value (json), | 824 | return make_string_from_utf8 (json_string_value (json), |
| 823 | json_string_length (json)); | 825 | json_string_length (json)); |
| 824 | case JSON_ARRAY: | 826 | case JSON_ARRAY: |
| 825 | { | 827 | { |
| 826 | if (++lisp_eval_depth > max_lisp_eval_depth) | 828 | if (++lisp_eval_depth > max_lisp_eval_depth) |
| @@ -879,7 +881,7 @@ json_to_lisp (json_t *json, struct json_configuration *conf) | |||
| 879 | json_t *value; | 881 | json_t *value; |
| 880 | json_object_foreach (json, key_str, value) | 882 | json_object_foreach (json, key_str, value) |
| 881 | { | 883 | { |
| 882 | Lisp_Object key = build_utf8_string (key_str); | 884 | Lisp_Object key = build_string_from_utf8 (key_str); |
| 883 | EMACS_UINT hash; | 885 | EMACS_UINT hash; |
| 884 | ptrdiff_t i = hash_lookup (h, key, &hash); | 886 | ptrdiff_t i = hash_lookup (h, key, &hash); |
| 885 | /* Keys in JSON objects are unique, so the key can't | 887 | /* 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) | |||
| 896 | json_t *value; | 898 | json_t *value; |
| 897 | json_object_foreach (json, key_str, value) | 899 | json_object_foreach (json, key_str, value) |
| 898 | { | 900 | { |
| 899 | Lisp_Object key = Fintern (build_utf8_string (key_str), Qnil); | 901 | Lisp_Object key |
| 902 | = Fintern (build_string_from_utf8 (key_str), Qnil); | ||
| 900 | result | 903 | result |
| 901 | = Fcons (Fcons (key, json_to_lisp (value, conf)), | 904 | = Fcons (Fcons (key, json_to_lisp (value, conf)), |
| 902 | result); | 905 | result); |