Alain Guibert wrote: > > The behaviour change in "checking for long long int" is intended. The > > users of the gnulib macros now expect to be able to use long longs in > > preprocessor directives (even if there are some known bugs with values > > outside the 32-bit 'int' range). > > But the preprocessor can define and assign long longs, and the compiler > is able to do everything with them. Not defining HAVE_LONG_LONG_INT may > waste this capacity, no?
Yes. This was discussed in October 2007, around the time when gettext-0.17 was released. Now the gnulib tests don't "waste so much capacity". > > Regarding the four other failures, I cannot guess what the problem is > > with the little info that you gave. > > I fear gdb breakpoints to be over me. But maybe some debug printfs can > already give some hints: > > >>| FAIL: test-c-strcase.sh > > Rather strange: LC_ALL=fr_FR setlocale(LC_ALL, "") returns NULL, and > following setlocale(LC_ALL, NULL) return "C". Outside of gettext, a > simple test program shows that setlocale() works normally and returns > "fr_FR" in both cases. If test-c-strn?casecmp.c are built with an -lc > inserted *before* /tmp/gettext-0.17/gettext-tools/intl/.libs/libintl.so, > then setlocale() behaves normally, and test-c-strcase.sh PASSes. Weird. It looks as if some symbols from libintl (or its dependencies: libiconv) would be affecting/overriding the behaviour of libc. Can you look at which symbols are defined in libintl.so and libiconv.so: nm --dynamic libintl.so | grep ' T ' nm --dynamic libiconv.so | grep ' T ' > >>| checking for snprintf... yes > >>| test-snprintf.c:61: assertion failed > >>| FAIL: test-snprintf > > Inserting a printf just before line 61: > > | size=0 buf+size=12345 > | size=1 buf+size=2345 > | test-snprintf.c:62: assertion failed > > It seems that libc snprintf() behaves as expected when size is 2 or > more. But when size is 0 or 1, retval = -1 and buf is fully overwritten. > Size 0 succeeds the ASSERT only because 0 bytes are compared. Thanks. That bug is dangerous enough, and your info is concrete enough that I can add a workaround to gnulib (below). You can test whether the attemted workaround actually works by using this test dir: http://www.haible.de/bruno/gnu/testdirs.tar.gz > >>| checking for wcwidth... no > >>| test-wcwidth.c:45: assertion failed > >>| FAIL: test-wcwidth > > wcwidth(32)=-1, and the same for all ASCII characters. And iswprint(32) = ? And isprint(32) = ? > I tried to modify > rpl_wcwidth(), but the test was not impacted: I suppose the test uses > the previously installed rpl_wcwidth(), not the one being built? You can use tools like 'nm' or "gcc -E" to find out what got compiled as what. Bruno 2008-04-19 Bruno Haible <[EMAIL PROTECTED]> Work around snprintf bug on Linux libc5. * m4/printf.m4 (gl_SNPRINTF_SIZE1): New macro. * m4/snprintf-posix.m4 (gl_FUNC_SNPRINTF_POSIX): Invoke gl_SNPRINTF_SIZE1. * m4/vsnprintf-posix.m4 (gl_FUNC_VSNPRINTF_POSIX): Likewise. * m4/snprintf.m4 (gl_FUNC_SNPRINTF): Likewise. Replace snprintf if that test failed. * m4/vsnprintf.m4 (gl_FUNC_VSNPRINTF): Likewise. * lib/vasnprintf.c (USE_SNPRINTF): Set to 0 on Linux libc5 systems. * modules/snprintf (Files): Add m4/printf.m4. * modules/vsnprintf (Files): Likewise. * doc/posix-functions/snprintf.texi: Document Linux libc5 problem. * doc/posix-functions/vsnprintf.texi: Likewise. *** doc/posix-functions/snprintf.texi.orig 2008-04-19 21:35:48.000000000 +0200 --- doc/posix-functions/snprintf.texi 2008-04-19 18:57:54.000000000 +0200 *************** *** 11,16 **** --- 11,20 ---- @item This function is missing on some platforms: OSF/1 4.0, Solaris 2.5.1. + @item + This function overwrites memory even when a size argument of 1 is passed on some + platforms: + Linux libc5. @end itemize Portability problems fixed by Gnulib module @code{snprintf-posix}: *** doc/posix-functions/vsnprintf.texi.orig 2008-04-19 21:35:48.000000000 +0200 --- doc/posix-functions/vsnprintf.texi 2008-04-19 18:57:48.000000000 +0200 *************** *** 11,16 **** --- 11,20 ---- @item This function is missing on some platforms: OSF/1 4.0, Solaris 2.5.1. + @item + This function overwrites memory even when a size argument of 1 is passed on some + platforms: + Linux libc5. @end itemize Portability problems fixed by Gnulib module @code{vsnprintf-posix}: *** lib/vasnprintf.c.orig 2008-04-19 21:35:49.000000000 +0200 --- lib/vasnprintf.c 2008-04-19 18:46:28.000000000 +0200 *************** *** 177,186 **** # endif #else /* TCHAR_T is char. */ ! # /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'. But don't use it on BeOS, since BeOS snprintf produces no output if the ! size argument is >= 0x3000000. */ ! # if (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF) && !defined __BEOS__ # define USE_SNPRINTF 1 # else # define USE_SNPRINTF 0 --- 177,188 ---- # endif #else /* TCHAR_T is char. */ ! /* Use snprintf if it exists under the name 'snprintf' or '_snprintf'. But don't use it on BeOS, since BeOS snprintf produces no output if the ! size argument is >= 0x3000000. ! Also don't use it on Linux libc5, since there snprintf with size = 1 ! writes any output without bounds, like sprintf. */ ! # if (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF) && !defined __BEOS__ && !(__GNU_LIBRARY__ == 1) # define USE_SNPRINTF 1 # else # define USE_SNPRINTF 0 *** m4/printf.m4.orig 2008-04-19 21:35:49.000000000 +0200 --- m4/printf.m4 2008-04-19 21:06:51.000000000 +0200 *************** *** 1,4 **** ! # printf.m4 serial 22 dnl Copyright (C) 2003, 2007-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 ---- ! # printf.m4 serial 23 dnl Copyright (C) 2003, 2007-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, *************** *** 1115,1120 **** --- 1115,1145 ---- ]) ]) + dnl Test whether the snprintf function, when passed a size = 1, writes any + dnl output without bounds in this case, behaving like sprintf. This is the + dnl case on Linux libc5. + dnl Result is gl_cv_func_snprintf_size1. + + AC_DEFUN([gl_SNPRINTF_SIZE1], + [ + AC_REQUIRE([AC_PROG_CC]) + AC_CACHE_CHECK([whether snprintf respects a size of 1], + [gl_cv_func_snprintf_size1], + [ + AC_TRY_RUN([ + #include <stdio.h> + int main() + { + static char buf[8] = "DEADBEEF"; + snprintf (buf, 1, "%d", 12345); + return buf[1] != 'E'; + }], + [gl_cv_func_snprintf_size1=yes], + [gl_cv_func_snprintf_size1=no], + [gl_cv_func_snprintf_size1="guessing yes"]) + ]) + ]) + dnl Test whether the vsnprintf function, when passed a zero size, produces no dnl output. (ISO C99, POSIX:2001) dnl For example, snprintf nevertheless writes a NUL byte in this case *************** *** 1234,1240 **** dnl 15 = gl_SNPRINTF_TRUNCATION_C99 dnl 16 = gl_SNPRINTF_RETVAL_C99 dnl 17 = gl_SNPRINTF_DIRECTIVE_N ! dnl 18 = gl_VSNPRINTF_ZEROSIZE_C99 dnl dnl 1 = checking whether printf supports size specifiers as in C99... dnl 2 = checking whether printf supports 'long double' arguments... --- 1259,1266 ---- dnl 15 = gl_SNPRINTF_TRUNCATION_C99 dnl 16 = gl_SNPRINTF_RETVAL_C99 dnl 17 = gl_SNPRINTF_DIRECTIVE_N ! dnl 18 = gl_SNPRINTF_SIZE1 ! dnl 19 = gl_VSNPRINTF_ZEROSIZE_C99 dnl dnl 1 = checking whether printf supports size specifiers as in C99... dnl 2 = checking whether printf supports 'long double' arguments... *************** *** 1253,1282 **** dnl 15 = checking whether snprintf truncates the result as in C99... dnl 16 = checking whether snprintf returns a byte count as in C99... dnl 17 = checking whether snprintf fully supports the 'n' directive... ! dnl 18 = checking whether vsnprintf respects a zero size as in C99... dnl dnl . = yes, # = no. dnl ! dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ! dnl glibc 2.5 . . . . . . . . . . . . . . . . . . ! dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . ! dnl FreeBSD 5.4, 6.1 . . . . # . . . . . # . # . . . . . ! dnl MacOS X 10.3.9 . . . . # . . . . . # . # . . . . . ! dnl OpenBSD 3.9, 4.0 . . # # # # . . # . # . # . . . . . ! dnl Cygwin 2007 (= Cygwin 1.5.24) . . . . # # . . . ? # ? ? . . . . . ! dnl Cygwin 2006 (= Cygwin 1.5.19) # . . . # # . . # ? # ? ? . . . . . ! dnl Solaris 10 . . # # # . . . . . # . . . . . . . ! dnl Solaris 2.6 ... 9 # . # # # # . . . . # . . . . . . . ! dnl Solaris 2.5.1 # . # # # # . . . . # . . # # # # # ! dnl AIX 5.2 . . # # # . . . . . # . . . . . . . ! dnl AIX 4.3.2, 5.1 # . # # # # . . . . # . . . . . . . ! dnl HP-UX 11.31 . . . . # . . . . . # . . . . # # . ! dnl HP-UX 11.{00,11,23} # . . . # # . . . . # . . . . # # # ! dnl HP-UX 10.20 # . . . # # . . . # # . . . . # # # ! dnl IRIX 6.5 # . # # # # . . . . # . . . . # . . ! dnl OSF/1 5.1 # . # # # # . . . . # . . . . # . # ! dnl OSF/1 4.0d # . # # # # . . . . # . . # # # # # ! dnl NetBSD 4.0 . ? ? ? ? ? . . ? ? ? ? ? . . . ? ? ! dnl NetBSD 3.0 . . . . # # . # # ? # . # . . . . . ! dnl BeOS # # . # # # . # . ? . # ? . . . . . ! dnl mingw # # # # # # . # # . # # ? . # # # . --- 1279,1309 ---- dnl 15 = checking whether snprintf truncates the result as in C99... dnl 16 = checking whether snprintf returns a byte count as in C99... dnl 17 = checking whether snprintf fully supports the 'n' directive... ! dnl 18 = checking whether snprintf respects a size of 1... ! dnl 19 = checking whether vsnprintf respects a zero size as in C99... dnl dnl . = yes, # = no. dnl ! dnl 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ! dnl glibc 2.5 . . . . . . . . . . . . . . . . . . . ! dnl glibc 2.3.6 . . . . # . . . . . . . . . . . . . . ! dnl FreeBSD 5.4, 6.1 . . . . # . . . . . # . # . . . . . . ! dnl MacOS X 10.3.9 . . . . # . . . . . # . # . . . . . . ! dnl OpenBSD 3.9, 4.0 . . # # # # . . # . # . # . . . . . . ! dnl Cygwin 2007 (= Cygwin 1.5.24) . . . . # # . . . ? # ? ? . . . . . . ! dnl Cygwin 2006 (= Cygwin 1.5.19) # . . . # # . . # ? # ? ? . . . . . . ! dnl Solaris 10 . . # # # . . . . . # . . . . . . . . ! dnl Solaris 2.6 ... 9 # . # # # # . . . . # . . . . . . . . ! dnl Solaris 2.5.1 # . # # # # . . . . # . . # # # # # # ! dnl AIX 5.2 . . # # # . . . . . # . . . . . . . . ! dnl AIX 4.3.2, 5.1 # . # # # # . . . . # . . . . . . . . ! dnl HP-UX 11.31 . . . . # . . . . . # . . . . # # . . ! dnl HP-UX 11.{00,11,23} # . . . # # . . . . # . . . . # # . # ! dnl HP-UX 10.20 # . . . # # . . . # # . . . . # # ? # ! dnl IRIX 6.5 # . # # # # . . . . # . . . . # . . . ! dnl OSF/1 5.1 # . # # # # . . . . # . . . . # . . # ! dnl OSF/1 4.0d # . # # # # . . . . # . . # # # # # # ! dnl NetBSD 4.0 . ? ? ? ? ? . . ? ? ? ? ? . . . ? ? ? ! dnl NetBSD 3.0 . . . . # # . # # ? # . # . . . . . . ! dnl BeOS # # . # # # . # . ? . # ? . . . . . . ! dnl mingw # # # # # # . # # . # # ? . # # # . . *** m4/snprintf-posix.m4.orig 2008-04-19 21:35:49.000000000 +0200 --- m4/snprintf-posix.m4 2008-04-19 18:59:56.000000000 +0200 *************** *** 1,4 **** ! # snprintf-posix.m4 serial 12 dnl Copyright (C) 2007-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 ---- ! # snprintf-posix.m4 serial 13 dnl Copyright (C) 2007-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, *************** *** 25,30 **** --- 25,31 ---- gl_SNPRINTF_TRUNCATION_C99 gl_SNPRINTF_RETVAL_C99 gl_SNPRINTF_DIRECTIVE_N + gl_SNPRINTF_SIZE1 gl_VSNPRINTF_ZEROSIZE_C99 case "$gl_cv_func_printf_sizes_c99" in *yes) *************** *** 58,68 **** *yes) case "$gl_cv_func_snprintf_directive_n" in *yes) ! case "$gl_cv_func_vsnprintf_zerosize_c99" in *yes) ! # snprintf exists and is ! # already POSIX compliant. ! gl_cv_func_snprintf_posix=yes ;; esac ;; --- 59,73 ---- *yes) case "$gl_cv_func_snprintf_directive_n" in *yes) ! case "$gl_cv_func_snprintf_size1" in *yes) ! case "$gl_cv_func_vsnprintf_zerosize_c99" in ! *yes) ! # snprintf exists and is ! # already POSIX compliant. ! gl_cv_func_snprintf_posix=yes ! ;; ! esac ;; esac ;; *** m4/snprintf.m4.orig 2008-04-19 21:35:49.000000000 +0200 --- m4/snprintf.m4 2008-04-19 19:03:55.000000000 +0200 *************** *** 1,5 **** ! # snprintf.m4 serial 4 ! dnl Copyright (C) 2002, 2003, 2004, 2007 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 ---- ! # snprintf.m4 serial 5 ! dnl Copyright (C) 2002-2004, 2007-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, dnl with or without modifications, as long as this notice is preserved. *************** *** 7,14 **** AC_DEFUN([gl_FUNC_SNPRINTF], [ AC_REQUIRE([gl_STDIO_H_DEFAULTS]) AC_CHECK_FUNCS([snprintf]) ! if test $ac_cv_func_snprintf = no; then gl_REPLACE_SNPRINTF fi AC_CHECK_DECLS_ONCE([snprintf]) --- 7,23 ---- AC_DEFUN([gl_FUNC_SNPRINTF], [ AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + gl_cv_func_snprintf_usable=no AC_CHECK_FUNCS([snprintf]) ! if test $ac_cv_func_snprintf = yes; then ! gl_SNPRINTF_SIZE1 ! case "$gl_cv_func_snprintf_size1" in ! *yes) ! gl_cv_func_snprintf_usable=yes ! ;; ! esac ! fi ! if test $gl_cv_func_snprintf_usable = no; then gl_REPLACE_SNPRINTF fi AC_CHECK_DECLS_ONCE([snprintf]) *** m4/vsnprintf-posix.m4.orig 2008-04-19 21:35:49.000000000 +0200 --- m4/vsnprintf-posix.m4 2008-04-19 19:00:48.000000000 +0200 *************** *** 1,4 **** ! # vsnprintf-posix.m4 serial 12 dnl Copyright (C) 2007-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 ---- ! # vsnprintf-posix.m4 serial 13 dnl Copyright (C) 2007-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, *************** *** 26,31 **** --- 26,32 ---- gl_SNPRINTF_TRUNCATION_C99 gl_SNPRINTF_RETVAL_C99 gl_SNPRINTF_DIRECTIVE_N + gl_SNPRINTF_SIZE1 gl_VSNPRINTF_ZEROSIZE_C99 case "$gl_cv_func_printf_sizes_c99" in *yes) *************** *** 59,69 **** *yes) case "$gl_cv_func_snprintf_directive_n" in *yes) ! case "$gl_cv_func_vsnprintf_zerosize_c99" in *yes) ! # vsnprintf exists and is ! # already POSIX compliant. ! gl_cv_func_vsnprintf_posix=yes ;; esac ;; --- 60,74 ---- *yes) case "$gl_cv_func_snprintf_directive_n" in *yes) ! case "$gl_cv_func_snprintf_size1" in *yes) ! case "$gl_cv_func_vsnprintf_zerosize_c99" in ! *yes) ! # vsnprintf exists and is ! # already POSIX compliant. ! gl_cv_func_vsnprintf_posix=yes ! ;; ! esac ;; esac ;; *** m4/vsnprintf.m4.orig 2008-04-19 21:35:49.000000000 +0200 --- m4/vsnprintf.m4 2008-04-19 19:05:10.000000000 +0200 *************** *** 1,5 **** ! # vsnprintf.m4 serial 4 ! dnl Copyright (C) 2002, 2003, 2004, 2007 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 ---- ! # vsnprintf.m4 serial 5 ! dnl Copyright (C) 2002-2004, 2007-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, dnl with or without modifications, as long as this notice is preserved. *************** *** 7,14 **** AC_DEFUN([gl_FUNC_VSNPRINTF], [ AC_REQUIRE([gl_STDIO_H_DEFAULTS]) AC_CHECK_FUNCS([vsnprintf]) ! if test $ac_cv_func_vsnprintf = no; then gl_REPLACE_VSNPRINTF fi AC_CHECK_DECLS_ONCE([vsnprintf]) --- 7,23 ---- AC_DEFUN([gl_FUNC_VSNPRINTF], [ AC_REQUIRE([gl_STDIO_H_DEFAULTS]) + gl_cv_func_vsnprintf_usable=no AC_CHECK_FUNCS([vsnprintf]) ! if test $ac_cv_func_vsnprintf = yes; then ! gl_SNPRINTF_SIZE1 ! case "$gl_cv_func_snprintf_size1" in ! *yes) ! gl_cv_func_vsnprintf_usable=yes ! ;; ! esac ! fi ! if test $gl_cv_func_snprintf_usable = no; then gl_REPLACE_VSNPRINTF fi AC_CHECK_DECLS_ONCE([vsnprintf]) *** modules/snprintf.orig 2008-04-19 21:35:49.000000000 +0200 --- modules/snprintf 2008-04-19 19:07:53.000000000 +0200 *************** *** 4,9 **** --- 4,10 ---- Files: lib/snprintf.c m4/snprintf.m4 + m4/printf.m4 Depends-on: stdio *** modules/vsnprintf.orig 2008-04-19 21:35:49.000000000 +0200 --- modules/vsnprintf 2008-04-19 19:08:02.000000000 +0200 *************** *** 5,10 **** --- 5,11 ---- Files: lib/vsnprintf.c m4/vsnprintf.m4 + m4/printf.m4 Depends-on: stdio
