locale: Avoid #define replacements in C++ mode.
authorBruno Haible <bruno@clisp.org>
Mon, 8 Mar 2010 00:08:24 +0000 (01:08 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 8 Mar 2010 02:11:11 +0000 (03:11 +0100)
ChangeLog
lib/locale.in.h
m4/duplocale.m4
m4/locale_h.m4
modules/locale

index 6ae4a29..90c2b73 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-03-07  Bruno Haible  <bruno@clisp.org>
 
+       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.
index 193e937..ad92d8f 100644 (file)
@@ -34,6 +34,8 @@
 # include <xlocale.h>
 #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.  */
 
 #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
index 91a8ffd..a444bfc 100644 (file)
@@ -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
index 0b7f493..4dd2286 100644 (file)
@@ -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])
 ])
index 2577468..c2fb269 100644 (file)
@@ -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 <locale.h> 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; \