diff options
author | Stefan Kangas <stefankangas@gmail.com> | 2024-01-04 02:24:13 +0100 |
---|---|---|
committer | Stefan Kangas <stefankangas@gmail.com> | 2024-01-04 03:42:28 +0100 |
commit | d91a4133b0ad6bb5f53fdbd9ae0e4410c1422a64 (patch) | |
tree | 7545c7e713769ecec20b2d8e8fcaf812fa3cdad5 | |
parent | 88ed501abe9666fced46703613c000c26e450ad8 (diff) | |
download | emacs-d91a4133b0ad6bb5f53fdbd9ae0e4410c1422a64.tar.gz |
Prefer build_unibyte_string where applicable
* src/fns.c (syms_of_fns):
* src/image.c (slurp_image): Prefer build_unibyte_string (str) to
make_unibyte_string (str, strlen (str)).
* admin/coccinelle/unibyte_string.cocci: Support string literals.
-rw-r--r-- | admin/coccinelle/unibyte_string.cocci | 6 | ||||
-rw-r--r-- | src/fns.c | 2 | ||||
-rw-r--r-- | src/image.c | 2 |
3 files changed, 8 insertions, 2 deletions
diff --git a/admin/coccinelle/unibyte_string.cocci b/admin/coccinelle/unibyte_string.cocci index 0ff8cafa15d..97f87e5a4ca 100644 --- a/admin/coccinelle/unibyte_string.cocci +++ b/admin/coccinelle/unibyte_string.cocci @@ -4,3 +4,9 @@ identifier I; @@ - make_unibyte_string (I, strlen (I)) + build_unibyte_string (I) + +@@ +constant C; +@@ +- make_unibyte_string (C, strlen (C)) ++ build_unibyte_string (C) diff --git a/src/fns.c b/src/fns.c index 05b7fe85601..c03aea02397 100644 --- a/src/fns.c +++ b/src/fns.c @@ -6337,7 +6337,7 @@ The same variable also affects the function `read-answer'. See also DEFVAR_LISP ("yes-or-no-prompt", Vyes_or_no_prompt, doc: /* String to append when `yes-or-no-p' asks a question. For best results this should end in a space. */); - Vyes_or_no_prompt = make_unibyte_string ("(yes or no) ", strlen ("(yes or no) ")); + Vyes_or_no_prompt = build_unibyte_string ("(yes or no) "); defsubr (&Sidentity); defsubr (&Srandom); diff --git a/src/image.c b/src/image.c index dea2730832b..252b83da992 100644 --- a/src/image.c +++ b/src/image.c @@ -4373,7 +4373,7 @@ slurp_image (Lisp_Object filename, ptrdiff_t *size, const char *image_type) char *result = slurp_file (fd, size); if (result == NULL) image_error ("Error loading %s image `%s'", - make_unibyte_string (image_type, strlen (image_type)), + build_unibyte_string (image_type), file); return result; } |