bug-gnulib
[Top][All Lists]
Advanced

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

Re: new module 'vasnprintf-posix'


From: Bruno Haible
Subject: Re: new module 'vasnprintf-posix'
Date: Thu, 8 Mar 2007 04:12:14 +0100
User-agent: KMail/1.5.4

Eric Blake wrote:
> >   AC_CHECK_FUNCS([vasnprintf])
> >   if expr "$gl_cv_func_printf_sizes_c99" : ".*yes" > /dev/null \
> >      && expr "$gl_cv_func_printf_directive_a" : ".*yes" > /dev/null \
> >      && expr "$gl_cv_func_printf_directive_n" : ".*yes" > /dev/null \
> >      && expr "$gl_cv_func_printf_positions" : ".*yes" > /dev/null \
> >      && test $ac_cv_func_vasnprintf = yes; then
> >     : # vasnprintf exists and is already POSIX compliant.
> 
> This is rather expensive in the number of forks (ie. noticeably slows down
> ./configure on cygwin).  Couldn't you rewrite it using shell builtins:
> 
> case "$gl_cv_func_printf_sizes_c99:$gl_cv_func_printf_directive_a:..." in
>  *no*) # vasnprintf needs help
> esac

Sorry, no: Such a rewrite makes the code harder to understand, especially
the '&&' (vs. '||') part. Besides that, the second expr invocation already
fails on cygwin, therefore you wouldn't gain much.

If you care about the execution speed of configure scripts, why don't you
ask
   - either the cygwin people to provide a fast posix_spawn function,
   - or the bash maintainers to make 'expr' and 'sed' shell built-ins,
     like 'test' and 'printf' are?

> >   if (sprintf (buf, "%zu %d", (size_t) 12345672, 33, 44, 55) < 0
> >       || strcmp (buf, "12345672 33") != 0)
> 
> This causes false negatives (more arguments than % directives) when
> configuring with gcc -Wall -Werror.

Yes. But you are provoking false results yourself by using "gcc -Wall -Werror".

The purpose of these additional arguments is to guarantee that if the
sprintf function and our <stdint.h> substitute disagree about intmax_t
or 'long double', it is noticed: the sprintf result would be
"12345672 44" or "12345672 55" instead of "12345672 33". Can you propose
a different way of guaranteeing this, without gcc warnings?

> 
> > changequote(,)dnl
> >        case "$host_os" in
> >                                dnl Guess yes on glibc systems.
> 
> 
> I'll just reiterate my dislike of changequote.  You violated your own
> copy-n-paste rule of thumb here by using dnl instead of shell comments
> inside a region that you are marking as shell literal.

I can well use '#', for easier copy&paste.

> I would rather see this as:
> 
> [[
>     case "$host_os" in
>            # Guess yes on glibc systems.
>         *-gnu*) ...
>            # Guess yes on MacOS X >= 10.3
>         darwin[1-6].*) ...
> ...
>     esac
> ]]
> 
> with the [[ and ]] serving as the delimiters of copy-n-pasteable
> shell-literal code rather than changequote(,).

You can do like this on macros you maintain. But I was tricked into
doing so, by a changequote hater like you, with the same argument, and
the result was that simple refactorings introduced bugs that I wouldn't
have had with changequote. I have been burnt, and I will not do it again.

> I'm also going to add %a and %A support to m4 2.0's format builtin, as a
> good test of this module, so expect some feedback as I try that.

These new modules have testsuites, but have not been tested on many platforms
so far. Therefore if till then it hasn't been tested more than it has today,
I'd suggest to distribute, together with the m4-2.0 prereleases, a
"gnulib --create-megatestdir $modules_needed_by_m4" result that people can
use for gaining confidence in these modules.

Bruno


--- m4/printf.m4        6 Mar 2007 02:00:30 -0000       1.10
+++ m4/printf.m4        8 Mar 2007 02:37:40 -0000
@@ -57,26 +57,26 @@
       [
 changequote(,)dnl
        case "$host_os" in
-                               dnl Guess yes on glibc systems.
+                               # Guess yes on glibc systems.
          *-gnu*)               gl_cv_func_printf_sizes_c99="guessing yes";;
-                               dnl Guess yes on FreeBSD >= 5.
+                               # Guess yes on FreeBSD >= 5.
          freebsd[1-4]*)        gl_cv_func_printf_sizes_c99="guessing no";;
          freebsd* | kfreebsd*) gl_cv_func_printf_sizes_c99="guessing yes";;
-                               dnl Guess yes on MacOS X >= 10.3.
+                               # Guess yes on MacOS X >= 10.3.
          darwin[1-6].*)        gl_cv_func_printf_sizes_c99="guessing no";;
          darwin*)              gl_cv_func_printf_sizes_c99="guessing yes";;
-                               dnl Guess yes on OpenBSD >= 3.9.
+                               # Guess yes on OpenBSD >= 3.9.
          openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
                                gl_cv_func_printf_sizes_c99="guessing no";;
          openbsd*)             gl_cv_func_printf_sizes_c99="guessing yes";;
-                               dnl Guess yes on Solaris >= 2.10.
+                               # Guess yes on Solaris >= 2.10.
          solaris2.[0-9]*)      gl_cv_func_printf_sizes_c99="guessing no";;
          solaris*)             gl_cv_func_printf_sizes_c99="guessing yes";;
-                               dnl Guess yes on NetBSD >= 3.
+                               # Guess yes on NetBSD >= 3.
          netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
                                gl_cv_func_printf_sizes_c99="guessing no";;
          netbsd*)              gl_cv_func_printf_sizes_c99="guessing yes";;
-                               dnl If we don't know, assume the worst.
+                               # If we don't know, assume the worst.
          *)                    gl_cv_func_printf_sizes_c99="guessing no";;
        esac
 changequote([,])dnl
@@ -136,7 +136,7 @@
 }], [gl_cv_func_printf_directive_a=yes], [gl_cv_func_printf_directive_a=no],
       [
        case "$host_os" in
-                               dnl Guess yes on glibc >= 2.5 systems.
+                               # Guess yes on glibc >= 2.5 systems.
          *-gnu*)
            AC_EGREP_CPP([BZ2908], [
              #include <features.h>
@@ -150,14 +150,14 @@
              [gl_cv_func_printf_directive_a="guessing no"])
            ;;
 changequote(,)dnl
-                               dnl Guess yes on FreeBSD >= 5.
+                               # Guess yes on FreeBSD >= 5.
          freebsd[1-4]*)        gl_cv_func_printf_directive_a="guessing no";;
          freebsd* | kfreebsd*) gl_cv_func_printf_directive_a="guessing yes";;
-                               dnl Guess yes on NetBSD >= 4.
+                               # Guess yes on NetBSD >= 4.
          netbsd[1-3]* | netbsdelf[1-3]* | netbsdaout[1-3]* | netbsdcoff[1-3]*)
                                gl_cv_func_printf_directive_a="guessing no";;
          netbsd*)              gl_cv_func_printf_directive_a="guessing yes";;
-                               dnl If we don't know, assume the worst.
+                               # If we don't know, assume the worst.
          *)                    gl_cv_func_printf_directive_a="guessing no";;
        esac
 changequote([,])dnl
@@ -270,39 +270,39 @@
       [
 changequote(,)dnl
        case "$host_os" in
-                               dnl Guess yes on glibc systems.
+                               # Guess yes on glibc systems.
          *-gnu*)               gl_cv_func_snprintf_truncation_c99="guessing 
yes";;
-                               dnl Guess yes on FreeBSD >= 5.
+                               # Guess yes on FreeBSD >= 5.
          freebsd[1-4]*)        gl_cv_func_snprintf_truncation_c99="guessing 
no";;
          freebsd* | kfreebsd*) gl_cv_func_snprintf_truncation_c99="guessing 
yes";;
-                               dnl Guess yes on MacOS X >= 10.3.
+                               # Guess yes on MacOS X >= 10.3.
          darwin[1-6].*)        gl_cv_func_snprintf_truncation_c99="guessing 
no";;
          darwin*)              gl_cv_func_snprintf_truncation_c99="guessing 
yes";;
-                               dnl Guess yes on OpenBSD >= 3.9.
+                               # Guess yes on OpenBSD >= 3.9.
          openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
                                gl_cv_func_snprintf_truncation_c99="guessing 
no";;
          openbsd*)             gl_cv_func_snprintf_truncation_c99="guessing 
yes";;
-                               dnl Guess yes on Solaris >= 2.6.
+                               # Guess yes on Solaris >= 2.6.
          solaris2.[0-5]*)      gl_cv_func_snprintf_truncation_c99="guessing 
no";;
          solaris*)             gl_cv_func_snprintf_truncation_c99="guessing 
yes";;
-                               dnl Guess yes on AIX >= 4.
+                               # Guess yes on AIX >= 4.
          aix[1-3]*)            gl_cv_func_snprintf_truncation_c99="guessing 
no";;
          aix*)                 gl_cv_func_snprintf_truncation_c99="guessing 
yes";;
-                               dnl Guess yes on HP-UX >= 11.
+                               # Guess yes on HP-UX >= 11.
          hpux[7-9]* | hpux10*) gl_cv_func_snprintf_truncation_c99="guessing 
no";;
          hpux*)                gl_cv_func_snprintf_truncation_c99="guessing 
yes";;
-                               dnl Guess yes on IRIX >= 6.5.
+                               # Guess yes on IRIX >= 6.5.
          irix6.5)              gl_cv_func_snprintf_truncation_c99="guessing 
yes";;
-                               dnl Guess yes on OSF/1 >= 5.
+                               # Guess yes on OSF/1 >= 5.
          osf[3-4]*)            gl_cv_func_snprintf_truncation_c99="guessing 
no";;
          osf*)                 gl_cv_func_snprintf_truncation_c99="guessing 
yes";;
-                               dnl Guess yes on NetBSD >= 3.
+                               # Guess yes on NetBSD >= 3.
          netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
                                gl_cv_func_snprintf_truncation_c99="guessing 
no";;
          netbsd*)              gl_cv_func_snprintf_truncation_c99="guessing 
yes";;
-                               dnl Guess yes on BeOS.
+                               # Guess yes on BeOS.
          beos*)                gl_cv_func_snprintf_truncation_c99="guessing 
yes";;
-                               dnl If we don't know, assume the worst.
+                               # If we don't know, assume the worst.
          *)                    gl_cv_func_snprintf_truncation_c99="guessing 
no";;
        esac
 changequote([,])dnl
@@ -336,31 +336,31 @@
       [
 changequote(,)dnl
        case "$host_os" in
-                               dnl Guess yes on glibc systems.
+                               # Guess yes on glibc systems.
          *-gnu*)               gl_cv_func_snprintf_retval_c99="guessing yes";;
-                               dnl Guess yes on FreeBSD >= 5.
+                               # Guess yes on FreeBSD >= 5.
          freebsd[1-4]*)        gl_cv_func_snprintf_retval_c99="guessing no";;
          freebsd* | kfreebsd*) gl_cv_func_snprintf_retval_c99="guessing yes";;
-                               dnl Guess yes on MacOS X >= 10.3.
+                               # Guess yes on MacOS X >= 10.3.
          darwin[1-6].*)        gl_cv_func_snprintf_retval_c99="guessing no";;
          darwin*)              gl_cv_func_snprintf_retval_c99="guessing yes";;
-                               dnl Guess yes on OpenBSD >= 3.9.
+                               # Guess yes on OpenBSD >= 3.9.
          openbsd[1-2].* | openbsd3.[0-8] | openbsd3.[0-8].*)
                                gl_cv_func_snprintf_retval_c99="guessing no";;
          openbsd*)             gl_cv_func_snprintf_retval_c99="guessing yes";;
-                               dnl Guess yes on Solaris >= 2.6.
+                               # Guess yes on Solaris >= 2.6.
          solaris2.[0-5]*)      gl_cv_func_snprintf_retval_c99="guessing no";;
          solaris*)             gl_cv_func_snprintf_retval_c99="guessing yes";;
-                               dnl Guess yes on AIX >= 4.
+                               # Guess yes on AIX >= 4.
          aix[1-3]*)            gl_cv_func_snprintf_retval_c99="guessing no";;
          aix*)                 gl_cv_func_snprintf_retval_c99="guessing yes";;
-                               dnl Guess yes on NetBSD >= 3.
+                               # Guess yes on NetBSD >= 3.
          netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
                                gl_cv_func_snprintf_retval_c99="guessing no";;
          netbsd*)              gl_cv_func_snprintf_retval_c99="guessing yes";;
-                               dnl Guess yes on BeOS.
+                               # Guess yes on BeOS.
          beos*)                gl_cv_func_snprintf_retval_c99="guessing yes";;
-                               dnl If we don't know, assume the worst.
+                               # If we don't know, assume the worst.
          *)                    gl_cv_func_snprintf_retval_c99="guessing no";;
        esac
 changequote([,])dnl
@@ -394,32 +394,32 @@
       [
 changequote(,)dnl
        case "$host_os" in
-                               dnl Guess yes on glibc systems.
+                               # Guess yes on glibc systems.
          *-gnu*)               gl_cv_func_snprintf_directive_n="guessing yes";;
-                               dnl Guess yes on FreeBSD >= 5.
+                               # Guess yes on FreeBSD >= 5.
          freebsd[1-4]*)        gl_cv_func_snprintf_directive_n="guessing no";;
          freebsd* | kfreebsd*) gl_cv_func_snprintf_directive_n="guessing yes";;
-                               dnl Guess yes on MacOS X >= 10.3.
+                               # Guess yes on MacOS X >= 10.3.
          darwin[1-6].*)        gl_cv_func_snprintf_directive_n="guessing no";;
          darwin*)              gl_cv_func_snprintf_directive_n="guessing yes";;
-                               dnl Guess yes on Solaris >= 2.6.
+                               # Guess yes on Solaris >= 2.6.
          solaris2.[0-5]*)      gl_cv_func_snprintf_directive_n="guessing no";;
          solaris*)             gl_cv_func_snprintf_directive_n="guessing yes";;
-                               dnl Guess yes on AIX >= 4.
+                               # Guess yes on AIX >= 4.
          aix[1-3]*)            gl_cv_func_snprintf_directive_n="guessing no";;
          aix*)                 gl_cv_func_snprintf_directive_n="guessing yes";;
-                               dnl Guess yes on IRIX >= 6.5.
+                               # Guess yes on IRIX >= 6.5.
          irix6.5)              gl_cv_func_snprintf_directive_n="guessing yes";;
-                               dnl Guess yes on OSF/1 >= 5.
+                               # Guess yes on OSF/1 >= 5.
          osf[3-4]*)            gl_cv_func_snprintf_directive_n="guessing no";;
          osf*)                 gl_cv_func_snprintf_directive_n="guessing yes";;
-                               dnl Guess yes on NetBSD >= 3.
+                               # Guess yes on NetBSD >= 3.
          netbsd[1-2]* | netbsdelf[1-2]* | netbsdaout[1-2]* | netbsdcoff[1-2]*)
                                gl_cv_func_snprintf_directive_n="guessing no";;
          netbsd*)              gl_cv_func_snprintf_directive_n="guessing yes";;
-                               dnl Guess yes on BeOS.
+                               # Guess yes on BeOS.
          beos*)                gl_cv_func_snprintf_directive_n="guessing yes";;
-                               dnl If we don't know, assume the worst.
+                               # If we don't know, assume the worst.
          *)                    gl_cv_func_snprintf_directive_n="guessing no";;
        esac
 changequote([,])dnl





reply via email to

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