summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2021-07-24 18:35:14 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2021-07-24 18:35:14 +0200
commit4b1367ee97446ed29b76aa49782e675918d5ca35 (patch)
treeded6beaf97773f193cd87259f4d6c446427ad6c0 /src
parent26da0b5ecb44ba5a8954be98b97ab59ccb391531 (diff)
downloademacs-4b1367ee97446ed29b76aa49782e675918d5ca35.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/coding.c2
-rw-r--r--src/fileio.c2
-rw-r--r--src/fns.c10
-rw-r--r--src/lisp.h1
4 files changed, 3 insertions, 12 deletions
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);