[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: new module 'wctob'
From: |
Bruno Haible |
Subject: |
Re: new module 'wctob' |
Date: |
Sun, 21 Dec 2008 01:24:02 +0100 |
User-agent: |
KMail/1.9.9 |
> New module 'wctob'.
> * lib/wchar.in.h (wctob): New declaration.
> * lib/wctob.c: New file.
> * m4/wctob.m4: New file.
> * modules/wctob: New file.
wctob does not work on Solaris 9 and older: It simply fails to recognize
single-byte characters, even in a simple ISO-8859-1 locale. This works around
it:
2008-12-20 Bruno Haible <address@hidden>
Work around wctob bug on Solaris <= 9.
* lib/wchar.in.h (wctob): Redefine if REPLACE_WCTOB is set.
* m4/wctob.m4 (gl_FUNC_WCTOB): Test whether wctob works.
* m4/wchar.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_WCTOB.
* modules/wchar (Makefile.am): Substitute REPLACE_WCTOB.
* modules/wctob (Files): Add m4/locale-fr.m4.
* doc/posix-functions/wctob.texi: Mention the Solaris bug.
--- lib/wchar.in.h.orig 2008-12-21 01:17:29.000000000 +0100
+++ lib/wchar.in.h 2008-12-21 00:53:48.000000000 +0100
@@ -97,7 +97,11 @@
/* Convert a wide character to a single-byte character. */
#if @GNULIB_WCTOB@
-# if !defined wctob && address@hidden@
+# if @REPLACE_WCTOB@
+# undef wctob
+# define wctob rpl_wctob
+# endif
+# if (!defined wctob && address@hidden@) || @REPLACE_WCTOB@
/* wctob is provided by gnulib, or wctob exists but is not declared. */
extern int wctob (wint_t wc);
# endif
--- m4/wctob.m4.orig 2008-12-21 01:17:29.000000000 +0100
+++ m4/wctob.m4 2008-12-21 01:10:49.000000000 +0100
@@ -1,4 +1,4 @@
-# wctob.m4 serial 2
+# wctob.m4 serial 3
dnl Copyright (C) 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -15,8 +15,59 @@
AC_LIBOBJ([wctob])
gl_PREREQ_WCTOB
else
- dnl IRIX 6.5 has the wctob() function but does not declare it.
- AC_CHECK_DECLS([wctob], [], [], [
+
+ dnl Solaris 9 has the wctob() function but it does not work.
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([gt_LOCALE_FR])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether wctob works],
+ [gl_cv_func_wctob_works],
+ [
+ dnl Initial guess, used when cross-compiling or when no suitable locale
+ dnl is present.
+changequote(,)dnl
+ case "$host_os" in
+ # Guess no on Solaris <= 9.
+ solaris2.[1-9] | solaris2.[1-9].*)
+ gl_cv_func_wctob_works="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_wctob_works="guessing yes" ;;
+ esac
+changequote([,])dnl
+ if test $LOCALE_FR != none; then
+ AC_TRY_RUN([
+#include <locale.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+ if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+ {
+ wchar_t wc;
+
+ if (mbtowc (&wc, "\374", 1) == 1)
+ if (wctob (wc) != (unsigned char) '\374')
+ return 1;
+ }
+ return 0;
+}],
+ [gl_cv_func_wctob_works=yes],
+ [gl_cv_func_wctob_works=no],
+ [])
+ fi
+ ])
+ case "$gl_cv_func_wctob_works" in
+ *yes) ;;
+ *) REPLACE_WCTOB=1 ;;
+ esac
+ if test $REPLACE_WCTOB = 1; then
+ gl_REPLACE_WCHAR_H
+ AC_LIBOBJ([wctob])
+ gl_PREREQ_WCTOB
+ else
+
+ dnl IRIX 6.5 has the wctob() function but does not declare it.
+ AC_CHECK_DECLS([wctob], [], [], [
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
<wchar.h>.
BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
@@ -26,9 +77,10 @@
#include <time.h>
#include <wchar.h>
])
- if test $ac_cv_have_decl_wctob != yes; then
- HAVE_DECL_WCTOB=0
- gl_REPLACE_WCHAR_H
+ if test $ac_cv_have_decl_wctob != yes; then
+ HAVE_DECL_WCTOB=0
+ gl_REPLACE_WCHAR_H
+ fi
fi
fi
])
--- m4/wchar.m4.orig 2008-12-21 01:17:29.000000000 +0100
+++ m4/wchar.m4 2008-12-21 00:54:36.000000000 +0100
@@ -7,7 +7,7 @@
dnl Written by Eric Blake.
-# wchar.m4 serial 12
+# wchar.m4 serial 13
AC_DEFUN([gl_WCHAR_H],
[
@@ -76,6 +76,7 @@
HAVE_MBSRTOWCS=1; AC_SUBST([HAVE_MBSRTOWCS])
HAVE_DECL_WCTOB=1; AC_SUBST([HAVE_DECL_WCTOB])
HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
+ REPLACE_WCTOB=0; AC_SUBST([REPLACE_WCTOB])
REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH])
WCHAR_H=''; AC_SUBST([WCHAR_H])
])
--- modules/wchar.orig 2008-12-21 01:17:29.000000000 +0100
+++ modules/wchar 2008-12-21 00:54:05.000000000 +0100
@@ -40,6 +40,7 @@
-e 's|@''HAVE_MBSRTOWCS''@|$(HAVE_MBSRTOWCS)|g' \
-e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
-e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
+ -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
-e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \
-e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \
< $(srcdir)/wchar.in.h; \
--- modules/wctob.orig 2008-12-21 01:17:29.000000000 +0100
+++ modules/wctob 2008-12-21 00:57:53.000000000 +0100
@@ -4,6 +4,7 @@
Files:
lib/wctob.c
m4/wctob.m4
+m4/locale-fr.m4
Depends-on:
wchar
--- doc/posix-functions/wctob.texi.orig 2008-12-21 01:17:29.000000000 +0100
+++ doc/posix-functions/wctob.texi 2008-12-21 00:56:07.000000000 +0100
@@ -12,6 +12,9 @@
This function is missing on some platforms:
HP-UX 11, IRIX 5.3, Solaris 2.6, mingw, Interix 3.5.
@item
+This function does not work on some platforms:
+Solaris 9.
address@hidden
This function is missing a declaration on some platforms:
IRIX 6.5.
@end itemize