wingo pushed a commit to branch wip-whippet
in repository guile.

commit 7c13e983b36a7c53ecab1cd7f879fe7ca14b5fea
Author: Andy Wingo <wi...@pobox.com>
AuthorDate: Mon Jun 30 15:43:56 2025 +0200

    Add srfi-14-internal.h
    
    * libguile/srfi-14-internal.h: New file.
    * libguile/Makefile.am (noinst_HEADERS): Add file.
    * libguile/srfi-14.h: Remove internal definitions.
    * libguile/init.c:
    * libguile/srfi-14.c:
    * libguile/eq.c:
    * libguile/print.c: Use internal file.
---
 libguile/Makefile.am        |  1 +
 libguile/eq.c               |  2 +-
 libguile/init.c             |  2 +-
 libguile/print.c            |  2 +-
 libguile/srfi-14-internal.h | 78 +++++++++++++++++++++++++++++++++++++++++++++
 libguile/srfi-14.c          | 50 ++---------------------------
 libguile/srfi-14.h          |  5 ---
 7 files changed, 84 insertions(+), 56 deletions(-)

diff --git a/libguile/Makefile.am b/libguile/Makefile.am
index d14d1e9e4..a910d6a5d 100644
--- a/libguile/Makefile.am
+++ b/libguile/Makefile.am
@@ -532,6 +532,7 @@ noinst_HEADERS = atomic.h                                   
\
                 ports-internal.h                               \
                 regex-posix.h                                  \
                 smob-internal.h                                \
+                srfi-14-internal.h                             \
                 strings-internal.h                             \
                 syntax.h                                       \
                 threads-internal.h                             \
diff --git a/libguile/eq.c b/libguile/eq.c
index 114d59401..a9057f679 100644
--- a/libguile/eq.c
+++ b/libguile/eq.c
@@ -39,7 +39,7 @@
 #include "pairs.h"
 #include "private-options.h"
 #include "smob.h"
-#include "srfi-14.h"
+#include "srfi-14-internal.h"
 #include "stackchk.h"
 #include "strorder.h"
 #include "struct.h"
diff --git a/libguile/init.c b/libguile/init.c
index d3b4dd240..c8f6be527 100644
--- a/libguile/init.c
+++ b/libguile/init.c
@@ -121,7 +121,7 @@
 #include "socket.h"
 #include "sort.h"
 #include "srfi-13.h"
-#include "srfi-14.h"
+#include "srfi-14-internal.h"
 #include "srfi-4.h"
 #include "srfi-60.h"
 #include "stackchk.h"
diff --git a/libguile/print.c b/libguile/print.c
index 2a7822d15..889b31fcf 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -62,7 +62,7 @@
 #include "programs.h"
 #include "read.h"
 #include "smob.h"
-#include "srfi-14.h"
+#include "srfi-14-internal.h"
 #include "strings-internal.h"
 #include "strports.h"
 #include "struct.h"
diff --git a/libguile/srfi-14-internal.h b/libguile/srfi-14-internal.h
new file mode 100644
index 000000000..d562f7d2c
--- /dev/null
+++ b/libguile/srfi-14-internal.h
@@ -0,0 +1,78 @@
+#ifndef SCM_SRFI_14_INTERNAL_H
+#define SCM_SRFI_14_INTERNAL_H
+
+/* srfi-14.c --- SRFI-14 procedures for Guile
+   Copyright 2001,2004,2006,2008,2011,2018,2025
+     Free Software Foundation, Inc.
+
+   This file is part of Guile.
+
+   Guile is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published
+   by the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   Guile is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+   License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with Guile.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+
+#include "libguile/srfi-14.h"
+
+typedef struct scm_char_range
+{
+  scm_t_wchar lo;
+  scm_t_wchar hi;
+} scm_t_char_range;
+
+/* We call this "charset" instead of "char_set" to avoid confusion with
+   "set" as a verb.  */
+struct scm_charset
+{
+  scm_t_bits tag_and_flags;
+  struct scm_bytevector *ranges;
+};
+
+static inline struct scm_charset*
+scm_to_charset (SCM scm)
+{
+  if (!scm_is_char_set (scm)) abort();
+  return (struct scm_charset *) SCM_UNPACK_POINTER (scm);
+}
+
+static inline SCM
+scm_from_charset (struct scm_charset *s)
+{
+  return SCM_PACK_POINTER (s);
+}
+
+static const scm_t_bits SCM_CHARSET_F_IMMUTABLE = 1 << 16;
+
+static inline int
+scm_charset_is_immutable (SCM charset)
+{
+  return scm_to_charset (charset)->tag_and_flags & SCM_CHARSET_F_IMMUTABLE;
+}
+
+#define SCM_VALIDATE_CHARSET(pos, x)                                    \
+  do {                                                                  \
+    SCM_ASSERT_TYPE (SCM_CHARSETP (x), x, pos, FUNC_NAME, "charset");   \
+  } while (0)
+
+#define SCM_VALIDATE_MUTABLE_CHARSET(pos, x)                            \
+  do {                                                                  \
+    SCM_ASSERT_TYPE (SCM_CHARSETP (x) && !scm_charset_is_immutable (x), \
+                     x, pos, FUNC_NAME, "mutable charset");             \
+  } while (0)
+
+SCM_INTERNAL int scm_i_char_sets_equal (SCM a, SCM b);
+SCM_INTERNAL int scm_i_print_char_set (SCM charset, SCM port,
+                                       scm_print_state *pstate);
+SCM_INTERNAL void scm_boot_srfi_14 (void);
+
+#endif /* SCM_SRFI_14_INTERNAL_H */
diff --git a/libguile/srfi-14.c b/libguile/srfi-14.c
index 7f8ff2f7d..9e193b7e3 100644
--- a/libguile/srfi-14.c
+++ b/libguile/srfi-14.c
@@ -43,39 +43,12 @@
 #include "values.h"
 #include "version.h"
 
-#include "srfi-14.h"
+#include "srfi-14-internal.h"
 
 
-typedef struct scm_char_range
-{
-  scm_t_wchar lo;
-  scm_t_wchar hi;
-} scm_t_char_range;
-
 /* Include the pre-computed standard charset data.  */
 #include "srfi-14.i.c"
 
-/* We call this "charset" instead of "char_set" to avoid confusion with
-   "set" as a verb.  */
-struct scm_charset
-{
-  scm_t_bits tag_and_flags;
-  struct scm_bytevector *ranges;
-};
-
-static inline struct scm_charset*
-scm_to_charset (SCM scm)
-{
-  if (!scm_is_char_set (scm)) abort();
-  return (struct scm_charset *) SCM_UNPACK_POINTER (scm);
-}
-
-static inline SCM
-scm_from_charset (struct scm_charset *s)
-{
-  return SCM_PACK_POINTER (s);
-}
-
 static inline scm_t_char_range*
 char_ranges (struct scm_bytevector *bv)
 {
@@ -131,25 +104,6 @@ charset_range_contains (struct scm_charset *s, size_t idx, 
scm_t_wchar c)
   return range->lo <= c && c <= range->hi;
 }
 
-static const scm_t_bits SCM_CHARSET_F_IMMUTABLE = 1 << 16;
-
-static inline int
-charset_is_immutable (SCM charset)
-{
-  return scm_to_charset (charset)->tag_and_flags & SCM_CHARSET_F_IMMUTABLE;
-}
-
-#define SCM_VALIDATE_CHARSET(pos, x)                                    \
-  do {                                                                  \
-    SCM_ASSERT_TYPE (SCM_CHARSETP (x), x, pos, FUNC_NAME, "charset");   \
-  } while (0)
-
-#define SCM_VALIDATE_MUTABLE_CHARSET(pos, x)                            \
-  do {                                                                  \
-    SCM_ASSERT_TYPE (SCM_CHARSETP (x) && !charset_is_immutable (x),     \
-                     x, pos, FUNC_NAME, "mutable charset");             \
-  } while (0)
-
 static const scm_t_char_range cs_full_ranges[] = {
   {0x0000, SCM_CODEPOINT_SURROGATE_START - 1},
   {SCM_CODEPOINT_SURROGATE_END + 1, SCM_CODEPOINT_MAX}
@@ -691,7 +645,7 @@ SCM_DEFINE_STATIC (scm_charset_mutable_p, 
"charset-mutable?", 1, 0, 0,
 #define FUNC_NAME s_scm_char_set_p
 {
   SCM_VALIDATE_CHARSET (1, cs);
-  return scm_from_bool (!charset_is_immutable (cs));
+  return scm_from_bool (!scm_charset_is_immutable (cs));
 }
 #undef FUNC_NAME
 
diff --git a/libguile/srfi-14.h b/libguile/srfi-14.h
index 3496ba46d..304d0947c 100644
--- a/libguile/srfi-14.h
+++ b/libguile/srfi-14.h
@@ -94,9 +94,4 @@ SCM_API SCM scm_char_set_ascii;
 SCM_API SCM scm_char_set_empty;
 SCM_API SCM scm_char_set_full;
 
-SCM_INTERNAL int scm_i_char_sets_equal (SCM a, SCM b);
-SCM_INTERNAL int scm_i_print_char_set (SCM charset, SCM port,
-                                       scm_print_state *pstate);
-SCM_INTERNAL void scm_boot_srfi_14 (void);
-
 #endif /* SCM_SRFI_14_H */

Reply via email to