wingo pushed a commit to branch wip-whippet in repository guile. commit db13048459a078e59e2a70984df7994603fdc342 Author: Andy Wingo <wi...@pobox.com> AuthorDate: Mon Jun 30 15:29:36 2025 +0200
Add i18n-internal.h * libguile/i18n-internal.h: New file. * libguile/Makefile.am: Add file. * libguile/i18n.c: * libguile/finalizers.c: * libguile/init.c: Use new file. --- libguile/Makefile.am | 1 + libguile/finalizers.c | 2 +- libguile/i18n-internal.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ libguile/i18n.c | 33 +----------------------- libguile/i18n.h | 7 ------ libguile/init.c | 2 +- 6 files changed, 69 insertions(+), 41 deletions(-) diff --git a/libguile/Makefile.am b/libguile/Makefile.am index 16f7c2309..407586db1 100644 --- a/libguile/Makefile.am +++ b/libguile/Makefile.am @@ -510,6 +510,7 @@ noinst_HEADERS = atomic.h \ custom-ports.h \ elf.h \ ephemerons.h \ + i18n-internal.h \ integers.h \ intrinsics.h \ quicksort.i.c \ diff --git a/libguile/finalizers.c b/libguile/finalizers.c index 70e45fc64..36a8d1b44 100644 --- a/libguile/finalizers.c +++ b/libguile/finalizers.c @@ -41,7 +41,7 @@ #include "gc-internal.h" #include "gsubr.h" #include "init.h" -#include "i18n.h" +#include "i18n-internal.h" #include "numbers.h" #include "ports.h" #ifdef ENABLE_REGEX diff --git a/libguile/i18n-internal.h b/libguile/i18n-internal.h new file mode 100644 index 000000000..1e815630d --- /dev/null +++ b/libguile/i18n-internal.h @@ -0,0 +1,65 @@ +#ifndef SCM_I18N_INTERNAL_H +#define SCM_I18N_INTERNAL_H + +/* Copyright 2006,2008-2009,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/scm.h" +#include "libguile/error.h" +#include "libguile/i18n.h" + +struct scm_locale +{ + scm_t_bits tag; + locale_t locale; +}; + +static inline int +scm_is_locale (SCM x) +{ + return SCM_HAS_TYP16 (x, scm_tc16_locale); +} + +static inline struct scm_locale * +scm_to_locale (SCM x) +{ + if (!scm_is_locale (x)) + abort (); + return (struct scm_locale *) SCM_UNPACK_POINTER (x); +} + +static inline SCM +scm_from_locale (struct scm_locale *x) +{ + return SCM_PACK_POINTER (x); +} + +#define SCM_LOCALE_P(x) (scm_is_locale (x)) +#define SCM_VALIDATE_LOCALE(pos, x) \ + SCM_MAKE_VALIDATE_MSG (pos, x, LOCALE_P, "locale") + + +SCM_INTERNAL SCM scm_nl_langinfo (SCM item, SCM locale); +SCM_INTERNAL void scm_i_finalize_locale (struct scm_thread *thread, SCM locale); + +SCM_INTERNAL void scm_init_i18n (void); +SCM_INTERNAL void scm_bootstrap_i18n (void); + + +#endif /* SCM_I18N_INTERNAL_H */ diff --git a/libguile/i18n.c b/libguile/i18n.c index 066960d1b..9860beb90 100644 --- a/libguile/i18n.c +++ b/libguile/i18n.c @@ -49,7 +49,7 @@ #include "variable.h" #include "version.h" -#include "i18n.h" +#include "i18n-internal.h" #ifndef SCM_MAX_ALLOCA # define SCM_MAX_ALLOCA 4096 /* Max bytes per string to allocate via alloca */ @@ -131,37 +131,6 @@ typedef locale_t scm_t_locale; SCM_GLOBAL_VARIABLE (scm_global_locale, "%global-locale"); -struct scm_locale -{ - scm_t_bits tag; - locale_t locale; -}; - -static inline int -scm_is_locale (SCM x) -{ - return SCM_HAS_TYP16 (x, scm_tc16_locale); -} - -static inline struct scm_locale * -scm_to_locale (SCM x) -{ - if (!scm_is_locale (x)) - abort (); - return (struct scm_locale *) SCM_UNPACK_POINTER (x); -} - -static inline SCM -scm_from_locale (struct scm_locale *x) -{ - return SCM_PACK_POINTER (x); -} - -#define SCM_LOCALE_P(x) (scm_is_locale (x)) -#define SCM_VALIDATE_LOCALE(pos, x) \ - SCM_MAKE_VALIDATE_MSG (pos, x, LOCALE_P, "locale") - - /* Validate parameter ARG as a locale object and set C_LOCALE to the corresponding C locale object. */ #define SCM_VALIDATE_LOCALE_COPY(_pos, _arg, _c_locale) \ diff --git a/libguile/i18n.h b/libguile/i18n.h index c38891f3e..1de37c392 100644 --- a/libguile/i18n.h +++ b/libguile/i18n.h @@ -44,11 +44,4 @@ SCM_API SCM scm_string_locale_titlecase (SCM chr, SCM locale); SCM_API SCM scm_locale_string_to_integer (SCM str, SCM base, SCM locale); SCM_API SCM scm_locale_string_to_inexact (SCM str, SCM locale); -SCM_INTERNAL SCM scm_nl_langinfo (SCM item, SCM locale); -SCM_INTERNAL void scm_i_finalize_locale (struct scm_thread *thread, SCM locale); - -SCM_INTERNAL void scm_init_i18n (void); -SCM_INTERNAL void scm_bootstrap_i18n (void); - - #endif /* SCM_I18N_H */ diff --git a/libguile/init.c b/libguile/init.c index 9c939792d..5b79ad01b 100644 --- a/libguile/init.c +++ b/libguile/init.c @@ -82,7 +82,7 @@ #include "gsubr.h" #include "hash.h" #include "hashtab.h" -#include "i18n.h" +#include "i18n-internal.h" #include "instructions.h" #include "intrinsics.h" #include "ioext.h"