# # # patch "ChangeLog" # from [98a19c78fc79c05644fcf3d868600397997533b3] # to [3bfb1366ba32a5dee36ab5542a74c36831cf18d0] # # patch "configure.ac" # from [0bbe01c42c3d25e72176fda5c606e1e4c3ec3e6d] # to [9ea33d30cbc295052c1ce443de46ff2974037b13] # ============================================================ --- ChangeLog 98a19c78fc79c05644fcf3d868600397997533b3 +++ ChangeLog 3bfb1366ba32a5dee36ab5542a74c36831cf18d0 @@ -1,5 +1,8 @@ 2006-03-12 Matthew Gregan + * configure.ac: Add a second sync_for_stdio test to work around a + bug in OS X. + * testsuite.at: Changes to Perl and Python UNB64_COMMAND invocations to work around some quoting issues broken/revealed in my last change. ============================================================ --- configure.ac 0bbe01c42c3d25e72176fda5c606e1e4c3ec3e6d +++ configure.ac 9ea33d30cbc295052c1ce443de46ff2974037b13 @@ -446,7 +446,8 @@ # Check whether sync_with_stdio(false) run on C++ streams works correctly. # It causes strange problems (EOF returned too early) on some versions of -# MinGW. +# MinGW and OS X. The first test is for the MinGW issue, the second for +# the OS X issue. # # In order to check for this issue, we first generate a large input file # (over 128KB) and then try to read it (using a buffer size over 512 @@ -499,13 +500,69 @@ ])], [if ./conftest$ac_exeext check_it_now <_conftest.dat; then AC_MSG_RESULT(yes) - AC_DEFINE(SYNC_WITH_STDIO_WORKS, 1, - [Define to 1 if sync_with_stdio works fine on C++ streams]) + ac_cv_sync_with_stdio=yes else AC_MSG_RESULT(no) + ac_cv_sync_with_stdio=no fi rm -f _conftest.dat]) + +# To check for this issue, we have a writer with a short delay between writes, +# and a reader who has set sync_with_stdio(false). +AC_MSG_CHECKING(whether C++ streams support sync_with_stdio 2) +AC_RUN_IFELSE([AC_LANG_SOURCE([ +#include +#include +#ifdef WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#define sleep(x) Sleep((x) * 1000) +#else +#include +#endif + +int +main(int argc, char * argv[]) +{ + if (argc == 1) + return EXIT_SUCCESS; + + if (argc == 2) + { + std::cin.sync_with_stdio(false); + int length = 0; + while (std::cin.good()) + { + char buffer@<:@1024@:>@; + (void)std::cin.read(buffer, sizeof(buffer)); + length += std::cin.gcount(); + } + + return length == 82 ? EXIT_SUCCESS : EXIT_FAILURE; + } + else + { + std::cout << "1234567890123456789012345678901234567890" << std::endl; + sleep(1); + std::cout << "1234567890123456789012345678901234567890" << std::endl; + } + return EXIT_SUCCESS; +} +])], + [if ./conftest$ac_exeext check_it_now please | ./conftest$ac_exeext foo; then + AC_MSG_RESULT(yes) + ac_cv_sync_with_stdio_2=yes + else + AC_MSG_RESULT(no) + ac_cv_sync_with_stdio_2=no + fi]) + +if test $ac_cv_sync_with_stdio = yes && test $ac_cv_sync_with_stdio_2 = yes; then + AC_DEFINE(SYNC_WITH_STDIO_WORKS, 1, + [Define to 1 if sync_with_stdio works fine on C++ streams]) +fi + # allow compiling with different flags/optimisation # for monotone versus libs, useful for testing. # only makes sense if CFLAGS="" or CXXFLAGS=""