From f4aa39b61508a65deafbd6d7fea752d7a989ce24 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 8 Mar 2010 01:08:24 +0100 Subject: [PATCH] locale: Avoid #define replacements in C++ mode. --- ChangeLog | 8 ++++++++ lib/locale.in.h | 16 +++++++++++++--- m4/duplocale.m4 | 4 +++- m4/locale_h.m4 | 3 ++- modules/locale | 5 ++++- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ae4a29ee..90c2b7385 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2010-03-07 Bruno Haible + locale: Avoid #define replacements in C++ mode. + * lib/locale.in.h: Include c++defs.h. + (duplocale): In C++, define a namespaced alias symbol. + * m4/locale_h.m4 (gl_LOCALE_H_DEFAULTS): Initialize HAVE_DUPLOCALE. + * m4/duplocale.m4 (gl_FUNC_DUPLOCALE): Set HAVE_DUPLOCALE. + * modules/locale (Depends-on): Add c++defs. + (Makefile.am): Update locale.h rule. Substitute HAVE_DUPLOCALE. + langinfo: Avoid #define replacements in C++ mode. * lib/langinfo.in.h: Include c++defs.h. (nl_langinfo): In C++, define a namespaced alias symbol. diff --git a/lib/locale.in.h b/lib/locale.in.h index 193e9375e..ad92d8f2b 100644 --- a/lib/locale.in.h +++ b/lib/locale.in.h @@ -34,6 +34,8 @@ # include #endif +/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ + /* The definition of _GL_ARG_NONNULL is copied here. */ /* The definition of _GL_WARN_ON_USE is copied here. */ @@ -46,10 +48,18 @@ #if @GNULIB_DUPLOCALE@ # if @REPLACE_DUPLOCALE@ -# undef duplocale -# define duplocale rpl_duplocale -extern locale_t duplocale (locale_t locale) _GL_ARG_NONNULL ((1)); +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef duplocale +# define duplocale rpl_duplocale +# endif +_GL_FUNCDECL_RPL (duplocale, locale_t, (locale_t locale) _GL_ARG_NONNULL ((1))); +_GL_CXXALIAS_RPL (duplocale, locale_t, (locale_t locale)); +# else +# if @HAVE_DUPLOCALE@ +_GL_CXXALIAS_SYS (duplocale, locale_t, (locale_t locale)); +# endif # endif +_GL_CXXALIASWARN (duplocale); #elif defined GNULIB_POSIXCHECK # undef duplocale # if HAVE_RAW_DECL_DUPLOCALE diff --git a/m4/duplocale.m4 b/m4/duplocale.m4 index 91a8ffd90..a444bfc52 100644 --- a/m4/duplocale.m4 +++ b/m4/duplocale.m4 @@ -1,4 +1,4 @@ -# duplocale.m4 serial 1 +# duplocale.m4 serial 2 dnl Copyright (C) 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, @@ -41,6 +41,8 @@ int main () case "$gl_cv_func_duplocale_works" in *no) REPLACE_DUPLOCALE=1 ;; esac + else + HAVE_DUPLOCALE=0 fi if test $REPLACE_DUPLOCALE = 1; then gl_REPLACE_LOCALE_H diff --git a/m4/locale_h.m4 b/m4/locale_h.m4 index 0b7f4935b..4dd2286d2 100644 --- a/m4/locale_h.m4 +++ b/m4/locale_h.m4 @@ -1,4 +1,4 @@ -# locale_h.m4 serial 7 +# locale_h.m4 serial 8 dnl Copyright (C) 2007, 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, @@ -85,5 +85,6 @@ AC_DEFUN([gl_LOCALE_H_DEFAULTS], [ GNULIB_DUPLOCALE=0; AC_SUBST([GNULIB_DUPLOCALE]) dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_DUPLOCALE=1; AC_SUBST([HAVE_DUPLOCALE]) REPLACE_DUPLOCALE=0; AC_SUBST([REPLACE_DUPLOCALE]) ]) diff --git a/modules/locale b/modules/locale index 257746825..c2fb26985 100644 --- a/modules/locale +++ b/modules/locale @@ -7,6 +7,7 @@ m4/locale_h.m4 Depends-on: arg-nonnull +c++defs extensions include_next stddef @@ -20,15 +21,17 @@ BUILT_SOURCES += locale.h # We need the following in order to create when the system # doesn't have one that provides all definitions. -locale.h: locale.in.h $(WARN_ON_USE_H) $(ARG_NONNULL_H) +locale.h: locale.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) $(AM_V_GEN)rm -f $@-t $@ && \ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ -e 's|@''NEXT_LOCALE_H''@|$(NEXT_LOCALE_H)|g' \ -e 's|@''GNULIB_DUPLOCALE''@|$(GNULIB_DUPLOCALE)|g' \ + -e 's|@''HAVE_DUPLOCALE''@|$(HAVE_DUPLOCALE)|g' \ -e 's|@''HAVE_XLOCALE_H''@|$(HAVE_XLOCALE_H)|g' \ -e 's|@''REPLACE_DUPLOCALE''@|$(REPLACE_DUPLOCALE)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \ < $(srcdir)/locale.in.h; \ -- 2.11.0