emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 4b1367e: Fix Fdirectory_append check for whether strings have to


From: Lars Ingebrigtsen
Subject: master 4b1367e: Fix Fdirectory_append check for whether strings have to be converted
Date: Sat, 24 Jul 2021 12:35:23 -0400 (EDT)

branch: master
commit 4b1367ee97446ed29b76aa49782e675918d5ca35
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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.
---
 src/coding.c |  2 +-
 src/fileio.c |  2 +-
 src/fns.c    | 10 ----------
 src/lisp.h   |  1 +
 4 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/coding.c b/src/coding.c
index 46e7fca..87b55ae 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 643fc36..60f5650 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 7b9e3b0..932800a 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 80efd77..15a42a4 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);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]