* configure.ac: Remove checks for <langinfo.h> and <nl_types.h>, and
`nl_langinfo'.
* libguile/i18n.c: Remove #ifdefs for HAVE_LANGINFO_H, HAVE_NL_TYPES_H,
HAVE_NL_ITEM, and HAVE_LANGINFO_CODESET.
(SCM_VALIDATE_OPTIONAL_LOCALE_COPY): Use `SCM_UNBNDP'.
* m4/gnulib-cache.m4 (gl_MODULES): Add `nl_langinfo'.
* module/ice-9/i18n.scm (define-vector-langinfo-mapping): Remove
`defaults' parameter; assume (provided? 'nl-langinfo) is always true.
Update users accordingly.
(define-simple-langinfo-mapping): Likewise.
(define-monetary-langinfo-mapping): Likewise, but do not assume
LOCAL-ITEM and INTL-ITEM are always defined.
# machine/fpu.h - on Tru64 5.1b, the declaration of fesetround(3) is in
# this file instead of <fenv.h>
# process.h - mingw specific
# machine/fpu.h - on Tru64 5.1b, the declaration of fesetround(3) is in
# this file instead of <fenv.h>
# process.h - mingw specific
-# langinfo.h, nl_types.h - SuS v2
# sched.h - missing on MinGW
#
AC_CHECK_HEADERS([complex.h fenv.h io.h libc.h limits.h memory.h process.h string.h \
sys/dir.h sys/ioctl.h sys/select.h \
sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h \
sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h \
# sched.h - missing on MinGW
#
AC_CHECK_HEADERS([complex.h fenv.h io.h libc.h limits.h memory.h process.h string.h \
sys/dir.h sys/ioctl.h sys/select.h \
sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h \
sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h \
-direct.h langinfo.h nl_types.h machine/fpu.h poll.h sched.h])
-
-# Reasons for testing:
-# nl_item - lacking on Cygwin
-AC_CHECK_TYPES([nl_item], [], [],
- [[#ifdef HAVE_LANGINFO_H
- # include <langinfo.h>
- #endif
- #ifdef HAVE_NL_TYPES_H
- # include <nl_types.h>
- #endif]])
+direct.h machine/fpu.h poll.h sched.h])
# "complex double" is new in C99, and "complex" is only a keyword if
# <complex.h> is included
# "complex double" is new in C99, and "complex" is only a keyword if
# <complex.h> is included
# isblank - available as a GNU extension or in C99
# _NSGetEnviron - Darwin specific
# strcoll_l, newlocale - GNU extensions (glibc), also available on Darwin
# isblank - available as a GNU extension or in C99
# _NSGetEnviron - Darwin specific
# strcoll_l, newlocale - GNU extensions (glibc), also available on Darwin
-# nl_langinfo - X/Open, not available on Windows.
# utimensat: posix.1-2008
# sched_getaffinity, sched_setaffinity: GNU extensions (glibc)
#
# utimensat: posix.1-2008
# sched_getaffinity, sched_setaffinity: GNU extensions (glibc)
#
-AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid fesetround ftime ftruncate fchown getcwd geteuid getsid gettimeofday gmtime_r ioctl lstat mkdir mknod nice pipe _pipe poll readdir_r readdir64_r readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt stat64 strftime strptime symlink sync sysconf tcgetpgrp tcsetpgrp times uname waitpid strdup system usleep atexit on_exit chown link fcntl ttyname getpwent getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp index bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron strcoll strcoll_l newlocale nl_langinfo utimensat sched_getaffinity sched_setaffinity])
+AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid fesetround ftime ftruncate fchown getcwd geteuid getsid gettimeofday gmtime_r ioctl lstat mkdir mknod nice pipe _pipe poll readdir_r readdir64_r readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt stat64 strftime strptime symlink sync sysconf tcgetpgrp tcsetpgrp times uname waitpid strdup system usleep atexit on_exit chown link fcntl ttyname getpwent getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp index bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron strcoll strcoll_l newlocale utimensat sched_getaffinity sched_setaffinity])
# Reasons for testing:
# netdb.h - not in mingw
# Reasons for testing:
# netdb.h - not in mingw
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
# the same distribution terms as the rest of that program.
#
# Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap canonicalize-lgpl ceil close connect dirfd duplocale environ extensions flock floor fpieee frexp full-read full-write func gendocs getaddrinfo getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring listen localcharset locale log1p maintainer-makefile malloc-gnu malloca nproc open pipe2 putenv recv recvfrom regex rename send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat trunc verify vsnprintf warnings wchar
+# Reproduce by: gnulib-tool --import --dir=. --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap canonicalize-lgpl ceil close connect dirfd duplocale environ extensions flock floor fpieee frexp full-read full-write func gendocs getaddrinfo getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring listen localcharset locale log1p maintainer-makefile malloc-gnu malloca nl_langinfo nproc open pipe2 putenv recv recvfrom regex rename send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat trunc verify vsnprintf warnings wchar
AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
#include "libguile/posix.h" /* for `scm_i_locale_mutex' */
#include "libguile/posix.h" /* for `scm_i_locale_mutex' */
-#ifdef HAVE_LANGINFO_H
-# include <langinfo.h>
-#endif
-#ifdef HAVE_NL_TYPES_H
-# include <nl_types.h>
-#endif
-#ifndef HAVE_NL_ITEM
-/* Cygwin has <langinfo.h> but lacks <nl_types.h> and `nl_item'. */
-typedef int nl_item;
-#endif
+/* Use Gnulib's header, which also provides `nl_item' & co. */
+#include <langinfo.h>
#ifndef HAVE_SETLOCALE
static inline char *
#ifndef HAVE_SETLOCALE
static inline char *
#define SCM_VALIDATE_OPTIONAL_LOCALE_COPY(_pos, _arg, _c_locale) \
do \
{ \
#define SCM_VALIDATE_OPTIONAL_LOCALE_COPY(_pos, _arg, _c_locale) \
do \
{ \
- if (!scm_is_eq ((_arg), SCM_UNDEFINED)) \
+ if (!SCM_UNBNDP (_arg)) \
SCM_VALIDATE_LOCALE_COPY (_pos, _arg, _c_locale); \
else \
(_c_locale) = NULL; \
SCM_VALIDATE_LOCALE_COPY (_pos, _arg, _c_locale); \
else \
(_c_locale) = NULL; \
"Reference Manual}).")
#define FUNC_NAME s_scm_nl_langinfo
{
"Reference Manual}).")
#define FUNC_NAME s_scm_nl_langinfo
{
SCM result;
nl_item c_item;
char *c_result;
scm_t_locale c_locale;
SCM result;
nl_item c_item;
char *c_result;
scm_t_locale c_locale;
-#ifdef HAVE_LANGINFO_CODESET
SCM_VALIDATE_INT_COPY (2, item, c_item);
SCM_VALIDATE_OPTIONAL_LOCALE_COPY (2, locale, c_locale);
SCM_VALIDATE_INT_COPY (2, item, c_item);
SCM_VALIDATE_OPTIONAL_LOCALE_COPY (2, locale, c_locale);
{
#ifdef USE_GNU_LOCALE_API
c_result = nl_langinfo_l (c_item, c_locale);
{
#ifdef USE_GNU_LOCALE_API
c_result = nl_langinfo_l (c_item, c_locale);
-#ifdef HAVE_LANGINFO_CODESET
codeset = nl_langinfo_l (CODESET, c_locale);
codeset = nl_langinfo_l (CODESET, c_locale);
-#endif /* HAVE_LANGINFO_CODESET */
#else /* !USE_GNU_LOCALE_API */
/* We can't use `RUN_IN_LOCALE_SECTION ()' here because the locale
mutex is already taken. */
#else /* !USE_GNU_LOCALE_API */
/* We can't use `RUN_IN_LOCALE_SECTION ()' here because the locale
mutex is already taken. */
else
{
c_result = nl_langinfo (c_item);
else
{
c_result = nl_langinfo (c_item);
-#ifdef HAVE_LANGINFO_CODESET
codeset = nl_langinfo (CODESET);
codeset = nl_langinfo (CODESET);
-#endif /* HAVE_LANGINFO_CODESET */
restore_locale_settings (&lsec_prev_locale);
free_locale_settings (&lsec_prev_locale);
restore_locale_settings (&lsec_prev_locale);
free_locale_settings (&lsec_prev_locale);
else
{
c_result = nl_langinfo (c_item);
else
{
c_result = nl_langinfo (c_item);
-#ifdef HAVE_LANGINFO_CODESET
codeset = nl_langinfo (CODESET);
codeset = nl_langinfo (CODESET);
-#endif /* HAVE_LANGINFO_CODESET */
}
c_result = strdup (c_result);
}
c_result = strdup (c_result);
-#ifdef HAVE_LANGINFO_CODESET
result = scm_from_stringn (c_result, strlen (c_result),
codeset,
SCM_FAILED_CONVERSION_QUESTION_MARK);
result = scm_from_stringn (c_result, strlen (c_result),
codeset,
SCM_FAILED_CONVERSION_QUESTION_MARK);
-#else /* !HAVE_LANGINFO_CODESET */
- /* This may be incorrectly encoded if the locale differs
- from the c_locale. */
- result = scm_from_locale_string (c_result);
-#endif /* !HAVE_LANGINFO_CODESET */
free (c_result);
}
}
return result;
free (c_result);
}
}
return result;
-#else
- scm_syserror_msg (FUNC_NAME, "`nl-langinfo' not supported on your system",
- SCM_EOL, ENOSYS);
-
- return SCM_BOOL_F;
-#endif
static inline void
define_langinfo_items (void)
{
static inline void
define_langinfo_items (void)
{
-#ifdef HAVE_LANGINFO_H
-
#define DEFINE_NLITEM_CONSTANT(_item) \
scm_c_define (# _item, scm_from_int (_item))
#define DEFINE_NLITEM_CONSTANT(_item) \
scm_c_define (# _item, scm_from_int (_item))
#endif
#undef DEFINE_NLITEM_CONSTANT
#endif
#undef DEFINE_NLITEM_CONSTANT
-
-#endif /* HAVE_NL_TYPES_H */
{
SCM global_locale_smob;
{
SCM global_locale_smob;
scm_add_feature ("nl-langinfo");
define_langinfo_items ();
scm_add_feature ("nl-langinfo");
define_langinfo_items ();
#include "libguile/i18n.x"
#include "libguile/i18n.x"
# Specification in the form of a command-line invocation:
# Specification in the form of a command-line invocation:
-# gnulib-tool --import --dir=. --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap canonicalize-lgpl ceil close connect dirfd duplocale environ extensions flock floor fpieee frexp full-read full-write func gendocs getaddrinfo getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring listen localcharset locale log1p maintainer-makefile malloc-gnu malloca nproc open pipe2 putenv recv recvfrom regex rename send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat trunc verify vsnprintf warnings wchar
+# gnulib-tool --import --dir=. --local-dir=gnulib-local --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --no-conditional-dependencies --libtool --macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen autobuild bind byteswap canonicalize-lgpl ceil close connect dirfd duplocale environ extensions flock floor fpieee frexp full-read full-write func gendocs getaddrinfo getpeername getsockname getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility libunistring listen localcharset locale log1p maintainer-makefile malloc-gnu malloca nl_langinfo nproc open pipe2 putenv recv recvfrom regex rename send sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string sys_stat trunc verify vsnprintf warnings wchar
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([gnulib-local])
# Specification in the form of a few gnulib-tool.m4 macro invocations:
gl_LOCAL_DIR([gnulib-local])
maintainer-makefile
malloc-gnu
malloca
maintainer-makefile
malloc-gnu
malloca
;;;; i18n.scm --- internationalization support -*- coding: utf-8 -*-
;;;; i18n.scm --- internationalization support -*- coding: utf-8 -*-
-;;;; Copyright (C) 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+;;;; Copyright (C) 2006, 2007, 2009, 2010, 2012 Free Software Foundation, Inc.
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
;;;
;; Helper macro: Define a procedure named NAME that maps its argument to
;;;
;; Helper macro: Define a procedure named NAME that maps its argument to
-;; NL-ITEMS (when `nl-langinfo' is provided) or DEFAULTS (when `nl-langinfo'
-;; is not provided).
-(define-macro (define-vector-langinfo-mapping name nl-items defaults)
+;; NL-ITEMS (when `nl-langinfo' is provided).
+(define-macro (define-vector-langinfo-mapping name nl-items)
(let* ((item-count (length nl-items))
(let* ((item-count (length nl-items))
- (defines (if (provided? 'nl-langinfo)
- `(define %nl-items (vector #f ,@nl-items))
- `(define %defaults (vector #f ,@defaults))))
+ (defines `(define %nl-items (vector #f ,@nl-items)))
(make-body (lambda (result)
`(if (and (integer? item) (exact? item))
(if (and (>= item 1) (<= item ,item-count))
(make-body (lambda (result)
`(if (and (integer? item) (exact? item))
(if (and (>= item 1) (<= item ,item-count))
(throw 'wrong-type-arg "wrong argument type" item)))))
`(define (,name item . locale)
,defines
(throw 'wrong-type-arg "wrong argument type" item)))))
`(define (,name item . locale)
,defines
- ,(make-body (if (provided? 'nl-langinfo)
- '(apply nl-langinfo (vector-ref %nl-items item) locale)
- '(vector-ref %defaults item))))))
+ ,(make-body '(apply nl-langinfo (vector-ref %nl-items item) locale)))))
(define-vector-langinfo-mapping locale-day-short
(define-vector-langinfo-mapping locale-day-short
- (ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5 ABDAY_6 ABDAY_7)
- ("Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat"))
+ (ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5 ABDAY_6 ABDAY_7))
(define-vector-langinfo-mapping locale-day
(define-vector-langinfo-mapping locale-day
- (DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 DAY_6 DAY_7)
- ("Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"))
+ (DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 DAY_6 DAY_7))
(define-vector-langinfo-mapping locale-month-short
(ABMON_1 ABMON_2 ABMON_3 ABMON_4 ABMON_5 ABMON_6
(define-vector-langinfo-mapping locale-month-short
(ABMON_1 ABMON_2 ABMON_3 ABMON_4 ABMON_5 ABMON_6
- ABMON_7 ABMON_8 ABMON_9 ABMON_10 ABMON_11 ABMON_12)
- ("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"))
+ ABMON_7 ABMON_8 ABMON_9 ABMON_10 ABMON_11 ABMON_12))
(define-vector-langinfo-mapping locale-month
(define-vector-langinfo-mapping locale-month
- (MON_1 MON_2 MON_3 MON_4 MON_5 MON_6 MON_7 MON_8 MON_9 MON_10 MON_11 MON_12)
- ("January" "February" "March" "April" "May" "June" "July" "August"
- "September" "October" "November" "December"))
+ (MON_1 MON_2 MON_3 MON_4 MON_5 MON_6 MON_7 MON_8 MON_9 MON_10 MON_11 MON_12))
-;; Helper macro: Define a procedure NAME that gets langinfo item ITEM.
-(define-macro (define-simple-langinfo-mapping name item default)
- (let ((body (if (and (provided? 'nl-langinfo) (defined? item))
- `(apply nl-langinfo ,item locale)
- default)))
- `(define (,name . locale)
- ,body)))
+;; Define a procedure NAME that gets langinfo item ITEM. Gnulib's
+;; `nl_langinfo' guarantees that all these items are supported.
+(define-syntax-rule (define-simple-langinfo-mapping name item)
+ (define* (name #:optional (locale %global-locale))
+ (nl-langinfo item locale)))
(define-simple-langinfo-mapping locale-am-string
(define-simple-langinfo-mapping locale-am-string
(define-simple-langinfo-mapping locale-pm-string
(define-simple-langinfo-mapping locale-pm-string
(define-simple-langinfo-mapping locale-date+time-format
(define-simple-langinfo-mapping locale-date+time-format
- D_T_FMT "%a %b %e %H:%M:%S %Y")
(define-simple-langinfo-mapping locale-date-format
(define-simple-langinfo-mapping locale-date-format
(define-simple-langinfo-mapping locale-time-format
(define-simple-langinfo-mapping locale-time-format
(define-simple-langinfo-mapping locale-time+am/pm-format
(define-simple-langinfo-mapping locale-time+am/pm-format
- T_FMT_AMPM "%I:%M:%S %p")
(define-simple-langinfo-mapping locale-era
(define-simple-langinfo-mapping locale-era
(define-simple-langinfo-mapping locale-era-year
(define-simple-langinfo-mapping locale-era-year
(define-simple-langinfo-mapping locale-era-date+time-format
(define-simple-langinfo-mapping locale-era-date+time-format
(define-simple-langinfo-mapping locale-era-date-format
(define-simple-langinfo-mapping locale-era-date-format
(define-simple-langinfo-mapping locale-era-time-format
(define-simple-langinfo-mapping locale-era-time-format
;;; Monetary information.
;;;
;;; Monetary information.
;;;
+;; Define a procedure NAME that gets item LOCAL-ITEM or INTL-ITEM,
+;; depending on whether the caller asked for the international version
+;; or not. Since Gnulib's `nl_langinfo' module doesn't guarantee that
+;; all these items are available, use DEFAULT/LOCAL and DEFAULT/INTL as
+;; default values when the system does not support them.
(define-macro (define-monetary-langinfo-mapping name local-item intl-item
default/local default/intl)
(let ((body
(define-macro (define-monetary-langinfo-mapping name local-item intl-item
default/local default/intl)
(let ((body
- (let ((intl (if (and (provided? 'nl-langinfo) (defined? intl-item))
+ (let ((intl (if (defined? intl-item)
`(apply nl-langinfo ,intl-item locale)
default/intl))
`(apply nl-langinfo ,intl-item locale)
default/intl))
- (local (if (and (provided? 'nl-langinfo) (defined? local-item))
+ (local (if (defined? local-item)
`(apply nl-langinfo ,local-item locale)
default/local)))
`(if intl? ,intl ,local))))
`(apply nl-langinfo ,local-item locale)
default/local)))
`(if intl? ,intl ,local))))
2 2)
(define-simple-langinfo-mapping locale-monetary-positive-sign
2 2)
(define-simple-langinfo-mapping locale-monetary-positive-sign
(define-simple-langinfo-mapping locale-monetary-negative-sign
(define-simple-langinfo-mapping locale-monetary-negative-sign
(define-simple-langinfo-mapping locale-monetary-decimal-point
(define-simple-langinfo-mapping locale-monetary-decimal-point
(define-simple-langinfo-mapping locale-monetary-thousands-separator
(define-simple-langinfo-mapping locale-monetary-thousands-separator
(define-simple-langinfo-mapping locale-monetary-digit-grouping
(define-simple-langinfo-mapping locale-monetary-digit-grouping
(define-monetary-langinfo-mapping locale-currency-symbol-precedes-positive?
P_CS_PRECEDES INT_P_CS_PRECEDES
(define-monetary-langinfo-mapping locale-currency-symbol-precedes-positive?
P_CS_PRECEDES INT_P_CS_PRECEDES
;;;
(define-simple-langinfo-mapping locale-digit-grouping
;;;
(define-simple-langinfo-mapping locale-digit-grouping
(define-simple-langinfo-mapping locale-decimal-point
(define-simple-langinfo-mapping locale-decimal-point
(define-simple-langinfo-mapping locale-thousands-separator
(define-simple-langinfo-mapping locale-thousands-separator
(define* (number->locale-string number
#:optional (fraction-digits #t)
(define* (number->locale-string number
#:optional (fraction-digits #t)
;;;
(define-simple-langinfo-mapping locale-yes-regexp
;;;
(define-simple-langinfo-mapping locale-yes-regexp
(define-simple-langinfo-mapping locale-no-regexp
(define-simple-langinfo-mapping locale-no-regexp
;; `YESSTR' and `NOSTR' are considered deprecated so we don't provide them.
;; `YESSTR' and `NOSTR' are considered deprecated so we don't provide them.