From: Eric Blake Date: Tue, 2 Dec 2008 18:51:44 +0000 (-0700) Subject: Improve AC_STATE_SAVE. X-Git-Tag: v2.63b~64 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fd651ae835b1b7a354bf4cd3d4b2fc0bab17656a;p=thirdparty%2Fautoconf.git Improve AC_STATE_SAVE. * tests/local.at (AC_STATE_SAVE): Avoid ls -1, and use one less process by hoisting the uniqueness check into sed. * doc/autoconf.texi (Limitations of Usual Tools) : Mention MacOS bug. Signed-off-by: Eric Blake --- diff --git a/ChangeLog b/ChangeLog index 7ca53e90e..cd343d811 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-12-03 Eric Blake + + Improve AC_STATE_SAVE. + * tests/local.at (AC_STATE_SAVE): Avoid ls -1, and use one less + process by hoisting the uniqueness check into sed. + * doc/autoconf.texi (Limitations of Usual Tools) : Mention + MacOS bug. + 2008-12-02 Eric Blake Avoid MacOS readdir bug in testsuite. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 1decd4b70..fe28f392f 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -16575,6 +16575,16 @@ was equivalent to @samp{sources='*.c not found'} in the absence of @samp{.c} files. This is no longer a practical problem, since current @command{ls} implementations send diagnostics to standard error. +The behavior of @command{ls} on a directory that is being concurrently +modified is not always predictable, because of a data race where cached +information returned by @code{readdir} does not match the current +directory state. In fact, MacOS 10.5 has an intermittent bug where +@code{readdir}, and thus @command{ls}, sometimes lists a file more than +once if other files were added or removed from the directory immediately +prior to the @command{ls} call. Since @command{ls} already sorts its +output, the duplicate entries can be avoided by piping the results +through @code{uniq}. + @anchor{mkdir} @item @command{mkdir} @c ------------------ diff --git a/tests/local.at b/tests/local.at index 2ec7bc5a2..ba81e7c0c 100644 --- a/tests/local.at +++ b/tests/local.at @@ -197,11 +197,25 @@ m4_define([AT_CONFIGURE_AC], # confirm that no test modifies variables outside the Autoconf namespace or # leaves temporary files. AT_CONFIG_CMP uses the variable dumps to confirm that # tests have the same side effects regardless of caching. -# The sort -u is necessary, since MacOS 10.5 has a bug where readdir can -# list a file multiple times in a rapidly changing directory. +# +# The sed script duplicates uniq functionality (thanks to 'info sed +# uniq' for the recipe), in order to avoid a MacOS 10.5 bug where +# readdir can list a file multiple times in a rapidly changing +# directory, while avoiding yet another fork. m4_defun([AC_STATE_SAVE], [(set) 2>&1 | sort >state-env.$][1 -ls -1 | sed '/^at-/d;/^state-/d;/^config\./d' | sort -u >state-ls.$][1 +ls | sed '/^at-/d;/^state-/d;/^config\./d + h + :b + $b + N + /^\(.*\)\n\1$/ { + g + bb + } + $b + P + D' >state-ls.$][1 ])# AC_STATE_SAVE ]])