From: Lars Ingebrigtsen Date: Sat, 24 Jul 2021 16:35:14 +0000 (+0200) Subject: Fix Fdirectory_append check for whether strings have to be converted X-Git-Tag: emacs-28.0.90~1714 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4b1367ee97446ed29b76aa49782e675918d5ca35;p=emacs.git Fix Fdirectory_append check for whether strings have to be converted * src/coding.c (string_ascii_p): Make it non-static. * src/fileio.c (Fdirectory_append): Fix check for whether we need to convert to multibyte. * src/fns.c (string_ascii_p): Remove copy. * src/lisp.h: Declare string_ascii_p. --- diff --git a/src/coding.c b/src/coding.c index 46e7fca0f43..87b55aecc05 100644 --- a/src/coding.c +++ b/src/coding.c @@ -9476,7 +9476,7 @@ not fully specified.) */) } /* Whether STRING only contains chars in the 0..127 range. */ -static bool +bool string_ascii_p (Lisp_Object string) { ptrdiff_t nbytes = SBYTES (string); diff --git a/src/fileio.c b/src/fileio.c index 643fc361689..60f5650302c 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -796,7 +796,7 @@ usage: (record DIRECTORY &rest COMPONENTS) */) { Lisp_Object arg = args[i]; /* Use multibyte or all-ASCII strings as is. */ - if (STRING_MULTIBYTE (arg) || SCHARS (arg) == SBYTES (arg)) + if (STRING_MULTIBYTE (arg) || string_ascii_p (arg)) elements[i] = arg; else elements[i] = make_multibyte_string (SSDATA (arg), SCHARS (arg), diff --git a/src/fns.c b/src/fns.c index 7b9e3b0f7fc..932800a3a49 100644 --- a/src/fns.c +++ b/src/fns.c @@ -5769,16 +5769,6 @@ characters. */ ) return list3 (make_int (lines), make_int (longest), make_float (mean)); } -static bool -string_ascii_p (Lisp_Object string) -{ - ptrdiff_t nbytes = SBYTES (string); - for (ptrdiff_t i = 0; i < nbytes; i++) - if (SREF (string, i) > 127) - return false; - return true; -} - DEFUN ("string-search", Fstring_search, Sstring_search, 2, 3, 0, doc: /* Search for the string NEEDLE in the string HAYSTACK. The return value is the position of the first occurrence of NEEDLE in diff --git a/src/lisp.h b/src/lisp.h index 80efd771139..15a42a44562 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3586,6 +3586,7 @@ extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t, extern void init_coding (void); extern void init_coding_once (void); extern void syms_of_coding (void); +extern bool string_ascii_p (Lisp_Object); /* Defined in character.c. */ extern ptrdiff_t chars_in_text (const unsigned char *, ptrdiff_t);