autoconf-patches
[Top][All Lists]
Advanced

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

Re: _AS_DETECT_BETTER_SHELL speedup


From: Paul Eggert
Subject: Re: _AS_DETECT_BETTER_SHELL speedup
Date: Fri, 28 Jan 2005 13:25:16 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

Ralf Wildenhues <address@hidden> writes:

> I hope to have been conservative enough:

Sorry, I'm still not sold on many of the changes, since I wouldn't
like shells outputting random garbage to stderr.  As far as I can tell
POSIX would permit such behavior -- it's not clear from the POSIX spec
-- so this problem might not be limited to older shells.

However, some of the problems can be rewritten in different ways, which
should be safe on any reasonable shell.  I installed the following
even-more-conservative patch.

2005-01-28  Paul Eggert  <address@hidden>

        * lib/autoconf/lang.m4 (_AC_COMPILER_OBJEXT): Avoid subshells when
        this is safe.
        * lib/autoconf/programs.m4 (AC_PROG_EGREP, AC_PROG_FGREP): Likewise.
        * lib/autoconf/specific.m4 (AC_SYS_LONG_FILE_NAMES): Likewise.
        * lib/autotest/general.m4 (AT_INIT): Likewise.
        * lib/m4sugar/m4sh.m4 (_AS_LINENO_WORKS): Likewise.
        * tests/mktests.sh: Likewise.

Index: lib/autoconf/lang.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/lang.m4,v
retrieving revision 1.169
diff -p -u -r1.169 lang.m4
--- lib/autoconf/lang.m4        20 Apr 2004 20:15:57 -0000      1.169
+++ lib/autoconf/lang.m4        28 Jan 2005 21:19:53 -0000
@@ -1,6 +1,6 @@
 # This file is part of Autoconf.                       -*- Autoconf -*-
 # Programming languages support.
-# Copyright (C) 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright (C) 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -622,7 +622,8 @@ m4_define([_AC_COMPILER_OBJEXT],
 [AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
 rm -f conftest.o conftest.obj
 AS_IF([AC_TRY_EVAL(ac_compile)],
-[for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+[for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
   case $ac_file in
     _AC_COMPILER_OBJEXT_REJECT ) ;;
     *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
Index: lib/autoconf/programs.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/programs.m4,v
retrieving revision 1.38
diff -p -u -r1.38 programs.m4
--- lib/autoconf/programs.m4    4 Jan 2005 23:50:01 -0000       1.38
+++ lib/autoconf/programs.m4    28 Jan 2005 21:19:53 -0000
@@ -364,7 +364,7 @@ AC_DEFUN([AC_PROG_AWK],
 AC_DEFUN([AC_PROG_EGREP],
 [AC_REQUIRE([AC_PROG_GREP])dnl
 AC_CACHE_CHECK([for egrep], ac_cv_path_EGREP,
-   [if echo a | ($GREP -E '(a|b)') >/dev/null 2>&1
+   [if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
    then ac_cv_path_EGREP="$GREP -E"
    else
      _AC_PROG_GREP(EGREP, egrep, ['EGREP$'])
@@ -379,7 +379,7 @@ AC_CACHE_CHECK([for egrep], ac_cv_path_E
 AC_DEFUN([AC_PROG_FGREP],
 [AC_REQUIRE([AC_PROG_GREP])dnl
 AC_CACHE_CHECK([for fgrep], ac_cv_path_FGREP,
-   [if echo 'ab*c' | ($GREP -F 'ab*c') >/dev/null 2>&1
+   [if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
    then ac_cv_path_FGREP="$GREP -F"
    else
      _AC_PROG_GREP(FGREP, fgrep, [FGREP])
Index: lib/autoconf/specific.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/specific.m4,v
retrieving revision 1.360
diff -p -u -r1.360 specific.m4
--- lib/autoconf/specific.m4    3 May 2004 20:15:44 -0000       1.360
+++ lib/autoconf/specific.m4    28 Jan 2005 21:19:53 -0000
@@ -2,7 +2,7 @@
 # Macros that test for specific, unclassified, features.
 #
 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004 Free Software Foundation, Inc.
+# 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -227,15 +227,10 @@ for ac_dir in  . $ac_tmpdirs `eval echo 
   (umask 077 && mkdir $ac_xdir 2>/dev/null) || continue
   ac_tf1=$ac_xdir/conftest9012345
   ac_tf2=$ac_xdir/conftest9012346
-  (echo 1 >$ac_tf1) 2>/dev/null
-  (echo 2 >$ac_tf2) 2>/dev/null
-  ac_val=`cat $ac_tf1 2>/dev/null`
-  if test ! -f $ac_tf1 || test "$ac_val" != 1; then
+  touch $ac_tf1 2>/dev/null && test -f $ac_tf1 && test ! -f $ac_tf2 ||
     ac_cv_sys_long_file_names=no
-    rm -f -r $ac_xdir 2>/dev/null
-    break
-  fi
   rm -f -r $ac_xdir 2>/dev/null
+  test $ac_cv_sys_long_file_names = no && break
 done])
 if test $ac_cv_sys_long_file_names = yes; then
   AC_DEFINE(HAVE_LONG_FILE_NAMES, 1,
Index: lib/autotest/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autotest/general.m4,v
retrieving revision 1.169
diff -p -u -r1.169 general.m4
--- lib/autotest/general.m4     1 Jan 2005 08:12:12 -0000       1.169
+++ lib/autotest/general.m4     28 Jan 2005 21:19:53 -0000
@@ -1,6 +1,8 @@
 # This file is part of Autoconf.                          -*- Autoconf -*-
 # M4 macros used in building test suites.
-# Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software
+# Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -547,7 +549,7 @@ done
 } >&AS_MESSAGE_LOG_FD
 
 at_start_date=`date`
-at_start_time=`(date +%s) 2>/dev/null`
+at_start_time=`date +%s 2>/dev/null || echo 0`
 echo "$as_me: starting at: $at_start_date" >&AS_MESSAGE_LOG_FD
 at_xpass_list=
 at_xfail_list=
@@ -726,13 +728,13 @@ cd "$at_dir"
 
 # Compute the duration of the suite.
 at_stop_date=`date`
-at_stop_time=`(date +%s) 2>/dev/null`
+at_stop_time=`date +%s 2>/dev/null || echo 0`
 echo "$as_me: ending at: $at_stop_date" >&AS_MESSAGE_LOG_FD
-at_duration_s=`(expr $at_stop_time - $at_start_time) 2>/dev/null`
-at_duration_m=`(expr $at_duration_s / 60) 2>/dev/null`
-at_duration_h=`(expr $at_duration_m / 60) 2>/dev/null`
-at_duration_s=`(expr $at_duration_s % 60) 2>/dev/null`
-at_duration_m=`(expr $at_duration_m % 60) 2>/dev/null`
+at_duration_s=`expr $at_stop_time - $at_start_time`
+at_duration_m=`expr $at_duration_s / 60`
+at_duration_h=`expr $at_duration_m / 60`
+at_duration_s=`expr $at_duration_s % 60`
+at_duration_m=`expr $at_duration_m % 60`
 at_duration="${at_duration_h}h ${at_duration_m}m ${at_duration_s}s"
 if test "$at_duration" != "h m s"; then
   echo "$as_me: test suite duration: $at_duration" >&AS_MESSAGE_LOG_FD
Index: lib/m4sugar/m4sh.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.131
diff -p -u -r1.131 m4sh.m4
--- lib/m4sugar/m4sh.m4 3 Jan 2005 23:32:35 -0000       1.131
+++ lib/m4sugar/m4sh.m4 28 Jan 2005 21:19:53 -0000
@@ -1,7 +1,9 @@
 # This file is part of Autoconf.                          -*- Autoconf -*-
 # M4 sugar for common shell constructs.
 # Requires GNU M4 and M4sugar.
-# Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+#
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software
+# Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -694,9 +696,8 @@ m4_define([_AS_LINENO_WORKS],
 [
   as_lineno_1=$LINENO
   as_lineno_2=$LINENO
-  as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
   test "x$as_lineno_1" != "x$as_lineno_2" &&
-  test "x$as_lineno_3"  = "x$as_lineno_2"])
+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2"])
 
 # _AS_LINENO_PREPARE
 # ------------------
Index: tests/mktests.sh
===================================================================
RCS file: /cvsroot/autoconf/autoconf/tests/mktests.sh,v
retrieving revision 1.41
diff -p -u -r1.41 mktests.sh
--- tests/mktests.sh    3 Jan 2005 07:40:10 -0000       1.41
+++ tests/mktests.sh    28 Jan 2005 21:19:53 -0000
@@ -1,7 +1,9 @@
 #! /bin/sh
 
 # Build some of the Autoconf test files.
-# Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
+# Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software
+# Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -190,7 +192,7 @@ au_exclude_egrep=$exclude_list$au_exclud
 
 # egrep
 # -----
-if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+if echo a | grep -E '(a|b)' >/dev/null 2>&1
 then egrep='grep -E'
 else egrep='egrep'
 fi




reply via email to

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