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.
This commit is contained in:
Stefan Kangas 2024-01-04 02:24:13 +01:00
parent 88ed501abe
commit d91a4133b0
3 changed files with 8 additions and 2 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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;
}