bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module 'btowc'


From: Bruno Haible
Subject: Re: new module 'btowc'
Date: Sun, 21 Dec 2008 17:35:45 +0100
User-agent: KMail/1.9.9

>       New module 'btowc'.

Some systems succeed in implementing even this simple function incorrectly.
Here is a workaround:


2008-12-21  Bruno Haible  <address@hidden>

        Work around a btowc() bug on IRIX 6.5.
        * lib/wchar.in.h (btowc): Override if REPLACE_BTOWC is set.
        * m4/btowc.m4 (gl_FUNC_BTOWC): Test whether btowc(EOF) is correct. Set
        REPLACE_WTOBC if not.
        * m4/wchar.m4 (gl_WCHAR_H_DEFAULTS): Initialize REPLACE_BTOWC.
        * modules/wchar (Makefile.am): Substitute REPLACE_BTOWC.
        * doc/posix-functions/btowc.texi: Mention the IRIX bug.

*** lib/wchar.in.h.orig 2008-12-21 17:31:42.000000000 +0100
--- lib/wchar.in.h      2008-12-21 17:14:56.000000000 +0100
***************
*** 84,90 ****
  
  /* Convert a single-byte character to a wide character.  */
  #if @GNULIB_BTOWC@
! # if address@hidden@
  extern wint_t btowc (int c);
  # endif
  #elif defined GNULIB_POSIXCHECK
--- 84,94 ----
  
  /* Convert a single-byte character to a wide character.  */
  #if @GNULIB_BTOWC@
! # if @REPLACE_BTOWC@
! #  undef btowc
! #  define btowc rpl_btowc
! # endif
! # if address@hidden@ || @REPLACE_BTOWC@
  extern wint_t btowc (int c);
  # endif
  #elif defined GNULIB_POSIXCHECK
*** m4/btowc.m4.orig    2008-12-21 17:31:42.000000000 +0100
--- m4/btowc.m4 2008-12-21 17:23:28.000000000 +0100
***************
*** 1,4 ****
! # btowc.m4 serial 2
  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,
--- 1,4 ----
! # btowc.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,
***************
*** 11,16 ****
--- 11,61 ----
    AC_CHECK_FUNCS_ONCE([btowc])
    if test $ac_cv_func_btowc = no; then
      HAVE_BTOWC=0
+   else
+ 
+     dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
+     AC_REQUIRE([AC_PROG_CC])
+     AC_REQUIRE([gt_LOCALE_FR])
+     AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+     AC_CACHE_CHECK([whether btowc(EOF) is correct],
+       [gl_cv_func_btowc_eof],
+       [
+         dnl Initial guess, used when cross-compiling or when no suitable 
locale
+         dnl is present.
+ changequote(,)dnl
+         case "$host_os" in
+                  # Guess no on IRIX.
+           irix*) gl_cv_func_btowc_eof="guessing no" ;;
+                  # Guess yes otherwise.
+           *)     gl_cv_func_btowc_eof="guessing yes" ;;
+         esac
+ changequote([,])dnl
+         if test $LOCALE_FR != none; then
+           AC_TRY_RUN([
+ #include <locale.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <wchar.h>
+ int main ()
+ {
+   if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+     {
+       if (btowc (EOF) != WEOF)
+         return 1;
+     }
+   return 0;
+ }],
+             [gl_cv_func_btowc_eof=yes],
+             [gl_cv_func_btowc_eof=no],
+             [])
+         fi
+       ])
+     case "$gl_cv_func_btowc_eof" in
+       *yes) ;;
+       *) REPLACE_BTOWC=1 ;;
+     esac
+   fi
+   if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then
      gl_REPLACE_WCHAR_H
      AC_LIBOBJ([btowc])
      gl_PREREQ_BTOWC
*** m4/wchar.m4.orig    2008-12-21 17:31:42.000000000 +0100
--- m4/wchar.m4 2008-12-21 17:16:16.000000000 +0100
***************
*** 7,13 ****
  
  dnl Written by Eric Blake.
  
! # wchar.m4 serial 17
  
  AC_DEFUN([gl_WCHAR_H],
  [
--- 7,13 ----
  
  dnl Written by Eric Blake.
  
! # wchar.m4 serial 18
  
  AC_DEFUN([gl_WCHAR_H],
  [
***************
*** 81,86 ****
--- 81,87 ----
    HAVE_DECL_WCTOB=1;   AC_SUBST([HAVE_DECL_WCTOB])
    HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH])
    REPLACE_MBSTATE_T=0; AC_SUBST([REPLACE_MBSTATE_T])
+   REPLACE_BTOWC=0;     AC_SUBST([REPLACE_BTOWC])
    REPLACE_WCTOB=0;     AC_SUBST([REPLACE_WCTOB])
    REPLACE_MBSINIT=0;   AC_SUBST([REPLACE_MBSINIT])
    REPLACE_MBRTOWC=0;   AC_SUBST([REPLACE_MBRTOWC])
*** modules/wchar.orig  2008-12-21 17:31:42.000000000 +0100
--- modules/wchar       2008-12-21 17:15:52.000000000 +0100
***************
*** 45,50 ****
--- 45,51 ----
              -e 's|@''HAVE_DECL_WCTOB''@|$(HAVE_DECL_WCTOB)|g' \
              -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \
              -e 's|@''REPLACE_MBSTATE_T''@|$(REPLACE_MBSTATE_T)|g' \
+             -e 's|@''REPLACE_BTOWC''@|$(REPLACE_BTOWC)|g' \
              -e 's|@''REPLACE_WCTOB''@|$(REPLACE_WCTOB)|g' \
              -e 's|@''REPLACE_MBSINIT''@|$(REPLACE_MBSINIT)|g' \
              -e 's|@''REPLACE_MBRTOWC''@|$(REPLACE_MBRTOWC)|g' \
*** doc/posix-functions/btowc.texi.orig 2008-12-21 17:31:41.000000000 +0100
--- doc/posix-functions/btowc.texi      2008-12-21 17:13:51.000000000 +0100
***************
*** 11,16 ****
--- 11,19 ----
  @item
  This function is missing on some platforms:
  HP-UX 11.00, IRIX 5.3, Solaris 2.6, mingw, Interix 3.5.
+ @item
+ This function does not return WEOF for an EOF argument on some platforms:
+ IRIX 6.5.
  @end itemize
  
  Portability problems not fixed by Gnulib:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]