On 09/08/2010 03:56 AM, Paolo Bonzini wrote:
On 09/08/2010 11:30 AM, Bruno Haible wrote:
Paolo Bonzini wrote:
On 09/07/2010 10:39 PM, Eric Blake wrote:
gl_awk_probe='BEGIN { for (v in ENVIRON)
if (v == "POSIXLY_CORRECT") print "x" }'
case ${POSIXLY_CORRECT:+x}`awk "$gl_awk_probe"</dev/null` in
xx) gl_had_POSIXLY_CORRECT=exported ;;
x) gl_had_POSIXLY_CORRECT=yes ;;
*) gl_had_POSIXLY_CORRECT= ;;
esac
Walking all of ENVIRON seems slow.
Then we should be able to use the faster:
if ("POSIXLY_CORRECT" in ENVIRON)
Autoconf documents that traditional awk has 'for (a in b)' but lacks 'if
(a in b)'; but we are already avoiding traditional awk for their lack of
ENVIRON, and all the [gmn]awk implementations I tested support both forms.
So maybe it should be ${POSIXLY_CORRECT+x}, not ${POSIXLY_CORRECT:+x}?
Right now it's inconsistent.
Good catch. I'm installing a fix for that:
diff --git i/ChangeLog w/ChangeLog
index 103ab6c..2daedad 100644
--- i/ChangeLog
+++ w/ChangeLog
@@ -1,3 +1,10 @@
+2010-09-08 Eric Blake <ebl...@redhat.com>
+
+ getopt: optimize previous patch
+ * m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS): Correctly check for
+ empty variable. Speed up awk script.
+ Reported by Paolo Bonzini.
+
2010-09-07 Eric Blake <ebl...@redhat.com>
strtod: work around IRIX 6.5 bug
diff --git i/m4/getopt.m4 w/m4/getopt.m4
index 720f048..d05e9d9 100644
--- i/m4/getopt.m4
+++ w/m4/getopt.m4
@@ -1,4 +1,4 @@
-# getopt.m4 serial 30
+# getopt.m4 serial 31
dnl Copyright (C) 2002-2006, 2008-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,
@@ -218,9 +218,8 @@ main ()
# so take care to revert to the correct (non-)export state.
dnl GNU Coding Standards currently allow awk but not env; besides, env
dnl is ambiguous with environment values that contain newlines.
- gl_awk_probe='BEGIN { for (v in ENVIRON)
- if (v == "POSIXLY_CORRECT") print "x" }'
- case ${POSIXLY_CORRECT:+x}`$AWK "$gl_awk_probe" </dev/null` in
+ gl_awk_probe='BEGIN { if ("POSIXLY_CORRECT" in ENVIRON) print "x" }'
+ case ${POSIXLY_CORRECT+x}`$AWK "$gl_awk_probe" </dev/null` in
xx) gl_had_POSIXLY_CORRECT=exported ;;
x) gl_had_POSIXLY_CORRECT=yes ;;
*) gl_had_POSIXLY_CORRECT= ;;
--
Eric Blake ebl...@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org