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

commit 4702becf8955461bf38227709b072221a003ef01
Author: Andy Wingo <wi...@pobox.com>
AuthorDate: Fri Jun 20 16:55:41 2025 +0200

    Move internal string interface definitions to internal header
    
    * libguile/strings-internal.h: New file.
    * libguile/strings.h: Gut.
    * libguile/Makefile.am: Add new file.
    * libguile/array-handle.c:
    * libguile/bytevectors.c:
    * libguile/foreign.c:
    * libguile/fports.c:
    * libguile/hash.c:
    * libguile/i18n.c:
    * libguile/init.c:
    * libguile/intrinsics.c:
    * libguile/load.c:
    * libguile/memoize.c:
    * libguile/numbers.c:
    * libguile/ports.c:
    * libguile/posix.c:
    * libguile/print.c:
    * libguile/random.c:
    * libguile/rdelim.c:
    * libguile/read.c:
    * libguile/rw.c:
    * libguile/srfi-13.c:
    * libguile/srfi-14.c:
    * libguile/strings.c:
    * libguile/strports.c:
    * libguile/struct.c:
    * libguile/symbols.c:
    * libguile/throw.c: Include new file.
---
 libguile/Makefile.am        |  1 +
 libguile/array-handle.c     |  2 +-
 libguile/bytevectors.c      |  2 +-
 libguile/foreign.c          |  1 +
 libguile/fports.c           |  2 +-
 libguile/hash.c             |  2 +-
 libguile/i18n.c             |  2 +-
 libguile/init.c             |  2 +-
 libguile/intrinsics.c       |  2 +-
 libguile/load.c             |  2 +-
 libguile/memoize.c          |  2 +-
 libguile/numbers.c          |  2 +-
 libguile/ports.c            |  2 +-
 libguile/posix.c            |  2 +-
 libguile/print.c            |  2 +-
 libguile/random.c           |  2 +-
 libguile/rdelim.c           |  4 +--
 libguile/read.c             |  2 +-
 libguile/rw.c               |  4 +--
 libguile/srfi-13.c          |  3 +-
 libguile/srfi-14.c          |  2 +-
 libguile/strings-internal.h | 84 +++++++++++++++++++++++++++++++++++++++++++++
 libguile/strings.c          |  2 +-
 libguile/strings.h          | 58 -------------------------------
 libguile/strports.c         |  2 +-
 libguile/struct.c           |  2 +-
 libguile/symbols.c          |  2 +-
 libguile/throw.c            |  2 +-
 28 files changed, 113 insertions(+), 84 deletions(-)

diff --git a/libguile/Makefile.am b/libguile/Makefile.am
index 1a8247d26..39b52f872 100644
--- a/libguile/Makefile.am
+++ b/libguile/Makefile.am
@@ -528,6 +528,7 @@ noinst_HEADERS = atomic.h                                   
\
                 programs.h                                     \
                 ports-internal.h                               \
                 regex-posix.h                                  \
+                strings-internal.h                             \
                 syntax.h                                       \
                 trace.h                                        \
                 whippet-embedder.h
diff --git a/libguile/array-handle.c b/libguile/array-handle.c
index 5acbb743e..3da246a14 100644
--- a/libguile/array-handle.c
+++ b/libguile/array-handle.c
@@ -35,7 +35,7 @@
 #include "list.h"
 #include "numbers.h"
 #include "pairs.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "symbols.h"
 #include "vectors.h"
 
diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c
index 2ddf6da8a..5734aafaa 100644
--- a/libguile/bytevectors.c
+++ b/libguile/bytevectors.c
@@ -54,7 +54,7 @@
 #include "pairs.h"
 #include "ports.h"
 #include "srfi-4.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "symbols.h"
 #include "threads.h"
 #include "uniform.h"
diff --git a/libguile/foreign.c b/libguile/foreign.c
index 37b1756b8..a7482ba74 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -51,6 +51,7 @@
 #include "ports.h"
 #include "programs.h"
 #include "stacks.h"
+#include "strings-internal.h"
 #include "symbols.h"
 #include "threads.h"
 #include "version.h"
diff --git a/libguile/fports.c b/libguile/fports.c
index b6bccdaaf..93d065c60 100644
--- a/libguile/fports.c
+++ b/libguile/fports.c
@@ -63,7 +63,7 @@
 # include "posix-w32.h"
 #endif
 #include "read.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "symbols.h"
 #include "syscalls.h"
 #include "variable.h"
diff --git a/libguile/hash.c b/libguile/hash.c
index ddc0333a8..27260c285 100644
--- a/libguile/hash.c
+++ b/libguile/hash.c
@@ -36,7 +36,7 @@
 #include "numbers.h"
 #include "pairs.h"
 #include "ports.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "struct.h"
 #include "symbols.h"
 #include "syntax.h"
diff --git a/libguile/i18n.c b/libguile/i18n.c
index b0f5baa71..2303ad494 100644
--- a/libguile/i18n.c
+++ b/libguile/i18n.c
@@ -41,7 +41,7 @@
 #include "numbers.h"
 #include "pairs.h"
 #include "posix.h"  /* for `scm_i_locale_mutex' */
-#include "strings.h"
+#include "strings-internal.h"
 #include "symbols.h"
 #include "syscalls.h"
 #include "threads.h"
diff --git a/libguile/init.c b/libguile/init.c
index 67010c41f..a6ebe4f65 100644
--- a/libguile/init.c
+++ b/libguile/init.c
@@ -127,7 +127,7 @@
 #include "stackchk.h"
 #include "stacks.h"
 #include "stime.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "strorder.h"
 #include "strports.h"
 #include "struct.h"
diff --git a/libguile/intrinsics.c b/libguile/intrinsics.c
index f250c7b9b..d7b02aa31 100644
--- a/libguile/intrinsics.c
+++ b/libguile/intrinsics.c
@@ -37,7 +37,7 @@
 #include "keywords.h"
 #include "modules.h"
 #include "numbers.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "struct.h"
 #include "symbols.h"
 #include "threads.h"
diff --git a/libguile/load.c b/libguile/load.c
index 5fc56903a..4de4eda53 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -55,7 +55,7 @@
 #include "procs.h"
 #include "read.h"
 #include "srfi-13.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "strports.h"
 #include "symbols.h"
 #include "threads.h"
diff --git a/libguile/memoize.c b/libguile/memoize.c
index 59a0ffd06..8c4043355 100644
--- a/libguile/memoize.c
+++ b/libguile/memoize.c
@@ -40,7 +40,7 @@
 #include "pairs.h"
 #include "ports.h"
 #include "print.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "symbols.h"
 #include "threads.h"
 #include "throw.h"
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 2bb5c99d0..fbd44fe2d 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -70,7 +70,7 @@
 #include "pairs.h"
 #include "ports.h"
 #include "simpos.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "threads.h"
 #include "values.h"
 
diff --git a/libguile/ports.c b/libguile/ports.c
index b29ae9710..93dbae6cc 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -70,7 +70,7 @@
 #include "ports-internal.h"
 #include "private-options.h"
 #include "procs.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "symbols.h"
 #include "syscalls.h"
 #include "variable.h"
diff --git a/libguile/posix.c b/libguile/posix.c
index ff97b35a9..fe349f4f4 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -73,7 +73,7 @@
 #include "scmsigs.h"
 #include "srfi-13.h"
 #include "srfi-14.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "symbols.h"
 #include "syscalls.h"
 #include "threads.h"
diff --git a/libguile/print.c b/libguile/print.c
index 443a9e3f1..926556d34 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -63,7 +63,7 @@
 #include "read.h"
 #include "smob.h"
 #include "srfi-14.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "strports.h"
 #include "struct.h"
 #include "symbols.h"
diff --git a/libguile/random.c b/libguile/random.c
index 4c61f2043..b8580f857 100644
--- a/libguile/random.c
+++ b/libguile/random.c
@@ -48,7 +48,7 @@
 #include "pairs.h"
 #include "srfi-4.h"
 #include "stime.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "symbols.h"
 #include "threads.h"
 #include "variable.h"
diff --git a/libguile/rdelim.c b/libguile/rdelim.c
index 9d41712dd..9e96d73bd 100644
--- a/libguile/rdelim.c
+++ b/libguile/rdelim.c
@@ -1,4 +1,4 @@
-/* Copyright 1995-2001,2006,2011,2018
+/* Copyright 1995-2001,2006,2011,2018,2025
      Free Software Foundation, Inc.
 
    This file is part of Guile.
@@ -33,7 +33,7 @@
 #include "pairs.h"
 #include "ports.h"
 #include "srfi-13.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "strports.h"
 
 #include "rdelim.h"
diff --git a/libguile/read.c b/libguile/read.c
index 7f69e0164..799b395b8 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -56,7 +56,7 @@
 #include "procs.h"
 #include "srfi-13.h"
 #include "srfi-4.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "strports.h"
 #include "symbols.h"
 #include "threads.h"
diff --git a/libguile/rw.c b/libguile/rw.c
index 7afae1c63..624310dc0 100644
--- a/libguile/rw.c
+++ b/libguile/rw.c
@@ -1,4 +1,4 @@
-/* Copyright 2001,2006,2009,2011,2014,2018
+/* Copyright 2001,2006,2009,2011,2014,2018,2025
      Free Software Foundation, Inc.
 
    This file is part of Guile.
@@ -40,7 +40,7 @@
 #include "numbers.h"
 #include "ports-internal.h"
 #include "ports.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "strports.h"
 #include "syscalls.h"
 
diff --git a/libguile/srfi-13.c b/libguile/srfi-13.c
index 0afe4dd31..f75f45f0c 100644
--- a/libguile/srfi-13.c
+++ b/libguile/srfi-13.c
@@ -1,4 +1,4 @@
-/* Copyright 2001,2004-2006,2008-2013,2017-2019
+/* Copyright 2001,2004-2006,2008-2013,2017-2019,2025
      Free Software Foundation, Inc.
 
    This file is part of Guile.
@@ -36,6 +36,7 @@
 #include "pairs.h"
 #include "procs.h"
 #include "srfi-14.h"
+#include "strings-internal.h"
 #include "symbols.h"
 
 #include "srfi-13.h"
diff --git a/libguile/srfi-14.c b/libguile/srfi-14.c
index e9e2af991..9cf6de03d 100644
--- a/libguile/srfi-14.c
+++ b/libguile/srfi-14.c
@@ -37,7 +37,7 @@
 #include "pairs.h"
 #include "ports.h"
 #include "procs.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "symbols.h"
 #include "threads.h"
 #include "values.h"
diff --git a/libguile/strings-internal.h b/libguile/strings-internal.h
new file mode 100644
index 000000000..11c0c4887
--- /dev/null
+++ b/libguile/strings-internal.h
@@ -0,0 +1,84 @@
+#ifndef SCM_STRINGS_INTERNAL_H
+#define SCM_STRINGS_INTERNAL_H
+
+/* Copyright 1995-1998,2000-2001,2004-2006,2008-2011,2013,2015-2019,2022,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/strings.h>
+
+
+
+SCM_INTERNAL SCM scm_nullstr;
+
+SCM_INTERNAL scm_t_string_failed_conversion_handler
+scm_i_default_string_failed_conversion_handler (void);
+
+/* Flags for shared and wide strings.  */
+#define SCM_I_STRINGBUF_F_WIDE        0x400
+#define SCM_I_STRINGBUF_F_MUTABLE     0x800
+
+SCM_INTERNAL void scm_i_print_stringbuf (SCM exp, SCM port,
+                                         scm_print_state *pstate);
+
+/* internal accessor functions.  Arguments must be valid. */
+
+SCM_INTERNAL SCM scm_i_make_string (size_t len, char **datap,
+                                   int read_only_p);
+SCM_INTERNAL SCM scm_i_make_wide_string (size_t len, scm_t_wchar **datap,
+                                        int read_only_p);
+SCM_INTERNAL SCM scm_i_substring (SCM str, size_t start, size_t end);
+SCM_INTERNAL SCM scm_i_substring_read_only (SCM str, size_t start, size_t end);
+SCM_INTERNAL SCM scm_i_substring_shared (SCM str, size_t start, size_t end);
+SCM_INTERNAL SCM scm_i_substring_copy (SCM str, size_t start, size_t end);
+SCM_INTERNAL size_t scm_i_string_length (SCM str);
+SCM_INTERNAL int scm_i_string_is_mutable (SCM str);
+SCM_INTERNAL const scm_t_wchar *scm_i_string_wide_chars (SCM str);
+SCM_INTERNAL const void *scm_i_string_data (SCM str);
+
+SCM_INTERNAL SCM scm_i_string_start_writing (SCM str);
+SCM_INTERNAL void scm_i_string_stop_writing (void);
+SCM_INTERNAL int scm_i_is_narrow_string (SCM str);
+SCM_INTERNAL scm_t_wchar scm_i_string_ref (SCM str, size_t x);
+SCM_INTERNAL int scm_i_string_contains_char (SCM str, char c);
+SCM_INTERNAL int scm_i_string_strcmp (SCM sstr, size_t start_x, const char 
*cstr);
+SCM_INTERNAL void scm_i_string_set_x (SCM str, size_t p, scm_t_wchar chr);
+
+SCM_INTERNAL SCM scm_i_make_symbol (SCM name, scm_t_bits flags,
+                                    unsigned long hash);
+SCM_INTERNAL const char *scm_i_symbol_chars (SCM sym);
+SCM_INTERNAL const scm_t_wchar *scm_i_symbol_wide_chars (SCM sym);
+SCM_INTERNAL size_t scm_i_symbol_length (SCM sym);
+SCM_INTERNAL int scm_i_is_narrow_symbol (SCM str);
+SCM_INTERNAL int scm_i_try_narrow_string (SCM str);
+SCM_INTERNAL SCM scm_i_symbol_substring (SCM sym, size_t start, size_t end);
+SCM_INTERNAL scm_t_wchar scm_i_symbol_ref (SCM sym, size_t x);
+SCM_INTERNAL void scm_encoding_error (const char *subr, int err,
+                                     const char *message, SCM port, SCM chr);
+SCM_INTERNAL void scm_decoding_error (const char *subr, int err,
+                                     const char *message, SCM port);
+
+SCM_INTERNAL void scm_i_get_substring_spec (size_t len,
+                                           SCM start, size_t *cstart,
+                                           SCM end, size_t *cend);
+
+SCM_INTERNAL void scm_init_strings (void);
+
+#endif  /* SCM_STRINGS_INTERNAL_H */
diff --git a/libguile/strings.c b/libguile/strings.c
index 728af4ec4..b8196c378 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -49,7 +49,7 @@
 #include "symbols.h"
 #include "threads.h"
 
-#include "strings.h"
+#include "strings-internal.h"
 
 
 #ifndef SCM_MAX_ALLOCA
diff --git a/libguile/strings.h b/libguile/strings.h
index 77988902f..e7e0099d3 100644
--- a/libguile/strings.h
+++ b/libguile/strings.h
@@ -99,11 +99,6 @@ typedef enum
   SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE = SCM_ICONVEH_ESCAPE_SEQUENCE
 } scm_t_string_failed_conversion_handler;
 
-SCM_INTERNAL SCM scm_nullstr;
-
-SCM_INTERNAL scm_t_string_failed_conversion_handler
-scm_i_default_string_failed_conversion_handler (void);
-
 SCM_API SCM scm_string_p (SCM x);
 SCM_API SCM scm_string (SCM chrs);
 SCM_API SCM scm_make_string (SCM k, SCM chr);
@@ -206,63 +201,14 @@ SCM_API SCM scm_makfromstrs (int argc, char **argv);
 
 
 
-/* internal constants */
 
 /* Type tag for read-only strings.  */
 #define scm_tc7_ro_string             (scm_tc7_string + 0x200)
 
-/* Flags for shared and wide strings.  */
-#define SCM_I_STRINGBUF_F_WIDE        0x400
-#define SCM_I_STRINGBUF_F_MUTABLE     0x800
-
-SCM_INTERNAL void scm_i_print_stringbuf (SCM exp, SCM port,
-                                         scm_print_state *pstate);
-
 /* internal accessor functions.  Arguments must be valid. */
 
-SCM_INTERNAL SCM scm_i_make_string (size_t len, char **datap,
-                                   int read_only_p);
-SCM_INTERNAL SCM scm_i_make_wide_string (size_t len, scm_t_wchar **datap,
-                                        int read_only_p);
-SCM_INTERNAL SCM scm_i_substring (SCM str, size_t start, size_t end);
-SCM_INTERNAL SCM scm_i_substring_read_only (SCM str, size_t start, size_t end);
-SCM_INTERNAL SCM scm_i_substring_shared (SCM str, size_t start, size_t end);
-SCM_INTERNAL SCM scm_i_substring_copy (SCM str, size_t start, size_t end);
-SCM_INTERNAL size_t scm_i_string_length (SCM str);
-SCM_INTERNAL int scm_i_string_is_mutable (SCM str);
 SCM_API /* FIXME: not internal */ const char *scm_i_string_chars (SCM str);
 SCM_API /* FIXME: not internal */ char *scm_i_string_writable_chars (SCM str);
-SCM_INTERNAL const scm_t_wchar *scm_i_string_wide_chars (SCM str);
-SCM_INTERNAL const void *scm_i_string_data (SCM str);
-
-SCM_INTERNAL SCM scm_i_string_start_writing (SCM str);
-SCM_INTERNAL void scm_i_string_stop_writing (void);
-SCM_INTERNAL int scm_i_is_narrow_string (SCM str);
-SCM_INTERNAL scm_t_wchar scm_i_string_ref (SCM str, size_t x);
-SCM_INTERNAL int scm_i_string_contains_char (SCM str, char c);
-SCM_INTERNAL int scm_i_string_strcmp (SCM sstr, size_t start_x, const char 
*cstr);
-SCM_INTERNAL void scm_i_string_set_x (SCM str, size_t p, scm_t_wchar chr);
-/* internal functions related to symbols. */
-
-SCM_INTERNAL SCM scm_i_make_symbol (SCM name, scm_t_bits flags,
-                                    unsigned long hash);
-SCM_INTERNAL const char *scm_i_symbol_chars (SCM sym);
-SCM_INTERNAL const scm_t_wchar *scm_i_symbol_wide_chars (SCM sym);
-SCM_INTERNAL size_t scm_i_symbol_length (SCM sym);
-SCM_INTERNAL int scm_i_is_narrow_symbol (SCM str);
-SCM_INTERNAL int scm_i_try_narrow_string (SCM str);
-SCM_INTERNAL SCM scm_i_symbol_substring (SCM sym, size_t start, size_t end);
-SCM_INTERNAL scm_t_wchar scm_i_symbol_ref (SCM sym, size_t x);
-SCM_INTERNAL void scm_encoding_error (const char *subr, int err,
-                                     const char *message, SCM port, SCM chr);
-SCM_INTERNAL void scm_decoding_error (const char *subr, int err,
-                                     const char *message, SCM port);
-
-/* internal utility functions. */
-
-SCM_INTERNAL void scm_i_get_substring_spec (size_t len,
-                                           SCM start, size_t *cstart,
-                                           SCM end, size_t *cend);
 
 /* Debugging functions */
 
@@ -290,8 +236,4 @@ scm_is_string (SCM x)
   } while (0)
 
 
-
-
-SCM_INTERNAL void scm_init_strings (void);
-
 #endif  /* SCM_STRINGS_H */
diff --git a/libguile/strports.c b/libguile/strports.c
index bb7a3f7d2..4ce0c829b 100644
--- a/libguile/strports.c
+++ b/libguile/strports.c
@@ -39,7 +39,7 @@
 #include "procs.h"
 #include "read.h"
 #include "srfi-4.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "symbols.h"
 #include "syscalls.h"
 #include "threads.h"
diff --git a/libguile/struct.c b/libguile/struct.c
index 1af406bc7..17b771200 100644
--- a/libguile/struct.c
+++ b/libguile/struct.c
@@ -45,7 +45,7 @@
 #include "pairs.h"
 #include "ports.h"
 #include "srfi-13.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "symbols.h"
 
 #include "struct.h"
diff --git a/libguile/symbols.c b/libguile/symbols.c
index 5d7e53c7d..b656c6ae8 100644
--- a/libguile/symbols.c
+++ b/libguile/symbols.c
@@ -41,7 +41,7 @@
 #include "private-options.h"
 #include "read.h"
 #include "srfi-13.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "strorder.h"
 #include "threads.h"
 #include "variable.h"
diff --git a/libguile/throw.c b/libguile/throw.c
index 28ea04c1b..7e6716b47 100644
--- a/libguile/throw.c
+++ b/libguile/throw.c
@@ -46,7 +46,7 @@
 #include "programs.h"
 #include "stackchk.h"
 #include "stacks.h"
-#include "strings.h"
+#include "strings-internal.h"
 #include "symbols.h"
 #include "variable.h"
 #include "vm.h"

Reply via email to