pspp-dev
[Top][All Lists]
Advanced

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

Re: Problem with pspp-master


From: Ben Pfaff
Subject: Re: Problem with pspp-master
Date: Mon, 17 May 2010 22:09:24 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Ben Pfaff <address@hidden> writes:

> Harry Thijssen <address@hidden> writes:
>
>> It seems the whole condition in printf.c is obsolete.
>>
>> The attached patch fixes that.
>>
>> Michel can you test if this works for you?
>
> It seems that Bruno's change here fixed Mingw but broke OpenSUSE
> and FreeBSD.  I'm following up with Bruno on the Gnulib list.

Bruno committed a fix to Gnulib as commit a43e24168 "Fix
collision between gnulib's and libintl's printf replacements."  I
can confirm that it fixes the problem on OpenBSD 4.6, so probably
for OpenSUSE as well.

Here is the patch.  You have to apply it to your Gnulib directory
and then rerun "make -f Smake" and "make" in PSPP.

>From 58a68142c51c754c14421b8f79ffb233e00cfd12 Mon Sep 17 00:00:00 2001
From: Bruno Haible <address@hidden>
Date: Sun, 16 May 2010 14:16:03 +0200
Subject: [PATCH] Fix collision between gnulib's and libintl's printf 
replacements.

---
 ChangeLog            |   18 ++++++++++++++++++
 lib/printf.c         |    4 ----
 lib/stdio-write.c    |    2 --
 lib/stdio.in.h       |   22 ++++++++++++++++++----
 m4/asm-underscore.m4 |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 m4/stdio_h.m4        |    3 ++-
 modules/stdio        |    2 ++
 7 files changed, 88 insertions(+), 11 deletions(-)
 create mode 100644 m4/asm-underscore.m4

diff --git a/ChangeLog b/ChangeLog
index 5b11d62..349ed47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2010-05-16  Bruno Haible  <address@hidden>
+
+       Fix collision between gnulib's and libintl's printf replacements.
+       * lib/stdio.in.h (_GL_STDIO_STRINGIZE,
+       _GL_STDIO_MACROEXPAND_AND_STRINGIZE): New macros.
+       (printf): When using GNU C, map the __printf__ function to rpl_printf
+       via __asm__. When not using GNU C, define rpl_printf instead of
+       __printf__.
+       * lib/printf.c: Ignore DEPENDS_ON_LIBINTL. Undoes the 2010-03-25
+       commit.
+       * lib/stdio-write.c: Ignore DEPENDS_ON_LIBINTL. Undoes the 2009-08-10
+       commit.
+       * m4/asm-underscore.m4: New file.
+       * m4/stdio_h.m4 (gl_STDIO_H): Require gl_ASM_SYMBOL_PREFIX.
+       * modules/stdio (Files): Add m4/asm-underscore.m4.
+       (Makefile.am): Substitute ASM_SYMBOL_PREFIX.
+       Reported by Ben Pfaff.
+
 2010-03-25  Eric Blake  <address@hidden>
 
        maint: use pragma consistently across replacement headers
diff --git a/lib/printf.c b/lib/printf.c
index c48042a..3746afe 100644
--- a/lib/printf.c
+++ b/lib/printf.c
@@ -23,8 +23,6 @@
 
 #include <stdarg.h>
 
-#if !DEPENDS_ON_LIBINTL /* avoid collision with intl/printf.c */
-
 /* Print formatted output to standard output.
    Return string length of formatted string.  On error, return a negative
    value.  */
@@ -40,5 +38,3 @@ printf (const char *format, ...)
 
   return retval;
 }
-
-#endif
diff --git a/lib/stdio-write.c b/lib/stdio-write.c
index f7da9e4..a6a0eb1 100644
--- a/lib/stdio-write.c
+++ b/lib/stdio-write.c
@@ -63,7 +63,6 @@
     }
 
 #  if !REPLACE_PRINTF_POSIX /* avoid collision with printf.c */
-#   if !DEPENDS_ON_LIBINTL /* avoid collision with intl/printf.c */
 int
 printf (const char *format, ...)
 {
@@ -76,7 +75,6 @@ printf (const char *format, ...)
 
   return retval;
 }
-#   endif
 #  endif
 
 #  if !REPLACE_FPRINTF_POSIX /* avoid collision with fprintf.c */
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 7647d48..80da020 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -63,6 +63,10 @@
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
+/* Macros for stringification.  */
+#define _GL_STDIO_STRINGIZE(token) #token
+#define _GL_STDIO_MACROEXPAND_AND_STRINGIZE(token) _GL_STDIO_STRINGIZE(token)
+
 
 #if @GNULIB_DPRINTF@
 # if @REPLACE_DPRINTF@
@@ -621,16 +625,26 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms 
- "
 #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
 # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
      || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && 
@GNULIB_STDIO_H_SIGPIPE@)
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#  if defined __GNUC__
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 /* Don't break __attribute__((format(printf,M,N))).  */
-#   define printf __printf__
-#  endif
-#  define GNULIB_overrides_printf 1
+#    define printf __printf__
+#   endif
 _GL_FUNCDECL_RPL_1 (__printf__, int,
                     (const char *format, ...)
+                    __asm__ (@ASM_SYMBOL_PREFIX@
+                             _GL_STDIO_MACROEXPAND_AND_STRINGIZE(rpl_printf))
                     __attribute__ ((__format__ (__printf__, 1, 2)))
                     _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL_1 (printf, __printf__, int, (const char *format, ...));
+#  else
+_GL_FUNCDECL_RPL (printf, int,
+                  (const char *format, ...)
+                  __attribute__ ((__format__ (__printf__, 1, 2)))
+                  _GL_ARG_NONNULL ((1)));
+_GL_CXXALIAS_RPL (printf, printf, int, (const char *format, ...));
+#  endif
+#  define GNULIB_overrides_printf 1
 # else
 _GL_CXXALIAS_SYS (printf, int, (const char *format, ...));
 # endif
diff --git a/m4/asm-underscore.m4 b/m4/asm-underscore.m4
new file mode 100644
index 0000000..1736cc4
--- /dev/null
+++ b/m4/asm-underscore.m4
@@ -0,0 +1,48 @@
+# asm-underscore.m4 serial 1
+dnl Copyright (C) 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.
+
+dnl From Bruno Haible. Based on as-underscore.m4 in GNU clisp.
+
+# gl_ASM_SYMBOL_PREFIX
+# Tests for the prefix of C symbols at the assembly language level and the
+# linker level. This prefix is either an underscore or empty. Defines the
+# C macro USER_LABEL_PREFIX to this prefix, and sets ASM_SYMBOL_PREFIX to
+# a stringified variant of this prefix.
+
+AC_DEFUN([gl_ASM_SYMBOL_PREFIX],
+[
+  dnl We don't use GCC's __USER_LABEL_PREFIX__ here, because
+  dnl 1. It works only for GCC.
+  dnl 2. It is incorrectly defined on some platforms, in some GCC versions.
+  AC_CACHE_CHECK(
+    [whether C symbols are prefixed with underscore at the linker level],
+    [gl_cv_prog_as_underscore],
+    [cat > conftest.c <<EOF
+#ifdef __cplusplus
+extern "C" int foo (void);
+#endif
+int foo(void) { return 0; }
+EOF
+     # Look for the assembly language name in the .s file.
+     AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -S conftest.c) >/dev/null 2>&1
+     if grep _foo conftest.s >/dev/null ; then
+       gl_cv_prog_as_underscore=yes
+     else
+       gl_cv_prog_as_underscore=no
+     fi
+     rm -f conftest*
+    ])
+  if test $gl_cv_prog_as_underscore = yes; then
+    USER_LABEL_PREFIX=_
+  else
+    USER_LABEL_PREFIX=
+  fi
+  AC_DEFINE_UNQUOTED([USER_LABEL_PREFIX], [$USER_LABEL_PREFIX],
+    [Define to the prefix of C symbols at the assembler and linker level,
+     either an underscore or empty.])
+  ASM_SYMBOL_PREFIX='"'${USER_LABEL_PREFIX}'"'
+  AC_SUBST([ASM_SYMBOL_PREFIX])
+])
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index 681fd8b..d64e51a 100644
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 26
+# stdio_h.m4 serial 31
 dnl Copyright (C) 2007-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,
@@ -8,6 +8,7 @@ AC_DEFUN([gl_STDIO_H],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
   AC_REQUIRE([AC_C_INLINE])
+  AC_REQUIRE([gl_ASM_SYMBOL_PREFIX])
   gl_CHECK_NEXT_HEADERS([stdio.h])
   dnl No need to create extra modules for these functions. Everyone who uses
   dnl <stdio.h> likely needs them.
diff --git a/modules/stdio b/modules/stdio
index 59a29bd..4424d1d 100644
--- a/modules/stdio
+++ b/modules/stdio
@@ -5,6 +5,7 @@ Files:
 lib/stdio.in.h
 lib/stdio-write.c
 m4/stdio_h.m4
+m4/asm-underscore.m4
 
 Depends-on:
 include_next
@@ -108,6 +109,7 @@ stdio.h: stdio.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) 
$(WARN_ON_USE_H)
              -e 's|@''REPLACE_VPRINTF''@|$(REPLACE_VPRINTF)|g' \
              -e 's|@''REPLACE_VSNPRINTF''@|$(REPLACE_VSNPRINTF)|g' \
              -e 's|@''REPLACE_VSPRINTF''@|$(REPLACE_VSPRINTF)|g' \
+             -e 's|@''ASM_SYMBOL_PREFIX''@|$(ASM_SYMBOL_PREFIX)|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)'; \
-- 
1.7.1


-- 
A bicycle is one of the world's beautiful machines, beautiful machines
are art, and art is civilisation, good living, and balm to the soul.
--Elisa Francesca Roselli



reply via email to

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