[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
mbsinit, mbrtowc, wcrtomb: Improve idioms
From: |
Bruno Haible |
Subject: |
mbsinit, mbrtowc, wcrtomb: Improve idioms |
Date: |
Mon, 5 Apr 2010 11:25:16 +0100 |
User-agent: |
KMail/1.9.9 |
A similar problem with the idiom coulds also lead to a C++ mode link error
with the functions mbsinit, mbrtowc, wcrtomb, etc. This improves it:
2010-04-05 Bruno Haible <address@hidden>
mbsinit, mbrtowc, wcrtomb: Improve idioms.
* m4/mbsinit.m4 (gl_FUNC_MBSINIT): When the function does not exist,
don't set REPLACE_MBSINIT to 1.
* m4/mbrtowc.m4 (gl_FUNC_MBRTOWC): When the function does not exist,
don't set REPLACE_MBRTOWC to 1.
* m4/mbsrtowcs.m4 (gl_FUNC_MBSRTOWCS): When the function does not
exist, don't set REPLACE_MBSRTOWCS to 1.
* m4/mbsnrtowcs.m4 (gl_FUNC_MBSNRTOWCS): When the function does not
exist, don't set REPLACE_MBSNRTOWCS to 1.
* m4/wcrtomb.m4 (gl_FUNC_WCRTOMB): When the function does not exist,
don't set REPLACE_WCRTOMB to 1.
* m4/wcsrtombs.m4 (gl_FUNC_WCSRTOMBS): When the function does not
exist, don't set REPLACE_WCSRTOMBS to 1.
* m4/wcsnrtombs.m4 (gl_FUNC_WCSNRTOMBS): When the function does not
exist, don't set REPLACE_WCSNRTOMBS to 1.
*** m4/mbrtowc.m4.orig Mon Apr 5 12:16:21 2010
--- m4/mbrtowc.m4 Mon Apr 5 12:14:16 2010
***************
*** 1,4 ****
! # mbrtowc.m4 serial 16
dnl Copyright (C) 2001-2002, 2004-2005, 2008-2010 Free Software Foundation,
dnl Inc.
dnl This file is free software; the Free Software Foundation
--- 1,4 ----
! # mbrtowc.m4 serial 17
dnl Copyright (C) 2001-2002, 2004-2005, 2008-2010 Free Software Foundation,
dnl Inc.
dnl This file is free software; the Free Software Foundation
***************
*** 11,48 ****
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
! if test $REPLACE_MBSTATE_T = 1; then
! REPLACE_MBRTOWC=1
! fi
AC_CHECK_FUNCS_ONCE([mbrtowc])
if test $ac_cv_func_mbrtowc = no; then
HAVE_MBRTOWC=0
! fi
! if test $HAVE_MBRTOWC != 0 && test $REPLACE_MBRTOWC != 1; then
! gl_MBRTOWC_NULL_ARG
! gl_MBRTOWC_RETVAL
! gl_MBRTOWC_NUL_RETVAL
! case "$gl_cv_func_mbrtowc_null_arg" in
! *yes) ;;
! *) AC_DEFINE([MBRTOWC_NULL_ARG_BUG], [1],
! [Define if the mbrtowc function has the NULL string argument bug.])
! REPLACE_MBRTOWC=1
! ;;
! esac
! case "$gl_cv_func_mbrtowc_retval" in
! *yes) ;;
! *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1],
! [Define if the mbrtowc function returns a wrong return value.])
! REPLACE_MBRTOWC=1
! ;;
! esac
! case "$gl_cv_func_mbrtowc_nul_retval" in
! *yes) ;;
! *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1],
! [Define if the mbrtowc function does not return 0 for a NUL
character.])
! REPLACE_MBRTOWC=1
! ;;
! esac
fi
if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
gl_REPLACE_WCHAR_H
--- 11,49 ----
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
!
AC_CHECK_FUNCS_ONCE([mbrtowc])
if test $ac_cv_func_mbrtowc = no; then
HAVE_MBRTOWC=0
! else
! if test $REPLACE_MBSTATE_T = 1; then
! REPLACE_MBRTOWC=1
! else
! gl_MBRTOWC_NULL_ARG
! gl_MBRTOWC_RETVAL
! gl_MBRTOWC_NUL_RETVAL
! case "$gl_cv_func_mbrtowc_null_arg" in
! *yes) ;;
! *) AC_DEFINE([MBRTOWC_NULL_ARG_BUG], [1],
! [Define if the mbrtowc function has the NULL string argument
bug.])
! REPLACE_MBRTOWC=1
! ;;
! esac
! case "$gl_cv_func_mbrtowc_retval" in
! *yes) ;;
! *) AC_DEFINE([MBRTOWC_RETVAL_BUG], [1],
! [Define if the mbrtowc function returns a wrong return value.])
! REPLACE_MBRTOWC=1
! ;;
! esac
! case "$gl_cv_func_mbrtowc_nul_retval" in
! *yes) ;;
! *) AC_DEFINE([MBRTOWC_NUL_RETVAL_BUG], [1],
! [Define if the mbrtowc function does not return 0 for a NUL
character.])
! REPLACE_MBRTOWC=1
! ;;
! esac
! fi
fi
if test $HAVE_MBRTOWC = 0 || test $REPLACE_MBRTOWC = 1; then
gl_REPLACE_WCHAR_H
*** m4/mbsinit.m4.orig Mon Apr 5 12:16:21 2010
--- m4/mbsinit.m4 Mon Apr 5 12:11:04 2010
***************
*** 1,5 ****
! # mbsinit.m4 serial 3
! dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
--- 1,5 ----
! # mbsinit.m4 serial 4
! dnl Copyright (C) 2008, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
***************
*** 10,21 ****
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
! if test $REPLACE_MBSTATE_T = 1; then
! REPLACE_MBSINIT=1
! fi
AC_CHECK_FUNCS_ONCE([mbsinit])
if test $ac_cv_func_mbsinit = no; then
HAVE_MBSINIT=0
fi
if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then
gl_REPLACE_WCHAR_H
--- 10,23 ----
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
!
AC_CHECK_FUNCS_ONCE([mbsinit])
if test $ac_cv_func_mbsinit = no; then
HAVE_MBSINIT=0
+ else
+ if test $REPLACE_MBSTATE_T = 1; then
+ REPLACE_MBSINIT=1
+ fi
fi
if test $HAVE_MBSINIT = 0 || test $REPLACE_MBSINIT = 1; then
gl_REPLACE_WCHAR_H
*** m4/mbsnrtowcs.m4.orig Mon Apr 5 12:16:21 2010
--- m4/mbsnrtowcs.m4 Mon Apr 5 11:59:43 2010
***************
*** 1,5 ****
! # mbsnrtowcs.m4 serial 1
! dnl Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
--- 1,5 ----
! # mbsnrtowcs.m4 serial 2
! dnl Copyright (C) 2008, 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
***************
*** 13,24 ****
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
! if test $REPLACE_MBSTATE_T = 1; then
! REPLACE_MBSNRTOWCS=1
! fi
AC_CHECK_FUNCS_ONCE([mbsnrtowcs])
if test $ac_cv_func_mbsnrtowcs = no; then
HAVE_MBSNRTOWCS=0
fi
if test $HAVE_MBSNRTOWCS = 0 || test $REPLACE_MBSNRTOWCS = 1; then
gl_REPLACE_WCHAR_H
--- 13,26 ----
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
!
AC_CHECK_FUNCS_ONCE([mbsnrtowcs])
if test $ac_cv_func_mbsnrtowcs = no; then
HAVE_MBSNRTOWCS=0
+ else
+ if test $REPLACE_MBSTATE_T = 1; then
+ REPLACE_MBSNRTOWCS=1
+ fi
fi
if test $HAVE_MBSNRTOWCS = 0 || test $REPLACE_MBSNRTOWCS = 1; then
gl_REPLACE_WCHAR_H
*** m4/mbsrtowcs.m4.orig Mon Apr 5 12:16:21 2010
--- m4/mbsrtowcs.m4 Mon Apr 5 12:02:52 2010
***************
*** 1,4 ****
! # mbsrtowcs.m4 serial 5
dnl Copyright (C) 2008-2010 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 ----
! # mbsrtowcs.m4 serial 6
dnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 10,28 ****
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
! if test $REPLACE_MBSTATE_T = 1; then
! REPLACE_MBSRTOWCS=1
! fi
AC_CHECK_FUNCS_ONCE([mbsrtowcs])
if test $ac_cv_func_mbsrtowcs = no; then
HAVE_MBSRTOWCS=0
! fi
! if test $HAVE_MBSRTOWCS != 0 && test $REPLACE_MBSRTOWCS != 1; then
! gl_MBSRTOWCS_WORKS
! case "$gl_cv_func_mbsrtowcs_works" in
! *yes) ;;
! *) REPLACE_MBSRTOWCS=1 ;;
! esac
fi
if test $HAVE_MBSRTOWCS = 0 || test $REPLACE_MBSRTOWCS = 1; then
gl_REPLACE_WCHAR_H
--- 10,29 ----
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
!
AC_CHECK_FUNCS_ONCE([mbsrtowcs])
if test $ac_cv_func_mbsrtowcs = no; then
HAVE_MBSRTOWCS=0
! else
! if test $REPLACE_MBSTATE_T = 1; then
! REPLACE_MBSRTOWCS=1
! else
! gl_MBSRTOWCS_WORKS
! case "$gl_cv_func_mbsrtowcs_works" in
! *yes) ;;
! *) REPLACE_MBSRTOWCS=1 ;;
! esac
! fi
fi
if test $HAVE_MBSRTOWCS = 0 || test $REPLACE_MBSRTOWCS = 1; then
gl_REPLACE_WCHAR_H
*** m4/wcrtomb.m4.orig Mon Apr 5 12:16:21 2010
--- m4/wcrtomb.m4 Mon Apr 5 12:09:09 2010
***************
*** 1,4 ****
! # wcrtomb.m4 serial 4
dnl Copyright (C) 2008-2010 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 ----
! # wcrtomb.m4 serial 5
dnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 10,46 ****
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
! if test $REPLACE_MBSTATE_T = 1; then
! REPLACE_WCRTOMB=1
! fi
AC_CHECK_FUNCS_ONCE([wcrtomb])
if test $ac_cv_func_wcrtomb = no; then
HAVE_WCRTOMB=0
! fi
! if test $HAVE_WCRTOMB != 0 && test $REPLACE_WCRTOMB != 1; then
! dnl On AIX 4.3, OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL)
sometimes
! dnl returns 0 instead of 1.
! AC_REQUIRE([AC_PROG_CC])
! AC_REQUIRE([gt_LOCALE_FR])
! AC_REQUIRE([gt_LOCALE_FR_UTF8])
! AC_REQUIRE([gt_LOCALE_JA])
! AC_REQUIRE([gt_LOCALE_ZH_CN])
! AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
! AC_CACHE_CHECK([whether wcrtomb return value is correct],
! [gl_cv_func_wcrtomb_retval],
! [
! dnl Initial guess, used when cross-compiling or when no suitable
locale
! dnl is present.
changequote(,)dnl
! case "$host_os" in
! # Guess no on AIX 4, OSF/1 and Solaris.
! aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no" ;;
! # Guess yes otherwise.
! *) gl_cv_func_wcrtomb_retval="guessing yes" ;;
! esac
changequote([,])dnl
! if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test
$LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
! AC_TRY_RUN([
#include <locale.h>
#include <stdio.h>
#include <string.h>
--- 10,46 ----
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
!
AC_CHECK_FUNCS_ONCE([wcrtomb])
if test $ac_cv_func_wcrtomb = no; then
HAVE_WCRTOMB=0
! else
! if test $REPLACE_MBSTATE_T = 1; then
! REPLACE_WCRTOMB=1
! else
! dnl On AIX 4.3, OSF/1 5.1 and Solaris 10, wcrtomb (NULL, 0, NULL)
sometimes
! dnl returns 0 instead of 1.
! AC_REQUIRE([AC_PROG_CC])
! AC_REQUIRE([gt_LOCALE_FR])
! AC_REQUIRE([gt_LOCALE_FR_UTF8])
! AC_REQUIRE([gt_LOCALE_JA])
! AC_REQUIRE([gt_LOCALE_ZH_CN])
! AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
! AC_CACHE_CHECK([whether wcrtomb return value is correct],
! [gl_cv_func_wcrtomb_retval],
! [
! dnl Initial guess, used when cross-compiling or when no suitable
locale
! dnl is present.
changequote(,)dnl
! case "$host_os" in
! # Guess no on AIX 4, OSF/1 and Solaris.
! aix4* | osf* | solaris*) gl_cv_func_wcrtomb_retval="guessing no"
;;
! # Guess yes otherwise.
! *) gl_cv_func_wcrtomb_retval="guessing yes"
;;
! esac
changequote([,])dnl
! if test $LOCALE_FR != none || test $LOCALE_FR_UTF8 != none || test
$LOCALE_JA != none || test $LOCALE_ZH_CN != none; then
! AC_TRY_RUN([
#include <locale.h>
#include <stdio.h>
#include <string.h>
***************
*** 69,83 ****
}
return 0;
}],
! [gl_cv_func_wcrtomb_retval=yes],
! [gl_cv_func_wcrtomb_retval=no],
! [:])
! fi
! ])
! case "$gl_cv_func_wcrtomb_retval" in
! *yes) ;;
! *) REPLACE_WCRTOMB=1 ;;
! esac
fi
if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then
gl_REPLACE_WCHAR_H
--- 69,84 ----
}
return 0;
}],
! [gl_cv_func_wcrtomb_retval=yes],
! [gl_cv_func_wcrtomb_retval=no],
! [:])
! fi
! ])
! case "$gl_cv_func_wcrtomb_retval" in
! *yes) ;;
! *) REPLACE_WCRTOMB=1 ;;
! esac
! fi
fi
if test $HAVE_WCRTOMB = 0 || test $REPLACE_WCRTOMB = 1; then
gl_REPLACE_WCHAR_H
*** m4/wcsnrtombs.m4.orig Mon Apr 5 12:16:21 2010
--- m4/wcsnrtombs.m4 Mon Apr 5 12:03:39 2010
***************
*** 1,4 ****
! # wcsnrtombs.m4 serial 2
dnl Copyright (C) 2008-2010 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 ----
! # wcsnrtombs.m4 serial 3
dnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 10,21 ****
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
! if test $REPLACE_MBSTATE_T = 1; then
! REPLACE_WCSNRTOMBS=1
! fi
AC_CHECK_FUNCS_ONCE([wcsnrtombs])
if test $ac_cv_func_wcsnrtombs = no; then
HAVE_WCSNRTOMBS=0
fi
if test $HAVE_WCSNRTOMBS = 0 || test $REPLACE_WCSNRTOMBS = 1; then
gl_REPLACE_WCHAR_H
--- 10,23 ----
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
!
AC_CHECK_FUNCS_ONCE([wcsnrtombs])
if test $ac_cv_func_wcsnrtombs = no; then
HAVE_WCSNRTOMBS=0
+ else
+ if test $REPLACE_MBSTATE_T = 1; then
+ REPLACE_WCSNRTOMBS=1
+ fi
fi
if test $HAVE_WCSNRTOMBS = 0 || test $REPLACE_WCSNRTOMBS = 1; then
gl_REPLACE_WCHAR_H
*** m4/wcsrtombs.m4.orig Mon Apr 5 12:16:21 2010
--- m4/wcsrtombs.m4 Mon Apr 5 12:06:05 2010
***************
*** 1,4 ****
! # wcsrtombs.m4 serial 4
dnl Copyright (C) 2008-2010 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 ----
! # wcsrtombs.m4 serial 5
dnl Copyright (C) 2008-2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
***************
*** 10,37 ****
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
! if test $REPLACE_MBSTATE_T = 1; then
! REPLACE_WCSRTOMBS=1
! fi
AC_CHECK_FUNCS_ONCE([wcsrtombs])
if test $ac_cv_func_wcsrtombs = no; then
HAVE_WCSRTOMBS=0
! fi
! if test $HAVE_WCSRTOMBS != 0 && test $REPLACE_WCSRTOMBS != 1; then
! gl_WCSRTOMBS_TERMINATION
! gl_WCSRTOMBS_NULL
! case "$gl_cv_func_wcsrtombs_termination" in
! *yes) ;;
! *) AC_DEFINE([WCSRTOMBS_TERMINATION_BUG], [1],
! [Define if the wcsrtombs function may set the source pointer to
NULL without NUL-terminating the destination.])
! REPLACE_WCSRTOMBS=1 ;;
! esac
! case "$gl_cv_func_wcsrtombs_null" in
! *yes) ;;
! *) AC_DEFINE([WCSRTOMBS_NULL_ARG_BUG], [1],
! [Define if the wcsrtombs function has the NULL destination
argument bug.])
! REPLACE_WCSRTOMBS=1 ;;
! esac
fi
if test $HAVE_WCSRTOMBS = 0 || test $REPLACE_WCSRTOMBS = 1; then
gl_REPLACE_WCHAR_H
--- 10,38 ----
AC_REQUIRE([AC_TYPE_MBSTATE_T])
gl_MBSTATE_T_BROKEN
!
AC_CHECK_FUNCS_ONCE([wcsrtombs])
if test $ac_cv_func_wcsrtombs = no; then
HAVE_WCSRTOMBS=0
! else
! if test $REPLACE_MBSTATE_T = 1; then
! REPLACE_WCSRTOMBS=1
! else
! gl_WCSRTOMBS_TERMINATION
! gl_WCSRTOMBS_NULL
! case "$gl_cv_func_wcsrtombs_termination" in
! *yes) ;;
! *) AC_DEFINE([WCSRTOMBS_TERMINATION_BUG], [1],
! [Define if the wcsrtombs function may set the source pointer to
NULL without NUL-terminating the destination.])
! REPLACE_WCSRTOMBS=1 ;;
! esac
! case "$gl_cv_func_wcsrtombs_null" in
! *yes) ;;
! *) AC_DEFINE([WCSRTOMBS_NULL_ARG_BUG], [1],
! [Define if the wcsrtombs function has the NULL destination
argument bug.])
! REPLACE_WCSRTOMBS=1 ;;
! esac
! fi
fi
if test $HAVE_WCSRTOMBS = 0 || test $REPLACE_WCSRTOMBS = 1; then
gl_REPLACE_WCHAR_H
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- mbsinit, mbrtowc, wcrtomb: Improve idioms,
Bruno Haible <=